Tutorial by Examples

Integer literals provide values that can be used where you need a byte, short, int, long or char instance. (This example focuses on the simple decimal forms. Other examples explain how to literals in octal, hexadecimal and binary, and the use of underscores to improve readability.) Ordinary integ...
<canvas id = "canvas" height='400' width='500'></canvas> var canvas = new fabric.Canvas(document.getElementById('canvas')); console.log(JSON.stringify(canvas)); // '{"objects":[],"background":""}' canvas.add(new fabric.Rect({ left: 10, ...
First Test.class: package foo.bar public class Test { } Also Test.class in another package package foo.bar.baz public class Test { } The above is fine because the two classes exist in different packages.
In Java if you don't provide an access modifier the default scope for variables is package-protected level. This means that classes can access the variables of other classes within the same package as if those variables were publicly available. package foo.bar public class ExampleClass { do...
Refer to this original Post by e.James According to Apple's NSInvocation class reference: An NSInvocation is an Objective-C message rendered static, that is, it is an action turned into an object. And, in a little more detail: The concept of messages is central to the objective-c philosophy....
jQuery plugins are typically installed via NPM or Yarn (if hosted there), or referencing an external script file containing the plugin, whether from a relative directory or a CDN. <script type="text/javascript" src="/path/to/plugin.jquery.js"></script>
First declare a property like this in the ViewController @property (nonatomic) UIRefreshControl *refreshControl; Later in the viewDidLoad() set up the refreshControl as given below: self.refreshControl = [[UIRefreshControl alloc]init]; [self.tableView addSubview:self.refreshControl]; [self.re...
For an easier transition to Angular 2, it's recommended to use Component, available since Angular 1.5.8 myModule.ts import { MyModuleComponent } from "./components/myModuleComponent"; import { MyModuleService } from "./services/MyModuleService"; angular .module("m...
Navigator works for both IOS and android. import React, { Component } from 'react'; import { Text, Navigator, TouchableHighlight } from 'react-native'; export default class NavAllDay extends Component { render() { return ( <Navigator initialRoute={{ title: 'Awesome Sc...
What is Concurrency? Doing multiple things at the same time. Taking advantage of number of cores available in multicore CPUs. Running multiple programs in parallel. Objectives of Concurrency Running program in background without hogging CPU. Define Tasks, Define Rules and let...
// plugin initialization $.fn.greenify = function() { // within the function you can use any of the jQuery methods // and `this` context refers to jQuery object this.css( "color", "green" ); }; // apply plugin $( "a" ).greenify();
This works, but there are a couple of things we need to do for our plugin to survive in the real world. One of jQuery's features is chaining, when you link five or six actions onto one selector. This is accomplished by having all jQuery object methods return the original jQuery object again (there a...
Jest is a javascript testing framework widely used for testing react applications. Its supported by facebook Here's a test import 'react-native'; import React from 'react'; import Index from '../index.android.js'; import renderer from 'react-test-renderer'; it('renders correctly', () =>...
To do this in Postman, you simply have to set the following: Set request type to POST In the Headers, set the following: Content-Type = application/json Authorization = < Your FCM Server Key > (See your Firebase Console's Cloud Messaging Tab) Set the payload parameters in the Body...
When a class needs to be provided with hard dependencies best practice is to use a constructor injection pattern where those dependencies are injected using a factory. Let's assume that MyClass is hard dependent on a value $dependency that needs to be resolved from the application config. <?php...
var person = { name: 'John Doe', age: 42, gender: 'male', bio: function() { console.log('My name is ' + this.name); } }; person.bio(); // logs "My name is John Doe" var bio = person.bio; bio(); // logs "My name is undefined" In the above code, person.bi...
One common pitfall is to try and use this in a nested function or an object, where the context has been lost. document.getElementById('myAJAXButton').onclick = function(){ makeAJAXRequest(function(result){ if (result) { // success this.className = 'success'; } }) }...
5.1 Every function has a bind method, which will create a wrapped function that will call it with the correct context. See here for more information. var monitor = { threshold: 5, check: function(value) { if (value > this.threshold) { this.display("Value is too high!&quot...
When using a function as a constructor, it has a special this binding, which refers to the newly created object: function Cat(name) { this.name = name; this.sound = "Meow"; } var cat = new Cat("Tom"); // is a Cat object cat.sound; // Returns "Meow" var ca...
There are various ways to use colours in Processing since Processing is very flexible with colour formats. RGB and RGBA This is the standard RGB(A) notation and the default color mode. The first three colour values (red, green, blue) range from 0 to 255. For example, the below example is the colou...

Page 1068 of 1336