This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "Registration" do | |
before(:all) do | |
FakeWeb.allow_net_connect = true | |
end | |
after(:all) do | |
FakeWeb.allow_net_connect = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: iso8859-1 | |
require 'yaml' | |
x = "Antonio Giménez Muñoz" | |
x.force_encoding('BINARY') | |
p x.encode('UTF-8') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def stub_module(full_name) | |
full_name.to_s.split(/::/).inject(Object) do |context, name| | |
begin | |
context.const_get(name) | |
rescue NameError | |
context.const_set(name, Module.new) | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat redis_keys.txt | cut --delimiter=: -f 1,2 | sort | uniq -c | sort -r -n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Watchable | |
def events | |
@events ||= Hash.new { |h,k| h[k] = [] } | |
end | |
def fire event, *args | |
events[event].each { |e| e[*args] } | |
end | |
def on event, &block |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# Annotate your "bundle outdated" with GitHub compare URLs | |
# | |
require 'open-uri' | |
require 'json' | |
def rubygems_gem_info(gem_name) |
OlderNewer