Tutorial by Examples: f

Optimizing by using the right data structures at the right time can change the time-complexity of the code. // This variant of stableUnique contains a complexity of N log(N) // N > number of elements in v // log(N) > insert complexity of std::set std::vector<std::string> stableUnique...
Creating a dictionary: set mydict [dict create a 1 b 2 c 3 d 4] dict get $mydict b ; # returns 2 set key c set myval [dict get $mydict $key] puts $myval # remove a value dict unset mydict b # set a new value dict set mydict e 5 Dictionary keys can be nested. dict set mycars mustang colo...
Java SE 1.2 strictfp modifier is used for floating-point calculations. This modifier makes floating point variable more consistent across multiple platforms and ensure all the floating point calculations are done according to IEEE 754 standards to avoid errors of calculation (round-off errors), ov...
This worked for me to move from Ubuntu 12.04 (Jenkins ver. 1.628) to Ubuntu 16.04 (Jenkins ver. 1.651.2). I first installed Jenkins from the repositories. Stop both Jenkins servers Copy JENKINS_HOME (e.g. /var/lib/jenkins) from the old server to the new one. From a console in the new serve...
Official page: https://www.rebar3.org/ Source code: https://github.com/erlang/rebar3 Rebar3 is mainly a dependency manager for Erlang and Elixir projects, but it also offers several other features, like bootstrapping projects (according to several templates, following the OTP principles), task exe...
As Rebar3 is free, open source and written in Erlang, it's possible to simply clone and build it from the source code. $ git clone https://github.com/erlang/rebar3.git $ cd rebar3 $ ./bootstrap This will create the rebar3 script, which you can put on your PATH or link to /usr/local/bin as expl...
(defun print-entry (key value) (format t "~A => ~A~%" key value)) (maphash #'print-entry *my-table*) ;; => NIL Using maphash allows to iterate over the entries of a hash table. The order of iteration is unspecified. The first argument is a function accepting two parameters: ...
Extractor behavior can be used to derive arbitrary values from their input. This can be useful in scenarios where you want to be able to act on the results of a transformation in the event that the transformation is successful. Consider as an example the various user name formats usable in a Window...
Map 'Mapping' across a collection uses the map function to transform each element of that collection in a similar way. The general syntax is: val someFunction: (A) => (B) = ??? collection.map(someFunction) You can provide an anonymous function: collection.map((x: T) => /*Do something wi...
Given these two CSV files: $ cat file1 1,line1 2,line2 3,line3 4,line4 $ cat file2 1,line3 2,line4 3,line5 4,line6 To print those lines in file2 whose second column occurs also in the first file we can say: $ awk -F, 'FNR==NR {lines[$2]; next} $2 in lines' file1 file2 1,line3 2,line4...
The -n flag enables you to check the syntax of a script without having to execute it: ~> $ bash -n testscript.sh testscript.sh: line 128: unexpected EOF while looking for matching `"' testscript.sh: line 130: syntax error: unexpected end of file
If your routes file is overwhelmingly big, you can put your routes in multiple files and include each of the files with Ruby’s require_relative method: config/routes.rb: YourAppName::Application.routes.draw do require_relative 'routes/admin_routes' require_relative 'routes/sidekiq_routes' ...
Almost every function in C standard library returns something on success, and something else on error. For example, malloc will return a pointer to the memory block allocated by the function on success, and, if the function failed to allocate the requested block of memory, a null pointer. So you sho...
String#squish Returns a version of the given string without leading or trailing whitespace, and combines all consecutive whitespace in the interior to single spaces. Destructive version squish! operates directly on the string instance. Handles both ASCII and Unicode whitespace. %{ Multi-line ...
String#pluralize Returns of plural form of the string. Optionally takes a count parameter and returns singular form if count == 1. Also accepts a locale parameter for language-specific pluralization. 'post'.pluralize # => "posts" 'octopus'.pluralize # => &quot...
When this program #include <stdio.h> #include <string.h> int main(void) { int num = 0; char str[128], *lf; scanf("%d", &num); fgets(str, sizeof(str), stdin); if ((lf = strchr(str, '\n')) != NULL) *lf = '\0'; printf("%d \"%s\&...
Create a new project dotnet new -l f# Restore any packages listed in project.json dotnet restore A project.lock.json file should be written out. Execute the program dotnet run The above will compile the code if required. The output of the default project created by dotnet new -l f# con...
Think this could example could be better but you get the gist import numpy as np from scipy.optimize import _minimize from scipy import special import matplotlib.pyplot as plt from matplotlib import cm from numpy.random import randn x, y = np.mgrid[-2:2:100j, -2:2:100j] plt.pcolor(x, y, op...
Creating a Window with OpenGL context (extension loading through GLEW): #define GLEW_STATIC #include <GL/glew.h> #include <SDL2/SDL.h> int main(int argc, char* argv[]) { SDL_Init(SDL_INIT_VIDEO); /* Initialises Video Subsystem in SDL */ /* Setting up OpenGL version a...
$username = 'Hadibut'; $email = '[email protected]'; $variables = compact('username', 'email'); // $variables is now ['username' => 'Hadibut', 'email' => '[email protected]'] This method is often used in frameworks to pass an array of variables between two components.

Page 202 of 457