Skip to content

Instantly share code, notes, and snippets.

View steveh's full-sized avatar

Steve Hoeksema steveh

View GitHub Profile
#!/usr/bin/env ruby
fn = ARGV[0]
if !fn
puts "Usage: #{$0} file.mustache"
puts
exit
end
git config --global alias.lg "log --graph --since='1 week ago' --pretty=format:'%Cblue%h%Creset %cr %Cgreen%an%Creset %s'"
git config --global alias.lg "log --date=relative --since='1 week ago' --pretty -…
…-graph"
#
# cucumber.yml
#
# Filter which features are run with each profile by the file extension
webrat: --require features/steps/common --require features/support/webrat_env.rb --exclude selenium.feature --format progress
selenium: --require features/steps/common --require features/support/selenium_env.rb --exclude webrat.feature --format progress
#
# features/support/env.rb
# Use on_change :property { # do stuff here }
# to make changes to models after a property has been changed
module OnChange
def on_change(attribute, &block)
after_save do
block.call if send("#{attribute}_changed?")
end
end
end
module ApplicationHelper
def local_time(time)
capture_haml do
haml_tag :span, time.utc.to_s, :class => 'time'
end
end
def local_date(time)
capture_haml do
class CanonicalHost
def initialize(app, host=nil, &block)
@app = app
@host = (block_given? && block.call) || host
end
def call(env)
if url = url(env)
[301, { 'Location' => url }, ['Redirecting...']]
else
class CanonicalHost
def initialize(app, host=nil, &block)
@app = app
@host = (block_given? && block.call) || host
end
def call(env)
if url = url(env)
[301, { 'Location' => url }, ['Redirecting...']]
else
# bootstrapper.rb
# Rails Bootstrapper using rails template
# Based on Extended Bort -http://github.com/laktek/extended-bort/tree/master
# Ideal to use when building a comprehensive web app
# Uses Braid to track remote repos.
# by Lakshan Perera
# Use Braid to track remote git or svn repos.
def braid(command, repo, options={})
other_params = ""
# extracted from marty andrew's presentation on ruby static code analysis
# http://www.slideshare.net/martin_j_andrews/code-quality-analysis
require 'flog'
require 'flay'
require 'roodi'
require 'roodi_task'
require 'metric_fu'
desc "Analyze for code complexity"