Skip to content

Instantly share code, notes, and snippets.

View steveh's full-sized avatar

Steve Hoeksema steveh

View GitHub Profile
# 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"
# 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"
<?php
$start_time = microtime (true);
function timer () {
global $start_time;
return sprintf ('%05.1f ', microtime(true)-$start_time);
}
$parent_dir = realpath (dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
#!/opt/ruby-enterprise/bin/ruby
FILES = '/home/rankers/production.rankers.co.nz/shared/system'
DATABASE = 'rankers_production'
# End configuration
@steveh
steveh / rankers-rotatelogs.rb
Created October 7, 2009 00:55
Rotate Rankers logs
#!/opt/ruby-enterprise/bin/ruby
require "date"
require "rubygems"
require "activesupport"
require "open4"
log_bucket = "rankers-logs"
(2007..(Time.now.year)).each do |year|
# 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 = ""
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
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
# 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