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 / interfaces
Created September 25, 2017 19:37
Network Interfaces Config
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
@cdesch
cdesch / gist:867d8d9a8aa2ae78af64f1d179fec89d
Last active March 10, 2019 11:03
elixir regex Cheat sheet
iex(1)> s1 = "Hello, World!"
"Hello, World!"
iex(2)> s2 = "ボリスくん"
"ボリスくん"
iex(3)> Regex.scan(~r/\S/, s1)
[["H"], ["e"], ["l"], ["l"], ["o"], [","], ["W"], ["o"], ["r"], ["l"], ["d"],
["!"]]
iex(4)> Regex.scan(~r/\S/, s2)
[[<<227>>], [<<131>>], [<<156>>], [<<227>>], [<<131>>], [<<170>>], [<<227>>],
[<<130>>], [<<185>>], [<<227>>], [<<129>>], [<<143>>], [<<227>>], [<<130>>],
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",
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)
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[
/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
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
@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;
@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
$ 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