Skip to content

Instantly share code, notes, and snippets.


Chris McGrath chrismcg

View GitHub Profile
View ieleccy.Rmd
title: "Ireland Electricity"
output: html_document
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
chrismcg / day5.ex
Created Dec 6, 2018
AoC 2018 day 5 in Elixir
View day5.ex
defmodule Day5 do
@moduledoc """
Day 5 Elixir solutions for Advent of Code 2018
@doc """
Removes all reacting units from the input and returns the final length
Algorithm from a Haskell implementation in reddit:
View example.ex
defmodule Cryptopals.AES.LookupTables.Galois do
@g2 {
0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e,
0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e,
0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e,
0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e,
0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe,
0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde,
0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0xfe,

Keybase proof

I hereby claim:

  • I am chrismcg on github.
  • I am chrismcg ( on keybase.
  • I have a public key ASDY8DfzwmNT_Z5zz53McTRBHcJaT3-SQjN2wOlaWTOS_wo

To claim this, I am signing this object:

View gist:2fb601eadd5bb1cfdc881c3b0f972e39
% iex --erl "-kernel shell_history enabled -kernel shell_history_path \"/Users/chris/.iex-history\""
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Interactive Elixir (1.4.5) - press Ctrl+C to exit (type h() ENTER for help)
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution
% export ERL_AFLAGS="-kernel shell_history enabled -kernel shell_history_path \"/Users/chris/.iex-history\""
View foo.ex
defmodule MyApp.Foo do
use MyApp.Web, :model
@derive [Poison.Encoder]
schema "foos" do
belongs_to :user, User
field :name, :string
chrismcg / filter_bench.exs
Created Mar 16, 2016
Quick elixir benchmark
View filter_bench.exs
# in bench/filter_bench.exs
defmodule FilterBench do
use Benchfella
@map (1..1000) |> -> {idx, Integer.to_string(idx)} end) |> Enum.into(%{})
bench "anonymous function" do
Enum.filter(@map, fn {k, _v} -> k > 10 end)
View dot_spacemacs.el
;; from
(add-to-list 'display-buffer-alist
`(,(rx bos (or
"*alchemist test report*"
"*alchemist macroexpand*"
"*alchemist mix*"
"*elixir help*"
View gist:8baec3521dd3de67222a
Looking up modules in dialyze_erlang-18.2.1_elixir-1.2.0-rc.1_deps-dev.plt
Looking up modules in dialyze_erlang-18.2.1_elixir-1.2.0-rc.1.plt
Looking up modules in dialyze_erlang-18.2.1.plt
Finding applications for dialyze_erlang-18.2.1.plt
Finding modules for dialyze_erlang-18.2.1.plt
Creating dialyze_erlang-18.2.1.plt
Looking up modules in dialyze_erlang-18.2.1.plt
Checking 10 modules in dialyze_erlang-18.2.1.plt
Adding 146 modules to dialyze_erlang-18.2.1.plt
Finding applications for dialyze_erlang-18.2.1_elixir-1.2.0-rc.1.plt
View gist:5ea3d6d58ee708a5e285
>>> linux d64fa8121fca9883d6fb14ca06d2abf66496195e Downloading
Doing full clone
Cloning into bare repository 'linux-d64fa8121fca9883d6fb14ca06d2abf66496195e'...
POST git-upload-pack (gzip 1590 to 829 bytes)
remote: Counting objects: 4522912, done.
remote: Compressing objects: 100% (7/7), done.
--2015-10-16 22:52:27--
Resolving (,
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 404 Not Found