Skip to content

Instantly share code, notes, and snippets.

@robyoung
robyoung / gist:2580217
Created May 2, 2012 20:33
Bit set encoding for number of options in a url
import unittest
import math
import base64
import bz2
import gzip
import StringIO
import struct
class BitSetEncoder(object):
def encode(self, integers):
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@remvee
remvee / ignore_unknown_http_method.rb
Created September 28, 2010 07:39
silence ActionController::UnknownHttpMethod exceptions
# Avoid annoying ActionController::UnknownHttpMethod exceptions like:
#
# ActionController::UnknownHttpMethod) "CONNECT, accepted HTTP methods are get, head, put, post, delete, and options"
#
# Install this file in app/metal and these requests will receive a 405
# "Method Not Allowed" status and will be logged under `info'.
class IgnoreUnknownHttpMethod
def self.call(env)
[
if ActionController::Request::HTTP_METHODS.include?(env["REQUEST_METHOD"].downcase)