Underscore example:
_.each([1, 2, 3], function(num) { alert(num); });
@synthesize firstName = _firstName; | |
@synthesize txtFirstName = _txtFirstName; | |
[RACAbleSelf(self.firstName) subscribeNext:^(id x) { [self firstNameChanged:x]; }]; | |
[self rac_bind:RAC_KEYPATH_SELF(self.firstName) to:self.txtFirstName.rac_textSubscribable]; | |
- (void) firstNameChanged:(id)firstName { | |
NSLog(@"changed: %@", firstName); | |
} |
Generate the list yourself:
$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./* | \
sed 's/NS_AVAILABLE_IOS(.*)//g' | \
sed 's/NS_DEPRECATED_IOS(.*)//g' | \
sed 's/API_AVAILABLE(.*)//g' | \
sed 's/API_UNAVAILABLE(.*)//g' | \
sed 's/UI_APPEARANCE_SELECTOR//g' | \
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
var dom = Bloop.dom; | |
var Box = Bloop.createClass({ | |
getInitialState: function() { | |
return { number: 0 }; | |
}, | |
updateNumber: function() { | |
this.state.number++; | |
}, |
struct InputStreamGenerator : Generator { | |
var inputStream : NSInputStream | |
var chunkSize : Int | |
init(inputStream : NSInputStream, chunkSize : Int) { | |
self.inputStream = inputStream | |
self.chunkSize = chunkSize | |
} | |
func s(x:Int)->[Int]{ | |
return x<2 ? | |
[]: | |
// Single line closure has implicit return | |
// Closure type is Int->[Int] | |
{[$0]+s(x/$0)}( // Argment to closure | |
// Filter full range 2 to x and take first factor (non lazy) | |
// x%x is guaranteed to be 0 so safe to take first element | |
filter(2...x){x % $0 == 0}[0] | |
) |
Functional programming gets a bad wrap about being too hard for mere mortals to comprehend. This is nonsense. The concepts are actually quite simple to grasp.
The jargon is the hardest part. A lot of that vocabulary comes from a specialized field of mathematical study called category theory (with a liberal sprinkling of type theory and abstract algebra). This sounds a lot scarier than it is. You can do this!
All examples using ES6 syntax. wrap (foo) => bar
means:
function wrap (foo) {
// Playground - noun: a place where people can play | |
import Foundation | |
typealias Byte = UInt8 | |
protocol GenericIntegerType: IntegerType { | |
init(_ v: Int) | |
init(_ v: UInt) | |
init(_ v: Int8) |
//load Global Terrorism Database | |
//Copy/Paste the load script below into your Neo4j-shell command-line utility | |
//In order to accelerate the loading process, you want to download the CSV file from | |
//https://www.dropbox.com/s/oequ58lrp8f9w6v/gtdb_transform.csv?dl=1 and then to a local file. | |
//After that, you would of course need to replace the URL in all of the queries below, and replace it with | |
//load csv with headers from "file:/path/to/your/file.csv" as csv | |
//load the countries | |
load csv with headers from "https://www.dropbox.com/s/oequ58lrp8f9w6v/gtdb_transform.csv?dl=1 |