Skip to content

Instantly share code, notes, and snippets.

View vonconrad's full-sized avatar

Sebastian von Conrad vonconrad

View GitHub Profile
@drnic
drnic / Guardfile
Created April 5, 2012 06:45
An example Guardfile with the works for a Rails app
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
" Highlight Ruby 1.8.x hash rocket
" This will prevent you to ever write it again
highlight ObsoleteHashRocket ctermbg=red guibg=red
au ColorScheme * highlight ObsoleteHashRocket guibg=red
au BufEnter * match ObsoleteHashRocket /=>/
au InsertEnter * match ObsoleteHashRocket /=>/
au InsertLeave * match ObsoleteHashRocket /=>/
@jasoncodes
jasoncodes / _form.html.haml
Created October 18, 2011 05:42
Using ActiveRecord optimistic locking with Inherited Resources
/ ...
- f.inputs do
= f.hidden_field :lock_version
/ ...
@jasoncodes
jasoncodes / gist:1223731
Created September 17, 2011 07:45
Installing Ruby 1.9.3 with rbenv on OS X
# The latest version of this script is now available at
# https://github.com/jasoncodes/dotfiles/blob/master/aliases/rbenv.sh
VERSION=1.9.3-p286
brew update
brew install rbenv ruby-build rbenv-vars readline ctags
if [ -n "${ZSH_VERSION:-}" ]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
else
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile

See all your work in a given repo over the last couple of weeks, collated by day. Makes filling out timesheets much easier.

To run the script, pass it a git repo as the first argument.

ruby timesheeting_like_a_boss.rb ~/projects/babushka

Here's what I see in babushka:

# 2011-05-25 (Wed)

c1dea1b: Return strings from #which and #cmd_dir.