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' | |
| get '/' do | |
| headers['Cached-Control'] = 'public, max-age=60' | |
| Time.now.to_s | |
| end | |
| run Sinatra::Application |
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
| 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. | |
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
| $ 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 | |
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' | |
| 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' |
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
| 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 |
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
| 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; } | |
| } |
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 'thread' | |
| require 'benchmark' | |
| N = 200000 | |
| def competition(&block) | |
| t1 = Thread.new { | |
| for i in 1..N | |
| block.call | |
| 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 'main' | |
| run Sinatra::Application |
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/local/lib/ruby/gems/1.8/gems/thin-1.0.0/lib/thin/server.rb:51: uninitialized constant Thin::Server::Forwardable (NameError) |
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 'sequel' | |
| @db = Sequel.connect("postgres://postgres@localhost/mydb") |