Skip to content

Instantly share code, notes, and snippets.

View joevandyk's full-sized avatar

Joe Van Dyk joevandyk

View GitHub Profile
View gist:8946810
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Append (cost=0.00..65.76 rows=10 width=109) (actual time=0.126..0.126 rows=0 loops=1)
-> Seq Scan on medias (cost=0.00..0.00 rows=1 width=588) (actual time=0.000..0.000 rows=0 loops=1)
Filter: (id = 2)
-> Index Scan using channel_medias_pkey on channel_medias (cost=0.28..8.29 rows=1 width=66) (actual time=0.015..0.015 rows=0 loops=1)
Index Cond: (id = 2)
-> Index Scan using product_medias_id_media_of_id_idx on product_medias (cost=0.29..8.31 rows=1 width=58) (actual time=0.007..0.007 rows=0 loops=1)
Index Cond: (id = 2)
-> Index Scan using comment_medias_pkey on comment_medias (cost=0.28..8.30 rows=1 width=51) (actual time=0.014..0.014 rows=0 loops=1)
View que_fork.rb
require 'que'
require 'logger'
require 'sequel'
# Preload MultiJson's code for finding most efficient json loader
# so we don't need to do this inside each worker process.
if defined?(MultiJson)
MultiJson.load('[]')
end
View gist:9622680
curl https://gist.githubusercontent.com/joevandyk/d1f08cdc7b05fec0c971/raw/9e8da2ec2c2c7eb224e304fa89b7e2fe3fac9bb3/gistfile1.txt | sh
View gist:9691869
require 'sequel'
require 'active_record'
DB = Sequel.connect('postgres://localhost/tanga_dev')
puts DB[:users].count
ActiveRecord::Base.connection.instance_variable_set(:@connection, DB.synchronize{|c| c})
puts ActiveRecord::Base.connection.select_one('select count(*) from users')
# results in
View gist:9778426
Sort (cost=514690.51..514940.51 rows=100000 width=2548) (actual time=20856.993..20991.397 rows=100000 loops=1)
Sort Key: data.line_item_internal_id, data.shipment_picked_up_at
Sort Method: external merge Disk: 53536kB
CTE data
-> Limit (cost=2160.08..394324.69 rows=100000 width=904) (actual time=15.456..20009.395 rows=100000 loops=1)
-> Nested Loop Left Join (cost=2160.08..16722360.84 rows=4263567 width=904) (actual time=15.455..19990.996 rows=100000 loops=1)
-> Hash Left Join (cost=2159.22..10424474.68 rows=4016402 width=792) (actual time=14.872..14675.085 rows=99204 loops=1)
Hash Cond: (pl.shipping_export_id = se.id)
-> Nested Loop Left Join (cost=3.28..10347011.19 rows=4016402 width=767) (actual time=0.145..14552.755 rows=99204 loops=1)
-> Nested Loop Left Join (cost=2.85..8305866.58 rows=4016402 width=739) (actual time=0.143..13375.717 rows=99204 loops=1)
View gist:9837788
Limit (cost=7171333.18..7171333.18 rows=1 width=244) (actual time=14789.118..14789.119 rows=1 loops=1)
-> Sort (cost=7171333.18..7171504.71 rows=68611 width=244) (actual time=14789.115..14789.115 rows=1 loops=1)
Sort Key: r.created_at
Sort Method: top-N heapsort Memory: 25kB
-> Subquery Scan on r (cost=428255.95..7170990.13 rows=68611 width=244) (actual time=14688.773..14788.721 rows=150 loops=1)
-> HashAggregate (cost=428255.95..7170304.02 rows=68611 width=92) (actual time=14688.769..14788.396 rows=150 loops=1)
-> Nested Loop (cost=223442.35..427569.84 rows=68611 width=92) (actual time=12644.172..14632.360 rows=383 loops=1)
Join Filter: (ac.order_id = acli.order_id)
-> Nested Loop (cost=223441.93..404408.50 rows=46678 width=96) (actual time=12621.925..14603.351 rows=191 loops=1)
Join Filter: (ac.order_id = li.order_id)
View gist:1a822d00a10cc7f7118c
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
View gist:a486f9cebfbb44858796
Site.all.each do |site|
Product.all.each do |product|
Coupon.create site_ids: [site.id], product_ids: [product.id]
end
end
View gist:4bdbf5a7a713575a761f
def foo
t = Thread.new do
begin
sleep 1
puts "finished thread"
rescue
puts "exception raised"
ensure
puts "ensure called"
end
View gist:0cda77aa7fb4e077447b
[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:~$