Skip to content

Instantly share code, notes, and snippets.

# encoding: utf-8
require 'abstract_unit'
class TestCaseInsensitivityFlag < Test::Unit::TestCase
def setup
@app = Rack::Mount::RouteSet.new do |set|
regex_1 = if supports_named_captures?
eval '/\A\/route1\/(?<first_part>[a-z]+)\/(?<second_part>[^\/.?]+)\Z/'
else
@aanand
aanand / about.md
Created May 12, 2010 21:13
Re-reader style for Readability

Re-reader style for Readability

Change your Readability bookmarklet URL to the one below and you'll get styling similar to John Holdun's Re-Reader.

Replace http://dl.dropbox.com/u/166030/readability/readability.css with whatever, if you want to make changes. For some reason serving it raw from Gist doesn't work, so you'll have to host it. Dropbox is pretty good!

javascript:(function(){%20readStyle='style-rereader';%20readSize='size-rereader';%20readMargin='margin-rereader';%20_readability_script=document.createElement('SCRIPT');%20_readability_script.type='text/javascript';%20_readability_script.src='http://lab.arc90.com/experiments/readability/js/readability.js?x='+(Math.random());%20document.getElementsByTagName('head')[0].appendChild(_readability_script);%20_readability_css=document.createElement('LINK');%20_readability_css.rel='stylesheet';%20_readability_css.href='http://dl.dropbox.com/u/166030/readability/readability.css';%20_r

@aanand
aanand / javascript.vim
Created August 12, 2010 20:02
Well-behaved Javascript indentation for vim, with my own addition for multiline var blocks
" Vim indent file
" Language: JavaScript
" Author: Robert Kieffer
" URL: -
" Last Change: 2010-08-12
"
" Improved JavaScript indent script.
" Indent script in place for this already?
if exists("b:did_indent")
[69, 78] in {...}/gems/actionpack-3.0.0.rc/lib/action_controller/metal/renderers.rb
69 INCLUDED.each(&:_write_render_options)
70 end
71 end
72
73 add :json do |json, options|
=> 74 json = ActiveSupport::JSON.encode(json, options) unless json.respond_to?(:to_str)
75 json = "#{options[:callback]}(#{json})" unless options[:callback].blank?
76 self.content_type ||= Mime::JSON
77 self.response_body = json
~ → rvm gem install haml
info: default (ruby-1.9.2-p0): ruby 1.9.2p0 (2010-08-18 revision 29036) [i386-darwin10.4.0]
Successfully installed haml-3.0.18
1 gem installed
info: rbx-1.0.1-20100603: rubinius 1.0.1 (1.8.7 release 2010-06-03 JI) [i686-apple-darwin10.4.0]
Successfully installed haml-3.0.18
def wrapper_method
puts "* SETUP *"
yield
puts "* TEARDOWN *"
end
f = Fiber.new do
wrapper_method do
Fiber.yield
end
@aanand
aanand / Briefly.md
Created January 6, 2011 13:09
"cannot run C compiled programs" when running `rvm install`

"cannot run C compiled programs" when running rvm install

If you get this error in your config.log when running rvm install <version>, you may have the wrong rvm_archflags set in your ~/.rvmrc.

Mine was set to:

rvm_archflags="-arch x86_64"

When it should have been:

if RUBY_VERSION < '1.9'
require 'redgreen'
else
require 'colored'
# A poor person's redgreen.
class ActiveSupport::TestCase
def run(*args, &block)
result = super(*args, &block)
@aanand
aanand / gif
Created November 23, 2011 11:39
Command-line gif creator
#!/usr/bin/env ruby
require "optparse"
default_file_pattern = "png/*.png"
default_output_filename = "out.gif"
start = nil
finish = nil
skip = 1
loading GPX...99 files loaded (total size 7809.02k)
Checking correctness
--------------------
checking json...ok
checking msgpack...ok
checking protobuf...ok
preparing serialized data...ok