Tutorial by Examples: c

Statistical functions in R make heavy use of the so-called Wilkinson-Rogers formula notation1 . When running model functions like lm for the Linear Regressions, they need a formula. This formula specifies which regression coefficients shall be estimated. my_formula1 <- formula(mpg ~ wt) class(...
//1) All attributes should be inherited from System.Attribute //2) You can customize your attribute usage (e.g. place restrictions) by using System.AttributeUsage Attribute //3) You can use this attribute only via reflection in the way it is supposed to be used //4) MethodMetadataAttribute is jus...
To find out the IP address of your container, use: docker inspect <container id> | grep IPAddress or use docker inspect docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${CID}
Payments Table CustomerPayment_typeAmountPeterCredit100PeterCredit300JohnCredit1000JohnDebit500 select customer, sum(case when payment_type = 'credit' then amount else 0 end) as credit, sum(case when payment_type = 'debit' then amount else 0 end) as debit from payments group by ...
If you need to remove one or more elements from a slice, or if you need to work with a sub slice of another existing one; you can use the following method. Following examples uses slice of int, but that works with all type of slice. So for that, we need a slice, from witch we will remove some ...
Maps in go are not safe for concurrency. You must take a lock to read and write on them if you will be accessing them concurrently. Usually the best option is to use sync.RWMutex because you can have read and write locks. However, a sync.Mutex could also be used. type RWMap struct { sync.RWMut...
Classes have 3 types of methods: instance, singleton and class methods. Instance Methods These are methods that can be called from an instance of the class. class Thing def somemethod puts "something" end end foo = Thing.new # create an instance of the class foo.somemeth...
ForEach has two different meanings in PowerShell. One is a keyword and the other is an alias for the ForEach-Object cmdlet. The former is described here. This example demonstrates printing all items in an array to the console host: $Names = @('Amy', 'Bob', 'Celine', 'David') ForEach ($Name in $...
A custom extraction can be written by implementing the unapply method and returning a value of type Option: class Foo(val x: String) object Foo { def unapply(foo: Foo): Option[String] = Some(foo.x) } new Foo("42") match { case Foo(x) => x } // "42" The retur...
Java provides several ways to copy an array. for loop int[] a = { 4, 1, 3, 2 }; int[] b = new int[a.length]; for (int i = 0; i < a.length; i++) { b[i] = a[i]; } Note that using this option with an Object array instead of primitive array will fill the copy with reference to the origi...
Example: Get a Stream of 30 elements, containing 21st to 50th (inclusive) element of a collection. final long n = 20L; // the number of elements to skip final long maxSize = 30L; // the number of elements the stream should be limited to final Stream<T> slice = collection.stream().skip(n).li...
Variable declaration for examples: Collection<String> abc = Arrays.asList("a", "b", "c"); Collection<String> digits = Arrays.asList("1", "2", "3"); Collection<String> greekAbc = Arrays.asList("alpha", "be...
Hash has a default value for keys that are requested but don't exist (nil): a = {} p a[ :b ] # => nil When creating a new Hash, one can specify the default: b = Hash.new 'puppy' p b[ :b ] # => 'puppy' Hash.new also takes a block, which allows you to automatically create n...
Two Arrays var array1 = [1, 2]; var array2 = [3, 4, 5]; 3 var array3 = array1.concat(array2); // returns a new array 6 var array3 = [...array1, ...array2] Results in a new Array: [1, 2, 3, 4, 5] Multiple Arrays var array1 = ["a", "b"], array2 = ["...
var object = { key1: 10, key2: 3, key3: 40, key4: 20 }; var array = []; for(var people in object) { array.push([people, object[people]]); } Now array is [ ["key1", 10], ["key2", 3], ["key3", 40], ["key4", 20] ] ...
For security reasons, PowerShell is set up by default to only allow signed scripts to execute. Executing the following command will allow you to run unsigned scripts (you must run PowerShell as Administrator to do this). Set-ExecutionPolicy RemoteSigned Another way to run PowerShell scripts is t...
1 + 2 # Addition 1 - 2 # Subtraction -1 # Set negative value 1 * 2 # Multiplication 1 / 2 # Division 1 % 2 # Modulus 100 -shl 2 # Bitwise Shift-left 100 -shr 1 # Bitwise Shift-right
-and # Logical and -or # Logical or -xor # Logical exclusive or -not # Logical not ! # Logical not
PowerShell comparison operators are comprised of a leading dash (-) followed by a name (eq for equal, gt for greater than, etc...). Names can be preceded by special characters to modify the behavior of the operator: i # Case-Insensitive Explicit (-ieq) c # Case-Sensitive Explicit (-ceq) Case-I...
Success output stream: cmdlet > file # Send success output to file, overwriting existing content cmdlet >> file # Send success output to file, appending to existing content cmdlet 1>&2 # Send success and error output to error stream Error output stream: cmdlet 2&g...

Page 79 of 826