Skip to content

Instantly share code, notes, and snippets.

View cjbottaro's full-sized avatar

Christopher J. Bottaro cjbottaro

  • AcademicWorks, Inc
  • Austin, Tx
View GitHub Profile
@cjbottaro
cjbottaro / gist:cc5d7d3ae4329e35d7f9
Created April 27, 2015 20:34
log_lock_waits output (partial)
[scholarship_app_development] STATEMENT: UPDATE applications SET updated_at = '2015-04-27 20:25:35 +0000' WHERE id = 455423
[scholarship_app_development] LOG: process 97776 still waiting for ExclusiveLock on tuple (408,65) of relation 5436886 of database 5158717 after 1000.090 ms
[scholarship_app_development] STATEMENT: UPDATE applications SET updated_at = '2015-04-27 20:25:29 +0000' WHERE id = 455423
[scholarship_app_development] LOG: process 96629 still waiting for ExclusiveLock on tuple (408,65) of relation 5436886 of database 5158717 after 1000.175 ms
[scholarship_app_development] STATEMENT: UPDATE applications SET updated_at = '2015-04-27 20:25:22 +0000' WHERE id = 455423
[scholarship_app_development] LOG: process 97110 still waiting for ExclusiveLock on tuple (408,65) of relation 5436886 of database 5158717 after 1001.027 ms
[scholarship_app_development] STATEMENT: UPDATE applications SET updated_at = '2015-04-27 20:25:32 +0000' WHERE id = 455423
[scholarship_app_development] LOG: process 96891
@cjbottaro
cjbottaro / gist:a966008af75fbbd874e1
Created June 8, 2015 21:04
Chef bootstrap error
Connecting to 10.1.13.242
10.1.13.242 Installing Chef Client...
10.1.13.242 --2015-06-08 20:51:43-- https://www.opscode.com/chef/install.sh
10.1.13.242 Resolving www.opscode.com (www.opscode.com)... 184.106.28.91
10.1.13.242 Connecting to www.opscode.com (www.opscode.com)|184.106.28.91|:443... connected.
10.1.13.242 HTTP request sent, awaiting response... 504 Gateway Time-out
10.1.13.242 2015-06-08 20:53:44 ERROR 504: Gateway Time-out.
10.1.13.242
10.1.13.242 Starting first Chef Client run...
10.1.13.242 bash: line 88: chef-client: command not found
@cjbottaro
cjbottaro / gist:6f8f8f2f235a2293fe62
Last active August 29, 2015 14:26
Installing MUQ on OS X
brew install boost --c++11
brew tap homebrew/science
brew install eigen flann hdf5 sundials gcc
cd /tmp
git clone https://bitbucket.org/mituq/muq
cd muq/MUQ/build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/muq ..
make && make install
defmodule MacroFun do
defmacro a(str, do: block) do
quote do
res = [a: unquote(str)]
unquote(block)
res
end
end
defmodule MacroFun do
defmacro a(str, do: block) do
quote do
{ :ok, var!(buffer, MacroFun) } = Agent.start_link fn -> [a: unquote(str)] end
unquote(block)
res = Agent.get var!(buffer, MacroFun), &(&1)
Agent.stop var!(buffer, MacroFun)
Enum.reverse res
end
@cjbottaro
cjbottaro / .ex
Created January 12, 2016 04:07
var!/2
defmodule Foo do
defmacro foo(do: block) do
quote do
var!(foo, Foo) = "foo"
unquote(block)
end
end
end
@cjbottaro
cjbottaro / .rb
Created January 14, 2016 20:45
Optimize lookups with Hash
require "benchmark"
def slow(list1, list2)
count = 0
list1.each do |n|
count += 1 if list2.include?(n)
end
count
end
@cjbottaro
cjbottaro / .ex
Last active January 16, 2016 19:29
Non-hurty, Ruby-like DSL in Elixir
##############
# Define DSL #
##############
defmodule Config.Dsl do
defmacro __using__(_) do
quote do
import unquote(__MODULE__)
@before_compile unquote(__MODULE__)
@cjbottaro
cjbottaro / .ex
Created January 17, 2016 00:18
Dynamically define function using module attribute as name
defmodule Definer do
defmacro define(do: block) do
quote bind_quoted: [block: Macro.escape(block)] do
func_name = @name |> String.to_atom |> Macro.var(__MODULE__)
def unquote(func_name) do
unquote(block)
end
end
end
end
[88396] 2016/12/30 10:36:39.184894 [DBG] 127.0.0.1:49506 - cid:73 - Client connection created
[88396] 2016/12/30 10:36:39.185146 [TRC] 127.0.0.1:49506 - cid:73 - ->> [CONNECT {"version":"1.3","verbose":true,"protocol":1,"pedantic":false,"lang":"elixir"}]
[88396] 2016/12/30 10:36:39.185191 [TRC] 127.0.0.1:49506 - cid:73 - <<- [OK]
[88396] 2016/12/30 10:36:39.185439 [TRC] 127.0.0.1:49506 - cid:73 - ->> [SUB one_off.c4b487b4 c4b487b4]
[88396] 2016/12/30 10:36:39.185464 [TRC] 127.0.0.1:49506 - cid:73 - <<- [OK]
[88396] 2016/12/30 10:36:39.185622 [TRC] 127.0.0.1:49506 - cid:73 - ->> [UNSUB c4b487b4 1]
[88396] 2016/12/30 10:36:39.185634 [DBG] 127.0.0.1:49506 - cid:73 - Deferring actual UNSUB(one_off.c4b487b4): 1 max, 0 received
[88396] 2016/12/30 10:36:39.185640 [TRC] 127.0.0.1:49506 - cid:73 - <<- [OK]
[88396] 2016/12/30 10:36:39.185801 [TRC] 127.0.0.1:49506 - cid:73 - ->> [PUB _STAN.discover.test-cluster one_off.c4b487b4 28]
[88396] 2016/12/30 10:36:39.185812 [TRC] 127.0.0.1:49506 - cid:73 - ->> MSG_PAYLOAD: [