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
group :development do | |
gem 'guard-rspec', '~> 3.0.2' | |
gem 'guard-spork', '~> 1.5.1' | |
gem 'spork-rails', github: 'sporkrb/spork-rails' | |
gem 'rb-fsevent', '~> 0.9.3' | |
end | |
group :development, :test do | |
gem "rspec-rails", "~> 2.14.0" | |
gem "factory_girl_rails", "~> 4.2.1" |
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
data = Service.available_for(shop).map do |service| | |
[service.name_de, service.id, service.category, service.service_type, (service.global ? 'Ja': 'Nein')] | |
end | |
require 'spreadsheet' | |
def to_excel(data,filename = 'out.xls') | |
Spreadsheet.client_encoding = 'UTF-8' | |
book = Spreadsheet::Workbook.new | |
sheet = book.create_worksheet :name => filename |
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 NotesController < ApplicationController | |
def index | |
load_notes | |
end | |
def show | |
load_note | |
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 parse_rockantenne | |
url = 'http://www.webradio.de/webradio/titleinfos/rockantenne_rahome2.php' | |
doc= open(url).read | |
matched = doc.match(/<b>Aktueller Titel:<\/b><br>(.*)<br>(.*?)<\/div>/) | |
puts "#{matched[1]}-#{matched[2]}" | |
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 system!(*args) | |
system(*args) || abort("\n== Command #{args} failed ==") | |
end | |
# for bin/setup | |
# system! 'gem install bundler --conservative' | |
# https://github.com/rails/rails/pull/20926/files |
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 |
OlderNewer