Tutorial by Examples

var pattern = createPattern(imageObject,repeat) Creates a reusable pattern (object). The object can be assigned to any strokeStyle and/or fillStyle. Then stroke() or fill() will paint the Path with the pattern of the object. Arguments: imageObject is an image that will be used as a patter...
context.stroke() Causes the perimeter of the Path to be stroked according to the current context.strokeStyle and the stroked Path is visually drawn onto the canvas. Prior to executing context.stroke (or context.fill) the Path exists in memory and is not yet visually drawn on the canvas. The unu...
context.fill() Causes the inside of the Path to be filled according to the current context.fillStyle and the filled Path is visually drawn onto the canvas. Prior to executing context.fill (or context.stroke) the Path exists in memory and is not yet visually drawn on the canvas. Example code usi...
context.clip Limits any future drawings to display only inside the current Path. Example: Clip this image into a triangular Path <!doctype html> <html> <head> <style> body{ background-color:white; } #canvas{border:1px solid red; } </style> <sc...
This function executes an AJAX request using the HEAD method allowing us to check whether a file exists in the directory given as an argument. It also enables us to launch a callback for each case (success, failure). function fileExists(dir, successCallback, errorCallback) { var xhttp = new XM...
You can also perform this task recursively, but I have chosen in this example to use an iterative approach. This task is useful if you are inserting all of your nodes at the beginning of a linked list. Here is an example: #include <stdio.h> #include <stdlib.h> #define NUM_ITEMS 10...
The Python interpreter compiles code to bytecode before executing it on the Python's virtual machine (see also What is python bytecode?. Here's how to view the bytecode of a Python function import dis def fib(n): if n <= 2: return 1 return fib(n-1) + fib(n-2) # Display the disas...
CPython allows access to the code object for a function object. The __code__object contains the raw bytecode (co_code) of the function as well as other information such as constants and variable names. def fib(n): if n <= 2: return 1 return fib(n-1) + fib(n-2) dir(fib.__code__) de...
Dictionaries map keys to values. car = {} car["wheels"] = 4 car["color"] = "Red" car["model"] = "Corvette" Dictionary values can be accessed by their keys. print "Little " + car["color"] + " " + car["model&q...
Detailed instructions on getting ibm-mobilefirst set up or installed.
This example goes over how to set up CoreNLP from the GitHub repo. The GitHub code has newer features than the official release, but may be unstable. This example will take you through downloading, building, and running a simple command-line invocation of CoreNLP. Prerequisites: Java 8 or newer....
To install NLTK with Continuum's anaconda / conda. If you are using Anaconda, most probably nltk would be already downloaded in the root (though you may still need to download various packages manually). Using conda: conda install nltk To upgrade nltk using conda: conda update nltk With a...
There are many compilers that support different versions of the OpenMP specification. OpenMP maintains a list here with the compiler that support it and the supported version. In general, to compile (and link) an application with OpenMP support you need only to add a compile flag and if you use the ...
Get current date and time lib.date = TEXT lib.date { data = date:U strftime = %d.%m.%Y %H:%M:%S wrap = Today is | } Get last login time and date from fe_users lib.date = TEXT lib.date { data = TSFE:fe_user|user|lastlogin strftime = %d.%m.%Y %H:%M:%S wrap = Last logi...
Given this setup code: var dict = new Dictionary<int, string>() { { 1, "First" }, { 2, "Second" }, { 3, "Third" } }; Use the Remove method to remove a key and its associated value. bool wasRemoved = dict.Remove(2); Executing this code remo...
A common use case for a for loop is to iterate over a predefined range or collection, and do the same task for all its elements. For instance, here we combine a for loop with a conditional if-elseif-else statement: for i in 1:100 if i % 15 == 0 println("FizzBuzz") elsei...
The while loop runs its body as long as the condition holds. For instance, the following code computes and prints the Collatz sequence from a given number: function collatz(n) while n ≠ 1 println(n) n = iseven(n) ? n ÷ 2 : 3n + 1 end println("1... and 4, 2, 1, ...
In some situations, one might want to return from a function before finishing an entire loop. The return statement can be used for this. function primefactor(n) for i in 2:n if n % i == 0 return i end end @assert false # unreachable end Usage: jul...
In Julia, a for loop can contain a comma (,) to specify iterating over multiple dimensions. This acts similarly to nesting a loop within another, but can be more compact. For instance, the below function generates elements of the Cartesian product of two iterables: function cartesian(xs, ys) f...
Julia provides macros to simplify distributing computation across multiple machines or workers. For instance, the following computes the sum of some number of squares, possibly in parallel. function sumofsquares(A) @parallel (+) for i in A i ^ 2 end end Usage: julia> sumo...

Page 587 of 1336