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.constants.select do |constant_name| | |
constant = eval constant_name | |
if not constant.nil? | |
puts "#{constant_name} : #{constant}" | |
end | |
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
def self.timeout_guard(sec) | |
main = Thread.current | |
timer = Thread.new { sleep sec; main.raise "Timeout after #{sec} seconds" } | |
begin | |
yield | |
ensure | |
timer.kill | |
end | |
end | |
# use timeout_guard(10) {do_somthing } |
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 logger | |
@logger ||= Logger.new(STDOUT, Logger::WARN) | |
end | |
#siehe http://blog.hasmanythrough.com/2009/12/15/no-returns | |
def logger | |
RAILS_DEFAULT_LOGGER | |
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
#template | |
#Constants | |
app_name = `pwd`.split('/').last.strip | |
rails_version = '2.3.2' | |
jquery_version = '1.3.2' | |
##### remove files ################# | |
run "rm README" | |
run "rm -rf test" |
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 self.in_time_log(name="",logger=nil) | |
(logger || RAILS_DEFAULT_LOGGER).info("#{name} start") | |
start_time = Time.now | |
yield | |
duration = Time.now-start_time | |
(logger || RAILS_DEFAULT_LOGGER).info("#{name} duration: #{ ([duration/3600, duration/60 % 60, duration % 60].map{|t| "%02d" % t.to_i.to_s}).join(':')}") | |
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 'digest/md5' | |
Digest::MD5.hexdigest('http://foo-bar.com/yay/?foo=bar&a=22') | |
# "43facc5eb5ce09fd41a6b55dba3fe2fe" | |
#http://stackoverflow.com/questions/67890/whats-the-best-way-to-hash-a-url-in-ruby |
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 "rubygems" | |
require "progressbar" | |
pbar = ProgressBar.new("Update Offer",big_array.size) | |
big_array.each do | e | | |
do_something | |
pbar.inc | |
end | |
###################### oder mit progress-monitor http://github.com/mikisvaz/progress-monitor |
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
sudo gem update --system | |
sudo gem install gemcutter --source http://gemcutter.org | |
sudo gem tumble |
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
RAILS_DEFAULT_LOGGER.error {my_object.errors.full_messages.to_s} |
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
Rails.env.staging? | |
Rails.env => "development" |
OlderNewer