Skip to content

Instantly share code, notes, and snippets.

Erik Berlin sferik

Block or report user

Report or block sferik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View reverse_gem_deps.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'rubygems/remote_fetcher'
file = "Marshal.#{Gem.marshal_version}.Z"
# uri = URI.parse "{file}"
# data = Gem::RemoteFetcher.fetcher.fetch_path uri
data =
sferik / gist:962083
Created May 9, 2011
Gems that depend on bundler
View gist:962083
  1. bundler
  2. aavkontakte
  3. AbsoluteRenamer
  4. accessible_attributes
  5. accumulators
  6. active_diigo
  7. activerecord-mysql2legacydb-adapter
  8. active_record_shards
  9. activerecord-simpledb-adapter
  10. activerecord-table_version
sferik / Questions
Created Jul 12, 2011
Magma Rails Give-away
View Questions
Day Job: Fellow at Code for America
Open Source contribution: lots of gems: rails_admin, omniauth, multi_xml, multi_json, faraday, twitter, simple_oauth, oauth2, octokit, and many more.
Tell me about your experience with Ruby/Rails: I started using Rails in 2006, shortly after version 1 was released. I then switched to primarily using Merb in 2008 and released my first Open Source project on GitHub: MerbAdmin. I then switched back after Rails 3 was released and oversaw the porting of MerbAdmin to Rails 3 as a Ruby Summer of Code mentor.
How do you use GitHub: GitHub is my life.
Favorite luchador(es): I must confess, I know almost nothing about lucha libre.
View struct_bench.rb
require 'benchmark/ips'
require 'ostruct'
N = 100
ATTRS = (:aa..:zz).take(N)
HASH = Hash[ { |x| [x, x] }]
CStruct =*ATTRS)
def struct
sferik / Gemfile
Created Aug 8, 2011
Is it Rubinius? Ask Travis!
View Gemfile
source ''
gem 'sinatra'
gem 'nokogiri'
gem 'multi_xml'
gem 'slim'
sferik / gist:1143058
Created Aug 12, 2011
Gems that depend on faraday_middleware
View gist:1143058
  • agilezen
  • flexmls_api
  • freckly
  • gowalla
  • gstock
  • mad_mimi
  • mlb
  • octokit
  • open311
  • t
View snowman.rb
ruby-1.9.2-head :001 > a = {}
=> {}
ruby-1.9.2-head :002 > a["☃"] = 1
=> 1
ruby-1.9.2-head :003 > a
=> {"☃"=>1}
View benchmark.rb
iterations = 100
test_file = "#{File.dirname(__FILE__)}/"
implementations = [
{class_name: 'BlueCloth', gem_name: 'bluecloth', require_name: 'bluecloth'},
{class_name: 'RDiscount', gem_name: 'rdiscount', require_name: 'rdiscount'},
{class_name: 'Maruku', gem_name: 'maruku', require_name: 'maruku'},
{class_name: 'PEGMarkdown', gem_name: 'rpeg-markdown', require_name: 'peg_markdown'},
# Attempt to require each implementation and remove any that are not
View bench.rb
require "rubygems"
require "rbench"
class A
def initialize(hash={})
hash.each do |key, value|
instance_variable_set(:"@#{key}", value)
View number_with_indefinite_article.rb
# Helper function that returns a number with its correct indefinite article
# e.g. number_with_indefinite_article(10) #=> "a 10"
# e.g. number_with_indefinite_article(80, "$") #=> "an $80"
def number_with_indefinite_article(number, prefix=nil)
[indefinite_article_for_number(number), " ", prefix, number].compact.join
# Helper function that returns the correct indefinite article for a number
# e.g. indefinite_article_for_number(10) #=> "a"
# e.g. indefinite_article_for_number(80) #=> "an"
You can’t perform that action at this time.