Tutorial by Examples

A classic use of here documents is to create a file by typing its content: cat > fruits.txt << EOF apple orange lemon EOF The here-document is the lines between the << EOF and EOF. This here document becomes the input of the cat command. The cat command simply outputs its in...
You can override 4 methods of SKScene to detect user touch class GameScene: SKScene { override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { } override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) { ...
If you need to add custom headers to your volley requests, you can't do this after initialisation, as the headers are saved in a private variable. Instead, you need to override the getHeaders() method of Request.class as such: new JsonObjectRequest(REQUEST_METHOD, REQUEST_URL, REQUEST_BODY, RESP_L...
expr or Evaluate expressions evaluates an expression and writes the result on standard output Basic arithmetics expr 2 + 3 5 When multiplying, you need to escape the * sign expr 2 \* 3 6 You can also use variables a=2 expr $a + 3 5 Keep in mind that it only supports integers, so exp...
Due to not being Excel-VBA exclusive contents this Example has been moved to VBA documentation. Link: Dynamic Arrays (Array Resizing and Dynamic Handling)
Most of the built-in operators (including conversion operators) can be overloaded by using the operator keyword along with the public and static modifiers. The operators comes in three forms: unary operators, binary operators and conversion operators. Unary and binary operators requires at least o...
// Shows the author and commit per line of specified file git blame test.c // Shows the author email and commit per line of specified git blame -e test.c file // Limits the selection of lines by specified range git blame -L 1,10 test.c
Configure your app's URLconf to automatically use a URL namespace by setting the app_name attribute: # In <myapp>/urls.py from django.conf.urls import url from .views import overview app_name = 'myapp' urlpatterns = [ url(r'^$', overview, name='overview'), ] This will set t...
NOTE: This is only available in Scala 2.12+ (and in recent 2.11.x versions with the -Xexperimental -Xfuture compiler flags) A SAM type can be implemented using a lambda: 2.11.8 trait Runnable { def run(): Unit } val t: Runnable = () => println("foo") The type can optional...
Setup First, install the necessary packages with: npm install express cors mongoose Code Then, add dependencies to server.js, create the database schema and the name of the collection, create an Express.js server, and connect to MongoDB: var express = require('express'); var cors = require('...
Use $this to refer to the current object. Use self to refer to the current class. In other words, use $this->member for non-static members, use self::$member for static members. In the example below, sayHello() and sayGoodbye() are using self and $this difference can be observed here. cl...
The factorial of a number (denoted with !, as for instance 9!) is the multiplication of that number with the factorial of one lower. So, for instance, 9! = 9 x 8! = 9 x 8 x 7! = 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1. So in code that becomes, using recursion: long Factorial(long x) { if (x < 1...
The dot operator repeats the last action performed, for instance: file test.tx helo, World! helo, David! (cursor at [1][1]) Now perform a cwHello<Esc> (Change Word helo to Hello) Now the buffer looks like that: Hello, World! helo, David! (cursor at [1][5]) After typing j_ the cur...
You can create temporary files which has a visible name on the file system which can be accessed via the name property. The file can, on unix systems, be configured to delete on closure (set by delete param, default is True) or can be reopened later. The following will create and open a named temp...
As we know we can declare an array with default values: int[] arr = new int[10]; This will create an array of 10 integers with each element of the array having value 0 (the default value of type int). To create an array initialized with a non-default value, we can use Enumerable.Repeat from the...
Event delegation is a process which allow us to avoid adding event listeners to specific nodes; instead, the event listener is added to parent node. This mechanism utilizes the event propagation/bubbling to handle an event at a higher level element/node in the DOM instead of using the element on whi...
You might have heard that everything in Python is an object, even literals. This means, for example, 7 is an object as well, which means it has attributes. For example, one of these attributes is the bit_length. It returns the amount of bits needed to represent the value it is called upon. x = 7 ...
A Scripting Dictionary object stores information in Key/Item pairs. The Keys must be unique and not an array but the associated Items can be repeated (their uniqueness is held by the companion Key) and can be of any type of variant or object. A dictionary can be thought of as a two field in-memory ...
The following example uses Express to create an HTTP server listening on port 3000, which responds with "Hello, World!". Express is a commonly-used web framework that is useful for creating HTTP APIs. First, create a new folder, e.g. myApp. Go into myApp and make a new JavaScript file con...
<svg width="900px" height="400px" viewBox="900 400"> <defs> <filter id="GaussianHardEdge" x="0%" y="0%" width="100%" height="100%"> <feGaussianBlur stdDeviation="5"/&gt...

Page 486 of 1336