Skip to content

Instantly share code, notes, and snippets.

View zachhale's full-sized avatar
🚴‍♂️
Riding my bike

Zach Hale zachhale

🚴‍♂️
Riding my bike
View GitHub Profile
# cell widths
cell_widths = [160,60]
# example data for rows_to_pdf
rows_to_pdf = [
['Row Name','200',300','400'],
['Row Name','200',300','400'],
['Row Name','200',300','400'],
['Row Name','200',300','400'],
['Row Name','200',300','400']
@zachhale
zachhale / .bashrc
Created January 15, 2009 01:49 — forked from henrik/.bashrc
Colored, w/out username
# 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)]/"
@zachhale
zachhale / gist:54861
Created January 30, 2009 00:55 — forked from peterc/gist:33337
# SUPER DARING APP TEMPLATE 1.0
# By Peter Cooper
# Link to local copy of edge rails
inside('vendor') { run 'ln -s ~/dev/rails/rails rails' }
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
>> o = Object.new
=> #<Object:0x815c45c>
>> o.class
=> Object
>> Class.superclass.superclass
=> Object
>> Object.class
=> Class
# we have
admin.resources :meals do |meal|
meal.resources :preparation_steps
meal.resources :preparation_tools, :collection => {:associate => :post},
:member => {:disassociate => :delete}
end
# i've added a "sort" method to the preparation_steps controller, and need
# to access /admin/meals/:meal_id/preparation_steps/:preparation_step_id/sort
#!/usr/bin/env ruby
require 'rubygems'
require 'daemon-spawn'
RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
class DelayedJobWorker < DaemonSpawn::Base
def start(args)
ENV['RAILS_ENV'] ||= args.first || 'development'
Dir.chdir RAILS_ROOT
alias ss="/rails/.shortcuts/ss.rb"
# requires rails environment to be loaded
include ActionView::Helpers::UrlHelper
include ActionController::UrlWriter
include ActionView::Helpers::TagHelper
default_url_options[:host] = 'www.website.com'
task :generate_static_pages => :environment do
ActionController::Dispatcher.define_dispatcher_callbacks(true) # same as config.cache_classes = true
class PreGenerateController < ApplicationController
layout 'secure'
def show
render :action => params[:id]
end
end
class Hash
def requires!(*args)
args.flatten.each do |arg|
raise ArgumentError, "#{arg} is required" unless has_key?(arg)
end
end
end