Skip to content

Instantly share code, notes, and snippets.

View pete-otaqui's full-sized avatar

Pete Otaqui pete-otaqui

View GitHub Profile
@pete-otaqui
pete-otaqui / Sinatra_ResponseFetcher.rb
Created February 5, 2010 12:42
Sinatra "Response Fetcher" which loads text files of HTTP responses and reconstructs them
# About:
# Fetches plain text files of complete http responses
# and reconstructs them into the header and body parts
#
# Usage:
# require 'sinatra'
# require 'sinatra/responsefetcher'
# get "/" do
# fetchresponse('responses/home_200.txt')
# end
@pete-otaqui
pete-otaqui / responsive_rakefile.rb
Created February 5, 2010 15:55
Rakefile for capturing HTTP responses and serializing as YAML
# should be called 'Rakefile'
#
# Usage:
# rake response:capture url=http://google.com/ filename=google_200
# rake response:capture url=http://google.com/404 filename=google_404
require 'rubygems'
require 'net/http'
require 'uri'
@pete-otaqui
pete-otaqui / Rakefile
Created February 8, 2010 11:14
Sinatra app for loading YAML serialized HTTP responses (404s 500s 302s etc)
# Usage:
# rake response:capture url=http://google.com/ filename=google_200
# rake response:capture url=http://google.com/404 filename=google_404
require 'rubygems'
require 'net/http'
require 'uri'
namespace :response do
@pete-otaqui
pete-otaqui / StandardSpider.rb
Created February 16, 2010 09:09
Prototype spider which uses 'bbc_standards' to test a whole website
# Prototype spider which uses 'bbc_standards' to test a whole website
require 'rubygems'
require 'anemone'
require 'bbc_standards'
require 'term/ansicolor'
class String
include Term::ANSIColor
end
@pete-otaqui
pete-otaqui / basic_carousel.html
Created June 10, 2010 15:34
Simple glow carousel implementation.
// strip all slashes (ignored by search anyway)
var reVal = this.val().replace(/[\\\/]/,'');
// strip all non alpha-numeric (or space) chars too
reVal = reVal.replace(/[^a-zA-Z0-9 ]/,'');
// make a regexp to match before, 'val()' and after
var regex = new RegExp('(.*?)('+reVal+')(.*?)', 'i');
// inject styling
name = name.replace(regex, '$1<span class="blq-search-underline">$2</span>$3');
@pete-otaqui
pete-otaqui / dependency_injection.php
Created September 3, 2010 10:02
vaguely realish code to demonstrate the dependency injection pattern
<?php
// this is the dependency injetion style stuff ...
class FlickrModel {
// first off, have some internal store for the object:
protected $_httpClient = null;
// have a method to get the object:
@pete-otaqui
pete-otaqui / app.js
Created September 9, 2010 04:32
Example node event emitter setup from neveraw.us
var pb = new PhoneBook('asdf.txt');
pb.on('error', function(error) {
console.log(error);
});
pb.on('data', function(data) {
console.log(data);
});
module Cucumber
module Formatter
class Html
def initialize(step_mother, path_or_io, options)
end
def after_features
puts "original after_features"
end
end
end
@pete-otaqui
pete-otaqui / Gemfile
Created August 11, 2011 14:32
Capybara, Cucumber, Webdriver, Mechanize and SauceLabs ... whew!
source "http://rubygems.org"
gem "cucumber"
gem "capybara"
gem "capybara-webkit", :platforms => [:ruby], :require => false, :git => "git://github.com/thoughtbot/capybara-webkit.git"
gem "capybara-mechanize", :git => "git://github.com/jeroenvandijk/capybara-mechanize.git"
gem "rspec"
gem "rake"