Skip to content

Instantly share code, notes, and snippets.

View sgoodwin's full-sized avatar

Samuel Goodwin sgoodwin

View GitHub Profile
require 'CSV'
require 'plist'
file = File.open('somecsv.csv')
list = CSV.parse(file.read)
1.upto(list.count) do |row|
if(!list[row].nil?)
hash[list[row][0]] = list[row][1]
end
#import <UIKit/UIKit.h>
@interface GOCustomView : UIView
@property(nonatomic, retain) UIColor *bgColor;
@property (nonatomic,retain) NSMutableArray *xArr;
@end
@sgoodwin
sgoodwin / gist:1174380
Created August 26, 2011 20:39
Lazy loading a variable.
- (NSMutableArray*)xArr{
if(_xArr){
return _xArry;
}
_xArr = [[NSMutableArray alloc] init];
return _xArr;
}
CGFloat maxX = 0.0f;
CGFloat maxY = 0.0f;
[self.points enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop){
CGPoint point = [obj CGPointValue];
if(point.x > maxX){
maxX = point.x;
}
if(point.y > maxY){
NSUInteger i = 0;
NSValue *value = [self.points objectAtIndex:i];
CGPoint point = [value CGPointValue];
// Do stuff with your point.
@sgoodwin
sgoodwin / gist:1360531
Created November 12, 2011 13:39
.git/hooks/git-commit
#!/bin/bash
#
# Don't allow commits that aren't mentioning a ticket.
#
test "" != "$(grep '#[0-9]\+' "$1")" || {
echo >&2 You must mention a ticket when commiting!
exit 1
}
@sgoodwin
sgoodwin / calendar_math.rb
Created January 26, 2012 07:45
Date-based financial math
#!/usr/bin/env ruby
require 'date'
puts "hi, I'm gonna do math!"
class CalendarItem
attr_accessor :date
attr_accessor :amount
def initialize(date, amount)
@sgoodwin
sgoodwin / counter.js
Created January 29, 2012 10:25
Count the time I've added up in my work textfile.
var fs = require('fs'),
async = require('async');
fs.readFile('work.txt', 'utf8', function(err, data){
if(err){
throw err;
}
var lines = data.split('\n');
var iterator = function(item, callback){
☁ Tribo [editable_templates] git submodule init
Submodule 'Dependencies/CocoaHTTPServer' () registered for path 'Dependencies/CocoaHTTPServer'
Submodule 'Dependencies/GRMustache' () registered for path 'Dependencies/GRMustache'
Submodule 'Dependencies/Sundown' () registered for path 'Dependencies/Sundown'
☁ Tribo [editable_templates] git submodule update
fatal: Not a git repository: /Users/sgoodwin/Desktop/Side Projects/Blogging/Tribo/.git/modules/Dependencies/CocoaHTTPServer
Unable to find current revision in submodule path 'Dependencies/CocoaHTTPServer'
☁ Tribo [editable_templates] git status
@sgoodwin
sgoodwin / gist:2347364
Created April 9, 2012 23:35
Example file!
//
// GOViewController.h
// Example
//
// Created by Samuel Goodwin on 4/10/12.
// Copyright (c) Your Momma. All rights reserved.
//
#import <UIKit/UIKit.h>