Instantly share code, notes, and snippets.

# This script will setup Evm (Emacs Version Manager) and Cask on
# Travis to use for Emacs Lisp testing.
# In .travis.yml, add this:
# - curl -fsSkL > && source ./
# Emacs 24.3 is installed in the above script because Cask requires
View gist:dfa6d886f12d85d7d1d54103d4a808b5
# Usage: mix run lib/producer_consumer.exs
# Hit Ctrl+C twice to stop it.
# This is a base example where a producer A emits items,
# which are amplified by a producer consumer B and printed
# by consumer C.
defmodule A do
use GenStage
View article.ex
defmodule Article do
defstruct [:content, comments: []]
# public commands
def execute(%Article{}, %PublishArticle{content: content}) do
%ArticlePublished{content: content}
def execute(%Article{}, %CommentOnArticle{} = comment) do
View Do you LOVE snow?
Diary of a Snow Shoveler
December 8: 6:00 PM. It started to snow. The first snow of the season and
the wife and I took our cocktails and sat for hours by the window
watching the huge soft flakes drift down from heaven. It looked like a Grandma
Moses print. So romantic we felt like newlyweds again. I love snow!
December 9: We woke to a beautiful blanket of crystal white snow
covering every inch of the landscape. What a fantastic sight! Can there be a more
lovely place in the Whole World? Moving here was the best idea I've ever

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

View unconsult.exs
With thanks to @voltone from the Elixir Slack
defmodule X do
def unconsult(filename, list) do!(filename, [:write], fn file ->
Enum.each(list, &:io.fwrite(file, '~p.~n', [&1]))
View gpg.rst

GPG Cheat sheet

A small guide to little things

Create a key


Keybase proof

I hereby claim:

  • I am trevoke on github.
  • I am trevoke ( on keybase.
  • I have a public key whose fingerprint is 48D1 9866 1459 C162 184F FB48 564E 4148 EBF9 21A9

To claim this, I am signing this object:

View hash.ex
# In case anyone is wondering how to easily use the :crypto hash or hmac API's from elixir-land, here you go.!(filename, [:read, {:read_ahead, 65535}], 65535)
|> Enum.reduce(:crypto.hash_init(:sha), &:crypto.hash_update(&2, &1))
|> :crypto.hash_final
|> Base.encode16
# Line 3 opens up a stream, and we're reading in 64KB chunks from the FS which is roughly pretty efficient
# In line 4, we initialize our hash (which returns a context) and put that as the default value in the reducer
# The hash_update in the reducer returns the modified context. Remember arg1 is the item, and arg2 is the accumulator