This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'sinatra' | |
| post '/' do | |
| request.body.read.length.to_s | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| begin | |
| raise "an exception" | |
| rescue | |
| puts "rescuing" | |
| raise | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| error do | |
| e = request.env['sinatra.error'] | |
| puts e.to_s | |
| puts e.backtrace.join("\n") | |
| "Internal server error" | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (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++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require '../lib/my_app' | |
| if ARGV.shift == 'server' | |
| MyApp.new(ARGV.shift).run | |
| else | |
| puts "client" | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'erb' | |
| def baz | |
| bad_call | |
| end | |
| def foo | |
| baz | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require File.dirname(__FILE__) + '/../config/boot' | |
| require File.dirname(__FILE__) + '/../config/environment' | |
| require 'lizzy_cloud' | |
| Lizzy.start do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'benchmark' | |
| gem = ARGV.shift.strip rescue '' | |
| if gem == '' | |
| STDERR.puts "usage: #{$0} [gem]" | |
| exit 1 | |
| end | |
| `free` |