Tutorial by Examples: f

To remove existing column name from users table, run the command: rails generate migration RemoveNameFromUsers name:string This will generate the following migration: class RemoveNameFromUsers < ActiveRecord::Migration[5.0] def change remove_column :users, :name, :string end end ...
To add a reference to a team to the users table, run this command: $ rails generate migration AddTeamRefToUsers team:references This generates the following migration: class AddTeamRefToUsers < ActiveRecord::Migration[5.0] def change add_reference :users, :team, foreign_key: true ...
Use the : operator to create sequences of numbers, such as for use in vectorizing larger chunks of your code: x <- 1:5 x ## [1] 1 2 3 4 5 This works both ways 10:4 # [1] 10 9 8 7 6 5 4 and even with floating point numbers 1.25:5 # [1] 1.25 2.25 3.25 4.25 or negatives -4:4 ...
The services lifecycle has the following callbacks onCreate() : Executed when the service is first created in order to set up the initial configurations you might need. This method is executed only if the service is not already running. onStartCommand() : Executed every time startService...
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 ...
In a nutshell, conditional pre-processing logic is about making code-logic available or unavailable for compilation using macro definitions. Three prominent use-cases are: different app profiles (e.g. debug, release, testing, optimised) that can be candidates of the same app (e.g. with extra log...
In PowerShell, there are many ways to achieve the same result. This can be illustrated nicely with the simple & familiar Hello World example: Using Write-Host: Write-Host "Hello World" Using Write-Output: Write-Output 'Hello world' It's worth noting that although Write-Outp...
./mongo localhost:27017/mydb myjsfile.js Explanation: This operation executes the myjsfile.js script in a mongo shell that connects to the mydb database on the mongod instance accessible via the localhost interface on port 27017. localhost:27017 is not mandatory as this is the default port mongo...
In order to filter out values from an array and obtain a new array containing all the values that satisfy the filter condition, you can use the array_filter function. Filtering non-empty values The simplest case of filtering is to remove all "empty" values: $my_array = [1,0,2,null,3,'',...
If you want to add custom.js script that is located in the js/ folder of your theme, you'll need to enqueue it. In functions.php add <?php add_action( 'after_setup_theme', 'yourtheme_theme_setup' ); if ( ! function_exists( 'yourtheme_theme_setup' ) ) { function yourtheme_theme_setup()...
Factors are one way to represent categorical variables in R. A factor is stored internally as a vector of integers. The unique elements of the supplied character vector are known as the levels of the factor. By default, if the levels are not supplied by the user, then R will generate the set of uniq...
When a column name matches a reserved keyword, standard SQL requires that you enclose it in double quotation marks: SELECT "ORDER", ID FROM ORDERS Note that it makes the column name case-sensitive. Some DBMSes have proprietary ways of quoting names. For example, SQL Serve...
Some convenience functions to manipulate data.frames are subset(), transform(), with() and within(). subset The subset() function allows you to subset a data.frame in a more convenient way (subset also works with other classes): subset(mtcars, subset = cyl == 6, select = c("mpg", "...
Functions can be written using several types of syntax function name() integer name name = 42 end function integer function name() name = 42 end function function name() result(res) integer res res = 42 end function Functions return values through a function result....
Quite often, the reason why code has been written in a for loop is to compute values from 'nearby' ones. The function bsxfun can often be used to do this in a more succinct fashion. For example, assume that you wish to perform a columnwise operation on the matrix B, subtracting the mean of each col...
if condition: body The if statements checks the condition. If it evaluates to True, it executes the body of the if statement. If it evaluates to False, it skips the body. if True: print "It is true!" >> It is true! if False: print "This won't get printed.....
The latest SDK can be downloaded here The latest SDK libraries are also available on NuGet under Microsoft's official crmsdk account
Display all data files for all databases with size and growth info SELECT d.name AS 'Database', d.database_id, SF.fileid, SF.name AS 'LogicalFileName', CASE SF.status & 0x100000 WHEN 1048576 THEN 'Percentage' WHEN 0 THEN 'MB...
As Array conforms to SequenceType, we can use map(_:) to transform an array of A into an array of B using a closure of type (A) throws -> B. For example, we could use it to transform an array of Ints into an array of Strings like so: let numbers = [1, 2, 3, 4, 5] let words = numbers.map { Stri...
The things Array contains values of Any type. let things: [Any] = [1, "Hello", 2, true, false, "World", 3] We can extract values of a given type and create a new Array of that specific type. Let's say we want to extract all the Int(s) and put them into an Int Array in a safe ...

Page 44 of 457