Tutorial by Examples: du

Node provides the module.exports interface to expose functions and variables to other files. The most simple way to do so is to export only one object (function or variable), as shown in the first example. hello-world.js module.exports = function(subject) { console.log('Hello ' + subject); }...
Tuples can be decomposed into individual variables with the following syntax: let myTuple = (name: "Some Name", age: 26) let (first, second) = myTuple print(first) // "Some Name" print(second) // 26 This syntax can be used regardless of if the tuple has unnamed properti...
Commits can be squashed during a git rebase. It is recommended that you understand rebasing before attempting to squash commits in this fashion. Determine which commit you would like to rebase from, and note its commit hash. Run git rebase -i [commit hash]. Alternatively, you can type HE...
Basics The Reflection API allows one to check the class structure of the code at runtime and invoke code dynamically. This is very powerful, but it is also dangerous since the compiler is not able to statically determine whether dynamic invocations are valid. A simple example would be to get the p...
Make sure you see Registering for local notifications in order for this to work: Swift let notification = UILocalNotification() notification.alertBody = "Hello, local notifications!" notification.fireDate = NSDate().dateByAddingTimeInterval(10) // 10 seconds after now UIApplication.sh...
The following queries will return a list of all Stored Procedures in the database, with basic information about each Stored Procedure: SQL Server 2005 SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' The ROUTINE_NAME, ROUTINE_SCHEMA and ROUTINE_DEFINITION columns are...
Functional Interfaces Lambdas can only operate on a functional interface, which is an interface with just one abstract method. Functional interfaces can have any number of default or static methods. (For this reason, they are sometimes referred to as Single Abstract Method Interfaces, or SAM Interf...
5.1 The reduce() method applies a function against an accumulator and each value of the array (from left-to-right) to reduce it to a single value. Array Sum This method can be used to condense all values of an array into a single value: [1, 2, 3, 4].reduce(function(a, b) { return a + b; }); ...
BuildConfigField Gradle allows buildConfigField lines to define constants. These constants will be accessible at runtime as static fields of the BuildConfig class. This can be used to create flavors by defining all fields within the defaultConfig block, then overriding them for individual build fla...
A compiler symbol is a keyword that is defined at compile-time that can be checked for to conditionally execute specific sections of code. There are three ways to define a compiler symbol. They can be defined via code: #define MYSYMBOL They can be defined in Visual Studio, under Project Propert...
1.8 You can remove a submodule (e.g. the_submodule) by calling: $ git submodule deinit the_submodule $ git rm the_submodule git submodule deinit the_submodule deletes the_submodules' entry from .git/config. This excludes the_submodule from git submodule update, git submodule sync and git ...
#Create Bosun unit file at /etc/systemd/system/bosun.service [Unit] Description=Bosun Service After=network.target After=rsyslog.service [Service] Type=simple User=root ExecStart=/opt/bosun/bosun -c /opt/bosun/config/prod.conf Restart=on-abort [Install] WantedBy=multi-user.target #...
#Create Scollector unit file at /etc/systemd/system/scollector.service [Unit] Description=Scollector Service After=network.target [Service] Type=simple User=root ExecStart=/opt/scollector/scollector -h mybosunserver.example.com Restart=on-abort [Install] WantedBy=multi-user.target #...
TSDBRelay can be used to forward metrics to an OpenTSDB instance, send to Bosun for indexing, and relay to another opentsdb compatible instance for backup/DR/HA. It also has options to denormalize metrics with high tag cardinality or create redis/ledis backed external counters. #Create tsdbrelay un...
To show all staged and unstaged changes, use: git diff HEAD NOTE: You can also use the following command: git status -vv The difference being that the output of the latter will actually tell you which changes are staged for commit and which are not.
In Python 2, reduce is available either as a built-in function or from the functools package (version 2.6 onwards), whereas in Python 3 reduce is available only from functools. However the syntax for reduce in both Python2 and Python3 is the same and is reduce(function_to_reduce, list_to_reduce). A...
Module serves as a container of different parts of your app such as controllers, services, filters, directives, etc. Modules can be referenced by other modules through Angular's dependency injection mechanism. Creating a module: angular .module('app', []); Array [] passed in above example ...
Eloquent is the ORM built into the Laravel framework. It allows you to interact with your database tables in an object-oriented manner, by use of the ActiveRecord pattern. A single model class usually maps to a single database table, and also relationships of different types (one-to-one, one-to-man...
INSERT INTO `table_name` (`index_field`, `other_field_1`, `other_field_2`) VALUES ('index_value', 'insert_value', 'other_value') ON DUPLICATE KEY UPDATE `other_field_1` = 'update_value', `other_field_2` = VALUES(`other_field_2`); This will INSERT into ta...
virtualenv is a tool to build isolated Python environments. This program creates a folder which contains all the necessary executables to use the packages that a Python project would need. Installing the virtualenv tool This is only required once. The virtualenv program may be available through yo...

Page 4 of 47