Tutorial by Examples: f

async functions do not replace the Promise type; they add language keywords that make promises easier to call. They are interchangeable: async function doAsyncThing() { ... } function doPromiseThing(input) { return new Promise((r, x) => ...); } // Call with promise syntax doAsyncThing() ...
When accessing arrays with pointers, there are no bounds check and therefore no IndexOutOfRangeException will be thrown. This makes the code faster. Assigning values to an array with a pointer: class Program { static void Main(string[] args) { unsafe { int...
The Oracle SQL and PL/SQL || operator allows you to concatenate 2 or more strings together. Example: Assuming the following customers table: id firstname lastname --- ----------- ---------- 1 Thomas Woody Query: SELECT firstname || ' ' || lastname || ' is in my database.' a...
CSS3 introduces a few new units, including the rem unit, which stands for "root em". Let's look at how rem works. First, let's look at the differences between em and rem. em: Relative to the font size of the parent. This causes the compounding issue rem: Relative to the font size of t...
Interaction with the history # List all previous commands history # Clear the history, useful if you entered a password by accident history -c Event designators # Expands to line n of bash history !n # Expands to last command !! # Expands to last command starting with "text&qu...
Prerequisites iOS 8 or later, macOS 10.9 or later, all versions of tvOS and watchOS. Xcode 8.0 or later required. Realm Swift 2.3.0 was the last version to support Swift 2.x and Xcode 7.3. Installation Dynamic Framework Download the latest release of Realm and extract the zip....
The second value in the curly braces dictates the length of the replacement string. By adjusting the second value to be positive or negative, the alignment of the string can be changed. string.Format("LEFT: string: ->{0,-5}<- int: ->{1,-5}<-", "abc", 123); string....
// Integral types as hex string.Format("Hexadecimal: byte2: {0:x2}; byte4: {0:X4}; char: {1:x2}", 123, (int)'A'); // Integers with thousand separators string.Format("Integer, thousand sep.: {0:#,#}; fixed length: >{0,10:#,#}<", 1234567); // Integer with leading zero...
Boxed value types can only be unboxed into their original Type, even if a conversion of the two Types is valid, e.g.: object boxedInt = (int)1; // int boxed in an object long unboxedInt1 = (long)boxedInt; // invalid cast This can be avoided by first unboxing into the original Type, e.g.: lon...
Examples below are given in Ruby, but same matchers should be available in any modern language. Let’s say we have the string "AℵNaïve", produced by Messy Artificial Intelligence. It consists of letters, but generic \w matcher won’t match much: ▶ "AℵNaïve"[/\w+/] #⇒ "A&q...
Create a circle image with glide. public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { ret...
All C functions are in actuality pointers to a spot in the program memory where some code exists. The main use of a function pointer is to provide a "callback" to other functions (or to simulate classes and objects). The syntax of a function, as defined further down on this page is: retu...
The "c" (or currency) format specifier converts a number to a string that represents a currency amount. string.Format("{0:c}", 112.236677) // $112.23 - defaults to system Precision Default is 2. Use c1, c2, c3 and so on to control precision. string.Format("{0:C1}"...
It is worth noting that in swift, unlike other languages people are familiar with, there is an implicit break at the end of each case statement. In order to follow through to the next case (i.e. have multiple cases execute) you need to use fallthrough statement. switch(value) { case 'one': //...
Use the Bash shell's filename expansion and brace expansion capabilities to obtain the filenames: # display the files and directories that are in the current directory printf "%s\n" * # display only the directories in the current directory printf "%s\n" */ # display only...
The following will list up to ten of the most recently modified files in the current directory, using a long listing format (-l) and sorted by time (-t). ls -lt | head
In this example we have an existing table, SuperHeros. This table contains a primary key ID. We will add a new table in order to store the powers of each super hero: CREATE TABLE HeroPowers ( ID int NOT NULL PRIMARY KEY, Name nvarchar(MAX) NOT NULL, HeroId int REFERENCES SuperHero...
Swift import SystemConfiguration /// Class helps to code reuse in handling internet network connections. class NetworkHelper { /** Verify if the device is connected to internet network. - returns: true if is connected to any internet network, false if is not co...
Although D3 is not specific for handling SVG elements, it is widely used for creating and manipulating complex SVG based data visualizations. D3 provides many powerful methods which helps to create various geometrical SVG structures with ease. It is recommended to understand basic concepts of SVG s...
The random number generator can (and should) be used for multiple distributions. #include <iostream> #include <random> int main() { std::default_random_engine pseudo_random_generator; std::uniform_int_distribution<int> int_distribution(0, 9); std::uniform_real_dis...

Page 60 of 457