Tutorial by Examples: l

Pass a native python dictionary mapping strings to strings to create(). Catalog.objects.create(name='Library of Congress', titles_to_authors={ 'Using HStoreField with Django': 'CrazyPython and la communidad', 'Flabbergeists and thingamajigs': 'La Artista Fooista', 'Pro Git': 'Scott C...
Catalog.objects.filter(titles__Pro_Git='Scott Chacon and Ben Straub')
The @while directive will loop over a block of code until the condition specified becomes false. In the following example, this loop will run until $font-size <= 18 while incrementing the value for $font-size by 2. $font-size: 12; @while $font-size <= 18 { .font-size-#{$font-size} { ...
The @for directive allows you to loop through some code for a set amount of iterations and has two forms: @for <var> from <start> through <end> {} @for <var> from <start> to <end> {} The difference in the two forms is the through and the to; the through key...
You often find yourself in a situation where you need to find a variables corresponding value, and collections got you covered. In the example below we got three different locales in an array with a corresponding calling code assigned. We want to be able to provide a locale and in return get the as...
# Fetch and install package to setup access to the official APT repository wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb sudo dpkg -i erlang-solutions_1.0_all.deb # Update package index sudo apt-get update # Install Erlang and Elixir sudo apt-get install esl-erlan...
Imagine that a system want to detect apples and oranges in a basket of fruits. System can pick a fruit, extract some property of it (e.g weight of that fruit). Suppose System has a Teacher! that teaches the system which objects are apples and which are oranges. This is an example of a supervised cl...
Run command below to install nginx. sudo apt-get install nginx By default, Nginx automatically starts when it is installed. You can access the default Nginx landing page to confirm that the software is running properly by visiting your server's domain name or public IP address in your web browse...
Dim array2D(,) As Integer = {{1, 2, 3}, {4, 5, 6}} ' array2D(0, 0) is 1 ; array2D(0, 1) is 2 ; array2D(1, 0) is 4 Dim array3D(,,) As Integer = {{{1, 2, 3}, {4, 5, 6}}, {{7, 8, 9}, {10, 11, 12}}} ' array3D(0, 0, 0) is 1 ; array3D(0, 0, 1) is 2 ' array3D(0, 1, 0) is 4 ; array3D(1, 0, 0) is 7 ...
Note the parenthesis to distinguish between a jagged array and a multidimensional array SubArrays can be of different length Dim jaggedArray()() As Integer = { ({1, 2, 3}), ({4, 5, 6}), ({7}) } ' jaggedArray(0) is {1, 2, 3} and so jaggedArray(0)(0) is 1 ' jaggedArray(1) is {4, 5, 6} and so jagge...
valgrind ./my-program arg1 arg2 < test-input This will run your program and produce a report of any allocations and de-allocations it did. It will also warn you about common errors like using uninitialized memory, dereferencing pointers to strange places, writing off the end of blocks allocate...
You can also turn on more tests, such as: valgrind -q --tool=memcheck --leak-check=yes ./my-program arg1 arg2 < test-input See valgrind --help for more information about the (many) options, or look at the documentation at http://valgrind.org/ for detailed information about what the output mea...
Here is a program that calls malloc but not free: #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { char *s; s = malloc(26); // the culprint return 0; } With no extra arguments, valgrind will not look for this error. But if we turn on...
Unary folds are used to fold parameter packs over a specific operator. There are 2 kinds of unary folds: Unary Left Fold (... op pack) which expands as follows: ((Pack1 op Pack2) op ...) op PackN Unary Right Fold (pack op ...) which expands as follows: Pack1 op (... (Pack(N-1) op Pac...
Binary folds are basically unary folds, with an extra argument. There are 2 kinds of binary folds: Binary Left Fold - (value op ... op pack) - Expands as follows: (((Value op Pack1) op Pack2) op ...) op PackN Binary Right Fold (pack op ... op value) - Expands as follows: Pack1 op (......
wikipedia definition: Command pattern is a behavioral design pattern in which an object is used to encapsulate all information needed to perform an action or trigger an event at a later time UML diagram from dofactory: Basic components and workflow: Command declares an interface for abst...
Describes ranges of symbols You can enumerate symbols explicitly /[abc]/ # 'a' or 'b' or 'c' Or use ranges /[a-z]/ # from 'a' to 'z' It is possible to combine ranges and single symbols /[a-cz]/ # 'a' or 'b' or 'c' or 'z' Leading dash (-) is treated as charachter /[-a-c]/ # '-' or 'a' o...
Unions are useful for minimizing memory usage for exclusive data, such as when implementing mixed data types. struct AnyType { enum { IS_INT, IS_FLOAT } type; union Data { int as_int; float as_float; } value; AnyType(int i) : type...
You can test if a string matches several regular expressions using a switch statement. Example case "Ruby is #1!" when /\APython/ puts "Boooo." when /\ARuby/ puts "You are right." else puts "Sorry, I didn't understand that." end This w...
Pointer initialization is a good way to avoid wild pointers. The initialization is simple and is no different from initialization of a variable. #include <stddef.h> int main() { int *p1 = NULL; char *p2 = NULL; float *p3 = NULL; /* NULL is a macro defined in st...

Page 212 of 861