Tutorial by Examples

SVG can be written directly into a HTML document. Inline SVG can be styled and manipulated using CSS and JavaScript. <body> <svg class="attention" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 1000 1000&qu...
You can add external SVG files using the background-image property, just as you would do with any other image. HTML: <div class="attention"></div> CSS: .attention { background-image: url(attention.svg); background-size: 100% 100%; width: 50px; height: ...
You can split a string into an array of parts, divided by a separator character. NSString * yourString = @"Stack,Exchange,Network"; NSArray * yourWords = [yourString componentsSeparatedByString:@","]; // Output: @[@"Stack", @"Exchange", @"Network&quot...
To search if a String contains a substring, do the following: NSString *myString = @"This is for checking substrings"; NSString *subString = @"checking"; BOOL doesContainSubstring = [myString containsString:subString]; // YES If targeting iOS 7 or OS X 10.9 (or earlier)...
Office Blog - Excel VBA Performance Coding Best Practices Often, best performance is achieved by avoiding the use of Range as much as possible. In this example we read in an entire Range object into an array, square each number in the array, and then return the array back to the Range. This accesse...
typedef double (^Operation)(double first, double second); If you declare a block type as a typedef, you can then use the new type name instead of the full description of the arguments and return values. This defines Operation as a block that takes two doubles and returns a double. The type can b...
Variables hold data. Name them after what they're used for, not after their data type or scope, using a noun. If you feel compelled to number your variables (e.g. thing1, thing2, thing3), then consider using an appropriate data structure instead (e.g. an array, a Collection, or a Dictionary). Names...
Procedures do something. Name them after what they're doing, using a verb. If accurately naming a procedure is not possible, likely the procedure is doing too many things and needs to be broken down into smaller, more specialized procedures. Some common VBA naming conventions go thus: For all Pr...
Given the following HTML file: index.html <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>React Tutorial</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.2.1/react.js"></script>...
<link rel="alternate stylesheet" href="path/to/style.css" title="yourTitle"> Some browsers allow alternate style sheets to apply if they are offered. By default they will not be applied, but usually they can be changed through the browser settings: Firefox l...
Unlike classes, structures cannot inherit: class MyView: NSView { } // works struct MyInt: Int { } // error: inheritance from non-protocol type 'Int' Structures, however, can adopt protocols: struct Vector: Hashable { ... } // works
If a case class has exactly two values, its extractor can be used in infix notation. case class Pair(a: String, b: String) val p: Pair = Pair("hello", "world") val x Pair y = p //x: String = hello //y: String = world Any extractor that returns a 2-tuple can work this way....
The for-in loop allows you to iterate over any sequence. Iterating over a range You can iterate over both half-open and closed ranges: for i in 0..<3 { print(i) } for i in 0...2 { print(i) } // Both print: // 0 // 1 // 2 Iterating over an array or set let names = [&quo...
Similar to the while loop, only the control statement is evaluated after the loop. Therefore, the loop will always execute at least once. var i: Int = 0 repeat { print(i) i += 1 } while i < 3 // 0 // 1 // 2
A while loop will execute as long as the condition is true. var count = 1 while count < 10 { print("This is the \(count) run of the loop") count += 1 }
You can use the Enumerable class alongside Linq queries to convert for loops into Linq one liners. Select Example Opposed to doing this: var asciiCharacters = new List<char>(); for (var x = 0; x < 256; x++) { asciiCharacters.Add((char)x); } You can do this: var asciiCharacter...
When you need to remove a specific value from an array, you can use the following one-liner to create a copy array without the given value: array.filter(function(val) { return val !== to_remove; }); Or if you want to change the array itself without creating a copy (for example if you write a fun...
Composer tracks which versions of packages you have installed in a file called composer.lock, which is intended to be committed to version control, so that when the project is cloned in the future, simply running composer install will download and install all the project's dependencies. Composer de...
A lot of the power of ReactJS is its ability to allow nesting of components. Take the following two components: var React = require('react'); var createReactClass = require('create-react-class'); var CommentList = reactCreateClass({ render: function() { return ( <div className...
From NSString: NSString *urlString = @"https://www.stackoverflow.com"; NSURL *myUrl = [NSURL URLWithString: urlString]; You can also use the following methods: - initWithString: + URLWithString:relativeToURL: - initWithString:relativeToURL: + fileURLWithPath:isDirectory: - initF...

Page 145 of 1336