Tutorial by Examples: c

This program illustrates how one can copy a file using readable and writable streams using the createReadStream(), and createWriteStream() functions provided by the file system module. //Require the file System module var fs = require('fs'); /* Create readable stream to file in current direc...
Sometimes it might be necessary to manually promisify a callback function. This could be for a case where the callback does not follow the standard error-first format or if additional logic is needed to promisify: Example with fs.exists(path, callback): var fs = require('fs'); var existsAsync =...
Sometimes you just need a diff to apply using patch. The regular git --diff does not work. Try this instead: git diff --no-prefix > some_file.patch Then somewhere else you can reverse it: patch -p0 < some_file.patch
Node.js has 3 basic ways to handle exceptions/errors: try-catch block error as the first argument to a callback emit an error event using eventEmitter try-catch is used to catch the exceptions thrown from the synchronous code execution. If the caller (or the caller's caller, ...) used try/ca...
In Terminal on your Mac operating system, enter the following 2 commands: lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
INSTALLATION PROCESS You can install Node Version Manager using git, curl or wget. You run these commands in Terminal on Mac OSX. curl example: curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.3/install.sh | bash wget example: wget -qO- https://raw.githubusercontent.com/creatio...
It's a regular pattern in design these days to vertically align call to actions inside its containing cards like this: This can be achieved using a special trick with flexbox HTML <div class="cards"> <div class="card"> <p>Lorem ipsum Magna proident ...
{!join from=personid to=id fromIndex=AddressCore}address:Address1 So if you have two cores that look like this: PersonCore - id, name AddressCore - id, address, personid This will find all PersonCore documents at a specific address
It is often useful for debugging purposes to find the root cause of an error. In order to examine an error value that implements std::error::Error: use std::error::Error; let orig_error = call_returning_error(); // Use an Option<&Error>. This is the return type of Error.cause(). le...
You can use an environment filter to change the author of commits. Just modify and export $GIT_AUTHOR_NAME in the script to change who authored the commit. Create a file filter.sh with contents like so: if [ "$GIT_AUTHOR_NAME" = "Author to Change From" ] then export GIT_A...
Screen shot: Option 1 (pure adb) The shell adb command allows us to execute commands using a device's built-in shell. The screencap shell command captures the content currently visible on a device and saves it into a given image file, e.g. /sdcard/screen.png: adb shell screencap /sdcard/screen.png...
4.4 Recording the display of devices running Android 4.4 (API level 19) and higher: adb shell screenrecord [options] <filename> adb shell screenrecord /sdcard/demo.mp4 (press Ctrl-C to stop recording) Download the file from the device: adb pull /sdcard/demo.mp4 Note: Stop the scre...
This function casts a ray from point origin in direction direction of length maxDistance against all colliders in the scene. The function takes in the origin direction maxDistance and calculate if there is a collider in front of the GameObject. Physics.Raycast(origin, direction, maxDistance); F...
Example method in controller @RequestMapping(value = "/test") public String showCheckbox(Model model) { boolean myBooleanVariable = false; model.addAttribute("myBooleanVariable", myBooleanVariable); return "sample-checkbox"; } View: sample-checkbox....
You may want to nest cached fragments inside other cached fragments. This is called Russian doll caching. The advantage of Russian doll caching is that if a single product is updated, all the other inner fragments can be reused when regenerating the outer fragment. As explained in the previous sec...
Query caching is a Rails feature that caches the result set returned by each query. If Rails encounters the same query again for that request, it will use the cached result set as opposed to running the query against the database again. For example: class ProductsController < ApplicationControl...
In order to have google maps work properly with turbolinks, add the javascript tag directly to the layout header rather than including it in a view. # app/views/layouts/my_layout.html.haml !!! %html{:lang => 'en'} %head - # ... = google_maps_api_script_tag The google_maps_api_s...
Suppose, your users and/or groups have profiles and you want to display address profile fields on a google map. # app/models/profile_fields/address.rb class ProfileFields::Address < ProfileFields::Base # Attributes: # label, e.g. "Work address" # value, e.g. "Willy-Bran...
Suppose, there is a .google_map div, which will become the map, and which has the address fields to show as markers as data attribute. For example: <!-- http://localhost:3000/profiles/123 --> <div class="google_map" data-address-fields="[ {label: 'Work address', value: ...
Provided an App.GoogleMap coffee script class, the google map can be initialized like this: # app/assets/javascripts/google_maps.js.coffee # ... class App.GoogleMap map_div: {} map: {} constructor: (map_div)-> @map_div = map_div @init_map() @reference_the_map_as_dat...

Page 222 of 826