Marcin Stecki madsheep

View sessions.rb
1 2 3 4 5 6 7 8 9 10
# session controller
# receives callbacks with oauth
class SessionsController < ApplicationController
 
skip_before_filter :login_required
 
def create
login.run!
redirect_to root_path
end
View discipline.rb
1 2 3 4 5 6
# in your spec_helper.rb
RSpec.configure do |config|
config.around(:each) do |example|
timeout(0.2) { example.run }
end
end
View circle.yml
1 2 3 4 5 6 7 8 9 10
machine:
environment:
AWS_ACCESS_KEY_ID:
AWS_SECRET_ACCESS_KEY:
dependencies:
pre:
- pip install cli53 --user
test:
override:
- "rake"
View apply.rb
1 2 3 4 5 6 7 8 9 10
cli53 = '/home/ubuntu/.local/bin/cli53'
zones_on_aws = `#{cli53} list`.lines.select{|e| e =~ /Name/ }.map{|e| e.split(":").last.strip.sub(/\.$/, '') }
 
Dir.glob('zones/*.bind').each do |zone|
zone_name = File.basename(zone, '.bind')
unless zones_on_aws.include?(zone_name)
system("#{cli53} create #{zone_name}")
puts "#{zone_name} created."
end
abort("Can't sync #{zone_name}...") unless system("#{cli53} import #{zone_name} --file #{zone} --replace")
View kitten_mailer.rb
1 2 3 4 5 6 7 8
class KittenMailer < ActionMailer::Base
 
def mail *args
attachments['cat.jpeg'] = open("http://placekitten.com/#{rand(300)+300}/#{rand(300)+300}").read
super
end
end
View application_controller.rb
1 2 3
class ApplicationController < ActionController::Base
extend DecentDecorate
end
View syntax_spec.rb
1 2 3 4 5 6 7 8 9 10
feature "correct syntax in project" do
 
scenario "validate coffeescript files for errors" do
Dir["#{Rails.root}/**/*.coffee"].each do |file|
%x[coffee --lint -p #{file} ]
$?.success?.should be_true
end
end
scenario "validate haml files" do
View package.json
1 2 3 4 5 6 7
{
"name": "some_project",
"version": "0.0.1",
"dependencies": {
"coffee-script": "1.1.1"
}
}
View hash.rb
1 2 3 4 5 6 7 8 9 10
class Hash
define_method '[]_with_try_on', do |*args|
if args.size == 1 and (args.is_a?(Symbol) or args.is_a?(String))
self.send(:'[]_with_try_on', args.first)
else
args.inject(self.dup){|memo, e| memo.dup.delete(e) if memo.is_a?(Hash) }
end
end
View hash.rb
1 2 3 4 5 6 7 8 9 10
class Hash
def keep_on_trying(*args)
args.inject(self.dup){|memo, e| memo.dup.delete(e) if memo.is_a?(Hash) }
end
end
 
ruby-1.9.2-head :109 > a
=> {:test=>{:this=>"aaa"}}
ruby-1.9.2-head :110 > a.keep_on_trying(:test)
=> {:this=>"aaa"}
Something went wrong with that request. Please try again.