This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface NSArray (MehAdditions) | |
- (NSArray*) filter:(BOOL (^)(id)) block; | |
- (NSArray*) map:(id (^)(id)) block; | |
- (id) reduce:(id) value block:(id (^)(id, id)) aBlock; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation NSArray (Mehdditions) | |
- (NSArray*) filter:(BOOL (^)(id)) block { | |
NSMutableArray* result = [NSMutableArray new]; | |
for (id item in self) | |
if (block(item)) | |
[result addObject:item]; | |
return result; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface MyExistingClass (SomeRandomNamePreferablyWithAdditionsPostfixed) | |
- (void) extraMethod; | |
+ (void) extraStaticMethod; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSMutableArray* yay = [NSMutableArray new]; | |
[yay addObject:@"1"]; | |
[yay addObject:@"2"]; | |
[yay addObject:@"3"]; | |
NSNumber* reduced = [yay reduce:[NSNumber numberWithInt:0] block:^id(id sum, id i) { | |
return [NSNumber numberWithInt:[sum intValue] + [i intValue]]; | |
}]; | |
STAssertEquals([reduced intValue], 6, @"whut?!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# $1 nodejs version, e.g. "0.6.12" | |
sudo apt-get install -y libssl-dev g++ | |
if [ ! -d "node-v$1" ]; then | |
# download + extract | |
curl http://nodejs.org/dist/v$1/node-v$1.tar.gz | tar xzf - | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cd ~ | |
git clone -n [email protected]:tralamazza/skel.git | |
mv skel/.git . | |
rm -rf skel | |
git checkout HEAD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ $# -lt 3 ]; then | |
echo "Missing arguments" | |
exit 1 | |
fi | |
COUPON=$1 | |
PASSWORD=$2 | |
EMAIL=$3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"klass": "InputGate", | |
"params": { | |
"positionFromTop": 280, | |
"editable": true | |
} | |
}, | |
{ | |
"klass": "Redirector", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// source: https://github.com/felixge/node-mysql#server-disconnects | |
var mysql = require('mysql'); | |
function supportReconnect(connection, cb) { | |
connection.on('error', function(err) { | |
if (!err.fatal) return; | |
if (err.code !== 'PROTOCOL_CONNECTION_LOST') throw err; | |
connection = mysql.createConnection(connection.config); | |
if (cb(connection)) | |
supportReconnect(connection, cb); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function intercept(f, cb) { | |
return function() { | |
cb(arguments); | |
f.apply(f, Array.prototype.slice.call(arguments, 0)); | |
}; | |
} |