Skip to content

Instantly share code, notes, and snippets.

View elbow-jason's full-sized avatar
🏠
Working from home

Jason Goldberger elbow-jason

🏠
Working from home
View GitHub Profile
@elbow-jason
elbow-jason / mnesia.exs
Last active August 29, 2015 14:17 — forked from joshnuss/mnesia.exs
# define a record, first attribute is considered the key
defrecord User, email: "", first: "", last: ""
# encapsulates mnesia calls
defmodule Database do
def create_schema do
create_table User
end
def find(record, id) do
@elbow-jason
elbow-jason / gist:baee81b0e2fe8d3f8690
Last active August 29, 2015 14:17
Dynamic Functions with or without args?
defmodule DynaFuncs do
#this works - dynamic name with no args
{:ok, other_func_name} = Code.string_to_quoted(:half)
def unquote(other_func_name), do: IO.puts(1/2)
# but this doesn't work - static name with no args
def unquote(:one_third), do: IO.puts(1/3)
# and this works - static name with args
@elbow-jason
elbow-jason / gist:a81b51370822b62a0d5a
Last active August 29, 2015 14:16
Stream is causing iex to hang for some reason...
defmodule LoggerHandler do
use GenEvent
# Callbacks
def handle_event({:log, x}, messages) do
{:ok, [x|messages]}
end
@elbow-jason
elbow-jason / true_lies.ipynb
Created July 24, 2014 01:05
A demo of the mro()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.