Skip to content

Instantly share code, notes, and snippets.

View cdesch's full-sized avatar
🏠
Working from home

cdesch cdesch

🏠
Working from home
View GitHub Profile
@cdesch
cdesch / pgbench
Created March 19, 2018 11:58
pg bench and timescale db
L
9.5.10
listen_addresses = 'localhost'
listen_addresses = '*'
max_connections = 100
max_connections = 200
shared_buffers = 128MB
shared_buffers = 16GB
@cdesch
cdesch / Rubminecrashlog
Created March 13, 2018 17:40
rubymine crash log 3/13/2018
Process: rubymine [30235]
Path: /Applications/RubyMine.app/Contents/MacOS/rubymine
Identifier: com.jetbrains.rubymine
Version: 2017.3.3 (RM-173.4548.40)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: rubymine [30235]
User ID: 501
Date/Time: 2018-03-13 13:37:48.696 -0400
$ cargo build --verbose
Fresh lazy_static v0.1.16
Fresh utf8-ranges v0.1.3
Fresh num-traits v0.1.42
Fresh unicode-xid v0.0.4
Fresh unicode-segmentation v1.2.0
Fresh regex-syntax v0.3.9
Fresh winapi-build v0.1.1
Fresh getopts v0.2.17
Fresh void v1.0.2
@cdesch
cdesch / rubyminecrashlog.log
Created February 3, 2018 20:27
Rubymine Crash Log Feb3rd 2018
Process: rubymine [9344]
Path: /Applications/RubyMine.app/Contents/MacOS/rubymine
Identifier: com.jetbrains.rubymine
Version: 2017.3.2 (RM-173.4301.17)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: rubymine [9344]
User ID: 501
Date/Time: 2018-02-03 15:26:40.835 -0500
@cdesch
cdesch / postgresCheatSheet.sql
Created February 2, 2018 15:37
Postgres Cheat Sheet
#Create User with Role and Password
CREATE USER postgres WITH PASSWORD 'password' CREATEDB CREATEROLE SUPERUSER;
Process: rubymine [14719]
Path: /Applications/RubyMine.app/Contents/MacOS/rubymine
Identifier: com.jetbrains.rubymine
Version: 2017.3.2 (RM-173.4301.17)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: rubymine [14719]
User ID: 501
Date/Time: 2018-01-26 20:47:56.271 -0500
/Users/cj/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/ransack-d8ab32f813a0/lib/ransack/helpers/form_builder.rb:9:in `value'
/Users/cj/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/rails-634dbfcd6f4c/actionview/lib/action_view/helpers/tags/base.rb:53:in `value_before_type_cast'
/Users/cj/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/rails-634dbfcd6f4c/actionview/lib/action_view/helpers/tags/text_field.rb:15:in `block in render'
/Users/cj/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/rails-634dbfcd6f4c/actionview/lib/action_view/helpers/tags/text_field.rb:15:in `fetch'
/Users/cj/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/rails-634dbfcd6f4c/actionview/lib/action_view/helpers/tags/text_field.rb:15:in `render'
/Users/cj/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/rails-634dbfcd6f4c/actionview/lib/action_view/helpers/form_helper.rb:1502:in `email_field'
/Users/cj/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/rails-634dbfcd6f4c/actionview/lib/act
iex(49)> MyRewards.Merchants.new_merchant_transactions(1,60)
[debug] QUERY OK source="my_rewards_transactions" db=2.6ms decode=0.2ms
SELECT m0."id", m0."amount", m0."type", m0."reference_number", m0."user_id", m0."merchant_id", m0."reward_id", m0."inserted_at", m0."updated_at" FROM "my_rewards_transactions" AS m0 INNER JOIN (SELECT m0."id" AS "id", COUNT(*) OVER (PARTITION BY m0."user_id") AS "count" FROM "my_rewards_transactions" AS m0 WHERE (m0."merchant_id" = $1)) AS s1 ON s1."id" = m0."id" WHERE (s1."count" > 1) [1]
** (Protocol.UndefinedError) protocol Ecto.Queryable not implemented for [%MyRewards.Transaction{__meta__: #Ecto.Schema.Metadata<:loaded, "my_rewards_transactions">, amount: %Money{amount: 300, currency: :USD}, id: 1, inserted_at: ~N[2017-03-09 16:48:34.514414], merchant: #Ecto.Association.NotLoaded<association :merchant is not loaded>, merchant_id: 1, reference_number: nil, reward: #Ecto.Association.NotLoaded<association :reward is not loaded>, reward_id: nil, type: "debit", updated_at: ~N[
def try_async(files, num_process) do
files
|> Enum.chunk_every(round(length(files)/num_process))
|> Enum.each(fn(x) -> load_async(x, 3) end)
end
#Break that chunk into a few tasks to run parallel
def load_async(files, chunk_by) do
files
|> Enum.chunk_every(chunk_by)
defmodule AdLock.DataProcessTest do
@timeout 60000
def start do
#list of files
# files = ["/Volumes/Backup/samples/raw-000000000000.csv.gz",
# "/Volumes/Backup/samples/raw-000000000001.csv.gz"]
#files = ["/Volumes/Backup/samples/raw-000000000000.csv.gz"]
#files = ["/Volumes/Backup/samples/raw-000000000000.csv"]
files = ["/Users/cj/Downloads/raw-1-small.csv.gz",