Skip to content

Instantly share code, notes, and snippets.

@hisea
hisea / nginx
Created January 1, 2012 23:37
ubuntu passenger nginx init.d script
sudo cp nginx /etc/init.d/
sudo update-rc.d nginx defaults
sudo chmod +x /etc/init.d/nginx
/etc/init.d/nginx start
@jarib
jarib / file.rb
Created June 14, 2011 13:02
selenium-webdriver bug report template
require 'rubygems'
require 'selenium-webdriver'
path = File.expand_path("test.html")
File.open(path, "w") { |io| io << DATA.read }
browser = Selenium::WebDriver.for :firefox # replace :firefox with the browser you're having trouble with
begin
browser.get "file://#{path}"
@jarib
jarib / tryselenium.rb
Created April 5, 2011 20:44
Nested LoadableComponents in Ruby
require 'selenium-webdriver'
#
# Read more about LoadableComponent here:
#
# http://code.google.com/p/selenium/wiki/LoadableComponent
#
class LoadableComponent
attr_reader :driver
@theconektd
theconektd / gist:12991
Created September 25, 2008 23:55
Generates a per_page select for will_paginate
def per_page_select(collection, name=nil, value=nil, options={})
unless collection.empty?
per_page = collection.first.class.per_page
name = name || 'per_page'
value = value || params[:per_page] || per_page.to_s
before = options[:before_default] || ["#{per_page/2}"]
after = options[:after_default] || ["#{per_page*2}"]
choices = options_for_select(before + ["#{per_page}"] + after, value)
select_tag name, choices, options
end