Tutorial by Examples: du

Assuming we want to modify bit n of an integer primitive, i (byte, short, char, int, or long): (i & 1 << n) != 0 // checks bit 'n' i |= 1 << n; // sets bit 'n' to 1 i &= ~(1 << n); // sets bit 'n' to 0 i ^= 1 << n; // toggles the value of bit 'n' Us...
In order to obtain class-like behavior, type and related procedures (subroutine and functions) shall be placed in a module: Example: module MShape implicit none private type, public :: Shape private integer :: radius contains procedure :: set => sh...
Let's say we have model Travel with many related fields: class Travel(models.Model): tags = models.ManyToManyField( Tag, related_name='travels', ) route_places = models.ManyToManyField( RoutePlace, related_name='travels', ) coordinate = models.F...
Sometimes it is useful to create union types with only one case to implement record-like types: type Point = Point of float * float let point1 = Point(0.0, 3.0) let point2 = Point(-2.5, -4.0) These become very useful because they can be decomposed via pattern matching in the same way as tu...
C# statements executes in either checked or unchecked context. In a checked context, arithmetic overflow raises an exception. In an unchecked context, arithmetic overflow is ignored and the result is truncated. short m = 32767; short n = 32767; int result1 = checked((short)(m + n)); //will ...
Download and extract the OSGi starter kit for your platform from Equinox download page for Neon release. Start the framework from the rt/plugins folder with the following command (or your platform's rt executable from the rt folder): rt/plugins$ java -jar org.eclipse.equinox.launcher_1.3.200.v2016...
Optionals (also known as Maybe types) are used to represent a type whose contents may or may not be present. They are implemented in C++17 as the std::optional class. For example, an object of type std::optional<int> may contain some value of type int, or it may contain no value. Optionals ar...
A metatable defines a set of operations which alter the behaviour of a lua object. A metatable is just an ordinary table, which is used in a special way. local meta = { } -- create a table for use as metatable -- a metatable can change the behaviour of many things -- here we modify the 'tostrin...
Ionic Framework A Cross-platform mobile application development framework using Angular JS and Front End web technologies. Official website: http://ionicframework.com/ Documentation: http://ionicframework.com/docs/ Installation and Setup Installation Ionic required NPM(Node Package Manager) an...
The Windows API documentation for functions taking one or more string as argument will usually look like this: BOOL WINAPI CopyFile( _In_ LPCTSTR lpExistingFileName, _In_ LPCTSTR lpNewFileName, _In_ BOOL bFailIfExists ); The datatype for the two string parameters is made of several ...
really_neat.info name = Really Neat Module description = Provides a really neat page for your site core = 7.x really_neat.module <?php /** * @file * Hook implementation and shared functions for the Really Neat Module. */ /** * Implements hook_menu(). */ function really_nea...
Problem # models.py: class Library(models.Model): name = models.CharField(max_length=100) books = models.ManyToManyField(Book) class Book(models.Model): title = models.CharField(max_length=100) # views.py def myview(request): # Query the database. libraries = Librar...
Problem Django querysets are evaluated in a lazy fashion. For example: # models.py: class Author(models.Model): name = models.CharField(max_length=100) class Book(models.Model): author = models.ForeignKey(Author, related_name='books') title = models.CharField(max_length=100) ...
In Python 3.x, the reduce function already explained here has been removed from the built-ins and must now be imported from functools. from functools import reduce def factorial(n): return reduce(lambda a, b: (a*b), range(1, n+1))
Intervals are simplest way of recording timespans in lubridate. An interval is a span of time that occurs between two specific instants. # create interval by substracting two instants today_start <- ymd_hms("2016-07-22 12-00-00", tz="IST") today_start ## [1] "2016-07-...
Unlike durations, periods can be used to accurately model clock times without knowing when events such as leap seconds, leap days, and DST changes occur. start_2012 <- ymd_hms("2012-01-01 12:00:00") ## [1] "2012-01-01 12:00:00 UTC" # period() considers leap year calculati...
Files: - example.rs (root of our modules tree, generally named lib.rs or main.rs when using Cargo) - first.rs - second/ - mod.rs - sub.rs Modules: - example -> example - first -> example::first - second -> example::second - sub -> exampl...
Install haveged (example sudo apt-get install haveged) to speed up the random byte process. Then: gpg --gen-key gpg --list-keys outputs: pub 2048R/NNNNNNNN 2016-01-01 uid Name <[email protected]> sub 2048R/xxxxxxxx 2016-01-01 Then publish: gpg --keyserver pgp.mi...
Tuples in Python are values separated by commas. Enclosing parentheses for inputting tuples are optional, so the two assignments a = 1, 2, 3 # a is the tuple (1, 2, 3) and a = (1, 2, 3) # a is the tuple (1, 2, 3) are equivalent. The assignment a = 1, 2, 3 is also called packing because it...
Redux is the most common state management library used with React-Native. The following example demonstrates how to use the fetch API and dispatch changes to your applications state reducer using redux-thunk. export const fetchRecipes = (action) => { return (dispatch, getState) => { f...

Page 10 of 47