Skip to content

Instantly share code, notes, and snippets.

View doomspork's full-sized avatar
👨‍🍼
Busy being a dad

Sean Callan doomspork

👨‍🍼
Busy being a dad
View GitHub Profile
import fs from "fs";
import path from "path";
import type { ZudokuConfig } from "zudoku";
import yaml from "yaml";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// Simple path resolution to specs directory
const specsDir = path.resolve(__dirname, "../specs/v4");
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