Skip to content

Instantly share code, notes, and snippets.

View Sutto's full-sized avatar

Darcy Laycock Sutto

View GitHub Profile
# Darcy's public key
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAlhcBKPcWKMOVHreqrlSCO5JIKGsmOL30+y/OmqlsbNOHrs0/JpiLpVGowPgAfP02pIjp/GlMFjtfvkgsidXTbkqywZmh45Axh0D5ZmO305N42xTekZ3VJR2x6fn6uZySXrd7GOZIDuQcTsEqsl4wrae1DT66a769RNwYbIRKarBTxlA8C2Zb8I9qvizLg6OV45/Q7vH0TMtQ+3Rfs6GlGJzrbeqH4S8mNzPH9Z9cz2vB+6y0NFBcROT/5xIjFVr0yaKjJiyGOOh/IQZ7aO2pwl/Ozr3vweJ6wTnDCgJ5+5AGLCmzi75JR0f4bEcR+Gt5f4hnOFrOZpM+ppG4Sx4WvQ==
if defined?(ActionDispatch); begin; ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML); rescue; end; end
if defined?(ActionController::Base) && ActionController::Base.respond_to?(:param_parsers); begin; ActionController::Base.param_parsers.delete(Mime::XML); rescue; end; end
if defined?(ActionDispatch); begin; ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::JSON); rescue; end; end
if defined?(ActionController::Base) && ActionController::Base.respond_to?(:param_parsers); begin; ActionController::Base.param_parsers.delete(Mime::JSON); rescue; end; end
@Sutto
Sutto / version_recognizers.rb
Created November 26, 2012 13:20
Initial RocketPants 2.0 Version Recognition Thoughts
class VersionRecognizer
attr_reader :app, :matcher
def initialize(app, matcher)
@app = app
@matcher = compile_matcher(matcher)
end
def extract_version(env)
class NetflixApi
# http://api.netflix.com/catalog/titles/series/70105286
class Response
def initialize(item, client)
@item = item
@client = client
end
The Umpire needs to ensure the "fair play" of the "game".
He asks "is this team / Group (Progressive Voice) misleading voters"?
Voters are advised that the group / party running as "Progressive Voice" in the Guild Elections has had 3 name changes:-
1. It was originally named by the candidates as "Student Action"
2. The candidates then changed the name to "Student Labor"
3. The "Umpire" (RO) then rejected use of the name "Student Labor".
4. The Group then changed the name to "Progressive Voice".
@Sutto
Sutto / irish-stew-recipe.md
Created June 13, 2012 00:46
A super simple recipe for a delicious Irish Stew from my Grandmother

Irish Stew Recipe

A very basic, but utterly delicious Irish Stew recipe my grandmother wrote up for me. Perfect on cold winters days, especially when served with bits of fresh crusty bread.

Note that this is pretty much types verbatim from the hand written copy she gave me, so if there are any issues let me know and I'll clarify them.

Ingredients

# You can change the number per env.
set(:resque_workers) { 2 }
# Make sure you have a server with the role worker.
namespace :resque do
desc "Stops resque workers"
task :stop, :roles => :worker do
resque :stop
end
in response to http://twitter.com/#!/sj26/status/179435393622605825 - Namely, did I consider using Headers on the response.
Now, I didn't consider them in depth but I did consider them a little. Most of the reasons to use them were pragmatic in nature
(following a possibly flawed thought pattern):
- I felt that those details about the data are part of the data itself - versus extra metadata about the resource in general.
- Collections still ideally to be under an object (versus an array) for security reasons - http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx
- In doing so, it makes sense that if you're going to put the data inside a nested object, ideally you should place the data there as well for consistency.
- It makes the style of clients slightly easier because JSON conveys type information not necessarily present in headers.
- Unicorns.
#!/usr/bin/env ruby
require 'rubygems'
require 'httparty'
require 'awesome_print'
ap HTTParty.get(ARGV[0]).parsed_response
@Sutto
Sutto / backup-github.rb
Created September 7, 2011 05:25
Automatically backs up a github accounts repositories
require 'fileutils'
require 'octokit'
require 'ap'
ACCOUNT_NAME = "your-user-name"
ACCOUNT_TOKEN = "your-api-token"
ITEMS_UNDER = "target-user-or-organisation"
REPO_ROOT = File.expand_path('../repositories', __FILE__)