Tutorial by Examples: diff

Python 2.x2.3 Objects of different types can be compared. The results are arbitrary, but consistent. They are ordered such that None is less than anything else, numeric types are smaller than non-numeric types, and everything else is ordered lexicographically by type. Thus, an int is less than a st...
CommandDescriptionaAppend text following current cursor positionAAppend text at the end of current lineiInsert text before the current cursor positionIInsert text before first non-blank character of current linegIInsert text in first column of cursor linegiInsert text at same position where it was l...
To run migrations in the test environment, run this shell command: rake db:migrate RAILS_ENV=test 5.0 Starting in Rails 5.0, you can use rails instead of rake: rails db:migrate RAILS_ENV=test
Let's create our own error type for this example. 2.2 enum CustomError: ErrorType { case SomeError case AnotherError } func throwing() throws { throw CustomError.SomeError } 3.0 enum CustomError: Error { case someError case anotherError } func throwing() thr...
git diff myfile.txt Shows the changes between the previous commit of the specified file (myfile.txt) and the locally-modified version that has not yet been staged. This also works for directories: git diff documentation The above shows the changes between the previous commit of all files in ...
You can archive different Textsizes inside a Textview with a Span TextView textView = (TextView) findViewById(R.id.textView); Spannable span = new SpannableString(textView.getText()); span.setSpan(new RelativeSizeSpan(0.8f), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(span)...
__FUNCTION__ returns only the name of the function whereas __METHOD__ returns the name of the class along with the name of the function: <?php class trick { public function doit() { echo __FUNCTION__; } public function doitagain() { echo __METHOD_...
__CLASS__ magic constant returns the same result as get_class() function called without parameters and they both return the name of the class where it was defined (i.e. where you wrote the function call/constant name ). In contrast, get_class($this) and get_called_class() functions call, will both ...
git diff [HEAD|--staged...] --word-diff Rather than displaying lines changed, this will display differences within lines. For example, rather than: -Hello world +Hello world! Where the whole line is marked as changed, word-diff alters the output to: Hello [-world-]{+world!+} You can omit...
You can access SharedPreferences in several ways: Get the default SharedPreferences file: import android.preference.PreferenceManager; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Get a specific SharedPreferences file: public static final String PREF_FILE_NAM...
Examples below are given in Ruby, but same matchers should be available in any modern language. Let’s say we have the string "AℵNaïve", produced by Messy Artificial Intelligence. It consists of letters, but generic \w matcher won’t match much: ▶ "AℵNaïve"[/\w+/] #⇒ "A&q...
def numberOrCharacterSwitch(toggleNumber: Boolean)(number: Int)(character: Char): String = if (toggleNumber) number.toString else character.toString // need to explicitly specify the type of the parameter to be curried // resulting function signature Boolean => String val switchBetween3A...
You can specify different application IDs or package names for each buildType or productFlavor using the applicationIdSuffix configuration attribute: Example of suffixing the applicationId for each buildType: defaultConfig { applicationId "com.package.android" minSdkVersion 17 ...
When running from the CLI, PHP exhibits some different behaviours than when run from a web server. These differences should be kept in mind, especially in the case where the same script might be run from both environments. No directory change When running a script from a web server, the current w...
Consider the character class [aeiou]. This character class can be used in a regular expression to match a set of similarly spelled words. b[aeiou]t matches: bat bet bit bot but It does not match: bout btt bt Character classes on their own match one and only one character at a time...
Two Random class created at the same time will have the same seed value. Using System.Guid.NewGuid().GetHashCode() can get a different seed even in the same time. Random rnd1 = new Random(); Random rnd2 = new Random(); Console.WriteLine("First 5 random number in rnd1"); for (int i = 0...
This query selects all employees not on the Supervisors table. SELECT * FROM Employees WHERE EmployeeID not in (SELECT EmployeeID FROM Supervisors) The same results can be achieved using a LEFT JOIN. SELECT * FROM Employees AS e LEFT JOIN Supervisors AS s ON s.E...
Occasionally you'd want to catch an exception and throw it from a different thread or method while preserving the original exception stack. This can be done with ExceptionDispatchInfo: using System.Runtime.ExceptionServices; void Main() { ExceptionDispatchInfo capturedException = null; ...
Start a named process on one IP address: $ iex --name [email protected] --cookie chocolate iex([email protected])> Node.ping :"[email protected]" :pong iex([email protected])> Node.list [:"[email protected]"] Start another named process on a different IP address: $ iex ...
git diff HEAD^ HEAD This will show the changes between the previous commit and the current commit.

Page 2 of 10