Tutorial by Examples: bi

Run command below to install nginx. sudo apt-get install nginx By default, Nginx automatically starts when it is installed. You can access the default Nginx landing page to confirm that the software is running properly by visiting your server's domain name or public IP address in your web browse...
Binary folds are basically unary folds, with an extra argument. There are 2 kinds of binary folds: Binary Left Fold - (value op ... op pack) - Expands as follows: (((Value op Pack1) op Pack2) op ...) op PackN Binary Right Fold (pack op ... op value) - Expands as follows: Pack1 op (......
If you need to know whether a value's type extends or implements a given type, but you don't want to actually cast it as that type, you can use the is operator. if(value is int) { Console.WriteLine(value + "is an int"); }
public class Singleton { private static class InstanceHolder { static final Singleton INSTANCE = new Singleton(); } public static Singleton getInstance() { return InstanceHolder.INSTANCE; } private Singleton() {} } This initializes the INSTANCE vari...
Enums can be mutable, this is another way to obtain a singleton behavior: enum class Planet(var population: Int = 0) { EARTH(7 * 100000000), MARS(); override fun toString() = "$name[population=$population]" } println(Planet.MARS) // MARS[population=0] Planet.MARS.p...
To convert decimal number to binary format use base 2 Int32 Number = 15; Console.WriteLine(Convert.ToString(Number, 2)); //OUTPUT : 1111 To convert decimal number to octal format use base 8 int Number = 15; Console.WriteLine(Convert.ToString(Number, 8)); //OUTPUT : 17 To conv...
Values can be given names using let: # let a = 1;; val a : int = 1 You can use similar syntax to define a function. Just provide additional parameters for the arguments. # let add arg1 arg2 = arg1 + arg2;; val add : int -> int -> int = <fun> We can call it like this: # add 1...
A helper function to create a bitmap copy of an object. This can be used to convert vector objects, text or complex nested Sprite's to a flattened bitmap. function makeBitmapCopy(displayObj:IBitmapDrawable, transparent:Boolean = false, bgColor:uint = 0x00000000, smooth:Boolean = true):Bitmap { ...
To forbid null values in your table columns, add the :null parameter to your migration, like this: class AddPriceToProducts < ActiveRecord::Migration def change add_column :products, :float, null: false end end
The Java language provides 4 operators that perform bitwise or logical operations on integer or boolean operands. The complement (~) operator is a unary operator that performs a bitwise or logical inversion of the bits of one operand; see JLS 15.15.5.. The AND (&) operator is a binary operat...
Iota can be very useful when creating a bitmask. For instance, to represent the state of a network connection which may be secure, authenticated, and/or ready, we might create a bitmask like the following: const ( Secure = 1 << iota // 0b001 Authn // 0b010 Ready ...
import random probability = 0.3 if random.random() < probability: print("Decision with probability 0.3") else: print("Decision with probability 0.7")
The pattern matching library trivia provides a system trivia.ppcre that allows captured groups to be bound through pattern matching (trivia:match "John Doe" ((trivia.ppcre:ppcre "(.*)\\W+(.*)" first-name last-name) (list :first-name first-name :last-name last-name))) ;...
itertools.combinations will return a generator of the k-combination sequence of a list. In other words: It will return a generator of tuples of all the possible k-wise combinations of the input list. For Example: If you have a list: a = [1,2,3,4,5] b = list(itertools.combinations(a, 2)) print ...
Generic parameters can also be bound to more than one type using the T extends Type1 & Type2 & ... syntax. Let's say you want to create a class whose Generic type should implement both Flushable and Closeable, you can write class ExampleClass<T extends Flushable & Closeable> { }...
CREATE TRIGGER BooksDeleteTrigger ON MyBooksDB.Books AFTER DELETE AS INSERT INTO BooksRecycleBin SELECT * FROM deleted; GO
The following example shows how to merge two arrays into one associative array, where the key values will be the items of the first array, and the values will be from the second: $array_one = ['key1', 'key2', 'key3']; $array_two = ['value1', 'value2', 'value3']; $array_three = array_combine($ar...
options = { "x": ["a", "b"], "y": [10, 20, 30] } Given a dictionary such as the one shown above, where there is a list representing a set of values to explore for the corresponding key. Suppose you want to explore "x"="a" w...
C-style bit manipulation A bit can be set using the bitwise OR operator (|). // Bit x will be set number |= 1LL << x; Using std::bitset set(x) or set(x,true) - sets bit at position x to 1. std::bitset<5> num(std::string("01100")); num.set(0); // num is now 01101 ...
C-style bit-manipulation A bit can be cleared using the bitwise AND operator (&). // Bit x will be cleared number &= ~(1LL << x); Using std::bitset reset(x) or set(x,false) - clears the bit at position x. std::bitset<5> num(std::string("01100")); num.reset(2); ...

Page 8 of 29