Tutorial by Examples: call

preg_replace_callback works by sending every matched capturing group to the defined callback and replaces it with the return value of the callback. This allows us to replace strings based on any kind of logic. $subject = "He said 123abc, I said 456efg, then she said 789hij"; $regex = &q...
You can see list with all environment variables with: Get-Childitem env:
In order to convert any callback API to promises assuming the promisify and promisifyAll version doesn't fit - you can use the promise constructor. Creating promises generally means specifying when they settle - that means when they move to the fulfilled (completed) or rejected (errored) phase to i...
$ npm install -g parse-server mongodb-runner $ mongodb-runner start $ parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://localhost/test You can use any arbitrary string as your application id and master key. These will be used by your clients to authenticate with...
file:write_file("myfile.txt", ["Hi " [<<"there">>], $\n]).
Depending on the service, you will either need to use Basic Authentication with a username and password or pass an apikey as a parameter in each request. Some services also support token authentication. GET using Tone Analyzer: curl -X GET \ -u "username":"password" \ -d &qu...
To automatically reload vimrc upon save, add the following to your vimrc: if has('autocmd') " ignore this section if your vim does not support autocommands augroup reload_vimrc autocmd! autocmd! BufWritePost $MYVIMRC,$MYGVIMRC nested source % augroup END endif a...
Mongoose connect has 3 parameters, uri, options, and the callback function. To use them see sample below. var mongoose = require('mongoose'); var uri = 'mongodb://localhost:27017/DBNAME'; var options = { user: 'user1', pass: 'pass' } mongoose.connect(uri, options, function(err){...
@IBAction func axisChange(sender: UISwitch) { UIView.animateWithDuration(1.0) { self.updateConstraintsForAxis() } } The updateConstraintForAxis function just sets the axis of the stack view containing the two image views: private func updateConstraintsForAxis() { if (axi...
Express passes a next callback to every route handler and middleware function that can be used to break logic for single routes across multiple handlers. Calling next() with no arguments tells express to continue to the next matching middleware or route handler. Calling next(err) with an error will ...
The following statement will create a new table called employee: CREATE TABLE EMPLOYEE ( EMPNO CHAR(6) NOT NULL, FIRSTNME VARCHAR(12) NOT NULL, LASTNAME VARCHAR(15) NOT NULL, SALARY DECIMAL(9,2) , PRIMARY KEY (EMPNO) ...
In PubNub JavaScript v3, you could implement a unique callback for every channel that you subscribed to as long as you called the subscribe function for each channel and implemented the callback in that subscribe like this: var pubnub = new PubNub({ publishKey: "your-pub-key", s...
It is very common that during development, one may find very useful to lock/unlock the device screen during specific parts of the code. For instance, while showing a Dialog with information, the developer might want to lock the screen's rotation to prevent the dialog from being dismissed and the cu...
Following example requires that node.js is installed and npm is available. Full working code can be forked from GitHub @ https://github.com/mikkoviitala/angular-grunt-run-local Usually one of the first things you want to do when developing new web application is to make it run locally. Below ...
The libc crate is 'feature gated' and can only be accessed on nightly Rust versions until it is considered stable. #![feature(libc)] extern crate libc; use libc::pid_t; #[link(name = "c")] extern { fn getpid() -> pid_t; } fn main() { let x = unsafe { getpid() }; ...
In 32-bit Linux, system calls are usually done by using the sysenter instruction (I say usually because older programs use the now deprecated int 0x80) however, this can take up quite alot of space in a program and so there are ways that one can cut corners in order to shorten and speed things up. ...
Either input can be an array of 3- (or 2-) element vectors. >>> a=np.array([[1,0,0],[0,1,0],[0,0,1]]) >>> b=np.array([1,0,0]) >>> np.cross(a,b) array([[ 0, 0, 0], [ 0, 0, -1], [ 0, 1, 0]]) The result in this case is array([np.cross(a[0],b), np.c...
One of most common use cases of Gitflow Initialize repo and define branches $ git flow init # if you use default setup, you'll define six types of branches: # # main branches (lives forever) # # 1. master: for production releases # 2. develop: for "next ...
add_action( 'init', function() { // do something here } ); Using a function block to hook a set of instructions. With the init hook, the set of instructions will be executed right after wordpress has finished loading the necessary components.

Page 11 of 18