Tutorial by Examples: sin

First, install Mongoose with: npm install mongoose Then, add it to server.js as dependencies: var mongoose = require('mongoose'); var Schema = mongoose.Schema; Next, create the database schema and the name of the collection: var schemaName = new Schema({ request: String, time: Nu...
Setup First, install the necessary packages with: npm install express cors mongoose Code Then, add dependencies to your server.js file, create the database schema and the name of the collection, create an Express.js server, and connect to MongoDB: var express = require('express'); var cors =...
Setup First, install the necessary packages with: npm install express cors mongoose Code Then, add dependencies to server.js, create the database schema and the name of the collection, create an Express.js server, and connect to MongoDB: var express = require('express'); var cors = require('...
The difference in months between two dates can be found using the MONTHS_BETWEEN( date1, date2 ): SELECT MONTHS_BETWEEN( DATE '2016-03-10', DATE '2015-03-10' ) AS difference FROM DUAL; Outputs: DIFFERENCE ---------- 12 If the difference includes part months then it will return the ...
You can use re.finditer to iterate over all matches in a string. This gives you (in comparison to re.findall extra information, such as information about the match location in the string (indexes): import re text = 'You can try to find an ant in this string' pattern = 'an?\w' # find 'an' either w...
The Windows API GetTickCount function returns the number of milliseconds since the system (computer) was started. The simplest example follows: var Start, Stop, ElapsedMilliseconds: cardinal; begin Start := GetTickCount; // do something that requires measurement Stop := GetTickCount; ...
We will parse the highlighted tag data through NSXMLParser We have declared few properties as follows @property(nonatomic, strong)NSMutableArray *results; @property(nonatomic, strong)NSMutableString *parsedString; @property(nonatomic, strong)NSXMLParser *xmlParser; //Fetch xml data NSURLSe...
@IBOutlet weak var title: UILabel! { didSet { label.textColor = UIColor.redColor() label.font = UIFont.systemFontOfSize(20) label.backgroundColor = UIColor.blueColor() } } It's also possible to both set a value and initialize it: private var loginButton = UIButton() { ...
Move every outlet to an NSObject. Then drag an Object from the library to the controller scene of the storyboard and hook the elements there. class ContactFormStyle: NSObject { @IBOutlet private weak var message: UILabel! { didSet { message.font = UIFont.systemFontOfSize(12) ...
Another way to hide admin bar is to add if ( !current_user_can( 'manage_options' ) ) { add_filter( 'show_admin_bar', '__return_false' , 1000 ); } The users who don't have privileges to access Settings page, won't be able to see the admin bar.
'use strict'; const co = require('co'); module.exports = { // This is the index action and the route is mapped via /config/routes.js index(req, res) { co(function* index() { // Return a view without view model data // This typically will return the view defined at /vie...
Headers may be used to declare globally used read-only resources, like string tables for example. Declare those in a separate header which gets included by any file ("Translation Unit") which wants to make use of them. It's handy to use the same header to declare a related enumeration to ...
SELECT * FROM customers WHERE id IN ( SELECT DISTINCT customer_id FROM orders ); The above will give you all the customers that have orders in the system.
You can use Help class in code, to provide these kinds of help: Show a help pop-up for a control Open a CHM file based on context (Show table of content, Show a keyword or index, show a topic) Navigate to a URL using default browser Show Help pop-up window You can use Help.ShowPopup to disp...
SELECT product, SUM(quantity) AS "Total quantity" FROM order_details GROUP BY product;
Assume a table of employees in which each row is an employee who has a name, a department, and a salary. SELECT department, MIN(salary) AS "Lowest salary" FROM employees GROUP BY department; This would tell you which department contains the employee with the lowest salary, and what t...
Below is a recursive code to reverse a string /** * Just a snippet to explain the idea of recursion * **/ public class Reverse { public static void main (String args[]) { String string = "hello world"; System.out.println(reverse(string)); //prints dlrow oll...
If a bean is defined with singleton scope, there will only be one single object instance initialized in the Spring container. All requests to this bean will return the same shared instance. This is the default scope when defining a bean. Given the following MyBean class: public class MyBean { ...
This will trigger the native email client for sharing text. Parameters : Email To address, Subject, Body. Code Sample : you can call the function wherever you need, (mostly inside click listeners) like below Calling function shareEmail("[email protected]", "Email sharing example&q...
Although available, defining a class from scratch is not recommended in modern Perl. Use one of helper OO systems which provide more features and convenience. Among these systems are: Moose - inspired by Perl 6 OO design Class::Accessor - a lightweight alternative to Moose Class::Tiny...

Page 54 of 161