Skip to content

Instantly share code, notes, and snippets.

@seancribbs
seancribbs / Readme.md
Last active September 7, 2021 17:51 — forked from jszmajda/Readme.md
Game of Life in Erlang

Conway's Game of Life in Erlang, in 2 hours, with 0 Erlang experience, in 20 lines of code.

1337 h4x0rs:

  • @jszmajda
  • @ngauthier
  • @ericoestrich
  • @danivovich
  • @kafuchau
# This function is only included for context - it creates a multi-operation transaction structure
# for a single widget and its associated options
def create_multi(params, operation_type, widget, identifier \\ :widget) do
changeset = Widget.changeset(widget, params)
apply(Ecto.Multi, operation_type, [Ecto.Multi.new(), identifier, changeset])
|> maybe_merge_widget_options(identifier, params)
end
# Here's the usage of reduce. Notice the map + "mappend"(?) inside the reduce. If Ecto.Multi
;; Support mix format command
(defun alchemist-mix-format (&optional prefix)
"Runs mix format in the project"
(interactive)
(alchemist-mix-execute (list "format") prefix))
(defun alchemist-mix-format-buffer (&optional prefix)
"Runs mix format on the current buffer"
(interactive)
defmodule Mix.Tasks.PrintCode do
@shortdoc "Prints decompiled Erlang source for a module"
@moduledoc """
Pretty-prints the *Erlang-equivalent* source code of an *Elixir*
module. This is useful for understanding how particular Elixir
features (e.g. macros, protocols) operate under the covers.
*Erlang modules are not yet supported.*
@seancribbs
seancribbs / qcon-nyc-2017-resources.md
Last active July 29, 2017 16:49
Resources for my talk "Adopting Stream Processing for Instrumentation" at QCon New York 2017
@seancribbs
seancribbs / init.el
Last active August 22, 2017 11:10
seancribbs.com/emacs.d
;; Use org-babel to load config
(require 'org)
(org-babel-load-file (expand-file-name "seancribbs.org" user-emacs-directory))
@seancribbs
seancribbs / ifelse.erl
Last active December 4, 2020 05:37
IF / ELSE in erlang, via parse_transform. EVIL, DO NOT USE
%% @doc A VERY EVIL parse_transform that allows two things:
%%
%% 1) The use of 'else' instead of 'true' in the final clause of an if
%% expression.
%%
%% 2) Automatic extraction of non-guard expressions into
%% anonymous variables that can then be used directly in the clause
%% guards.
%%
%% Until Erlang actually implements the 'cond' construct, this is a
** (Protocol.UndefinedError) protocol String.Chars not implemented for {:git, 'git://github.com/basho/lager.git', {:tag, '2.1.1'}}
(elixir) lib/string/chars.ex:3: String.Chars.impl_for!/1
(elixir) lib/string/chars.ex:17: String.Chars.to_string/1
(mix) lib/mix/rebar.ex:122: Mix.Rebar.compile_req/1
(mix) lib/mix/rebar.ex:88: Mix.Rebar.parse_dep/2
(elixir) lib/enum.ex:977: anonymous fn/3 in Enum.map/2
(elixir) lib/enum.ex:1261: Enum."-reduce/3-lists^foldl/2-0-"/3
(elixir) lib/enum.ex:977: Enum.map/2
(mix) lib/mix/dep/loader.ex:250: anonymous fn/2 in Mix.Dep.Loader.rebar_children/1

Keybase proof

I hereby claim:

  • I am seancribbs on github.
  • I am seancribbs (https://keybase.io/seancribbs) on keybase.
  • I have a public key whose fingerprint is C40B E0F2 EA7F B696 8D69 E1D1 2AAA 6B61 8089 7A6C

To claim this, I am signing this object:

# Customizations
. ~/.bash/colors.sh
. ~/.bash/editor.sh
. ~/.bash/git.sh
. ~/.bash/erlang.sh
. ~/.bash/ruby.sh
. ~/.bash/ghc.sh
. ~/.bash/prompt.sh
. ~/.bash/gif.sh