Skip to content

Instantly share code, notes, and snippets.

@nbibler
nbibler / environment.rb
Created June 4, 2010 03:19
Simplepay submit tag customization example
# /config/environment.rb
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
config.gem 'simplepay', :lib => 'simplepay/rails'
config.time_zone = 'UTC'
end
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by mdbtools configure 0.6pre1, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ ./configure --prefix=/usr/local/Cellar/mdbtools/HEAD --mandir=/usr/local/Cellar/mdbtools/HEAD/share/man
## --------- ##
## Platform. ##
module ClassMethods
def my_context(description, options = {}, &block)
context(description) do
before(:each) do
puts "omg!"
end
after(:each) do
puts "win!"
end
@nbibler
nbibler / amazon_cloudfront_invalidation.rb
Created September 7, 2010 14:50
Ruby script interacting with the Amazon AWS CloudFront invalidation
require 'rubygems'
require 'hmac-sha1'
require 'net/https'
require 'base64'
AWS_KEY = '...'
AWS_SECRET = '...'
CLOUDFRONT_DISTRIBUTION_ID = '...'
date = Time.now.utc
@nbibler
nbibler / net_http_exceptions.rb
Created October 25, 2010 14:14
A collection of exceptions raised by Net::HTTP(S)
HTTP_ERRORS = [
Timeout::Error,
Errno::EADDRNOTAVAIL,
Errno::ETIMEDOUT,
Errno::EINVAL,
Errno::ECONNRESET,
Errno::ECONNREFUSED,
Errno::EHOSTUNREACH,
EOFError,
Net::HTTPBadResponse,
@nbibler
nbibler / en.yml
Created December 20, 2010 12:58
An ActiveModel::EachValidator to check local attribute value against "project" value.
en:
errors:
messages:
project_effort_exceeded: 'cannot be larger than project effort'
@nbibler
nbibler / gist:883455
Created March 23, 2011 16:50
Ruby script interacting with the Amazon AWS CloudFront Custom Origin API
#!/usr/bin/env ruby -w
require 'rubygems'
require 'hmac-sha1'
require 'net/https'
require 'base64'
AWS_KEY = '...'
AWS_SECRET = '...'
@nbibler
nbibler / backtrace
Created April 19, 2011 02:42
RestClient::ServiceUnavailable: 503 Service Unavailable
.bundle/gems/ruby/1.9.1/gems/rest-client-1.6.1/lib/restclient/abstract_response.rb:48:in `return!'
.bundle/gems/ruby/1.9.1/gems/rest-client-1.6.1/lib/restclient/request.rb:220:in `process_result'
.bundle/gems/ruby/1.9.1/gems/rest-client-1.6.1/lib/restclient/request.rb:169:in `block in transmit'
/usr/ruby1.9.2/lib/ruby/1.9.1/net/http.rb:627:in `start'
.bundle/gems/ruby/1.9.1/gems/rest-client-1.6.1/lib/restclient/request.rb:166:in `transmit'
.bundle/gems/ruby/1.9.1/gems/rest-client-1.6.1/lib/restclient/request.rb:60:in `execute'
.bundle/gems/ruby/1.9.1/gems/rest-client-1.6.1/lib/restclient/request.rb:31:in `execute'
.bundle/gems/ruby/1.9.1/gems/rest-client-1.6.1/lib/restclient/resource.rb:51:in `get'
.bundle/gems/ruby/1.9.1/gems/heroku-1.20.1/lib/heroku/client.rb:540:in `process'
From 56145a7faf608ae8d91bba81024d8b32df31032b Mon Sep 17 00:00:00 2001
From: Nathaniel Bibler <nate@envylabs.com>
Date: Fri, 1 Jul 2011 01:23:19 -0400
Subject: [PATCH] Define custom big_primary_key column type for postgresql
---
config/initializers/postgresql.rb | 1 +
db/migrate/20110701044205_create_logins.rb | 5 +++--
db/schema.rb | 2 ++
3 files changed, 6 insertions(+), 2 deletions(-)
@nbibler
nbibler / rack-lint-demo.rb
Created June 15, 2012 03:59
A demo of using a testing beacon to determine body manipulation and state.
require 'rack'
module Rack
# This would be Rack::Lint. The demonstrable functionality here is to call
# up the stack, then inspect the env['rack.linkbeacon'] object to determine
# whether or not it was left in an unclosed state.
#
class LintDemo
def initialize(app)
@app = app