Tutorial by Examples

add_filter('template_include', 'custom_function'); function custom_function($template){ /* * This example is a little more advanced. * It will check to see if $template contains our post-type in the path. * If it does, the theme contains a high level templat...
Save the current state of working directory and the index (also known as the staging area) in a stack of stashes. git stash To include all untracked files in the stash use the --include-untracked or -u flags. git stash --include-untracked To include a message with your stash to make it more ...
git stash list This will list all stashes in the stack in reverse chronological order. You will get a list that looks something like this: stash@{0}: WIP on master: 67a4e01 Merge tests into develop stash@{1}: WIP on master: 70f0d95 Add user role to localStorage on user login You can refer t...
Shows the changes saved in the last stash git stash show Or a specific stash git stash show stash@{n} To show content of the changes saved for the specific stash git stash show -p stash@{n}
Remove all stash git stash clear Removes the last stash git stash drop Or a specific stash git stash drop stash@{n}
To apply the last stash and remove it from the stack - type: git stash pop To apply specific stash and remove it from the stack - type: git stash pop stash@{n}
Applies the last stash without removing it from the stack git stash apply Or a specific stash git stash apply stash@{n}
The background-attachment property sets whether a background image is fixed or scrolls with the rest of the page. body { background-image: url('img.jpg'); background-attachment: fixed; } ValueDescriptionscrollThe background scrolls along with the element. This is default.fixedThe backgro...
The background-repeat property sets if/how a background image will be repeated. By default, a background-image is repeated both vertically and horizontally. div { background-image: url("img.jpg"); background-repeat: repeat-y; } Here's how a background-repeat: repeat-y looks lik...
Math.random(); produces an evenly distributed random number between 0 (inclusive) and 1 (exclusive) Example output: 0.22282187035307288 0.3948539895936847 0.9987191134132445
function randomMinMax(min:Number, max:Number):Number { return (min + (Math.random() * Math.abs(max - min))); } This function is called by passing a range of minimum and maximum values. Example: randomMinMax(1, 10); Example outputs: 1.661770915146917 2.5521070677787066 9.4362709657...
function randomAngle():Number { return (Math.random() * 360); } Example outputs: 31.554428357630968 230.4078639484942 312.7964010089636
More complicated tests sometimes need to have things set up before you run the code you want to test. It is possible to do this in the test function itself, but then you end up with large test functions doing so much that it is difficult to tell where the setup stops and the test begins. You can als...
To ignore a file foo.txt in any directory you should just write its name: foo.txt # matches all files 'foo.txt' in any directory If you want to ignore the file only in part of the tree, you can specify the subdirectories of a specific directory with ** pattern: bar/**/foo.txt # matches all file...
Example that builds an executable (editor) and links a library (highlight) to it. Project structure is straightforward, it needs a master CMakeLists and a directory for each subproject: CMakeLists.txt editor/ CMakeLists.txt src/ editor.cpp highlight/ CMakeLists.txt in...
Multiple rows can be inserted with a single insert command: INSERT INTO tbl_name (field1, field2, field3) VALUES (1,2,3), (4,5,6), (7,8,9); For inserting large quantities of data (bulk insert) at the same time, DBMS-specific features and recommendations exist. MySQL - LOAD DATA INFILE MSSQL - B...
The setup script is the centre of all activity in building, distributing, and installing modules using the Distutils. It's purpose is the correct installation of the software. If all you want to do is distribute a module called foo, contained in a file foo.py, then your setup script can be as simpl...
Travis CI has CMake 2.8.7 pre-installed. A minimal .travis.yml script for an out-of source build language: cpp compiler: - gcc before_script: # create a build folder for the out-of-source build - mkdir build # switch to build directory - cd build # run cmake; here we assume...
The CMake version preinstalled on Travis is very old. You can use the official Linux binaries to build with a newer version. Here is an example .travis.yml: language: cpp compiler: - gcc # the install step will take care of deploying a newer cmake version install: # first we creat...
int a = 1; int *a_pointer = &a; To dereference a_pointer and change the value of a, we use the following operation *a_pointer = 2; This can be verified using the following print statements. printf("%d\n", a); /* Prints 2 */ printf("%d\n", *a_pointer); /* Also prints...

Page 178 of 1336