Skip to content

Instantly share code, notes, and snippets.

View owainhunt's full-sized avatar

Owain Hunt owainhunt

View GitHub Profile
[engine repositoriesWithSuccess:^(id response){
NSLog(@"Got an array of repos: %@", obj);
} failure:^(NSError *error) {
NSLog(@"Crapsticks: %@", error);
}];
[engine user:@"this_guy" isCollaboratorForRepository:@"UAGithubEngine" success:^(BOOL hotOrNot) {
NSLog(@"%d", hotOrNot);
} failure:^(NSError *error){
NSLog(@"Monkey balls: %@", error);
@owainhunt
owainhunt / Custom Inflector#titleize for Rails
Created July 23, 2009 16:33
Custom Inflector#titleize for Rails that ignores words which are already all-capitalized.
module ActiveSupport
module Inflector
def titleize(word)
words = word.split(' ')
processed_words = []
words.each do |aWord|
aWord = aWord.capitalize unless /^[A-Z]*$/.match(aWord)
processed_words << aWord
end
processed_words.join(" ")
@owainhunt
owainhunt / gist:133921
Created June 22, 2009 10:53
In Place Edit With Validation
def in_place_edit_with_validation_for(object, attribute)
define_method("set_#{object}_#{attribute}") do
klass = object.to_s.camelize.constantize
@item = klass.find(params[:id])
@item.send("#{attribute}=", params[:value])
if @item.save
render :update do |page|
page.replace_html("#{object}_#{attribute}_#{params[:id]}_in_place_editor",
@item.send(attribute))
end
# http://blog.leetsoft.com/2006/5/29/easy-migration-between-databases
def interesting_tables
ActiveRecord::Base.connection.tables.sort.reject! do |tbl|
['schema_migrations', 'sessions', 'public_exceptions'].include?(tbl)
end
end
def backup
dir = RAILS_ROOT + '/db/backup'
ORHMatch *newMatch = [[ORHMatch alloc] init];
newMatch.battingTeamId = batting;