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
Given /^I visit subdomain (.+)$/ do |sub| | |
host! "#{sub}.#{TEST_DOMAIN}" #TEST_DOMAIN is defined in test.rb. In my case TEST_DOMAIN = 'example.com' | |
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
# Put this file in your config/initializers directory and behold a tastier auto_link! | |
module ActionView | |
module Helpers | |
module TextHelper | |
# Use auto_link and friends from Rails 3. They do the right thing (tm). | |
remove_const(:AUTO_LINK_RE) if defined?(AUTO_LINK_RE) | |
AUTO_LINK_RE = %r{ | |
( https?:// | www\. ) |
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
class ApplicationController < ActionController::Base | |
include Intercession | |
before_filter :load_skin | |
before_filter :require_user | |
before_filter :require_matching_skin | |
before_filter :require_admin | |
def load_skin | |
session.skin = Skin.for_request(request) |
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
require 'nokogiri' | |
ugly = Nokogiri::HTML ARGF | |
tidy = Nokogiri::XSLT File.open('tidy.xsl') | |
nice = tidy.transform(ugly).to_html | |
puts nice |
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
# Rackup file for serving up a static site from a "public" directory | |
# | |
# Useful for chucking a static site on Heroku | |
class IndexRewriter | |
def initialize(app) @app = app end | |
def call(env) | |
env["PATH_INFO"].gsub! /\/$/, '/index.html' | |
@app.call(env) | |
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
// Based on http://snipt.net/boriscy/datetime-jquery-formtastic/ | |
$.tools.dateinput.localize("ja", { | |
months: '1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月', | |
shortMonths: '1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月', | |
days: '日曜日,月曜日,火曜日,水曜日,木曜日,金曜日,土曜日', | |
shortDays: '日,月,火,水,木,金,土' | |
}); | |
$.tools.dateinput.conf.format = 'yyyy-mm-dd'; |
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
#!/usr/bin/env ruby | |
# | |
# Quick hack to help you find and deal with old watched repos, forks and owned repos. | |
# | |
# It will ask you to confirm once if you want to unwatch a repo. | |
# | |
# You can't unwatch your own repos, so they will need to be deleted. | |
# THIS SCRIPT WILL ASK YOU FOR CONFIRMATION TWICE BEFORE IT DELETES A REPO. | |
# | |
require 'rubygems' |
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
Object.class_eval do | |
def self.method_added(name) | |
raise "You forgot to spell initialize the American way, again." if :initialise == name | |
end | |
end | |
class A | |
def initialise |
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
<<-LRUG Hola El Rug, | |
Here's a little teaser for you... | |
I have two sets of photos; we'll call them urban and nature. Both sets contain about 6-9 photos, but not necessarily the same number. | |
I also have about 15-20 pages on a site, spread more or less evenly across three sections. Each page has a title unique to its section (and, if it helps, we can assume unique across all the pages). | |
On each page I want to display one photo from each set. |
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
require 'rubygems' | |
require 'typhoeus' | |
hydra = Typhoeus::Hydra.new | |
# Create all your requests | |
request = Typhoeus::Request.new("http://your_image_url") | |
request.on_complete do |response| | |
# Check if the returned data really is an image | |
OlderNewer