Skip to content

Instantly share code, notes, and snippets.

View ohammersmith's full-sized avatar

Otto Hammersmith ohammersmith

View GitHub Profile
@ohammersmith
ohammersmith / 0_reuse_code.js
Last active August 29, 2015 14:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
Given /^There (?:is|are) (\d+|a) (.*?)(.*?)(?: with "(.*?)" for (.*?))?$/ do |count, model, factory_suffix, value, attribute|
count = 1 if count == "a"
factory_name = model.singularize << factory_suffix.gsub(" ", "_")
if attribute and value
count.to_i.times { Factory(factory_name.to_sym, attribute.to_sym => value) }
else
count.to_i.times { Factory(factory_name.to_sym) }
end
end
When /^I fill in the country for the degree with "(.*)"$/ do |value|
within("#degrees") do
fill_in("Country", value)
end
end
% script/generate model GrandParent name:string
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/grand_parent.rb
create test/unit/grand_parent_test.rb
create test/fixtures/grand_parents.yml
create db/migrate
create db/migrate/20090127182616_create_grand_parents.rb
@ohammersmith
ohammersmith / .bashrc
Created January 16, 2009 02:04 — forked from henrik/.bashrc
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
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)]/"
#!/usr/bin/ruby
require 'rubygems'
require 'git'
log = "~/gitlog.txt"
tmp = "/tmp/gitlog"
commit = Git.open('.').log.first
message = [
commit.date.strftime('%D'),
@ohammersmith
ohammersmith / gist:32498
Created December 5, 2008 20:24 — forked from tomharris/gist:32495
Using Google Maps API to get coordinates of an address.
require "net/http"
require "uri"
module Google
class Geocode
attr_accessor :address
attr_reader :key, :latutude, :longitude
def initialize( key, address )
@key = key