View unpivot.py
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/python | |
import sys, csv | |
def main(): | |
csvIn = csv.reader(sys.stdin, delimiter=',', quotechar='"') | |
csvOut = csv.writer(sys.stdout) | |
for rowNum, row in enumerate(csvIn): | |
if rowNum == 0: |
View gist:1791618
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
mkdir heroku | |
cd heroku/ | |
virtualenv --no-site-packages env | |
source env/bin/activate | |
pip install bottle | |
pip freeze > requirements.txt | |
cat >app.py <<EOF | |
import bottle, os |
View newflask.sh
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/bash | |
if [ $# -eq 0 ] ; then | |
echo "Usage: $0 <flask_app_name>" | |
exit 1 | |
fi | |
ROOT=$HOME | |
#### Flask #### |
View NSKeyedArchiverUserDefaults.m
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
- (HKQueryAnchor *)anchor { | |
return [NSKeyedUnarchiver unarchiveTopLevelObjectWithData:[NSUserDefaults.standardUserDefaults dataForKey:@"anchor"] error:nil]; | |
} | |
- (void)setAnchor:(HKQueryAnchor *)value { | |
[NSUserDefaults.standardUserDefaults setObject:[NSKeyedArchiver archivedDataWithRootObject:value] forKey:@"anchor"]; | |
} |
View MonitorNSNotificationCenter.m
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
[[NSNotificationCenter defaultCenter] addObserverForName:nil | |
object:nil | |
queue:nil | |
usingBlock:^(NSNotification *notification) { | |
NSLog(@"%@", notification.name); | |
}]; |
View CBUUIDNames.m
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
for(int i=0;i<256;i++) { | |
CBUUID *u = [CBUUID UUIDWithString:[NSString stringWithFormat:@"18%02X", i]]; | |
if(![u.UUIDString isEqualToString:u.description]) | |
NSLog(@"%@\t%@", u.UUIDString, u.description); | |
} | |
// 1800 Generic Access Profile | |
// 1801 Generic Attribute Profile | |
// 1805 Current Time | |
// 1808 Glucose |
View NSUserDefaults+ParameterlessOptions.m
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
// Enable parameterless options (e.g., `-verbose`) to be passed in as command line arguments. | |
NSMutableDictionary *arguments = [[NSUserDefaults.standardUserDefaults volatileDomainForName:NSArgumentDomain] mutableCopy]; | |
for(NSString *arg in NSProcessInfo.processInfo.arguments) | |
if([arg hasPrefix:@"-"] && [arguments objectForKey:[arg substringFromIndex:1]] == nil) | |
[arguments setObject:@YES forKey:[arg substringFromIndex:1]]; | |
[NSUserDefaults.standardUserDefaults removeVolatileDomainForName:NSArgumentDomain]; // remove to prevent NSInvalidArgumentException (per documentation) | |
[NSUserDefaults.standardUserDefaults setVolatileDomain:arguments forName:NSArgumentDomain]; |
View UnUppercaseTableView.m
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)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section { | |
if([view isKindOfClass:UITableViewHeaderFooterView.class]) { | |
((UITableViewHeaderFooterView *)view).textLabel.text = [self tableView:tableView titleForHeaderInSection:section]; | |
} | |
} |
View getservbyname.m
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
struct servent *s = getservbyname("http", NULL); | |
if(!!s) { | |
NSLog(@"%s %i %s", s->s_name, CFSwapInt16BigToHost(s->s_port), s->s_proto); | |
for(size_t i=0; !!s->s_aliases[i]; i++) { | |
NSLog(@"%lu\t%s", i, s->s_aliases[i]); | |
} | |
} |
View FPDistributedNotificationCenter
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
@interface FPDistributedNotificationCenter : NSObject | |
@end | |
@implementation FPDistributedNotificationCenter | |
- (id)init { | |
if(self = [super init]) { | |
[NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(receivedDistributedNotification:) name:nil object:nil]; | |
} | |
return self; | |
} |
OlderNewer