Tutorial by Examples: def

Create groovy file by path $JENKINS_HOME/init.groovy.d/basic-security.groovy In Ubuntu 16 Jenkins home directory places in /var/lib/jenkins Place in file next code #!groovy import jenkins.model.* import hudson.security.* def instance = Jenkins.getInstance() def hudsonRealm = new...
Unary operators can be defined by prepending the operator with unary_. Unary operators are limited to unary_+, unary_-, unary_! and unary_~: class Matrix(rows: Int, cols: Int, val data: Seq[Seq[Int]]){ def +(that: Matrix) = { val newData = for (r <- 0 until rows) yield for (c <...
Springfox defines a set default response messages that are applied to all API controllers by default. This includes e.g. 201 - Created and 204 - No Content, as well as several 40x responses. There might be cases, in which the default response messages don't apply for your API. You have to build-in p...
Define a new basic command A macro can be defined using \newcommand. For example: \newcommand{\foo}{Just foo, you see?} defines a macro \foo that expands to Just foo, you see?. It can then be used like any built-in command, for example after that definition: He said: ``\foo'' expands to He...
For giving short names to a data type Instead of: long long int foo; struct mystructure object; one can use /* write once */ typedef long long ll; typedef struct mystructure mystruct; /* use whenever needed */ ll foo; mystruct object; This reduces the amount of typing needed if the ...
import argparse import sys def check(): print("status") return 0 parser = argparse.ArgumentParser(prog="sub", add_help=False) subparser = parser.add_subparsers(dest="cmd") subparser.add_parser('status', help='show status') subparser.add_parser('lis...
There are important changes in how we use and declare default props and their types. React.createClass In this version, the propTypes property is an Object in which we can declare the type for each prop. The getDefaultProps property is a function that returns an Object to create the initial props....
class Functor f where fmap :: (a -> b) -> f a -> f b One way of looking at it is that fmap lifts a function of values into a function of values in a context f. A correct instance of Functor should satisfy the functor laws, though these are not enforced by the compiler: fmap id = i...
As an example you want to disable pagination in your default index action and get all results in index. How can you do that? It's simple. You should override the index action in your controller like this: public function actions() { $actions = parent::actions(); unset($actions['index'])...
Despite you can write a binary number in C++14 like: int number =0b0001'0101; // ==21 here comes a famous example with a self-made implementation for binary numbers: Note: The whole template expanding program is running at compile time. template< char FIRST, char... REST > struct binary {...
We can use the unit type as a function argument to define functions that we don't want executed until later. This is often useful in asynchronous background tasks, when the main thread may want trigger some predefined functionality of the background thread, like maybe moving it to a new file, or if...
The simplest and cleanest way to add an external configuration is through a separate Gradle file build.gradle apply from: './keystore.gradle' android{ signingConfigs { release { storeFile file(keystore.storeFile) storePassword keystore.storePassword ...
set clipboard=unnamed This makes it possible to copy/paste between Vim and the system clipboard without specifying any special register. yy yanks the current line into the system clipboard p pastes the content of the system clipboard into Vim This only works if your Vim installation has cli...
Open a raster that covers the globe and extract a subset of the raster. import gdal # Path to a tiff file covering the globe # http://visibleearth.nasa.gov/view.php?id=57752 tif_name = "/path_name/land_shallow_topo_21600.tif" # Open raster in read only mode ds = gdal.Open(tif_n...
Bifunctor is the class of types with two type parameters (f :: * -> * -> *), both of which can be covariantly mapped over simultaneously. class Bifunctor f where bimap :: (a -> c) -> (b -> d) -> f a b -> f c d bimap can be thought of as applying a pair of fmap operation...
Although not necessary in PHP however it is a very good practice to initialize variables. Uninitialized variables have a default value of their type depending on the context in which they are used: Unset AND unreferenced var_dump($unset_var); // outputs NULL Boolean echo($unset_bool ? "tr...
tslint can extend an existing rule set and is shipped with the defaults tslint:recommended and tslint:latest. tslint:recommended is a stable, somewhat opinionated set of rules which we encourage for general TypeScript programming. This configuration follows semver, so it will not have breaking ch...
The MIME type must be defined using the type attribute. <embed type="video/mp4" src="video.mp4" width="640" height="480">
Avoid this Anti-Pattern var myDeferred = $q.defer(); $http(config).then(function(res) { myDeferred.resolve(res); }, function(error) { myDeferred.reject(error); }); return myDeferred.promise; There is no need to manufacture a promise with $q.defer as the $http service alread...
A enum declares a set of ordered values - the typedef just adds a handy name to this. The 1st element is 0 etc. typedef enum { Monday=1, Tuesday, Wednesday } WORKDAYS; WORKDAYS today = Monday;//value 1

Page 21 of 27