Skip to content

Instantly share code, notes, and snippets.

require 'sinatra'
get '/' do
headers['Cached-Control'] = 'public, max-age=60'
Time.now.to_s
end
run Sinatra::Application
26 minutes ago
@natfriedman: Heroku looks amazing, but the pricing is awful. I wish I could get their deployment architecture on my own servers.
9 minutes ago
@natfriedman: Oh my god, I take it all back. Heroku is so wonderful I just started crying a little bit. This is worth the money.
$ psql
=# create table bigtable ( id bigserial, name text );
NOTICE: CREATE TABLE will create implicit sequence "bigtable_id_seq" for serial column "bigtable.id"
CREATE TABLE
=# \d bigtable
Table "public.bigtable"
Column | Type | Modifiers
--------+--------+-------------------------------------------------------
id | bigint | not null default nextval('bigtable_id_seq'::regclass)
name | text |
require 'rubygems'
gem 'sequel', '= 3.0.0'
gem 'sinatra', '= 0.9.2'
require File.dirname(__FILE__) + '/lib/taps/config'
Taps::Config.database_url = ENV['DATABASE_URL'] # production db
Taps::Config.taps_database_url = ENV['TAPS_DATABASE_URL'] # db for taps
Taps::Config.login = 'myserverlogin'
def cmd_receive_data
puts "Receiving data"
tables_with_counts, record_count = fetch_remote_tables_info
puts "#{tables_with_counts.size} tables, #{format_number(record_count)} records"
tables_with_counts.each do |table_name, count|
table = db[table_name.to_sym]
chunksize = default_chunksize
task :environment do
require File.dirname(__FILE__) + '/lib/all'
end
require 'benchmark'
namespace :bench do
task :write => :environment do
puts Benchmark.realtime {
1000.times { |x| c = Counting.new; c.num = x; c.save; }
}
require 'thread'
require 'benchmark'
N = 200000
def competition(&block)
t1 = Thread.new {
for i in 1..N
block.call
end
require 'rubygems'
require 'main'
run Sinatra::Application
/usr/local/lib/ruby/gems/1.8/gems/thin-1.0.0/lib/thin/server.rb:51: uninitialized constant Thin::Server::Forwardable (NameError)
#!/usr/bin/env ruby
require 'rubygems'
require 'sequel'
@db = Sequel.connect("postgres://postgres@localhost/mydb")