Applying a function to a collection/stream and creating a new collection/stream is called a projection.
/// Projection
var newReleases = [
[
"id": 70111470,
"title": "Die Hard",
"boxart": "http://cdn-0.nflximg.com/images...
Create a stream by selecting the elements from a stream that pass a certain condition is called filtering
var newReleases = [
[
"id": 70111470,
"title": "Die Hard",
"boxart": "http://cdn-0.nflximg.com/images/2891/DieHard.j...
A HAVING clause filters the results of a GROUP BY expression. Note: The following examples are using the Library example database.
Examples:
Return all authors that wrote more than one book (live example).
SELECT
a.Id,
a.Name,
COUNT(*) BooksWritten
FROM BooksAuthors ba
INNER JOIN Aut...
When results need to have some logic applied 'on the fly' one can use CASE statement to implement it.
SELECT CASE WHEN Col1 < 50 THEN 'under' ELSE 'over' END threshold
FROM TableName
also can be chained
SELECT
CASE WHEN Col1 < 50 THEN 'under'
WHEN Col1 > 50 AND Col1 ...
Sometimes when tables are used mostly (or only) for reads, indexing does not help anymore and every little bit counts, one might use selects without LOCK to improve performance.
SQL Server
SELECT * FROM TableName WITH (nolock)
MySQL
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;...
Sometimes one wants to capture the records that have just been updated.
CREATE TABLE #TempUpdated(ID INT)
Update TableName SET Col1 = 42
OUTPUT inserted.ID INTO #TempUpdated
WHERE Id > 50
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...
When files are not available, the require family will throw a LoadError. This is an example which illustrates loading optional modules only if they exist.
module TidBits
@@unavailableModules = []
[
{ name: 'CoreExtend', file: 'core_extend/lib/core_extend' } \
, { name: 'Fs' ...
The Kernel#load method will evaluate the code in the given file. The search path will be constructed as with require. It will re-evaluate that code on every subsequent call unlike require. There is no load_relative.
load `somefile`
You can use any ruby technique to dynamically create a list of files to load. Illustration of globbing for files starting with test, loaded in alphabetical order.
Dir[ "#{ __dir__ }**/test*.rb" ) ].sort.each do |source|
require_relative source
end
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...
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...
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 ...
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...