Tutorial by Examples: pre

sudo apt-add-repository ppa:brightbox/ruby-ng Hit Enter to confirm sudo apt-get update Then you can install your ruby version of choice (the ppa supports ruby2.0 ruby2.1 ruby2.2 ruby2.3 and legacy versions ruby1.8 ruby1.9.1) Don't forget to include the respective -dev package for your version. Ot...
example: df = pd.DataFrame({'group1' : ['A', 'A', 'A', 'A', 'B', 'B', 'B', 'B'], 'group2' : ['C', 'C', 'C', 'D', 'E', 'E', 'F', 'F'], 'B' : ['one', np.NaN, np.NaN, np.NaN, ...
Express is based on Connect, which is what provides the middleware functionality of Express. To understand what connect is, you can see that it provides the basic app structure that you use when you use express const connect = require('connect') const app = connect() app.listen(3000) This wi...
This example is inspired by this question. We'll assume you know how to load a file using the File API. // preliminary code to handle getting local file and finally printing to console // the results of our function ArrayBufferToBinary(). var file = // get handle to local file. var reader = new...
This substitute command can use Regular Expressions and will match any instance of foo followed by any( one ) character since the period . in Regular Expressions matches any character, hence the following command will match all instances of foo followed by any character in the current line. :s/foo....
Python multithreading performance can often suffer due to the Global Interpreter Lock. In short, even though you can have multiple threads in a Python program, only one bytecode instruction can execute in parallel at any one time, regardless of the number of CPUs. As such, multithreading in cases w...
List comprehensions are a syntactic construct to create a list based on existing lists. In erlang a list comprehension has the form [Expr || Qualifier1, ..., QualifierN]. Where qualifiers are either generators Pattern <- ListExpr or filter like integer(X) evaluating to either true or false. Th...
All integers or pointers can be used in an expression that is interpreted as "truth value". int main(int argc, char* argv[]) { if (argc % 4) { puts("arguments number is not divisible by 4"); } else { puts("argument number is divisible by 4"); } ... ...
A lambda closure is created when a lambda expression references the variables of an enclosing scope (global or local). The rules for doing this are the same as those for inline methods and anonymous classes. Local variables from an enclosing scope that are used within a lambda have to be final. Wit...
auto can also cause problems where expression templates come into play: auto mult(int c) { return c * std::valarray<int>{1}; } auto v = mult(3); std::cout << v[0]; // some value that could be, but almost certainly is not, 3. The reason is that operator* on valarray gives yo...
Here's the utility class: public class SharedPreferencesCompat { public static void putStringSet(SharedPreferences.Editor editor, String key, Set<String> values) { if (Build.VERSION.SDK_INT >= 11) { while (true) { try { ...
A lambda can only have a trailing return type; the leading return type syntax is not applicable to lambdas. Note that in many cases it is not necessary to specify a return type for a lambda at all. struct Base {}; struct Derived1 : Base {}; struct Derived2 : Base {}; auto lambda = [](bool b) -&g...
add: add the specified files on the next commit addremove: add all new files, delete all missing files backout: reverse effect of earlier changeset commit, ci: commit the specified files or all outstanding changes copy, cp: mark files as copied for the next commit forge...
In Scala (in contrast to Java and most other languages), if is an expression instead of a statement. Regardless, the syntax is identical: if(x < 1984) { println("Good times") } else if(x == 1984) { println("The Orwellian Future begins") } else { println("Po...
When you have a Stream you need to map but want to preserve the initial values as well, you can map the Stream to a Map.Entry<K,V> using a utility method like the following: public static <K, V> Function<K, Map.Entry<K, V>> entryMapper(Function<K, V> mapper){ retu...
runOutsideAngular can be used to run code outside Angular 2 so that it does not trigger change detection unnecessarily. This can be used to for example run multiple HTTP request to get all the data before rendering it. To execute code again inside Angular 2, run method of NgZone can be used. my.com...
Mapping URLs to specific templates To fully grasp WordPress themes, you must understand two primary concepts: Permalinks The Template Hierarchy A permalink is a permanent, non-changing URL (or link, to a specific resource. For instance: example.com/about-us/ (a Page in WP) example.com/se...
There are a number of predefined global variables that you can set in the front matter of a page or post. VariableDescriptionlayoutIf set, this specifies the layout file to use. Use the layout file name without the file extension. Layout files must be placed in the _layouts directory.permalinkIf y...
namespace CodeContractsDemo { using System; using System.Collections.Generic; using System.Diagnostics.Contracts; public class PaymentProcessor { private List<Payment> _payments = new List<Payment>(); public void Add(Payment payment) ...
A container will stop if no command is running on the foreground. Using the -t option will keep the container from stopping, even when detached with the -d option. docker run -t -d debian bash

Page 15 of 34