Skip to content

Instantly share code, notes, and snippets.

require 'open-uri'
failed = []
File.read('File.txt').lines.each do |x|
begin
sleep 1
st = Time.now.to_f
puts "#{x}: #{open(x).status} in #{(et - st)}"
et = Time.now.to_f
rescue
# 2010 Modularity Olympics
# ===
# This is a contest, open to programming languages from all over the world, to write modular and
# extensible code to solve the following problem: Implement a service that can run queries on a database.
# A programmer without control over the source-code of that service must be able to later add
# enhancements such as statistics collecting, timeouts, memoization, and so forth. There are a few
# requirements:
# 1. the "enhancements" must be specified in a configuration object which is consumed at run-time
# (e.g., it could be based on user-input).
# 2. The enhancements are ordered (stats collecting wraps timeouts, not the other way around) but
def model_for_table(table_name)
table_name.classify.constantize
end
def index
schemas = Hash.new
ActiveRecord::Base.connection.tables.each do |table|
if table != "schema_migrations"
model = model_for_table(table)
schemas[model.table_name] << model.columns.map { |c| { :name => c.name, :type => c.type } }
@capotej
capotej / gist:72128
Created February 28, 2009 22:18 — forked from pauldix/gist:57285
require 'feedzirra'
# fetching a single feed
feed = Feedzirra::Feed.fetch_and_parse("http://feeds.feedburner.com/PaulDixExplainsNothing")
# feed and entries accessors
feed.title # => "Paul Dix Explains Nothing"
feed.url # => "http://www.pauldix.net"
feed.feed_url # => "http://feeds.feedburner.com/PaulDixExplainsNothing"
feed.etag # => "GunxqnEP4NeYhrqq9TyVKTuDnh0"
@capotej
capotej / gist:72125
Created February 28, 2009 22:06 — forked from pauldix/gist:57285
require 'feedzirra'
# fetching a single feed
feed = Feedzirra::Feed.fetch_and_parse("http://feeds.feedburner.com/PaulDixExplainsNothing")
# feed and entries accessors
feed.title # => "Paul Dix Explains Nothing"
feed.url # => "http://www.pauldix.net"
feed.feed_url # => "http://feeds.feedburner.com/PaulDixExplainsNothing"
feed.etag # => "GunxqnEP4NeYhrqq9TyVKTuDnh0"
let's make a list of sinatra-based apps!
apps:
- http://github.com/cschneid/irclogger "Sinatra based irclogger.com"
- http://github.com/rtomayko/wink "minimalist blogging engine"
- http://github.com/foca/integrity "The easy and fun Continuous Integration server"
- http://github.com/sr/git-wiki "git-powered wiki"
- http://github.com/entp/seinfeld "Seinfeld-inspired productivity calendar to track your public github commits."
- http://github.com/karmi/marley "Marley, the blog engine without <textareas>. See in action @ www.restafari.org"
- http://github.com/ichverstehe/gaze "Serve up your Markdown files with this tiny Sinatra app!"