This file contains 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 | |
FILE_URL=http://speedtest.wdc01.softlayer.com/downloads/test10.zip | |
if [ -e /usr/bin/curl ] && [ -e /usr/bin/bc ] && [ -e /usr/bin/xargs ]; then | |
echo "scale=2; `curl --progress-bar -w "%{speed_download}" $FILE_URL -o /dev/null` / 131072"\ | |
| bc\ | |
| xargs -I {} echo {} mbps | |
elif [ -e /usr/bin/curl ]; then | |
curl -o /dev/null $FILE_URL |
This file contains 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 | |
RESULT=$(xcodebuild -configuration Debug RUN_CLANG_STATIC_ANALYZER=YES) | |
if `echo ${RESULT} | grep "generated." 1>/dev/null 2>&1` | |
then | |
echo "commit failed: anaylzer error found" | |
exit 1 | |
fi |
This file contains 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
#ifndef NDEBUG | |
#define InfDebugLog( ... ) NSLog( __VA_ARGS__ ) | |
#else | |
#define InfDebugLog( ... ) | |
#endif |
This file contains 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
#define blockSafe_cat(A, B) A##B | |
#define blockSafe_line(V, TMP) typeof(V) blockSafe_cat(blockSafe_tmp__, TMP) = V; __block typeof(V) V = blockSafe_cat(blockSafe_tmp__, TMP) | |
#define blockSafe(V) blockSafe_line(V, __LINE__) |
This file contains 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
1. Thou shalt always use Key Value Observing | |
2. Thou shalt not block the main thread | |
3. Thou shalt compile with zero errors or warnings | |
4. Thou shalt use #pragma mark to separate code into groups based on related functionality |
This file contains 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
NSData *bom = nil; | |
NSStringEncoding encoding = ...; | |
NSData *a = [@"a" dataUsingEncoding:encoding]; | |
NSData *aa = [@"aa" dataUsingEncoding:encoding]; | |
if ([a length] * 2 != [aa length]) { | |
NSUInteger characterLength = [aa length] - [a length]; | |
bom = [a subdataWithRange:NSMakeRange(0, [a length]-characterLength)]; | |
} |
This file contains 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
-(void)addContact{ | |
ABRecordRef person; | |
ABMultiValueRef social = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType); | |
ABMultiValueAddValueAndLabel(social, [NSDictionary dictionaryWithObjectsAndKeys: | |
(NSString *)kABPersonSocialProfileServiceTwitter, kABPersonSocialProfileServiceKey, | |
@"justinbieber", kABPersonSocialProfileUsernameKey, | |
nil], kABPersonSocialProfileServiceTwitter, NULL); | |
ABRecordSetValue(person, kABPersonSocialProfileProperty, social, NULL); | |
CFRelease(social); |
This file contains 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
require ["envelope", "imapflags", "fileinto", "reject", "notify", "vacation", "regex", "relational", "comparator-i;ascii-numeric", "body", "copy"]; | |
# Spam processing | |
if not header :contains ["X-Spam-known-sender"] "yes" { | |
if allof ( | |
header :contains ["X-Backscatter"] "yes", | |
not header :matches ["X-LinkName"] "*" | |
) { | |
discard; | |
stop; |
This file contains 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
#!/usr/bin/env ruby | |
# | |
# This script can be used to check the in-store availability of the iPhone 5S. | |
# By default, it searches for all AT&T models. You can change this by editing | |
# the MY_DEVICES array below. While the Apple API supports searching for | |
# multiple devices at once, there is a limit. | |
# | |
# Once you have properly configured the MY_DEVICES array, you can run this script | |
# from the terminal. It takes a single parameter, which should be the zip code you | |
# wish to use for your search. |
OlderNewer