Skip to content

Instantly share code, notes, and snippets.

View ohammersmith's full-sized avatar

Otto Hammersmith ohammersmith

View GitHub Profile
@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)]/"
# Taken from the image_science gem.
require 'rubygems'
require 'test/unit/testcase'
require 'test/unit' if $0 == __FILE__
require 'image_science'
class TestImageScience < Test::Unit::TestCase
def deny x; assert ! x; end
@ohammersmith
ohammersmith / gist:48788
Created January 18, 2009 22:14
Ruby script in a Windows batch script
@echo off
goto endofruby
#!/bin/ruby
git_repo = "git://github.com/rails/rails.git"
help = %Q{
Rails Info:
-v, --version Show the Rails version number and quit.
-h, --help Show this help message and quit.
DELIMITER $
drop FUNCTION if exists tFunc
$
drop PROCEDURE if exists tProc
$
#!/usr/bin/env ruby
# Taken from http://www.napcsweb.com/blog/2008/04/24/create-a-new-edge-rails-project/
git_repo = "git://github.com/rails/rails.git"
help = %Q{
Rails Info:
-v, --version Show the Rails version number and quit.
-h, --help Show this help message and quit.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby /Users/otto/Desktop/Incubator/Protopipe/protopipe/vendor/plugins/rspec/bin/spec spec/controllers/criteria_controller_spec.rb -O spec/spec.opts
...F...F......F....F.....
1)
'CriteriaController GET 'edit' should render a 404 if the specified criterion doesn't exist' FAILED
expected "/Users/otto/Desktop/Incubator/Protopipe/protopipe/public/404.html", got "criteria/edit.html.erb"
./spec/controllers/criteria_controller_spec.rb:227:
2)
NoMethodError in 'CriteriaController PUT 'update' should render a 404 if the specified criterion doesn't exist'
% 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 / 25things.rb
Created February 2, 2009 01:45
Annoy your facebook friends right back!
#!/usr/bin/env ruby
# You know that Facebook - fuck I don't know what to call it - you write a note with 25 things about yourself and then
# tag^H^H^Hannoy your friends to do it too. Here's the thing about the power of the network effect... you get annoyed
# a lot.
#
# This is my solution.
#
# Feel free to pick either the plain old random or the rot13(plain old random) version
{:country=>"United States", :state=>"Delaware", :keyword_filters_attributes=>{"new_1"=>{:any=>true, :keywords=>"Lorem ipsum dolor sit amet,", :must_have=>false, :weight=>4}, "new_2"=>{:any=>true, :keywords=>"Lorem ipsum dolor sit amet,", :must_have=>false, :weight=>8}}, :city=>"Rotorua", :range=>nil, :postal_code=>"03887"}
#!/usr/bin/env ruby
class Demo
def initialize(n)
@secret = n
end
def getBinding
return binding()
end
end