Skip to content

Instantly share code, notes, and snippets.

View doomspork's full-sized avatar
👋
How's it going?

Sean Callan doomspork

👋
How's it going?
View GitHub Profile
defmodule Contributors do
@client %Tentacat.Client{auth: ""}
def commit(user, repo), do: Tentacat.Commits.list(user, repo, @client)
def analysis(commits) do
commits
|> Enum.filter(&is_map/1)
|> Enum.reduce(%{}, &users_first_commit/2)
|> Enum.sort(fn {_, date1}, {_, date2} -> date1 < date2 end)
defmodule Example do
def reverse(list, acc \\ [])
def reverse([], acc) do
acc
end
def reverse([head|tail], acc) do
reverse(tail, [head | acc])
end
defmodule Example do
def split(list, chunk_size) do
do_split(list, chunk_size, [[]])
end
defp do_split([], _chunk_size, acc) do
acc
end
defp do_split([item|rest], chunk_size, [cur|acc]) do
#!/bin/bash
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && \
sudo dpkg -i erlang-solutions_1.0_all.deb && \
sudo apt-get update && \
sudo apt-get -y install esl-erlang && \
sudo apt-get -y install elixir
defmodule Concoct do
@alphabet "abcdefghijklmnopqrstuvwxyx"
@reserved ~w(init module_info)a
defmacro __using__(mod, _opts \\ []) do
wrappers = mod.module_info
|> Keyword.get(:exports)
|> Enum.filter(&Concoct.reserved_fun/1)
|> Enum.map(&Concoct.wrap_erl_fun/1)
1) test does not create resource and renders errors when data is invalid (AssignBug.ThingControllerTest)
test/controllers/thing_controller_test.exs:24
** (ArgumentError) assign @owners not available in eex template.
Please make sure all proper assigns have been set. If this
is a child template, ensure assigns are given explicitly by
the parent template as they are not automatically forwarded.
Available assigns: [:changeset, :conn, :view_module, :view_template]
defmodule Example.User do
@derive [Poison.Encoder]
defstruct [:name, :age]
end
iex> json = ~s({"name": "uto", "age": "old"})
"{\"name\": \"uto\", \"age\": \"old\"}"
iex> Poison.decode!(json, as: Example.User)
%Example.User{age: "old", name: "uto"}
{:ok, file} = File.open 'test.txt', [:write]
escaped = "foo&quote;bar&#39;s"
|> String.replace("&quote;", "\"")
|> String.replace("&#39;", "'")
|> String.replace("&#38;", "&")
file
|> IO.binwrite(escaped)
|> File.close
defp handle_reply(socket, {status, payload}, :handle_in)
when is_atom(status) and is_map(payload) do
send socket.transport_pid, %Reply{status: status, topic: socket.topic,
ref: socket.ref, payload: socket.assigns ++ payload}
end
@doomspork
doomspork / keybase.md
Created May 7, 2014 19:53
Keybase Identity Proof

Keybase proof

I hereby claim:

  • I am doomspork on github.
  • I am spork (https://keybase.io/spork) on keybase.
  • I have a public key whose fingerprint is DAA1 22C6 5803 2F11 6865 5211 CB3E DE36 56B1 9262

To claim this, I am signing this object: