This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Example do | |
def reverse(list, acc \\ []) | |
def reverse([], acc) do | |
acc | |
end | |
def reverse([head|tail], acc) do | |
reverse(tail, [head | acc]) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:ok, file} = File.open 'test.txt', [:write] | |
escaped = "foo"e;bar's" | |
|> String.replace(""e;", "\"") | |
|> String.replace("'", "'") | |
|> String.replace("&", "&") | |
file | |
|> IO.binwrite(escaped) | |
|> File.close |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder