Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View adamwiggins's full-sized avatar

Adam Wiggins adamwiggins

View GitHub Profile
require 'resolv'
def ips_for(host)
Resolv::DNS.open do |dns|
ress = dns.getresources(host, Resolv::DNS::Resource::IN::A)
ress.map { |r| r.address.to_s }
end
end
puts ips_for('heroku.com').sort.first
begin
raise "an exception"
rescue
puts "rescuing"
raise
end
error do
e = request.env['sinatra.error']
puts e.to_s
puts e.backtrace.join("\n")
"Internal server error"
end
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!"
- (bool)someoneWon {
// horizontal
for (int x = 0; x < 3; x++)
{
if (spots[x][0] != ' ' && spots[x][0] == spots[x][1] && spots[x][1] == spots[x][2])
return spots[x][0];
}
// vertical
for (int y = 0; y < 3; y++)
#!/usr/bin/env ruby
require '../lib/my_app'
if ARGV.shift == 'server'
MyApp.new(ARGV.shift).run
else
puts "client"
end
require 'rubygems'
require 'erb'
def baz
bad_call
end
def foo
baz
end
#!/usr/bin/env ruby
require 'rubygems'
require File.dirname(__FILE__) + '/../config/boot'
require File.dirname(__FILE__) + '/../config/environment'
require 'lizzy_cloud'
Lizzy.start do
require 'rubygems'
require 'benchmark'
gem = ARGV.shift.strip rescue ''
if gem == ''
STDERR.puts "usage: #{$0} [gem]"
exit 1
end
`free`
# RAILS_ROOT is read-only on Heroku. Write to tmp dir, which is read/write.
require 'acts_as_ferret'
ActsAsFerret.index_dir = "#{RAILS_ROOT}/tmp/index"