Tutorial by Examples: and

Linux uses some conventions for present and parent directories. This can be a little confusing for beginners. Whenever you are in a terminal in Linux, you will be in what is called the current working directory. Often your command prompt will display either the full working directory, or just the l...
Given a string, strspn calculates the length of the initial substring (span) consisting solely of a specific list of characters. strcspn is similar, except it calculates the length of the initial substring consisting of any characters except those listed: /* Provided a string of "tokens&quo...
class A: x = None # type: float def __init__(self, x: float) -> None: """ self should not be annotated init should be annotated to return None """ self.x = x @classmethod def from_int(cls, x: int...
Variables are annotated using comments: x = 3 # type: int x = negate(x) x = 'a type-checker might catch this error' Python 3.x3.6 Starting from Python 3.6, there is also new syntax for variable annotations. The code above might use the form x: int = 3 Unlike with comments, it is also pos...
Double quoteSingle quoteAllows variable expansionPrevents variable expansionAllows history expansion if enabledPrevents history expansionAllows command substitutionPrevents command substitution* and @ can have special meaning* and @ are always literalsCan contain both single quote or double quoteSin...
class Plane { enum Emergency: ErrorType { case NoFuel case EngineFailure(reason: String) case DamagedWing } var fuelInKilograms: Int //... init and other methods not shown func fly() throws { // ... if fuelInKilograms ...
process.argv is an array containing the command line arguments. The first element will be node, the second element will be the name of the JavaScript file. The next elements will be any additional command line arguments. Code Example: Output sum of all command line arguments index.js var sum = 0...
A whole circle is 360 degrees or Math.PI * 2 radians. Half of those values follows to be 180 degrees or Math.PI radians. A quarter is then 90 degrees or Math.PI / 2 radians. To get a segment as a percentage of a whole circle in radians: function getSegment(percent:Number):Number { retur...
clojure.spec/and & clojure.spec/or can be used to create more complex specs, using multiple specs or predicates: (clojure.spec/def ::pos-odd (clojure.spec/and odd? pos?)) (clojure.spec/valid? ::pos-odd 1) ;;=> true (clojure.spec/valid? ::pos-odd -3) ;;=> false or works similarl...
A slider element can have its value set on initialization by providing a value option. This option is a number: $( "#slider" ).slider({ value: 5 }); A range slider can also have its values set in this way by providing a values option. This option is an array of numbers: $( &qu...
The slider provides an event called change that will trigger after the mouse completes a slider handle drag or if the value(s) have been changed programmatically. This function holds a reference to the slide event and a reference to the slider ui object. The ui object holds a jQuery object for the ...
The @Header and @Body annotations can be placed into the method signatures and Retrofit will automatically create them based on your models. public interface MyService { @POST("authentication/user") Call<AuthenticationResponse> authenticateUser(@Body AuthenticationReques...
Import in your gradle root file classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' Import in your gradle app file apt 'com.google.auto.value:auto-value:1.2' apt 'com.ryanharter.auto.value:auto-value-gson:0.3.1' provided 'com.jakewharton.auto.value:auto-value-annotations:1.2-update...
When you need to set a pixel value for something like Paint.setTextSize but still want it be scaled based on the device, you can convert dp and sp values. DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics(); float pixels = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12f, m...
ENV ENV <key> <value> ENV <key>=<value> ... The ENV instruction sets the environment variable <key> to the value . This value will be in the environment of all “descendant” Dockerfile commands and can be replaced inline in many as well. The ENV instruction has two...
This script, from here and here, will return all Tables and Columns where a specified value exists. This is powerful in finding out where a certain value is in a database. It can be taxing, so it is suggested that it be executed in a backup / test enviroment first. DECLARE @SearchStr nvarchar(100) ...
Using the Authors table in the Library Database CREATE PROCEDURE GetName ( @input_id INT = NULL, --Input parameter, id of the person, NULL default @name VARCHAR(128) = NULL --Input parameter, name of the person, NULL default ) AS BEGIN SELECT Name + ' is from ' + Country...
Once Powershell remoting is enabled (Enable-PSRemoting) You can run commands on the remote computer like this: Invoke-Command -ComputerName "RemoteComputerName" -ScriptBlock { Write host "Remote Computer Name: $ENV:ComputerName" } The above method creates a temporary se...
The rep function can be used to repeat a vector in a fairly flexible manner. # repeat counting numbers, 1 through 5 twice rep(1:5, 2) [1] 1 2 3 4 5 1 2 3 4 5 # repeat vector with incomplete recycling rep(1:5, 2, length.out=7) [1] 1 2 3 4 5 1 2 The each argument is especially useful for ex...
var multiplexer = ConnectionMultiplexer.Connect("localhost"); IDatabase db = multiplexer.GetDatabase(); // intialize key with empty string await db.StringSetAsync("key", ""); // create transaction that utilize multiplexing and pipelining ITransaction transacton...

Page 46 of 153