Skip to content

Instantly share code, notes, and snippets.

View reiddraper's full-sized avatar

Reid Draper reiddraper

View GitHub Profile
<title>This is the title</title>

Keybase proof

I hereby claim:

  • I am reiddraper on github.
  • I am reiddraper ( on keybase.
  • I have a public key ASCTgRUWMsnLUEBwyA44G_kTvXoTxwmpb2DIRVET0WxXYwo

To claim this, I am signing this object:

terraform plan -var-file terraform.tfvars -out terraform.tfplan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but
will not be persisted to local or remote state storage. Refreshing state... (ID: vol-1291439a)
aws_ebs_volume.pg6_sdh: Refreshing state... (ID: vol-33cb1587)
aws_ebs_volume.pg7_sdf: Refreshing state... (ID: vol-3b9f4db3)
aws_eip.nat-2a: Refreshing state... (ID: eipalloc-cb74a9ac) Refreshing state... (ID: vol-65a266e6)
Here's an explanation from 30k ft. of the generator namespace. There are three monads
involved, one of which simply contains the other two (but is not a monad transformer). They're
not named explicitly like this in the module, but let's call them: RoseTree, Generator and Gen.
Gen is the monad that is a wrapper around Gen (RoseTree a), to use Haskell types. A RoseTree
is simply an n-ary. In Haskell, it'd be defined like:
data RoseTree a = RoseTree a [RoseTree a]
In Clojure I represent it as a two-element vector, the first element being the node's value,
and the second being a lazy-sequence of the children. Since we use a lazy-seq, we can
make[1]: *** [libraries/Cabal/Cabal/dist-boot/] Segmentation fault (core dumped)
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [utils/hsc2hs/dist/] Segmentation fault (core dumped)
make: *** [all] Error 2
make -j8 131.49s user 2.92s system 99% cpu 2:15.43 total

Debugging Erlang Applications In Real Time

Reid Draper @reiddraper

We'll be using a tool called redbug, which is an abstraction and safety layer of Erlang's built-in dbg tracing facilities. You can follow along at home:

select(2, [0 1], NULL, NULL, {900, 0}) = 1 (in [0], left {899, 949910})
wait4(1401, 0x7fffe90edd0c, WNOHANG, NULL) = 0
read(0, "10:53:10.322 [error] Supervisor "..., 8192) = 438
lseek(2, 0, SEEK_END) = 90736
write(2, "10:53:10.322 [error] Supervisor "..., 438) = 438
select(2, [0 1], NULL, NULL, {900, 0}) = 1 (in [0], left {899, 958221})
wait4(1401, 0x7fffe90edd0c, WNOHANG, NULL) = 0
read(0, "10:53:14.135 [error] Supervisor "..., 8192) = 461
lseek(2, 0, SEEK_END)
dd if=/dev/zero of=/tmp/output bs=25k count=1k
for i in {1..10}; do time curl -X PUT localhost:8098/riak/foo/a --data-binary @/tmp/output > foo; done
12:50:24 <{mochiweb_acceptor,init,3}> {riak_client,new,2}
12:50:24 <{mochiweb_acceptor,init,3}> {riak_client,instance,2}
12:50:24 <{mochiweb_acceptor,init,3}> {riak_client,get,4}
12:50:24 <{mochiweb_acceptor,init,3}> {riak_client,mk_reqid,1}
12:50:24 <{mochiweb_acceptor,init,3}> {riak_client,recv_timeout,2}
reiddraper / sort-idempotent.clj
Created October 23, 2013 00:32
Uses simple-check to test that sorting is idempotent.
(require '[simple-check.core :as sc])
(require '[simple-check.generators :as gen])
(require '[ :as prop])
(def sort-idempotent-prop
(prop/for-all [v (gen/vector gen/int)]
(= (sort v) (sort (sort v)))))
(sc/quick-check 100 sort-idempotent-prop)
;; => {:result true, :num-tests 100, :seed 1382488326530}