Skip to content

Instantly share code, notes, and snippets.

View adambair's full-sized avatar

Adam Bair adambair

View GitHub Profile
Horror Code Session.
module Footnoted
def self.included(base)
base.extend(ClassMethods)
has_footnote
end
module ClassMethods
def has_footnote
require 'yaml'
# write yaml to a file
open('filename', 'w') {|f| f << something.to_yaml}
# read yaml from a file
something = YAML.load(open('filename'))
#import <foundation/foundation.h>
#import "SQLitePersistentObject.h"
@interface PersistablePerson : SQLitePersistentObject {
NSString *lastName;
}
@property (nonatomic, retain) NSString * lastName;
@end
PersistablePerson *person = [[PersistablePerson alloc] init];
@adambair
adambair / some_hash_method.java
Created December 11, 2008 20:12
Needed to convert this java method to Objective-C. It turnes out that it's only doing starndard HmacSHA1. Don't ask how long it took me to figure it out.
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
public static String someHashMethod(String data, String hash) {
byte[] hashBytes = hash.getBytes();
SecretKeySpec signKey = new SecretKeySpec(hashBytes, "HmacSHA1");
Mac mac = Mac.getInstance("HmacSHA1");
mac.init(signKey);
syn match rspecDescribe "^\W*describe\W"
syn match rspecIt "^\W*it\W"
hi def link rspecDescribe Define
hi def link rspecIt Define
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "☠"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1) $(parse_git_dirty)/"
}
export PS1='\[\033[1;33m\]\w\[\033[0m\] $(parse_git_branch)\n→ '
/opt/local/bin/ruby -Ilib:test "/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb"
/opt/local/bin/ruby -Ilib:test "/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb"
/opt/local/bin/ruby -Ilib:test "/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb"
→ grep -Rn :default vendor/rails/railties/lib/tasks/*
vendor/rails/railties/lib/tasks/misc.rake:1:#task :default => :test
@adambair
adambair / gist:81994
Created March 19, 2009 18:44
Git post-commit hook for Present.ly (presentlyapp.com)
#!/usr/bin/perl
# change your account, username, password, and group
# it'll run every time you commit (not push, mind you)
$account='account';
$username='username';
$password='password';
$group='group';
$git_text = `git log -n1 --pretty=format:"(%h) %s"`;