Skip to content

Instantly share code, notes, and snippets.

View joevandyk's full-sized avatar

Joe Van Dyk joevandyk

View GitHub Profile
require 'active_support'
require 'active_support/core_ext'
require 'ruby-prof'
require "minitest/autorun"
class Array
def rest
self[1..-1]
end
end
interface BingoStatus {
won: boolean
}
interface BingoCell {
number: string,
freebie?: boolean,
completed?: boolean
}
Running cd shared/gems/tanga_models && rake test TEST=test/test_exports.rb
/usr/local/tanga/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.3.5/lib/minitest.rb:286: [BUG] vm_call_cfunc - cfp consistency error
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0011 p:---- s:0050 e:000049 CFUNC :each
c:0010 p:0008 s:0047 e:000046 BLOCK /usr/local/tanga/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.3.5/lib/minitest.rb:286
c:0009 p:0036 s:0045 e:000044 METHOD /usr/local/tanga/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.3.5/lib/minitest.rb:317
c:0008 p:0020 s:0038 E:000d38 METHOD /usr/local/tanga/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.3.5/lib/minitest.rb:306
c:0007 p:0062 s:0032 E:001a20 METHOD /usr/local/tanga/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.3.5/lib/minitest.rb:285
### Create a table that has name and email, and create a view that versions the way to access the table.
tanga_dev=# create table foos (id serial primary key, name text, email text);
tanga_dev=# create view "1".foos as (select * from foos);
### That's all the code, now we can use http to get, read, update, and delete the data.
$ curl -d '{"name": "bob", "email": "bob@tanga.com"}' http://localhost:3000/foos
$ curl http://localhost:3000/foos
[{"id":3,"name":"bob","email":"bob@tanga.com"}]
require 'active_record'
require 'pg'
require 'benchmark'
require 'sequel'
ActiveRecord::Base.establish_connection("postgres://localhost/test")
DB = Sequel.connect('postgres://localhost/test')
ActiveRecord::Base.connection.execute <<-SQL
drop table t1 cascade; drop table t2 cascade; drop table t3 cascade;
[joe@deadlift.local:~] $ ssh tanga
[monkey@dev.tanga.com:~] $ ls .ssh
authorized_keys config known_hosts
[monkey@dev.tanga.com:~] $ ssh pair1.tanga.com
monkey@pair1:~$
def foo
t = Thread.new do
begin
sleep 1
puts "finished thread"
rescue
puts "exception raised"
ensure
puts "ensure called"
end
BEGIN;
create table test_table (id serial primary key, name text);
insert into test_table (name) values ('joe'), ('bob');
create schema database_reports;
create table database_reports.queries (
query_id bigserial primary key,
parent_id bigint references database_reports.queries,
Site.all.each do |site|
Product.all.each do |product|
Coupon.create site_ids: [site.id], product_ids: [product.id]
end
end
diff --git a/config/service_definitions/tanga_rails/run b/config/service_definitions/tanga_rails/run
index 7ba34fc..fd31b8f 100755
--- a/config/service_definitions/tanga_rails/run
+++ b/config/service_definitions/tanga_rails/run
@@ -2,5 +2,6 @@
exec 2>&1
export HOME=/home/monkey
cd $HOME/tanga/sites/tanga
+export UNICORN_WORKERS=2