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
def transform_hash(original, options={}, &block) | |
original.inject({}){|result, (key,value)| | |
value = if (options[:deep] && Hash === value) | |
transform_hash(value, options, &block) | |
else | |
if Array === value | |
value.map{|v| transform_hash(v, options, &block)} | |
else | |
value | |
end |
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
require 'yaml' | |
desc 'Generates database.yml, optional arguments: [adapter, user, password]' | |
task :dbconfig => 'database.yml' | |
file 'database.yml', [:adapter, :username, :password] do |t, args| | |
Dir.chdir('config') | |
args.with_defaults(:project_path => Dir.pwd) | |
DBConfigGenerator.new(t, args).generate | |
end |
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
require 'RMagick' | |
$scale_size = 256.0 | |
$img_fn1 = ARGV[0] | |
$img_fn2 = ARGV[1] | |
$scale_size = ARGV[2].to_f if ARGV[2] | |
def calculate_threshold(img_fn) | |
dir_name = File.dirname(img_fn) |