Tutorial by Examples: ble

To add multiple columns to a table, separate field:type pairs with spaces when using rails generate migration command. The general syntax is: rails generate migration NAME [field[:type][:index] field[:type][:index]] [options] For example, the following will add name, salary and email fields to ...
Create a simple table create table MY_table ( what varchar2(10), who varchar2(10), mark varchar2(10) ); Insert values (you can omit target columns if you provide values for all columns) insert into my_table (what, who, mark) values ('Hello', 'world', '!' ); insert into my_table ...
Variables inside single quotes ' don't get expanded by POSIX compatible shells, so using a shell variable in a sed substitution requires the use of double quotes " instead of single quotes ': $ var="he" $ echo "hello" | sed "s/$var/XX/" XXllo $ var="he&q...
Using environment variables is a widely used way to setting an app's config depending on it environment, as stated in The Twelve-Factor App. As configurations are likely to change between deployment environments, this is a very interesting way to modify the configuration without having to dig in th...
If the variable contains a value of an immutable type (e.g. a string) then it is okay to assign a default value like this class Rectangle(object): def __init__(self, width, height, color='blue'): self.width = width self.height = height self.color = color d...
Ansible maintains a PPA repository that can be used to install the Ansible binaries: sudo apt-add-repository ppa:ansible/ansible -y sudo apt-get update && sudo apt-get install ansible -y To install a specific version, use pip. The PPA may be out of date.
There are two main ways way to install Ansible on OS X, either using the Homebrew or Pip package manager. If you have homebrew, the latest Ansible can be installed using the following command: brew install ansible To install Ansible 1.9.X branch use following command: brew install homebrew/ver...
When Fortran was originally developed memory was at a premium. Variables and procedure names could have a maximum of 6 characters, and variables were often implicitly typed. This means that the first letter of the variable name determines its type. variables beginning with i, j, ..., n are intege...
Python 3.x3.3 Use yield from if you want to yield all values from another iterable: def foob(x): yield from range(x * 2) yield from range(2) list(foob(5)) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1] This works with generators as well. def fibto(n): a, b = 1, 1 while True: ...
5.0 In PowerShell 5.0+ you can list available constructors by calling the static new-method without parentheses. PS> [DateTime]::new OverloadDefinitions ------------------- datetime new(long ticks) datetime new(long ticks, System.DateTimeKind kind) datetime new(int year, int month, int d...
The data.table package provides a convenient way to group by runs in data. Consider the following example data: library(data.table) (DT <- data.table(x = c(1, 1, 2, 2, 2, 1), y = 1:6)) # x y # 1: 1 1 # 2: 1 2 # 3: 2 3 # 4: 2 4 # 5: 2 5 # 6: 1 6 The variable x has three runs: a run ...
NSArray *myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; // Convert myColors to mutable NSMutableArray *myColorsMutable = [myColors mutableCopy];
std::enable_if is a convenient utility to use boolean conditions to trigger SFINAE. It is defined as: template <bool Cond, typename Result=void> struct enable_if { }; template <typename Result> struct enable_if<true, Result> { using type = Result; }; That is, enable_...
Variables hold data. Name them after what they're used for, not after their data type or scope, using a noun. If you feel compelled to number your variables (e.g. thing1, thing2, thing3), then consider using an appropriate data structure instead (e.g. an array, a Collection, or a Dictionary). Names...
This thread-safe version of a singleton was necessary in the early versions of .NET where static initialization was not guaranteed to be thread-safe. In more modern versions of the framework a statically initialized singleton is usually preferred because it is very easy to make implementation mistak...
Sometimes it's not a good practice expose an internal collection since it can lead to a malicious code vulnerability due to it's mutable characteristic. In order to provide "read-only" collections java provides its unmodifiable versions. An unmodifiable collection is often a copy of a mod...
This example of the Sortable using a Placeholder is common usage. Sortable is applied to a group of DOM elements, allowing the user to move items around in the list via Drag'n Drop style actions. <!doctype html> <html lang="en"> <head> <meta charset="utf-8&q...
At some point in your use of Django, you may find yourself wanting to interact with tables which have already been created, or with database views. In these cases, you would not want Django to manage the tables through its migrations. To set this up, you need to add only one variable to your model's...
This type of testing is popular technique for testing with predefined input and output values. Create a file called main.go with content: package main import ( "fmt" ) func main() { fmt.Println(Sum(4, 5)) } func Sum(a, b int) int { return a + b } After you r...
public IEnumerable<int> F1() { for (int i = 0; i < 3; i++) yield return i; //return F2(); // Compile Error!! foreach (var element in F2()) yield return element; } public int[] F2() { return new[] { 3, 4, 5 }; }

Page 7 of 62