Tutorial by Examples: c

The Kernel#require method will load files only once (several calls to require will result in the code in that file being evaluated only once). It will search your ruby $LOAD_PATH to find the required file if the parameter is not an absolute path. Extensions like .rb, .so, .o or .dll are optional. Re...
The method Kernel#autoload registers filename to be loaded (using Kernel::require) the first time that module (which may be a String or a symbol) is accessed. autoload :MyModule, '/usr/local/lib/modules/my_module.rb' The method Kernel#autoload? returns filename to be loaded if name is registere...
To get records having any of the given ids select * from products where id in (1,8,3) The query above is equal to select * from products where id = 1 or id = 8 or id = 3
DECLARE @DateFrom DATETIME = '2016-06-01 06:00' DECLARE @DateTo DATETIME = '2016-07-01 06:00' DECLARE @IntervalDays INT = 7 -- Transition Sequence = Rest & Relax into Day Shift into Night Shift -- RR (Rest & Relax) = 1 -- DS (Day Shift) = 2 -- NS (Night Shift) = 3 ;WITH roster AS ...
This function returns the floating-point remainder of the division of x/y. The returned value has the same sign as x. #include <math.h> /* for fmod() */ #include <stdio.h> /* for printf() */ int main(void) { double x = 10.0; double y = 5.1; double modulus = fmod(x,...
Requirements: Docker can be installed on any Linux with a kernel of at least version 3.10. Docker is supported on the following 64-bit versions of Ubuntu Linux: Ubuntu Xenial 16.04 (LTS) Ubuntu Wily 15.10 Ubuntu Trusty 14.04 (LTS) Ubuntu Precise 12.04 (LTS) Easy Installation Note: Installi...
Whenever a template is called upon, the default data context of the template is implicitly gained from the caller as in example the childTemplate gains the data context of the parentTemplate i.e caller template <template name="parentTemplate"> {{#with someHelperGettingDataForPa...
Custom sigils can be made by creating a method sigil_X where X is the letter you want to use (this can only be a single letter). defmodule Sigils do def sigil_j(string, options) do # Split on the letter p, or do something more useful String.split string, "p" end # Use t...
Ensure you have the most recent Node.js LTS installed. If you use Homebrew this can be done with brew install node4-lts. Open Terminal and type npm install -g nativescript. If you get an EACCES error, use sudo npm install -g nativescript. In the command prompt type ruby -e "$(curl -fsSL htt...
Visual Studio Code is an open-source and feature-rich code editor from Microsoft. To set it up it for NativeScript development, open the Command Palette (F1 or ⌘+Shift+P) and type ext install NativeScript. Once the NativeScript extension is installed, the debugger should allow you to set breakpoint...
In the following example, the greet function inside Greeter module is run in a separate process: defmodule Greeter do def greet do IO.puts "Hello programmer!" end end iex> spawn(Greeter, :greet, []) Hello #PID<0.122.0> Here #PID<0.122.0> is the ...
Named Functions defmodule Math do # one way def add(a, b) do a + b end # another way def subtract(a, b), do: a - b end iex> Math.add(2, 3) 5 :ok iex> Math.subtract(5, 2) 3 :ok Private Functions defmodule Math do def sum(a, b) do a...
Elixir matches a function call to its body based on the value of its arguments. defmodule Math do def factorial(0): do: 1 def factorial(n): do: n * factorial(n - 1) end Here, factorial of positive numbers matches the second clause, while factorial(0) matches the first. (ignoring negat...
Guard clauses enables us to check the arguments before executing the function. Guard clauses are usually preferred to if and cond due to their readability, and to make a certain optimization technique easier for the compiler. The first function definition where all guards match is executed. Here is...
Enable USB Debugging on your device and from command line type adb devices. If everything is OK, the response should be: List of devices attached 1234567890 device Where 1234567890 is the device's id. If multiple devices are connected, you should see all of them: List of devices at...
Named vector can be created in several ways. With c: xc <- c('a' = 5, 'b' = 6, 'c' = 7, 'd' = 8) which results in: > xc a b c d 5 6 7 8 with list: xl <- list('a' = 5, 'b' = 6, 'c' = 7, 'd' = 8) which results in: > xl $a [1] 5 $b [1] 6 $c [1] 7 $d [1] 8 Wi...
NOW() + INTERVAL 1 DAY -- This time tomorrow CURDATE() - INTERVAL 4 DAY -- Midnight 4 mornings ago Show the mysql questions stored that were asked 3 to 10 hours ago (180 to 600 minutes ago): SELECT qId,askDate,minuteDiff FROM ( SELECT qId,askDate, TIMESTAMPDIFF(MINUTE,askDate,no...
To clone a specific branch of a repository, type --branch <branch name> before the repository url: git clone --branch <branch name> <url> [directory] To use the shorthand option for --branch, type -b. This command downloads entire repository and checks out <branch name>. ...
A sequence is a series of elements that can be enumerated. It is an alias of System.Collections.Generic.IEnumerable and lazy. It stores a series of elements of the same type (can be any value or object, even another sequence). Functions from the Seq.module can be used to operate on it. Here is a s...
template<class InputIterator, class Function> Function for_each(InputIterator first, InputIterator last, Function f); Effects: Applies f to the result of dereferencing every iterator in the range [first, last) starting from first and proceeding to last - 1. Parameters: first, last -...

Page 255 of 826