This example assumes Ruby and Ruby on Rails have already been installed properly.
If not, you can find how to do it here.
Open up a command line or terminal. To generate a new rails application, use rails new command followed by the name of your application:
$ rails new my_app
If you want to c...
import random
randint()
Returns a random integer between x and y (inclusive):
random.randint(x, y)
For example getting a random number between 1 and 8:
random.randint(1, 8) # Out: 8
randrange()
random.randrange has the same syntax as range and unlike random.randint, the last value is no...
Standard Creation
It is recommended to use this form only when creating regex from dynamic variables.
Use when the expression may change or the expression is user generated.
var re = new RegExp(".*");
With flags:
var re = new RegExp(".*", "gmi");
With a backsl...
x > y
x < y
These operators compare two types of values, they're the less than and greater than operators. For numbers this simply compares the numerical values to see which is larger:
12 > 4
# True
12 < 4
# False
1 < 4
# True
For strings they will compare lexicographical...
Arrays can be created by enclosing a list of elements in square brackets ([ and ]). Array elements in this notation are separated with commas:
array = [1, 2, 3, 4]
Arrays can contain any kind of objects in any combination with no restrictions on type:
array = [1, 'b', nil, [3, 4]]
Arrays of strings can be created using ruby's percent string syntax:
array = %w(one two three four)
This is functionally equivalent to defining the array as:
array = ['one', 'two', 'three', 'four']
Instead of %w() you may use other matching pairs of delimiters: %w{...}, %w[...] or %w<...&...
2.0
array = %i(one two three four)
Creates the array [:one, :two, :three, :four].
Instead of %i(...), you may use %i{...} or %i[...] or %i!...!
Additionally, if you want to use interpolation, you can do this with %I.
2.0
a = 'hello'
b = 'goodbye'
array_one = %I(#{a} #{b} world)
array_tw...
An empty Array ([]) can be created with Array's class method, Array::new:
Array.new
To set the length of the array, pass a numerical argument:
Array.new 3 #=> [nil, nil, nil]
There are two ways to populate an array with default values:
Pass an immutable value as second argument.
P...
The groupingBy(classifier, downstream) collector allows the collection of Stream elements into a Map by classifying each element in a group and performing a downstream operation on the elements classified in the same group.
A classic example of this principle is to use a Map to count the occurrence...
You can define a new class using the class keyword.
class MyClass
end
Once defined, you can create a new instance using the .new method
somevar = MyClass.new
# => #<MyClass:0x007fe2b8aa4a18>
A hash in Ruby is an object that implements a hash table, mapping keys to values. Ruby supports a specific literal syntax for defining hashes using {}:
my_hash = {} # an empty hash
grades = { 'Mark' => 15, 'Jimmy' => 10, 'Jack' => 10 }
A hash can also be created using the standard new...
With a Frame
When you know the exact dimensions you want to set for your label, you can initialize a UILabel with a CGRect frame.
Swift
let frame = CGRect(x: 0, y: 0, width: 200, height: 21)
let label = UILabel(frame: frame)
view.addSubview(label)
Objective-C
CGRect frame = CGRectMake(0, 0,...
CREATE INDEX ix_cars_employee_id ON Cars (EmployeeId);
This will create an index for the column EmployeeId in the table Cars. This index will improve the speed of queries asking the server to sort or select by values in EmployeeId, such as the following:
SELECT * FROM Cars WHERE EmployeeId = 1
...
A basic Employees table, containing an ID, and the employee's first and last name along with their phone number can be created using
CREATE TABLE Employees(
Id int identity(1,1) primary key not null,
FName varchar(20) not null,
LName varchar(20) not null,
PhoneNumber varchar(10)...
When the Repeater is Bound, for each item in the data, a new table row will be added.
<asp:Repeater ID="repeaterID" runat="server" OnItemDataBound="repeaterID_ItemDataBound">
<HeaderTemplate>
<table>
<thead>
...
alias word='command'
Invoking word will run command. Any arguments supplied to the alias are simply appended to the target of the alias:
alias myAlias='some command --with --options'
myAlias foo bar baz
The shell will then execute:
some command --with --options foo bar baz
To include mul...
Any function can be invoked as a goroutine by prefixing its invocation with the keyword go:
func DoMultiply(x,y int) {
// Simulate some hard work
time.Sleep(time.Second * 1)
fmt.Printf("Result: %d\n", x * y)
}
go DoMultiply(1,2) // first execution, non-blocking
go DoMu...
PorterDuff.Mode is used to create a PorterDuffColorFilter. A color filter modifies the color of each pixel of a visual resource.
ColorFilter filter = new PorterDuffColorFilter(Color.BLUE, PorterDuff.Mode.SRC_IN);
The above filter will tint the non-transparent pixels to blue color.
The color fil...