Tutorial by Examples: ch

To match something that does not contain a given string, one can use negative lookahead: Regex syntax: (?!string-to-not-match) Example: //not matching "popcorn" String regexString = "^(?!popcorn).*$"; System.out.println("[popcorn] " + ("popcorn".matches(r...
A char is single letter stored inside a variable. It is built-in value type which takes two bytes of memory space. It represents System.Char data type found in mscorlib.dll which is implicitly referenced by every C# project when you create them. There are multiple ways to do this. char c = 'c'; ...
The MediaPlayer$prepare() is a blocking call and will freeze the UI till execution completes. To solve this problem, MediaPlayer$prepareAsync() can be used. mMediaPlayer = ... // Initialize it here mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener(){ @Override public ...
Inline style You can manipulate the inline CSS style of an HTML element by simply reading or editing its style property. Assume the following element: <div id="element_id" style="color:blue;width:200px;">abc</div> With this JavaScript applied: var element = doc...
To modify an existing column in Rails with a migration, run the following command: rails g migration change_column_in_table This will create a new migration file in db/migration directory (if it doesn’t exist already), which will contain the file prefixed with timestamp and migration file name w...
# load the library library(ggplot2) # create a blank canvas g <- ggplot(data = diamonds) g + geom_bar(aes(x = cut, fill = cut)) + scale_fill_discrete(guide = guide_legend(title = "CUT", keywidth = 2, ...
When Flash makes a request for data from an external source, that operation is asynchronous. The most basic explanation of what this means is that the data loads "in the background" and triggers the event handler you allocate to Event.COMPLETE when it is received. This can happen at any po...
If you need to roll for a true or false in an "x% chance" situation, use: function roll(chance:Number):Boolean { return Math.random() >= chance; } Used like: var success:Boolean = roll(0.5); // True 50% of the time. var again:Boolean = roll(0.25); // True 25% of the time. ...
To display the hunks that are staged for commit: git diff --cached
2.2 func removeCharactersNotInSetFromText(text: String, set: Set<Character>) -> String { return String(text.characters.filter { set.contains( $0) }) } let text = "Swift 3.0 Come Out" var chars = Set([Character]("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLKMNOPQRSTUVWXYZ&...
array_chunk() splits an array into chunks Let's say we've following single dimensional array, $input_array = array('a', 'b', 'c', 'd', 'e'); Now using array_chunk() on above PHP array, $output_array = array_chunk($input_array, 2); Above code will make chunks of 2 array elements and create a...
A Value Converter can be used alongside other value converters and you can infinitely chain them using the | pipe separator. ${myString | toUppercase | removeCharacters:'&,%,-,+' | limitTo:25} The above theoretical example firstly applies toUppercase which capitalizes our string. Then it app...
This example was done in order to demonstrate how you can perform a deep filter in a child array without the necessity of a custom filter. Controller: (function() { "use strict"; angular .module('app', []) .controller('mainCtrl', mainCtrl); function mainCtrl() { ...
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...
Use to push commits made on your local branch to a remote repository. The git push command takes two arguments: A remote name, for example, origin A branch name, for example, master For example: git push <REMOTENAME> <BRANCHNAME> As an example, you usually run git push orig...
To get Unix Epoch Time, use the constant timeIntervalSince1970: Swift let date = NSDate() // current date let unixtime = date.timeIntervalSince1970 Objective-C NSDate *date = [NSDate date]; // current date int unixtime = [date timeIntervalSince1970];
Let's say you have an object like this: var myObject = { name: 'Peter' } Later in your code, you try to access myObject.name and you get George instead of Peter. You start wondering who changed it and where exactly it was changed. There is a way to place a debugger (or something else) on e...
Sample Data: CREATE TABLE table_name ( id, list ) AS SELECT 1, 'a,b,c,d' FROM DUAL UNION ALL -- Multiple items in the list SELECT 2, 'e' FROM DUAL UNION ALL -- Single item in the list SELECT 3, NULL FROM DUAL UNION ALL -- NULL list SELECT 4, 'f,,g' FROM DUAL; -- NULL item...
var dict = ["name": "John", "surname": "Doe"] // Set the element with key: 'name' to 'Jane' dict["name"] = "Jane" print(dict)
using System.Net; ... string serverResponse; try { // Call a method that performs an HTTP request (per the above examples). serverResponse = PerformHttpRequest(); } catch (WebException ex) { if (ex.Status == WebExceptionStatus.ProtocolError) { HttpWebResponse...

Page 18 of 109