Tutorial by Examples

To remove a value from a WeakSet, use the .delete() method. This method returns true if the value existed and has been removed, otherwise false. const obj1 = {}, obj2 = {}; const weakset = new WeakSet([obj1]); console.log(weakset.delete(obj1)); // true console.log(weakset.delete(obj2));...
import java.util.stream.IntStream; public class Concurrent { public static void printAndWait(String s) { System.out.println(s); try { Thread.sleep(1000); } catch (Exception e) {} } public static void main(String[] args) { Threa...
The loop macro has two forms: the "simple" form and the "extended" form. The extended form is covered in another documentation topic, but the simple loop is useful for very basic loop. The simple loop form takes a number of forms and repeats them until the loop is exited using ...
Our server object is given an 'application' parameter which can be any callable application object (see other examples). It writes first the headers, then the body of data returned by our application to the system standard output. import os, sys def run(application): environ['wsgi.inpu...
The name Smalltalk usually refers to ANSI Smalltalk or Smalltalk 80 (of which the first is based on). While most implementations are close to the standard, they vary in different aspects (usually referred to as dialects). Each implementation has it's own method of installation. Well known FOSS imp...
Care must be taken when initializing variables of type float to literal values or comparing them with literal values, because regular floating point literals like 0.1 are of type double. This may lead to surprises: #include <stdio.h> int main() { float n; n = 0.1; if (n > ...
Description This is a self-contained running example including/showcasing: minimum dependencies needed, Java Configuration, Bean declaration by annotation and Java Configuration, Dependency Injection by Constructor and by Property, and Pre/Post hooks. Dependencies These dependencies are needed in...
Once an object has an effective type, you should not attempt to modify it through a pointer of another type, unless that other type is a character type, char, signed char or unsigned char. #include <inttypes.h> #include <stdio.h> int main(void) { uint32_t a = 57; // conversion...
To do this first locate config folder in your root. Then open connections.js Locate // someMysqlServer: { // adapter: 'sails-mysql', // host: 'YOUR_MYSQL_SERVER_HOSTNAME_OR_IP_ADDRESS', // user: 'YOUR_MYSQL_USER', //optional // password: 'YOUR_MYSQL_PASSWORD', //optional /...
A problem: Canvas only remembers pixels, not shapes or images This is an image of a circular beach ball, and of course, you can't drag the ball around the image. It may surprise you that just like an image, if you draw a circle on a Canvas you cannot drag that circle around the canvas. That's be...
What is a "Shape"? You typically save your shapes by creating a JavaScript "shape" object representing each shape. var myCircle = { x:30, y:20, radius:15 }; Of course, you're not really saving shapes. Instead, you're saving the definition of how to draw the shapes. Then put...
Most Canvas drawings are either rectangular (rectangles, images, text-blocks) or circular (circles). Circles & rectangles have mathematical tests to check if the mouse is inside them. This makes testing circles and rectangles easy, quick and efficient. You can "hit-test" hundreds of c...
See this Example for a general explanation of dragging Shapes around the Canvas. This annotated example shows how to drag images around the Canvas // canvas related vars var canvas=document.createElement("canvas"); var ctx=canvas.getContext("2d"); canvas.width=378; canvas.h...
Here is an example of an IntentService that pretends to load images in the background. All you need to do to implement an IntentService is to provide a constructor that calls the super(String) constructor, and you need to implement the onHandleIntent(Intent) method. public class ImageLoaderIntentSe...
The exposition pipe operator, %$%, exposes the column names as R symbols within the left-hand side object to the right-hand side expression. This operator is handy when piping into functions that do not have a data argument (unlike, say, lm) and that don't take a data.frame and column names as arg...
Given the 3 points of a quadratic curve the following function returns the length. function quadraticBezierLength(x1,y1,x2,y2,x3,y3) var a, e, c, d, u, a1, e1, c1, d1, u1, v1x, v1y; v1x = x2 * 2; v1y = y2 * 2; d = x1 - v1x + x3; d1 = y1 - v1y + y3; e = v1x - 2 * x1; ...
Open Script Editor. 2.12.4 With Mac OS X Leopard and earlier, and OS X Yosemite and later, Script Editor is located at /Applications/Utilities/Script Editor.app 2.12.4 Between Mac OS X Snow Leopard and OS X Mavericks inclusive, Script Editor is AppleScript Editor. /Applications/Utiliti...
Composing multiple functions into one is a functional programming common practice; composition makes a pipeline through which our data will transit and get modified simply working on the function-composition (just like snapping pieces of a track together)... you start out with some single responsi...
Python's built-in crypto functionality is currently limited to hashing. Encryption requires a third-party module like pycrypto. For example, it provides the AES algorithm which is considered state of the art for symmetric encryption. The following code will encrypt a given message using a passphrase...
Consider the following Python2.x code. Save the file as example.py Python 2.x2.0 def greet(name): print "Hello, {0}!".format(name) print "What's your name?" name = raw_input() greet(name) In the above file, there are several incompatible lines. The raw_input() meth...

Page 739 of 1336