Tutorial by Examples: c

The most common way to install the RSpec gem is using Bundler. Add this line to your application's Gemfile: gem 'rspec' And then execute bundle to install the dependencies: $ bundle Alternatively, you can install the gem manually: $ gem install rspec After installing the gem, run the fol...
When an extension method returns a value that has the same type as its this argument, it can be used to "chain" one or more method calls with a compatible signature. This can be useful for sealed and/or primitive types, and allows the creation of so-called "fluent" APIs if the me...
There are situations when you need to calculate something really large in your Flash application, while not interrupting the user's experience. For this, you need to devise your lengthy process as a multi-step process with saved state between iterations. For example, you need to perform a background...
Shiny is an R package developed by RStudio that allows the creation of web pages to interactively display the results of an analysis in R. There are two simple ways to create a Shiny app: in one .R file, or in two files: ui.R and server.R. A Shiny app is divided into two parts: ui: A user...
Prerequisites sudo apt-get install build-essential sudo apt-get install python [optional] sudo apt-get install git Get source and build cd ~ git clone https://github.com/nodejs/node.git OR For the latest LTS Node.js version 6.10.2 cd ~ wget https://nodejs.org/dist/v6.3.0/node-v6.10....
A common way to download Go dependencies is by using the go get <package> command, which will save the package into the global/shared $GOPATH/src directory. This means that a single version of each package will be linked into each project that includes it as a dependency. This also means that...
A class in Scala is a 'blueprint' of a class instance. An instance contains the state and behavior as defined by that class. To declare a class: class MyClass{} // curly braces are optional here as class body is empty An instance can be instantiated using new keyword: var instance = new MyClas...
The only way to catch exception in initializer list: struct A : public B { A() try : B(), foo(1), bar(2) { // constructor body } catch (...) { // exceptions from the initializer list and constructor are caught here // if no exception is thrown h...
void function_with_try_block() try { // try block body } catch (...) { // catch block body } Which is equivalent to void function_with_try_block() { try { // try block body } catch (...) { // catch block body } } Note t...
struct A { ~A() noexcept(false) try { // destructor body } catch (...) { // exceptions of destructor body are caught here // if no exception is thrown here // then the caught exception is re-thrown. } }; Note that, although this...
With Maven you can create Vaadin project with vaadin-archetype-application archetype. You can also add that archetype in IDE to create maven project with IDE. mvn archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-application -DarchetypeVersion=7....
It is possible to define local variables inside a function to reduce code repetition give name to subexpressions reduce the amount of passed arguments. The construct for this is let ... in .... bigNumbers = let allNumbers = [1..100] isBig number = ...
It is very convenient to use extension methods with interfaces as implementation can be stored outside of class and all it takes to add some functionality to class is to decorate class with interface. public interface IInterface { string Do() } public static class ExtensionMethods{ pu...

Mac

Ruby comes pre-installed on a Mac computer. Follow the instructions below to install Sass: Open CMD Run gem install sass If you get an error message, try sudo gem install sass Check it works using sass -v
Method chaining is a programming strategy that simplifies your code and beautifies it. Method chaining is done by ensuring that each method on an object returns the entire object, instead of returning a single element of that object. For example: function Door() { this.height = ''; this.w...
When you inherit from a class with a property, you can provide a new implementation for one or more of the property getter, setter or deleter functions, by referencing the property object on the parent class: class BaseClass(object): @property def foo(self): return some_calculate...
The following example listens to window.onerror event and uses an image beacon technique to send the information through the GET parameters of an URL. var hasLoggedOnce = false; // Some browsers (at least Firefox) don't report line and column numbers // when event is handled through window.addE...
CLP(FD) constraints (Finite Domains) implement arithmetic over integers. They are available in all serious Prolog implementations. There are two major use cases of CLP(FD) constraints: Declarative integer arithmetic Solving combinatorial problems such as planning, scheduling and allocation task...
Packages are bundles of classes. Every class must be declared within a package using the package statement. The package statement is followed by the name of your package, or followed by nothing in the case of adding classes to the top-level package. Sub-packages are created using dot (.) delimitatio...
Import the numpy module to use any part of it. import numpy as np Most examples will use np as shorthand for numpy. Assume "np" means "numpy" in code examples. x = np.array([1,2,3,4])

Page 156 of 826