Tutorial by Examples: o

JSON is a popular data interchange format. The most popular JSON library for Julia is JSON.jl. To install this package, use the package manager: julia> Pkg.add("JSON") The next step is to test whether the package is working on your machine: julia> Pkg.test("JSON") I...
JSON that has been encoded as a string can easily be parsed into a standard Julia type: julia> using JSON julia> JSON.parse("""{ "this": ["is", "json"], "numbers": [85, 16, 12.0], "and": [t...
The JSON.json function serializes a Julia object into a Julia String containing JSON: julia> using JSON julia> JSON.json(Dict(:a => :b, :c => [1, 2, 3.0], :d => nothing)) "{\"c\":[1.0,2.0,3.0],\"a\":\"b\",\"d\":null}" julia>...
You can list all files ignored by git in current directory with command: git status --ignored So if we have repository structure like this: .git .gitignore ./example_1 ./dir/example_2 ./example_2 ...and .gitignore file containing: example_2 ...than result of the command will be: $ g...
The clauses in a SELECT have a specific order: SELECT ... FROM ... WHERE ... GROUP BY ... HAVING ... ORDER BY ... -- goes here LIMIT ... OFFSET ...; ( SELECT ... ) UNION ( SELECT ... ) ORDER BY ... -- for ordering the result of the UNION. SELECT ... GROUP_CONCAT(DISTINCT x ORDER B...
ORDER BY FIND_IN_SET(card_type, "MASTER-CARD,VISA,DISCOVER") -- sort 'MASTER-CARD' first. ORDER BY x IS NULL, x -- order by `x`, but put `NULLs` last. Custom ordering SELECT * FROM some_table WHERE id IN (118, 17, 113, 23, 72) ORDER BY FIELD(id, 118, 17, 113, 23, 72); Returns th...
See what, when and why if you don't know about the affiliation of IFS to word splitting let's set the IFS to space character only: set -x var='I am a multiline string' IFS=' ' fun() { echo "-$1-" echo "*$2*" echo ".$3." } fun $var This time wo...
$ a='I am a string with spaces' $ [ $a = $a ] || echo "didn't match" bash: [: too many arguments didn't match [ $a = $a ] was interpreted as [ I am a string with spaces = I am a string with spaces ]. [ is the test command for which I am a string with spaces is not a single argument...
There are some cases where word splitting can be useful: Filling up array: arr=($(grep -o '[0-9]\+' file)) This will fill up arr with all numeric values found in file Looping through space separated words: words='foo bar baz' for w in $words;do echo "W: $w" done Output...
readarray -t arr <file Or with a loop: arr=() while IFS= read -r line; do arr+=("$line") done <file
while IFS= read -r line; do echo "$line" done <file If file may not include a newline at the end, then: while IFS= read -r line || [ -n "$line" ]; do echo "$line" done <file
var='line 1 line 2 line3' readarray -t arr <<< "$var" or with a loop: arr=() while IFS= read -r line; do arr+=("$line") done <<< "$var"
var='line 1 line 2 line3' while IFS= read -r line; do echo "-$line-" done <<< "$var" or readarray -t arr <<< "$var" for i in "${arr[@]}";do echo "-$i-" done
while IFS= read -r line;do echo "**$line**" done < <(ping google.com) or with a pipe: ping google.com | while IFS= read -r line;do echo "**$line**" done
The NSString formatting supports all the format strings available on the printf ANSI-C function. The only addition made by the language is the %@ symbol used for formatting all the Objective-C objects. It is possible to format integers int myAge = 21; NSString *formattedAge = [NSString stringWith...
Classes have instance variable (dependencies), on which they call methods. Example taken from http://www.jamesshore.com/Blog/Dependency-Injection-Demystified.html for reference public class Example { private DatabaseThingie myDatabase; public Example() { myDatabase = new DatabaseTh...
Let's assume that the field separator is : arr=() while IFS= read -d : -r field || [ -n "$field" ]; do arr+=("$field") done <file
Let's assume that the field separator is : var='1:2:3:4: newline' arr=() while IFS= read -d : -r field || [ -n "$field" ]; do arr+=("$field") done <<< "$var" echo "${arr[4]}" Output: newline
Let's assume that the field separator is : while IFS= read -d : -r field || [ -n "$field" ];do echo "**$field**" done < <(ping google.com) Or with a pipe: ping google.com | while IFS= read -d : -r field || [ -n "$field" ];do echo "**$field**&q...
A simple example which provides the options: OptAlt. OptDetails-h--helpShow help-v--versionShow version info-dr path--doc-root pathAn option which takes a secondary parameter (a path)-i--installA boolean option (true/false)-*--Invalid option #!/bin/bash dr='' install=false skip=false for op ...

Page 581 of 1038