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
# pm - Print methods of objects in irb/console sessions. | |
# Goes in ~./irbrc | |
# | |
begin # Utility methods | |
def pm(obj, *options) # Print methods | |
methods = obj.methods | |
methods -= Object.methods unless options.include? :more | |
filter = options.select {|opt| opt.kind_of? Regexp}.first | |
methods = methods.select {|name| name =~ filter} if filter |
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
profile = Selenium::WebDriver::Firefox::Profile.new | |
profile.add_extension("/path/to/firebug.xpi") | |
driver = Selenium::WebDriver.for :firefox, :profile => profile |
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
images = @album.image_assignments | |
changed = Array.new | |
# Get the images that changed order | |
for image in images | |
order = params["order_#{image.image_id}".to_sym] | |
if !order.blank? && order =~ /^\d+$/ && image.position.to_i != order.to_i | |
image.position = order.to_i | |
changed << image |
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
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776 | |
$ cd /usr/src | |
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz | |
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz | |
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz | |
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz | |
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz |
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
# Enable upload_progress module for easy cross browser progress bar support | |
# using only javascript client side | |
upload_progress foobar_uploads 1m; | |
server { | |
# We only need one server block to deal with HTTP and HTTPS | |
# avoids duplication | |
listen 80; | |
listen 443 default ssl; | |
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
Then /^"([^"]*)" from "([^"]*)" within "([^"]*)" should be disabled$/ do |option_name, type_label, selector| | |
with_scope(selector) do | |
x=page.find(:xpath, '//body').all(:xpath, XPath.generate { |x| x.descendant(:select).descendant(:option)[x.attr(:disabled) == 'disabled'] }) | |
x.collect(&:text).should include(option_text) | |
end | |
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
# blog post: http://blog.slashpoundbang.com/post/2613268281/changing-from-tz-database-identifiers-to-rails-friendly | |
{ | |
"Australia/Adelaide" => "Adelaide", | |
"Australia/Broken_Hill" => "Adelaide", | |
"America/Anchorage" => "Alaska", | |
"America/Juneau" => "Alaska", | |
"America/Nome" => "Alaska", | |
"America/Yakutat" => "Alaska", | |
"Pacific/Gambier" => "Alaska", | |
"Asia/Almaty" => "Almaty", |
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
# Locates a table cell based on given row and column content. | |
When /^(.*) in the "([^\"]*)" column of the "([^\"]*)" row$/ do |action, column_title, row_title| | |
col_number = 0 | |
all(:xpath, "//*[(th|td)/descendant-or-self::*[contains(text(), '#{column_title}')]]/th").each do |element| | |
col_number += 1 | |
break if element.has_content?(column_title) | |
end | |
within :xpath, "//*[(th|td)/descendant-or-self::*[contains(text(), '#{row_title}')]]/td[#{col_number}]" do | |
When action | |
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
#!/bin/sh | |
#################################### | |
# Output file for HTML5 video # | |
# Requirements: # | |
# - handbrakecli # | |
# - ffmpeg # | |
# - ffmpeg2theora # | |
# # | |
# usage: # |