This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/ruby-enterprise/bin/ruby | |
FILES = '/home/rankers/production.rankers.co.nz/shared/system' | |
DATABASE = 'rankers_production' | |
# End configuration | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/ruby-enterprise/bin/ruby | |
require "date" | |
require "rubygems" | |
require "activesupport" | |
require "open4" | |
log_bucket = "rankers-logs" | |
(2007..(Time.now.year)).each do |year| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
OlderNewer