Tutorial by Examples: al

localStorage.length property returns an integer number indicating the number of elements in the localStorage Example: Set Items localStorage.setItem('StackOverflow', 'Documentation'); localStorage.setItem('font', 'Helvetica'); localStorage.setItem('image', 'sprite.svg'); Get length localSto...
Nine-patch images allow optional definition of the padding lines in the image. The padding lines are the lines on the right and at the bottom. If a View sets the 9-patch image as its background, the padding lines are used to define the space for the View's content (e.g. the text input in an EditTex...
MATLAB supports the use of logical masking in order to perform selection on a matrix without the use of for loops or if statements. A logical mask is defined as a matrix composed of only 1 and 0. For example: mask = [1 0 0; 0 1 0; 0 0 1]; is a logical matrix representing the identity matrix. ...
Local hooks affect only the local repositories in which they reside. Each developer can alter their own local hooks, so they can't be used reliably as a way to enforce a commit policy. They are designed to make it easier for developers to adhere to certain guidelines and avoid potential problems dow...
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 =...
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 ...
Validates a value is a valid IP address var_dump(filter_var('185.158.24.24', FILTER_VALIDATE_IP)); var_dump(filter_var('2001:0db8:0a0b:12f0:0000:0000:0000:0001', FILTER_VALIDATE_IP)); var_dump(filter_var('192.168.0.1', FILTER_VALIDATE_IP)); var_dump(filter_var('127.0.0.1', FILTER_VALIDATE_IP)); ...
Since Unity 5.2.5 it's possible to use RuntimeInitializeOnLoadMethodAttribute to execute initialization logic bypassing MonoBehaviour order of execution. It provides a way to create more clean and robust implementation: using UnityEngine; sealed class GameDirector : MonoBehaviour { // Beca...
To forbid null values in your table columns, add the :null parameter to your migration, like this: class AddPriceToProducts < ActiveRecord::Migration def change add_column :products, :float, null: false end end
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...
Provided an App.GoogleMap coffee script class and the marker information being stored in the data-address-fields attribute of the .google_map div, the map markers can be initialized on the map like this: # app/assets/javascripts/google_maps.js.coffee # ... class App.GoogleMap # ... markers:...
Sometimes it can be useful to set your application locale based upon the request IP. You can easily achieve this using Geocoder. Among the many things Geocoder does, it can also tell the location of a request. First, add Geocoder to your Gemfile # Gemfile gem 'geocoder' Geocoder adds location...
In order to compile and run SystemVerilog code a tool called a simulator is needed. Most commonly, commercial tools from one of the Big Three EDA companies is used: Cadence Incisive Mentor Graphics QuestaSim Synopsys VCS Other EDA vendors also provide simulators: Aldec Riviera-PRO Xilinx...
GCD will guarantee that your singleton only gets instantiated once, even if called from multiple threads. Insert this into any class for a singleton instance called shared. + (instancetype)shared { // Variable that will point to the singleton instance. The `static` // modifier makes it ...
To differentiate between plural and singular strings, you can define a plural in your strings.xml file and list the different quantities, as shown in the example below: <?xml version="1.0" encoding="utf-8"?> <resources> <plurals name="hello_people&quo...
xml of the Dialog: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="mat...
String filename = "image.png"; String imagePath = getExternalFilesDir() + "/" + filename; Picasso.with(context) .load(new File(imagePath)) .into(imageView);
Callbacks offer a way to extend the functionality of a function (or method) without changing its code. This approach is often used in modules (libraries / plugins), the code of which is not supposed to be changed. Suppose we have written the following function, calculating the sum of a given array ...

Page 74 of 269