Skip to content

Instantly share code, notes, and snippets.

View sferik's full-sized avatar

Erik Berlin sferik

View GitHub Profile
View ahoward.rb
require 'gems'
require 'nokogiri'
require 'octokit'
require 'open-uri'
doc = Nokogiri::HTML(open(''))
repo_names ='.profile-list ol li a.profile-rubygem').map do |element|
gem =\s+/)[1])
gem['info'].match('kicks the ass') && gem['homepage_uri'].match(%r{github\.com/ahoward/(\w*)})[1]
View pmap.rb
def pmap(enum)
return to_enum(:pmap, enum) unless block_given? { |e| { yield e } }.map(&:value)
# Returns elements in order, as expected.
pmap(1..10) { |e| e } #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# Returns elements in nondeterministic order on MRI >= 1.9.3.
# Works as expected on JRuby, Rubinius, and earlier versions of MRI.
View exposable.rb
require 'set'
module Lotus
module Action
module Exposable
def self.included(base)
module ClassMethods
View stratus-installation.html
<script type="text/javascript">
key: "Enter your Client ID here",
links: ""
View stratus-customization.html
<script type="text/javascript">
auto_play: true,
download: false,
key: "Enter your Client ID here",
links: '',
random: true
sferik / 404_image_swap.js
Created August 11, 2009 20:14
JQuery code to swap out broken images with a replacement image.
View 404_image_swap.js
$(document).ready(function() {
$(this).attr('src', 'not_found.png');
View to_tags.rb
include Stemmable
class String
def to_tags
# lower case
# replace new lines, numbers, and puncuation with spaces
# break words on spaces
# get the word stem
# remove duplicates
# removed stems less than 3 letters
View classes.rb
#!/usr/bin/env ruby
nodes = []
edges = {}
ObjectSpace.each_object(Class) do |klass|
# Skip classes outside the global namespace
next if klass.to_s.include?(':')
# Skip classes like ARGF.class
next if klass.to_s.include?('.')
View winner.rb
require 'curb'
require 'json'
followers_response = Curl::Easy.http_get("")
followers = JSON.parse(followers_response.body_str)
winner_id = followers[rand(followers.length)]
users_response = Curl::Easy.http_get("{winner_id}.json")
winner = JSON.parse(users_response.body_str)
puts "We have a winner!"
sferik / config.rb
Created November 20, 2009 00:59 — forked from merbjedi/config.rb
MerbAdmin DSL
View config.rb
MerbAdmin.config User do
label "Users" # @model.pretty_name
list do
before do
puts "Called before list"
fields :name, :description # All columns
filters :publication_date, :retired # All booleans