Skip to content

Instantly share code, notes, and snippets.

View chrisroos's full-sized avatar

Chris Roos chrisroos

View GitHub Profile
@chrisroos
chrisroos / INSTALLATION
Created February 27, 2010 18:54 — forked from adonaldson/INSTALLATION
HSBC login bookmarklet
These are the steps I took to get the HSBC Bookmarklet (http://dies-el.co.uk/hsbc_bookmarklet) installed.
1. Get a copy of John Gruber's perl script to create bookmarklets (I've copied it and created a gist)
$ git clone git://gist.github.com/316867.git make-bookmarklet
2. Get a copy of Andrew Donaldson's HSBC auto logger inner
$ git clone git://gist.github.com/266260.git hsbc-bookmarklet
@chrisroos
chrisroos / README
Created May 5, 2010 13:51
Mysql data export script
I've moved this to its own repository - http://github.com/chrisroos/mysql-export
@chrisroos
chrisroos / lighthouse-ticket-2340-rails-smtp-error-check.rb
Created May 7, 2010 17:42
Check Rails apps to see whether they suffer from the vulnerability in lighthouse ticket 2340
# Introduction
# ------------
# I wanted a fairly simple/standalone way to check whether our rails apps were affected by the ActionMailer/SMTP error
# in lighthouse ticket 2340 - https://rails.lighthouseapp.com/projects/8994/tickets/2340
# Usage
# -----
# Use the script/runner within your rails app
# $ script/runner lighthouse-ticket-2340-rails-smtp-error-check.rb
# Remember to run it in the relevant environment, e.g. production
@chrisroos
chrisroos / Gemfile
Created May 7, 2010 10:11
Example tests and the equivalent specs
gem 'rspec'
@chrisroos
chrisroos / flash_helper.rb
Created May 14, 2010 14:04
Playing around with moving html from flash messages into helper methods
module FlashHelper
# If message contains symbol like strings we'll inject the value from that helper method
# e.g. 'foo :bar baz' will return 'foo <return value of the bar method> baz'
def render_flash_message(message)
h(message).gsub(/:(flash_\w+)/) { send $1 }
end
def flash_helper_method
'*you called a_helper_method*'
@chrisroos
chrisroos / gist:490352
Created July 26, 2010 09:23
Monkey patching soap4r to force it to use net/http so that we can mock/stub requests with Fakeweb
# HTTPStreamHandler will use httpclient if installed (which it will be if you've installed soap4r as a gem, as httpclient is listed as a dependency) and fall back to net/http if it's not. We want to force net/http so that we can use FakeWeb. This hack is pretty crappy because it relies on the implementation of Soap4r but it works so is good enough for now.
def force_soap4r_to_use_net_http!
require 'soap/netHttpClient'
SOAP::HTTPStreamHandler.send :remove_const, :Client
SOAP::HTTPStreamHandler.const_set(:Client, SOAP::NetHttpClient)
end
@chrisroos
chrisroos / download-calendar.rb
Created October 7, 2010 11:21
Command line util to download a google calendar
#!/usr/bin/env ruby
calendar_url = ARGV.shift
unless calendar_url
puts "Usage: #{File.basename(__FILE__)} <calendar-url> [<download-directory>]"
exit 1
end
download_directory = ARGV.shift
@chrisroos
chrisroos / 000_remove_index_from_mongo_collection.rb
Created February 9, 2011 13:46
Playing around with removing mongo indexes in standard active record migrations.
class RemoveIndexFromMongoCollection < ActiveRecord::Migration
def self.up
remove_mongo_index 'my_collection', 'my_index'
end
def self.down
# Intentionally blank
end
@chrisroos
chrisroos / redcloth-4.2.6-test.md
Created February 11, 2011 15:19
Explanation of what I believe the problem to be with RedCloth 4.2.6 on Mac OS X

Create a temporary directory for us to work in

$ cd ~
$ mkdir tmp-redcloth
$ cd tmp-redcloth

Install RedCloth 4.2.6

Use bundler to install RedCloth 4.2.6 into our temporary directory.