Skip to content

Instantly share code, notes, and snippets.

View sferik's full-sized avatar

Erik Berlin sferik

View GitHub Profile
@sferik
sferik / config.rb
Created November 20, 2009 00:59 — forked from merbjedi/config.rb
MerbAdmin DSL
MerbAdmin.config User do
label "Users" # @model.pretty_name
list do
before do
puts "Called before list"
end
fields :name, :description # All columns
filters :publication_date, :retired # All booleans
require 'curb'
require 'json'
followers_response = Curl::Easy.http_get("http://twitter.com/followers/ids/perpetually.json")
followers = JSON.parse(followers_response.body_str)
winner_id = followers[rand(followers.length)]
users_response = Curl::Easy.http_get("http://twitter.com/users/show/#{winner_id}.json")
winner = JSON.parse(users_response.body_str)
puts "We have a winner!"
#!/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?('.')
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
@sferik
sferik / 404_image_swap.js
Created August 11, 2009 20:14
JQuery code to swap out broken images with a replacement image.
$(document).ready(function() {
$('img').error(function(){
$(this).attr('src', 'not_found.png');
});
});