Skip to content

Instantly share code, notes, and snippets.

Consider me as a sexless value-delivering entity, please.

Aldric Giacomoni Trevoke

View GitHub Profile
Trevoke / watchers.ex
Last active Feb 2, 2019
macro problem
View watchers.ex
# My goal is this
defmodule Watchers do
use Ecstatic.Watcher
watch Health do
run PanicSystem, when: fn(pre, post) -> (pre.points - post.points) > 30 end
run BleedingSystem, when: fn(_pre, post) -> post.points == 0 end
run DeathSystem, when: fn(_pre, post) -> post.points == -10 end
# 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
Trevoke / gist:dfa6d886f12d85d7d1d54103d4a808b5
Last active Mar 18, 2018
producer_consumer does not modify events
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
Trevoke / article.ex
Created Jan 23, 2018 — forked from slashdotdash/article.ex
Commanded multi-entity aggregates
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

Trevoke / unconsult.exs
Created Apr 6, 2017
consulting/unconsulting a file
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]))
Trevoke / gpg.rst
Created Mar 3, 2016 — forked from paul-schwendenman/gpg.rst
GPG Cheatsheet
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
You can’t perform that action at this time.