Skip to content

Instantly share code, notes, and snippets.

View paneq's full-sized avatar
🏠
Working from home

Robert Pankowecki paneq

🏠
Working from home
View GitHub Profile
@paneq
paneq / development.rb
Created May 22, 2011 09:00
Faster rendering due to caching
# Add to:
# Rails.root/config/environments/development.rb
# Faster rendering:
# Technique described here:
# http://rails.lighthouseapp.com/projects/8994/tickets/5847-rails-301-configaction_viewcache_template_loading-is-missing
#
# According to Jose this is already in Rails 3.1
raise NotImplementedError if Rails.version.starts_with?("3.1")
@paneq
paneq / .gitignore
Created May 22, 2011 09:14
Reload rails on demand instead of doing it after every request
# Rails.root/.gitignore
config/watchr.notify
# app/controllers/bubbles_controller.rb
class BubblesController < ApplicationController
has_widgets do |root|
root << widget(:facebook)
end
end
@paneq
paneq / application.rb
Created June 26, 2011 18:40
My second solution
require 'guard'
require 'guard/guard'
require 'libnotify'
require 'thread'
module Guard
class Development < Guard
Sempahore = Mutex.new
@paneq
paneq / nake
Created July 1, 2011 08:43
rake with notification
#!/bin/bash
bundle exec rake "$@"
if [ $? = 0 ];
then
notify-send -u critical "Yeah" -i $HOME/bin/notify-images/happy.jpg
else
notify-send -u critical "fffuck!" -i $HOME/bin/notify-images/fffuuu.jpg
fi
@paneq
paneq / test.rb
Created July 1, 2011 11:43
rails
desc 'Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile, test:plugins)'
task :test do
errors = %w(test:units test:functionals test:integration).collect do |task|
begin
Rake::Task[task].invoke
nil
rescue => e
task
end
end.compact
@paneq
paneq / test.rb
Created July 14, 2011 08:21
Which version do you prefere?
require 'test/unit'
class KeyTest < Test::Unit::TestCase
def test_key
object = Object.new
assert_equal(:submit, object_key(object))
def object.persisted?; true end
assert_equal(:update, object_key(object))
@paneq
paneq / cp.rb
Created July 25, 2011 13:33
capybara time out example
people = 2
nap = 35
admins = people.times.map{ TestUser(:driver => :selenium, :login => admin_login, :password => admin_passwd).extend(Adm) }
admins.each{|a| a.sign_in; a.click_link("Business Objects") }
# sleep and click
admins.each{|a| a.sleep(nap); a.click_link("Dictionaries") }
@paneq
paneq / rake.rb
Created August 9, 2011 12:46
Rake is fuckin silly
14:41 <ruby-1.9.2-p180> ~/develop/gavdihrpif (master) > irb
ruby-1.9.2-p180-fastrequire :001 > install
NameError: undefined local variable or method `install' for main:Object
from (irb):1
from /home/rupert/.rvm/rubies/ruby-1.9.2-p180-fastrequire/bin/irb:16:in `<main>'
ruby-1.9.2-p180-fastrequire :002 > require 'rake'
true
ruby-1.9.2-p180-fastrequire :003 > install
ArgumentError: wrong number of arguments (1 for 2)
from /home/rupert/.rvm/rubies/ruby-1.9.2-p180-fastrequire/lib/ruby/1.9.1/fileutils.rb:846:in `install'
@paneq
paneq / rake.rb
Created August 9, 2011 13:00
a little less silly rake
14:59 <ruby-1.9.2-p180> ~/develop/gavdihrpif (master) > irb
ruby-1.9.2-p180-fastrequire :001 > module Rake
ruby-1.9.2-p180-fastrequire :002?> REDUCE_COMPAT = true
ruby-1.9.2-p180-fastrequire :003?> end
true
ruby-1.9.2-p180-fastrequire :004 > gem 'rake', '0.9.3.beta.1'
true
ruby-1.9.2-p180-fastrequire :005 > install
NameError: undefined local variable or method `install' for main:Object
from (irb):5