Skip to content

Instantly share code, notes, and snippets.

View swieton's full-sized avatar

Michael Swieton swieton

  • Raptive
  • Grand Rapids, Michigan
View GitHub Profile
@swieton
swieton / stylesheets_spec.rb
Created September 11, 2012 22:00
An acceptance test to make sure that all CSS files contain fewer than 4096 rules
feature 'Stylesheets' do
scenario 'are all smaller than the Internet Explorer maximum' do
stylesheets = []
#### This will examine the HTML at the given URL and check the stylesheets
#### linked therein. Add similar calls as needed to visit pages that expose
#### all of your site's CSS
stylesheets += stylesheets_at_url('/')
@swieton
swieton / Querystring
Created July 3, 2012 21:22
Incorrect ordering
cart[items][][id]=5&cart[items][][id]=6&cart[items][][name]=i1&cart[items][][name]=i2
@swieton
swieton / gist:949024
Created April 29, 2011 20:54
How to select your custom profile in your env.rb
Capybara.register_driver :firefox_custom do |app|
require 'selenium/webdriver'
profile_path = "/path/to/prototype_profile"
profile = Selenium::WebDriver::Firefox::Profile.new(profile_path)
driver = Capybara::Driver::Selenium.new(app, :profile => profile)
driver
end
@swieton
swieton / gist:949022
Created April 29, 2011 20:53
Creating Firefox permissions for offline web apps
$ mkdir prototype_profile
$ cd prototype_profile
$ sqlite3 permissions.sqlite3 # This filename is important
sqlite> CREATE TABLE moz_hosts ( id INTEGER PRIMARY KEY,host TEXT,type TEXT,permission INTEGER, expireType INTEGER, expireTime INTEGER);
sqlite> INSERT INTO "moz_hosts" VALUES(1,'localhost','offline-app',1,NULL,NULL);
sqlite> .quit
@swieton
swieton / gist:811191
Created February 4, 2011 14:56
Bash completion for thor
#!/usr/bin/env ruby
# Complete thor tasks script for bash
# Save it somewhere and then add
# complete -C path/to/script -o default thor
# to your ~/.bashrc
# Mike Swieton (swieton@atomicobject.com), based almost entirely on:
# Xavier Shay (http://rhnh.net), combining work from
# Francis Hwang ( http://fhwang.net/ ) - http://fhwang.net/rb/rake-complete.rb
# Nicholas Seckar <nseckar@gmail.com> - http://www.webtypes.com/2006/03/31/rake-completion-script-that-handles-namespaces
@swieton
swieton / vhost_tests.rb
Created November 7, 2010 19:00
Simple validation of redirects and URL rewrites
require 'rubygems'
require 'http-access2' # from gem httpclient
tests = {
# A simple test: GET a URL and expect a successful response
"Home page" => {
:get => "http://www.myapp.com/",
:result => 200
},