This file contains 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 'active_support' | |
require 'active_support/core_ext' | |
require 'ruby-prof' | |
require "minitest/autorun" | |
class Array | |
def rest | |
self[1..-1] | |
end | |
end |
This file contains 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
interface BingoStatus { | |
won: boolean | |
} | |
interface BingoCell { | |
number: string, | |
freebie?: boolean, | |
completed?: boolean | |
} |
This file contains 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
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 |
This file contains 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
### 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": "[email protected]"}' http://localhost:3000/foos | |
$ curl http://localhost:3000/foos | |
[{"id":3,"name":"bob","email":"[email protected]"}] |
This file contains 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 '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; |
This file contains 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
[[email protected]:~] $ ssh tanga | |
[[email protected]:~] $ ls .ssh | |
authorized_keys config known_hosts | |
[[email protected]:~] $ ssh pair1.tanga.com | |
monkey@pair1:~$ |
This file contains 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 foo | |
t = Thread.new do | |
begin | |
sleep 1 | |
puts "finished thread" | |
rescue | |
puts "exception raised" | |
ensure | |
puts "ensure called" | |
end |
This file contains 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; | |
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, |
This file contains 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
Site.all.each do |site| | |
Product.all.each do |product| | |
Coupon.create site_ids: [site.id], product_ids: [product.id] | |
end | |
end |
This file contains 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
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 |
NewerOlder