Tutorial by Examples: ch

preg_match checks whether a string matches the regular expression. $string = 'This is a string which contains numbers: 12345'; $isMatched = preg_match('%^[a-zA-Z]+: [0-9]+$%', $string); var_dump($isMatched); // bool(true) If you pass in a third parameter, it will be populated with the matchi...
Rails uses sqlite3 as the default database, but you can generate a new rails application with a database of your choice. Just add the -d option followed by the name of the database. $ rails new MyApp -T -d postgresql This is a (non-exhaustive) list of available database options: mysql oracle...
To convert a String to uppercase, use uppercaseString: NSString *myString = @"Emphasize this"; NSLog(@"%@", [myString uppercaseString]; // @"EMPHASIZE THIS" To convert a String to lowercase, use lowercaseString: NSString *myString = @"NORMALIZE this"; N...
The checked out file will overwrite not yet commited changes you did in this file. This command will check out the file file.example (which is located in the directory path/to/) and overwrite any changes you might have made to this file. git checkout some-branch path/to/file some-branch can be ...
The % wildcard appended to the beginning or end (or both) of a string will allow 0 or more of any character before the beginning or after the end of the pattern to match. Using '%' in the middle will allow 0 or more characters between the two parts of the pattern to match. We are going to use this...
There are 5 different types (MKMapType), MKMapView can display. iPhone OS 3 .standard Displays a street map that shows the position of all roads and some road names. Swift 2 mapView.mapType = .Standard Swift 3 mapView.mapType = .standard Objective-C _mapView.mapType = MKMapTypeStandard;...
Dart has a switch case which can be used instead of long if-else statements: var command = 'OPEN'; switch (command) { case 'CLOSED': executeClosed(); break; case 'OPEN': executeOpen(); break; case 'APPROVED': executeApproved(); break; case 'UNSURE': ...
To check for a precise number of elements in the collection def f(ints: Seq[Int]): String = ints match { case Seq() => "The Seq is empty !" case Seq(first) => s"The seq has exactly one element : $first" case Seq(first, second) => s"The...
All Java exceptions are instances of classes in the Exception class hierarchy. This can be represented as follows: java.lang.Throwable - This is the base class for all exception classes. Its methods and constructors implement a range of functionality common to all exceptions. java.lang.Excep...
SharedPreferences sharedPreferences = ...; sharedPreferences.registerOnSharedPreferenceChangeListener(mOnSharedPreferenceChangeListener); private final SharedPreferences.OnSharedPreferenceChangeListener mOnSharedPreferenceChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener(...
To delete a branch on the origin remote repository, you can use for Git version 1.5.0 and newer git push origin :<branchName> and as of Git version 1.7.0, you can delete a remote branch using git push origin --delete <branchName> To delete a local remote-tracking branch: git bra...
The function in_array() returns true if an item exists in an array. $fruits = ['banana', 'apple']; $foo = in_array('banana', $fruits); // $foo value is true $bar = in_array('orange', $fruits); // $bar value is false You can also use the function array_search() to get the key of a specifi...
traverse_ executes an Applicative action for every element in a Foldable structure. It ignores the action's result, keeping only the side-effects. (For a version which doesn't discard results, use Traversable.) -- using the Writer applicative functor (and the Sum monoid) ghci> runWriter $ trave...
An example that uses Parallel.ForEach loop to ping a given array of website urls. static void Main() { string [] urls = { "www.stackoverflow.com", "www.google.net", "www.facebook.com", "www.twitter.com" ...
This Makefile will cross compile and zip up executables for Windows, Mac and Linux (ARM and x86). # Replace demo with your desired executable name appname := demo sources := $(wildcard *.go) build = GOOS=$(1) GOARCH=$(2) go build -o build/$(appname)$(3) tar = cd build && tar -cvzf $...
This type of Singleton is thread safe, and prevents unnecessary locking after the Singleton instance has been created. Java SE 5 public class MySingleton { // instance of class private static volatile MySingleton instance = null; // Private constructor private MySingleton()...
Every case class defines an extractor that can be used to capture the members of the case class when pattern matching: case class Student(name: String, email: String) def matchStudent1(student: Student): String = student match { case Student(name, email) => s"$name has the following...
Swift textView.text = "Hello, world!" Objective-C: textView.text = @"Hello, world!";
Swift textView.textAlignment = .left Objective-C textView.textAlignment = NSTextAlignmentLeft;
Swift //System Font textView.font = UIFont.systemFont(ofSize: 12) //Font of your choosing textView.font = UIFont(name: "Font Name", size: 12) Objective-C //System Font textView.font = [UIFont systemFontOfSize:12]; //Font of your choosing textView.font = [UIFont fontWithName:...

Page 9 of 109