Tutorial by Examples: ch

public bool Check() { string input = "Hello World!"; string pattern = @"H.ll. W.rld!"; // true return Regex.IsMatch(input, pattern); }
public string Check() { string input = "Hello World!"; string pattern = @"W.rld"; // Hello Stack Overflow! return Regex.Replace(input, pattern, "Stack Overflow"); }
public string Check() { string input = "Hello World!"; string pattern = @"H.ll. (?<Subject>W.rld)!"; Match match = Regex.Match(input, pattern); // World return match.Groups["Subject"].Value; }
The following Go file can be compiled into a continuous external collector that will query a MSSQL server database that uses the StackExchange.Exceptional schema. It will query multiple servers/databases for all exceptions since UTC 00:00 to convert the raw entries into a counter. It also uses the b...
To recover a deleted branch you need to find the commit which was the head of your deleted branch by running git reflog You can then recreate the branch by running git checkout -b <branch-name> <sha1-of-commit> You will not be able to recover deleted branches if git's garbage col...
A newline can be included in a single-string or double-quoted string. Note that backslash-newline does not result in a newline, the line break is ignored. newline1=' ' newline2=" " newline3=$'\n' empty=\ echo "Line${newline1}break" echo "Line${newline2}break" ...
String comparison uses the == operator between quoted strings. The != operator negates the comparison. if [[ "$string1" == "$string2" ]]; then echo "\$string1 and \$string2 are identical" fi if [[ "$string1" != "$string2" ]]; then echo &quot...
In a normal string, the backslash character is the escape character, which instructs the compiler to look at the next character(s) to determine the actual character in the string. (Full list of character escapes) In verbatim strings, there are no character escapes (except for "" which is ...
# Create the nodes # In a real world scenario we would use at least 3 managers to cover the fail of one manager. docker-machine create -d virtualbox manager docker-machine create -d virtualbox worker1 # Create the swarm # It is possible to define a port for the *advertise-addr* and *listen-ad...
You can see what "hunks" of work would be staged for commit using the patch flag: git add -p or git add --patch This opens an interactive prompt that allows you to look at the diffs and let you decide whether you want to include them or not. Stage this hunk [y,n,q,a,d,/,s,e,?]? ...
VoiceOver works great most of the time, breezily reading aloud screens full of content and intuitively following the user. Alas, no general solution is perfect. Sometimes only you, the app developer, know where VoiceOver should be focused for an optimal user experience. Fortunately, VoiceOver listen...
In many cases, content within a single screen will update with new or different content. For example, imagine a form that reveals additional options based on the user’s answer to a previous question. In this case, a “layout change” notification lets you either announce the change or focus on a new e...
Closures are often used for asynchronous tasks, for example when fetching data from a website. 3.0 func getData(urlString: String, callback: (result: NSData?) -> Void) { // Turn the URL string into an NSURLRequest. guard let url = NSURL(string: urlString) else { return } let re...
Chef Scollector Cookbook: https://github.com/alexmbird/chef-scollector Chef Bosun Cookbook: https://github.com/ptqa/chef-bosun Puppet scollector module: https://github.com/axibase/axibase-puppet-modules Bosun Ansible/Vagrant example: https://github.com/gnosek/bosun-deploy
git bisect allows you to find which commit introduced a bug using a binary search. Start by bisecting a session by providing two commit references: a good commit before the bug, and a bad commit after the bug. Generally, the bad commit is HEAD. # start the git bisect session $ git bisect start ...
Rename the branch you have checked out: git branch -m new_branch_name Rename another branch: git branch -m branch_you_want_to_rename new_branch_name
To show all staged and unstaged changes, use: git diff HEAD NOTE: You can also use the following command: git status -vv The difference being that the output of the latter will actually tell you which changes are staged for commit and which are not.
This example requires the headers <algorithm>, <locale>, and <utility>. C++11 To trim a sequence or string means to remove all leading and trailing elements (or characters) matching a certain predicate. We first trim the trailing elements, because it doesn't involve moving any el...
The static (compile-time) type is used rather than the dynamic (run-time type) to match parameters. public class Base { public virtual string GetName() { return "Base"; } } public class Derived : Base { public override string GetName() { ...
Prefer public class Order { public OrderLine AddOrderLine(OrderLine orderLine) { if (orderLine == null) throw new ArgumentNullException(nameof(orderLine)); ... } } Over public class Order { public OrderLine AddOrderLine(OrderLine orderLine) { ...

Page 8 of 109