This file contains 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 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 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 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 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
#!/usr/bin/env rake | |
Dir.glob('*.rake').each { |r| import r } |
This file contains 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 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 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 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
class SandPaper | |
class NoValueForRequiredField < Exception; end | |
class UnsupportedBooleanValue < Exception; end | |
TYPE_CONVERTERS = [ :boolean, :string, :integer, :float] | |
TYPE_CONVERTERS.each do |type| | |
define_method type, ->(name, options = {}) { | |
options[:xpath] ||= "//#{name.to_s}" | |
@grain[name] = options.merge type: type |
This file contains 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
source :rubygems | |
gem 'sinatra' | |
gem 'trollop' | |
gem 'faraday' |
NewerOlder