Skip to content

Instantly share code, notes, and snippets.

View robwilliams's full-sized avatar

Rob Williams robwilliams

View GitHub Profile
class Test::Unit::TestCase
def self.should_require_login(*args)
args = Hash[*args]
login_url = args.delete :login_url
args.each do |action, verb|
should "Require login for '#{action}' action" do
send(verb, action)
assert_redirected_to(login_url)
end
end
// DO NOT use this code if you are using more than one psp !!
$(function() {
$checkout_sequence = $('input[@name="SEQUENCE"]');
// only execute the following code if we are on a checkout page
if($checkout_sequence.length > 0){
/*
// revenue tracking
$(function(){
if($('.receipt_order_id')) {
var order_id = $('.receipt_order_id').text();
var total = $('.receipt_total').text().replace(/[^0-9]/, '');
var tax = $('.receipt_tax').text().replace(/[^0-9]/, '');
var shipping = $('.receipt_shipping').text().replace(/[^0-9]/, '');
@robwilliams
robwilliams / serializable_hash_example.rb
Created April 23, 2011 21:49
using to_xml and to_json hiding certain attributes
# require 'rubygems'
require 'active_model'
class LegacyTable
include ActiveModel::Serialization
include ActiveModel::Serializers::JSON
include ActiveModel::Serializers::Xml
attr_accessor :nice_attribute,
git log --pretty=format:"%s" | pbcopy
@robwilliams
robwilliams / gist:991183
Created May 25, 2011 15:31
Unix version of gist
git log --pretty=format:"%s" > messages.txt
@robwilliams
robwilliams / LICENSE.txt
Created May 27, 2011 17:05 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@robwilliams
robwilliams / rails_app.mdown
Created June 9, 2011 08:19
Rails App Boot Time with 1.9.(3?)
@robwilliams
robwilliams / gist:1086509
Created July 16, 2011 16:24
How to install Wordpress on OS X

How to install Wordpress on OS X

There are simpler installers (and most probably guides) that will give you wordpress functionality on os x but if you want to get your hands dirty and do it yourself then read on.

Note: Whenever there is a line that starts with a $ you have to type the command into your Terminal (Found in your Applications folder) omitting the $.

Setup

A standard OS X install contains versions of Apache and PHP but not MySQL.

Apache and PHP

@robwilliams
robwilliams / add_user.sh
Created July 18, 2011 11:26
Hosting Wordpress Sites Using NGINX and FastCGI
# add a user
adduser {USER}
# add user group
adduser {USER} www-data
# You will be prompted to enter a password
# Ssh in as that user to ensure that in the next steps you are setting permissions correctly
ssh {USER}@yourhost.com