Skip to content

Instantly share code, notes, and snippets.

View niklas's full-sized avatar

Niklas H niklas

View GitHub Profile
activemodel (3.0.3) lib/active_model/attribute_methods.rb:364:in `method_missing'
activerecord (3.0.3) lib/active_record/attribute_methods.rb:46:in `method_missing'
devise (1.1.2) lib/devise/models/database_authenticatable.rb:40:in `password='
activerecord (3.0.3) lib/active_record/base.rb:1559:in `send'
activerecord (3.0.3) lib/active_record/base.rb:1559:in `attributes='
activerecord (3.0.3) lib/active_record/base.rb:1555:in `each'
activerecord (3.0.3) lib/active_record/base.rb:1555:in `attributes='
activerecord (3.0.3) lib/active_record/base.rb:1406:in `initialize'
adva-core (0.0.9) lib/patches/rails/sti_associations.rb:13:in `new'
adva-core (0.0.9) lib/patches/rails/sti_associations.rb:13:in `build_association'
@niklas
niklas / trace.txt
Created April 26, 2011 14:52
undefined local variable or method `o' for Gherkin::Rubify:Module
undefined local variable or method `o' for Gherkin::Rubify:Module
/var/lib/hudson/.rvm/gems/ree-1.8.7-2010.02/gems/gherkin-2.3.6/lib/gherkin/rubify.rb:19
/var/lib/hudson/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
/var/lib/hudson/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
/var/lib/hudson/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `load_dependency'
/var/lib/hudson/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in `new_constants_in'
/var/lib/hudson/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `load_dependency'
/var/lib/hudson/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
/var/lib/hudson/.rvm/gems/ree-1.8.7-2010.02/gems/cucumber-0.10.2/lib/cucumber/ast/table.rb:1
/var/lib/hudson/.rvm/gems/
@niklas
niklas / class-eval-yield.rb
Created May 25, 2011 15:16
yielding to a block within class_eval does not set self in the block?
class A
def self.my_eval
B.class_eval do
puts "self in A.my_eval: #{self}"
yield
end
end
end
class B
current_scheduler = scheduler(:availabilities)
def current_scheduler.handle_exception(job, exception)
Airbrake.do_the_right_thing(exception, other_params)
puts "job #{job.job_id} caught exception '#{exception}' - the Airbrake has been triggered"
end
class TaskManager
# [..]
# do you think this may work? (hoptoad_options scope)
@niklas
niklas / define_eigenclass_method_with_closure.rb
Created September 8, 2011 12:15
define Eigenclass method with closure
class Object
def eigenclass
class << self; self; end
end
def eigenclass_eval(&block)
eigenclass.instance_eval &block
end
end
@niklas
niklas / _flash.html.haml
Created November 2, 2011 10:35
render 'flash', :flash => flash # from layout, file put in app/views/application
- unless flash.blank?
#flash
- flash.each do |name, msg|
= content_tag :div, msg, :class => "flash #{name}
@niklas
niklas / gist:1344547
Created November 7, 2011 09:35 — forked from rsanheim/gist:1054078
Devise + Spork + Rails 3.1 RC4 hacks to keep User model from loading prefork
Spork.prefork do
require "rails/application"
# Prevent Devise from loading the User model super early with it's route hacks for Rails 3.1 rc4
# see also: https://github.com/sporkrb/spork/wiki/Spork.trap_method-Jujutsu
Spork.trap_method(Rails::Application, :reload_routes!)
Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
# rest of your prefork here...
end
@niklas
niklas / draper_rjs.rb
Created February 22, 2012 22:54
# make the RJS helper proxy `page` available in Draper's Decorator
# in your .js.rjs templates, you can call #decorate on the magic page object
# and then use RJS-powered methods from within your Decorator
#
# page.decorate User.first do |user|
# user.blink
# end
#
# class UserDecorator < ApplicationDecorator
# def blink
# page[ "user_#{model.id}" ].animate 'blink'
@niklas
niklas / plot_tekway.rb
Created March 11, 2012 14:33
434 Mhz grau
PPo00011110101010001111111110000001o
PPo00011110101010001111111100000011o
PPo00011110101010001111111110000011o
PPo00011110101010001111111110000000o
PPo00011110101010001111111110000000o
PPo00011110101010001111111100000000o
PPo00011110101010001111111110000010o
{"1000"=>"0", "1110"=>"1", "1111"=>"P", "0000"=>"o"}
@niklas
niklas / pause_steps.rb
Created May 4, 2012 10:35
Pause a cucumber scenario and ask for pry
When /^I pause|try pry|I pry|I debug$/ do
STDERR.puts "Pausing..."
if system(%Q~which zenity~)
if system(%Q~zenity --question --text="Paused. Want to pry?"~)
binding.pry
end
else
# no zenity installed, pry without asking
binding.pry
end