Skip to content

Instantly share code, notes, and snippets.

View listrophy's full-sized avatar

Brad Grzesiak listrophy

View GitHub Profile
parse_git_branch(){
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
parse_home_dir(){
pwd -P | sed -e "s/^$(echo $HOME | sed -e 's/\//\\\//g')/~/" -e 's/~\/Development/~\/dev/'
}
PS1="\$(parse_home_dir)\$(parse_git_branch) $ "
@listrophy
listrophy / gist:44189
Created January 7, 2009 05:39
The Birthday Problem!
lower_bound = (ARGV.shift || 2).to_i
upper_bound = (ARGV.shift || 35).to_i
iterations = (ARGV.shift || 20_000).to_i
(lower_bound..upper_bound).each do |person_count|
matches = 0
iterations.times do
matches += 1 if (1..person_count).map{|p| rand(365)}.uniq!
end
puts "Person count: %3d Success: %3.1f" %
' MACRO NAME:
' AddQuantity
' AUTHOR:
' Bradley Grzesiak
' FUNCTION:
' Increments the quantity of one or many dimensions in a drawing
' INSTALL:
' Create a "New Macro Button" via Tools->Customize->Commands->Macro in a toolbar.
' It is highly recommended that you assign a keystroke to this macro. I use "q"
' COMPATIBILITY:
@listrophy
listrophy / index.html.haml_spec.rb
Created March 21, 2009 18:23
users.size == 0... i think it should be 2
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe "/users/index.html.haml" do
include UsersHelper
fixtures :users
before(:each) do
assigns[:users] = users
print "\nuser size: #{users.size}\n"
end
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe StoriesController do
def mock_story(stubs={})
@mock_story ||= mock_model(Story, stubs)
end
def mock_errors(stubs={})
unless @mock_errors
@mock_errors = mock(:errors, stubs)
@mock_errors.should_receive(:on).with(:text).and_return("error on :text")
Shoes.setup do
gem 'activeresource'
end
require 'activeresource'
class Person < ActiveResource::Base
self.site = 'http://0.0.0.0:3000'
end
module Submethods
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def submethods type = :public
if self.class.name == "Object"
return nil
end
STRIPPED_PS1="$(echo "$PS1" | sed -e 's/\$ $//')"
function prompt_with_success {
previous_return_value=$?
RED="\[\033[0;31m\]"
GREEN="\[\033[0;32m\]"
COLOR_NONE="\[\e[0m\]"
if [ $previous_return_value -eq 0 ]
source :rubygems
gem 'activerecord', '2.3.5'
gem 'sqlite3-ruby'
source :rubygems
gem 'rails'
# Or find something else that returns true
# locally, but false on heroku
if RbConfig::CONFIG['host_os'] =~ /darwin/
group :test do
# heroku fails hard on this gem
gem 'specjour'