Skip to content

Instantly share code, notes, and snippets.

@mislav
mislav / backfill-releases.sh
Created February 5, 2014 17:37
Script to migrate releases from CHANGELOG.md to GitHub Releases
#!/bin/bash
# Usage: OAUTH_TOKEN="..." backfill-releases CHANGELOG.md [<project-title>]
set -e
log="${1?}"
project_name="${2}"
repo="$(git config remote.origin.url | grep -oE 'github\.com[/:][^/]+/[^/]+' | sed 's/\.git$//' | cut -d/ -f2-3)"
[ -n "${project_name}" ] || project_name="${repo#*/}"
@ordinaryzelig
ordinaryzelig / .ruby-version
Last active August 29, 2015 14:01
Test cases for thread-safety in mocking libraries (http://redningja.com/dev/parallel-tests-with-single-database/)
ruby-2.0.0-p353
@tiegz
tiegz / object_profiler.rb
Last active August 29, 2015 14:03
Object Profiler for ruby 2.1.0+
module ObjectSpace
def self.profile(&blk)
require 'objspace'
enable_gc = GC.disable
ObjectSpace.trace_object_allocations(&blk)
objs = Hash.new(0)
ObjectSpace.each_object { |o|
if (file = ObjectSpace.allocation_sourcefile(o)) && (line = ObjectSpace.allocation_sourceline(o))
objs["#{file}:#{line}:#{o.class.name}"] += 1
@janko
janko / benchmark.rb
Last active August 29, 2015 14:18
Minitest loads *slower* than RSpec?
require "benchmark/ips"
File.write "minitest_test.rb", <<-EOS
require "minitest/autorun"
require "minitest/pride"
class MintestTest < Minitest::Test
def test_foo
assert true
end
@mislav
mislav / Gemfile
Last active August 29, 2015 14:18 — forked from janko/benchmark.rb
source "https://rubygems.org"
gem "minitest"
gem "rspec"
require 'rspec'
require 'rspec/autorun'
require 'nokogiri'
class SomeClass
def example(doc); end
end
# Warning: running this _will_ freeze your computer or at the very least make it
# very slow, consume a lot of CPU and burn your lap (in case you're using a
@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
@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"
require 'spec_helper'
describe "Registration" do
before(:all) do
FakeWeb.allow_net_connect = true
end
after(:all) do
FakeWeb.allow_net_connect = false
# encoding: iso8859-1
require 'yaml'
x = "Antonio Giménez Muñoz"
x.force_encoding('BINARY')
p x.encode('UTF-8')