Tutorial by Examples

Use existing .NET classes instantly with PowerShell by using [class]::Method(args): PS C:\> [guid]::NewGuid() Guid ---- 8874a185-64be-43ed-a64c-d2fe4b6e31bc Similarly, in PowerShell 5+ you may use the New-Guid cmdlet: PS C:\> New-Guid Guid ---- 8874a185-64be-43ed-a64c-d2fe4b6e31...
import std.stdio; // Let's get going! void main() { writeln("Hello World!"); } To compile and run, save this text as a file called main.d. From the command line run dmd main.d to compile the program. Finally, run ./main to execute the program in a bash shell or you can click ...
If value types are assigned to variables of type object they are boxed - the value is stored in an instance of a System.Object. This can lead to unintended consequences when comparing values with ==, e.g.: object left = (int)1; // int in an object box object right = (int)1; // int in an object bo...
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...
The fetch function does not send cookies by default. There are two possible ways to send cookies: Only send cookies if the URL is on the same origin as the calling script. fetch('/login', { credentials: 'same-origin' }) Always send cookies, even for cross-origin calls. fetch('htt...
The Protractor API allows CSS element locators to use the jQuery-like shortcut notation $(). Normal CSS Element Locator: element(by.css('h1.documentation-text[ng-bind="title"]')); element(by.css('[ng-click="submit"])); Shortcut $() CSS Element Locator: $('h1.documentatio...
This example shows how to check permissions at runtime in Android 6 and later. public static final int MULTIPLE_PERMISSIONS = 10; // code you want. String[] permissions = new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA, Manifest.permission.ACC...
The GridLayout allows you to arrange components in the form of a grid. You pass the number of rows and columns you want the grid to have to the GridLayout's constructor, for example new GridLayout(3, 2) will create a GridLayout with 3 rows and 2 columns. When adding components to a container with ...
Use the speakUtterance: method of AVSpeechSynthesizer to convert text to speech. You need to pass an AVSpeechUtterance object to this method, which contains the text that you want to be spoken. Objective C AVSpeechSynthesizer *speaker = [[AVSpeechSynthesizer alloc] init]; AVSpeechUtterance *speec...
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...
This example shows, how to make a UIView or UIImageView, rounded with some radius like this: Objective-C someImageView.layer.cornerRadius = CGRectGetHeight(someImageView.frame) / 2; someImageView.clipsToBounds = YES; Swift someImageView.layer.cornerRadius = someImageView.frame.height/2 // ...
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...
const myArr = ['one', 'two', 'three'] const [ a, b, c ] = myArr // a = 'one', b = 'two, c = 'three' We can set default value in destructuring array, see the example of Default Value While Destructuring. With destructuring array, we can swap the values of 2 variables easily: var a = 1; var ...
Destructuring is a convenient way to extract properties from objects into variables. Basic syntax: let person = { name: 'Bob', age: 25 }; let { name, age } = person; // Is equivalent to let name = person.name; // 'Bob' let age = person.age; // 25 Destructuring and renaming: le...
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}"...
Atom https://atom.io/packages/language-elm https://atom.io/packages/elmjutsu Light Table https://github.com/rundis/elm-light Sublime Text https://packagecontrol.io/packages/Elm%20Language%20Support Vim https://github.com/ElmCast/elm-vim Emacs https://github.com/jcollard/e...
The splice()method can be used to remove elements from an array. In this example, we remove the first 3 from the array. var values = [1, 2, 3, 4, 5, 3]; var i = values.indexOf(3); if (i >= 0) { values.splice(i, 1); } // [1, 2, 4, 5, 3] The splice() method can also be used to add elemen...
function foo() { console.trace('My log statement'); } foo(); Will display this in the console: My log statement VM696:1 foo @ VM696:1 (anonymous function) @ (program):1 Note: Where available it's also useful to know that the same stack trace is accessible a...
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': //...

Page 187 of 1336