Tutorial by Examples: ch

git cherry-pick <commit-hash> will apply the changes made in an existing commit to another branch, while recording a new commit. Essentially, you can copy commits from branch to branch. Given the following tree (Source) dd2e86 - 946992 - 9143a9 - a6fd86 - 5a6057 [master] \ ...
Method Chaining is a technique explained in Martin Fowler's book Domain Specific Languages. Method Chaining is summarized as Makes modifier methods return the host object, so that multiple modifiers can be invoked in a single expression. Consider this non-chaining/regular piece of code (ported...
To publish the changes you made in your working copy, run the svn commit command. IMPORTANT: Review your changes before committing them! Use svn status and svn diff to review the changes. Also, make sure you are in the correct path before performing a commit. If you updated many files across vari...
The git check-ignore command reports on files ignored by Git. You can pass filenames on the command line, and git check-ignore will list the filenames that are ignored. For example: $ cat .gitignore *.o $ git check-ignore example.o Readme.md example.o Here, only *.o files are defined in .git...
There are three ways of creating a new branch feature which tracks the remote branch origin/feature: git checkout --track -b feature origin/feature, git checkout -t origin/feature, git checkout feature - assuming that there is no local feature branch and there is only one remote with the featur...
In this example we will write a basic program that checks the number of inputs and outputs passed to a MEX-function. As a starting point, we need to create a C++ file implementing the "MEX gateway". This is the function executed when the file is called from MATLAB. testinputs.cpp // Mat...
There are several ways to set which editor to use for committing, rebasing, etc. Change the core.editor configuration setting. $ git config --global core.editor nano Set the GIT_EDITOR environment variable. For one command: $ GIT_EDITOR=nano git commit Or for all commands run in a ...
Alt-text is used by screen readers for visually impaired users and by search engines. It's therefore important to write good alt-text for your images. The text should look correct even if you replace the image with its alt attribute. For example: <!-- Incorrect --> <img src="anonymo...
There are several ways to search a key in std::map or in std::multimap. To get the iterator of the first occurrence of a key, the find() function can be used. It returns end() if the key does not exist. std::multimap< int , int > mmp{ {1, 2}, {3, 4}, {6, 5}, {8, 9}, {3, 4}, {6, 7} }; ...
The container std::map has a member function empty(), which returns true or false, depending on whether the map is empty or not. The member function size() returns the number of element stored in a std::map container: std::map<std::string , int> rank {{"facebook.com", 1} ,{"goo...
A bit counter-intuitive to the way most other languages' standard I/O libraries do it, Haskell's isEOF does not require you to perform a read operation before checking for an EOF condition; the runtime will do it for you. import System.IO( isEOF ) eofTest :: Int -> IO () eofTest line = do ...
During a merge, you can pass --ours or --theirs to git checkout to take all changes for a file from one side or the other of a merge. $ git checkout --ours -- file1.txt # Use our version of file1, delete all their changes $ git checkout --theirs -- file2.txt # Use their version of file2, delete ...
Ordinarily, images are pulled automatically from Docker Hub. Docker will attempt to pull any image from Docker Hub that doesn't already exist on the Docker host. For example, using docker run ubuntu when the ubuntu image is not already on the Docker host will cause Docker to initiate a pull of the l...
While object property notation is usually written as myObject.property, this will only allow characters that are normally found in JavaScript variable names, which is mainly letters, numbers and underscore (_). If you need special characters, such as space, ☺, or user-provided content, this is poss...
To find a character or another string, you can use std::string::find. It returns the position of the first character of the first match. If no matches were found, the function returns std::string::npos std::string str = "Curiosity killed the cat"; auto it = str.find("cat"); ...
When local changes are present, the git pull command aborts reporting : error: Your local changes to the following files would be overwritten by merge In order to update (like svn update did with subversion), you can run : git stash git pull --rebase git stash pop A convenient way coul...
The STUFF() function inserts a string into another string by first deleting a specified number of characters. The following example, deletes "Svr" and replaces it with "Server". This happens by specifying the start_position and length of the replacement. SELECT STUFF('SQL Svr D...
Apple's Reachability class periodically checks the network status and alerts observers to changes. Reachability *internetReachability = [Reachability reachabilityForInternetConnection]; [internetReachability startNotifier];
Reachability uses NSNotification messages to alert observers when the network state has changed. Your class will need to become an observer. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil]; Elsewher...
// Java: Stream.of(1.0, 2.0, 3.0) .mapToInt(Double::intValue) .mapToObj(i -> "a" + i) .forEach(System.out::println); // a1 // a2 // a3 // Kotlin: sequenceOf(1.0, 2.0, 3.0).map(Double::toInt).map { "a$it" }.forEach(::println)

Page 7 of 109