Skip to content

Instantly share code, notes, and snippets.

@clarkware
clarkware / gist:1046693
Created June 25, 2011 17:37
View Source for Ruby
# Toss this in your ~/.irbrc file for a convenient way
# to peruse Ruby source code in TextMate. This
# only works in Ruby 1.9!
#
# Use it in irb like so:
#
# >> require 'active_record'
# >> ActiveRecord::Base.source_for_method(:create)
class Object
# encoding: utf-8
Encoding.default_external = 'utf-8'
Encoding.default_internal = 'utf-8'
ENV["LANG"] = 'en_US.UTF-8'
require 'psych' if ARGV.first == 'p'
require 'yaml'
puts 'hello: "h\xc3\xa4gar"'
# encoding: iso8859-1
require 'yaml'
x = "Antonio Giménez Muñoz"
x.force_encoding('BINARY')
p x.encode('UTF-8')
require 'spec_helper'
describe "Registration" do
before(:all) do
FakeWeb.allow_net_connect = true
end
after(:all) do
FakeWeb.allow_net_connect = false
@myronmarston
myronmarston / output
Created February 8, 2011 02:47
YAML modifies strings when it serializes them. What the crap?
$ ruby --version
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.5.0]
$ ruby yaml_bug.rb
YAML modifies strings when it serializes them!
Original: "1\n \n2"
Modified: "1\n\n2"
@avdi
avdi / example.rb
Created October 30, 2009 22:28
Rack::Stereoscope
require 'sinatra'
require 'json'
require 'addressable/uri'
require File.expand_path('rack_stereoscope.rb', File.dirname(__FILE__))
configure do
use Rack::Reloader;
use Rack::Lint;
use Rack::Stereoscope;
end