Skip to content

Instantly share code, notes, and snippets.

View jodell's full-sized avatar

Jeffrey ODell jodell

View GitHub Profile
@jodell
jodell / gist:2852956
Created June 1, 2012 15:27
class reference dictionary
NSString * const MYFoo = @"foo";
NSString * const MYBar = @"bar";
@implementation Baz
+ (NSDictionary *)metaSyntacticTypes {
static NSDictionary *_metaSyntacticTypes = nil;
if (_metaSyntacticTypes == nil) {
_metaSyntacticTypes = [NSDictionary dictionaryWithObjectsAndKeys:
@"foo", MYFoo,
@jodell
jodell / ec2-public-dns.sh
Created May 15, 2012 21:53
Find the public dns of an ec2 machine, internally.
# Hostname
curl -s http://169.254.169.254/latest/meta-data/public-hostname
# IP
curl -s http://169.254.169.254/latest/meta-data/public-ipv4
@jodell
jodell / gist:2562891
Created April 30, 2012 21:40
delete last knife ec2 server
knife ec2 server list | tail -n1 | cut -f1 -d' ' | xargs knife ec2 server delete -y
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
@jodell
jodell / let_tap.rb
Created April 30, 2012 19:34
let & tap reminders
# Reminder:
class Object
def let
yield self
end
end
class Object
def tap
# EC2 Magic, WTF
`curl http://169.254.169.254/latest/meta-data/public-ipv`
def foo
bar == "some value test" ?
"#{self.baz} some relevant but shitty string that takes up way too many characters" :
"#{self.baz} some other equally relevant and shitty string"
end
- (void)setupHeader {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"PlanHeaderLabel" owner:self options:nil];
PlanHeaderLabel *planHeaderLabel = [topLevelObjects objectAtIndex:0];
[planHeaderLabel updateWithPlan:self.plan];
self.myTableView.tableHeaderView = planHeaderLabel;
// Need to adjust the scroll window
UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, self.myTableView.tableHeaderView.frame.size.height, 0);
self.myTableView.contentInset = insets;
self.myTableView.scrollIndicatorInsets = insets;
@jodell
jodell / gist:1935388
Created February 28, 2012 21:49
Sort with a block
NSArray *sorted = [self.buy.placements sortedArrayUsingComparator:^(id a, id b) {
return [[(Placement *)a position] compare:[(Placement *)b position]];
}];
self.buy.placements = [NSMutableArray arrayWithArray:sorted];
NSSortDescriptor *descriptor = [[[NSSortDescriptor alloc] initWithKey:@"key" ascending:YES] autorelease];
[array sortUsingDescriptors:[NSArray arrayWithObjects:descriptor,nil]];