visit('/projects')
visit(post_comments_path(post))
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
#from here: http://stackoverflow.com/questions/2385186/check-if-internet-connection-exists-with-ruby | |
require 'open-uri' | |
def internet_connection? | |
begin | |
true if open("http://www.google.com/") | |
rescue | |
false | |
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 'rubygems' | |
require 'ohai' | |
ohai = Ohai::System.new | |
puts ohai.data.to_hash |
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
File.open("out.csv", 'w') { |f| f << Ranking.where(:client_instance_id => 14).map {|r| "#{r.id};\"#{r.supplier.name}\";\"#{r.comment}\" "}.join("\n") } |
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
SecureRandom.uuid |
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 |