commit stringlengths 40 40 | old_file stringlengths 4 264 | new_file stringlengths 4 264 | old_contents stringlengths 0 4.24k | new_contents stringlengths 1 5.44k | subject stringlengths 14 778 | message stringlengths 15 9.92k | lang stringclasses 277
values | license stringclasses 13
values | repos stringlengths 5 127k |
|---|---|---|---|---|---|---|---|---|---|
e00f0397111804755a8fcc4240db438d953f8b79 | template/lib/application_name/supervisor.ex | template/lib/application_name/supervisor.ex | defmodule <%= application_module %>.Supervisor do
use Supervisor
def start_link do
:supervisor.start_link(__MODULE__, [])
end
def init([]) do
children = []
# See http://elixir-lang.org/docs/stable/Supervisor.Behaviour.html
# for other strategies and supported options
supervise(children, s... | defmodule <%= application_module %>.Supervisor do
use Supervisor
def start_link do
:supervisor.start_link(__MODULE__, [])
end
def init([]) do
children = []
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
supervise(children, stra... | Fix broken link in generated comments. | Fix broken link in generated comments. | Elixir | mit | paulcsmith/phoenix,beni55/phoenix,stevedomin/phoenix,optikfluffel/phoenix,DavidAlphaFox/phoenix,trarbr/phoenix,tony612/phoenix,Rumel/phoenix,Joe-noh/phoenix,yonglehou/phoenix,0x00evil/phoenix,lono-devices/phoenix,andrewvy/phoenix,romul/phoenix,nshafer/phoenix,manukall/phoenix,daytonn/phoenix,rafbgarcia/phoenix,jwarwick... |
214a974ed7d7ddfb9b8b453613b65b3934720af5 | test/yodado/feature_test.exs | test/yodado/feature_test.exs | defmodule Yodado.FeatureTest do
defmodule AllTest do
use ExUnit.Case, async: true
alias Yodado.Feature, as: Feature
test "do?/2 returns a tuple {:ok, boolean} " do
fancy_feature = Feature.Feature[title: "Fancy feature",
description: "Does stuff",
master_switch_state: true,
... | defmodule Yodado.FeatureTest do
defmodule AllTest do
use ExUnit.Case, async: true
alias Yodado.Feature, as: Feature
test "do?/2 returns a tuple {:ok, boolean} " do
fancy_feature = Feature.Feature[title: "Fancy feature",
description: "Does stuff",
master_switch_state: true,
d... | Test serialization/deserialization of a feature | Test serialization/deserialization of a feature
| Elixir | mit | envato/iodized,envato/iodized |
abd7825d88911581e4692f121460bf70e0f68e3d | lib/dofus_next/frontend/session.ex | lib/dofus_next/frontend/session.ex | import Kernel, except: [send: 2]
defmodule DofusNext.Frontend.Session do
require Logger
defstruct transport: nil, socket: nil, attrs: %{}, closed?: false
alias __MODULE__, as: T
def send(s, data) do
Logger.debug "SND #{data}"
s.transport.send(s.socket, << data :: binary, 0 :: utf8 >>)
s
end
... | import Kernel, except: [send: 2]
defmodule DofusNext.Frontend.Session do
require Logger
defstruct transport: nil, socket: nil, attrs: %{}, closed?: false
alias __MODULE__, as: T
def send(s, data) when is_list(data) do
List.foldl(s, fn (x, acc) -> T.send(acc, x) end)
end
def send(s, data) do
Log... | Send a list of data | Send a list of data
| Elixir | mit | Blackrush/dofus.next,Blackrush/dofus.next |
4a87c7135b6c11aa3db9014bba8be133caeeac1e | web/views/layout_view.ex | web/views/layout_view.ex | defmodule Eecrit.LayoutView do
use Eecrit.Web, :view
import Eecrit.Router.Helpers
use Eecrit.TagHelpers
alias Eecrit.TagHelpers, as: T # TODO: this is a kludge to avoid conflicts
alias Eecrit.AggregateViewWidgets
def navigation(conn) do
iolists = [
AggregateViewWidgets.reports_launcher(conn),
... | defmodule Eecrit.LayoutView do
use Eecrit.Web, :view
import Eecrit.Router.Helpers
use Eecrit.TagHelpers
alias Eecrit.TagHelpers, as: T # TODO: this is a kludge to avoid conflicts
alias Eecrit.AggregateViewWidgets
def navigation(conn) do
iolists = [
link("Home", to: page_path(conn, :index)),
... | Add home link to top navbar | Add home link to top navbar | Elixir | mit | marick/eecrit,marick/eecrit,marick/eecrit |
61d19fa4a9ebd58e3b5d4d225724a04128017087 | lib/rotor/file_watcher.ex | lib/rotor/file_watcher.ex | defmodule Rotor.FileWatcher do
import Rotor.Utils
use GenServer
# group_info will have %{name: name, interval: interval}
def init(group_info) do
{:ok, group_info}
end
def handle_call(:state, _from, state) do
{:reply, state, state}
end
def handle_call(:poll, _from, state) do
{changed_fi... | defmodule Rotor.FileWatcher do
import Rotor.Utils
use GenServer
# group_info will have %{name: name, interval: interval}
def init(group_info) do
{:ok, group_info}
end
def handle_call(:state, _from, state) do
{:reply, state, state}
end
def handle_call(:poll, _from, state) do
{changed_fi... | Use a shorter method call for getting group info | Use a shorter method call for getting group info
| Elixir | mit | HashNuke/rotor |
6d87816b862df7b0449cb069b39eae409fdb20aa | web/controllers/api/game_controller.ex | web/controllers/api/game_controller.ex | defmodule BattleSnake.Api.GameController do
alias BattleSnake.{
GameForm,
GameServer
}
use BattleSnake.Web, :controller
defmodule Game do
defstruct [:id, :status]
@derive Poison.Encoder
end
def index(conn, __params) do
games = load_games()
render(conn, "index.json", games: games)
... | defmodule BattleSnake.Api.GameController do
alias BattleSnake.{
GameForm,
GameServer
}
use BattleSnake.Web, :controller
defmodule Game do
@derive [Poison.Encoder]
defstruct [:id, :status]
end
def index(conn, __params) do
games = load_games()
render(conn, "index.json", games: games... | Fix @derive annotation for game struct | Fix @derive annotation for game struct
| Elixir | agpl-3.0 | Dkendal/battle_snake,Dkendal/battle_snake,Dkendal/battle_snake,Dkendal/battle_snake,Dkendal/battle_snake |
4a111be79acbc4a43201e8556d0a0e0c63a75e3a | lib/ex_unit/assertions.ex | lib/ex_unit/assertions.ex | defexception ExUnit::AssertionError, message: "assertion failed"
defmodule ExUnit::Assertions do
def assert_included(base, container) do
if Erlang.string.str(container, base) == 0 do
raise ExUnit::AssertionError, message: "Expected #{inspect container} to include #{inspect base}"
end
end
end | defexception ExUnit::AssertionError, message: "assertion failed"
defmodule ExUnit::Assertions do
def assert_included(base, container) do
if Erlang.string.str(container, base) == 0 do
raise ExUnit::AssertionError, message: "Expected #{inspect container} to include #{inspect base}"
end
end
def asser... | Add assert, refute and assert_equal | Add assert, refute and assert_equal
| Elixir | apache-2.0 | gfvcastro/elixir,beedub/elixir,joshprice/elixir,kimshrier/elixir,pedrosnk/elixir,ggcampinho/elixir,kimshrier/elixir,michalmuskala/elixir,antipax/elixir,antipax/elixir,gfvcastro/elixir,lexmag/elixir,kelvinst/elixir,kelvinst/elixir,elixir-lang/elixir,lexmag/elixir,pedrosnk/elixir,ggcampinho/elixir,beedub/elixir |
9c803ff72cc25cf82558724d2d8f49c4d39c8451 | lib/ast_mangler.ex | lib/ast_mangler.ex | defmodule ASTMangler do
def expand([], _), do: []
def expand({fun, context, args}, replacement) do
new_args = replace(args, replacement)
{fun, context, new_args}
end
def expand([do: thing], replacement) do
[do: expand(thing, replacement)]
end
def expand(n, _), do: n
def replace(nil, _), do: n... | defmodule ASTMangler do
def expand(ast, replacement) do
Macro.prewalk(ast, fn(node) -> update(node, replacement) end)
end
def update(:__, replacement), do: replacement
def update(node, _), do: node
end
| Use prewalk to inject value into AST | Use prewalk to inject value into AST
| Elixir | mit | samstarling/elixir-koans,elixirkoans/elixir-koans |
a46acfc8cf816e43ff29b89675a3bd398f4ab062 | test/integration/public_channel_test.exs | test/integration/public_channel_test.exs | defmodule Poxa.Integration.PublicChannelTest do
use ExUnit.Case
@moduletag :integration
setup_all do
{:ok, pid} = PusherClient.connect!('ws://localhost:8080/app/app_key')
info = PusherClient.client_info(pid)
{:ok, [gen_event_pid: info.gen_event_pid, pid: pid]}
end
teardown_all context do
Pu... | defmodule Poxa.Integration.PublicChannelTest do
use ExUnit.Case
@moduletag :integration
setup_all do
{:ok, pid} = PusherClient.start_link('ws://localhost:8080/app/app_key')
{:ok, [pid: pid]}
end
teardown_all context do
PusherClient.disconnect!(context[:pid])
:ok
end
defmodule EchoHandl... | Fix deprecation warning on GenEvent | Fix deprecation warning on GenEvent
| Elixir | mit | RobertoSchneiders/poxa,edgurgel/poxa,edgurgel/poxa,edgurgel/poxa,joshk/poxa,joshk/poxa,waffleio/poxa,RobertoSchneiders/poxa,waffleio/poxa |
8fa3a37c076597d947b78b9bc21dca08395486d9 | blue_sky/lib/blue_sky/update_questions.ex | blue_sky/lib/blue_sky/update_questions.ex | defmodule BlueSky.UpdateQuestions do
use GenServer
alias BlueSky.GameService
def start_link do
GenServer.start_link(__MODULE__, %{})
end
def init(state) do
Process.send_after(self(), :work, 5_000) # In 5 seconds
{:ok, state}
end
def handle_info(:work, state) do
#get new question here a... | defmodule BlueSky.UpdateQuestions do
use GenServer
alias BlueSky.GameService
def start_link do
GenServer.start_link(__MODULE__, %{})
end
def init(state) do
Process.send_after(self(), :work, 5_000) # In 5 seconds
{:ok, state}
end
def handle_info(:work, state) do
#get new question here a... | Change question updating to 30 seconds, it's probably broken anyways though | Change question updating to 30 seconds, it's probably broken anyways though
| Elixir | mit | Rumel/bluesky,Rumel/bluesky,Rumel/bluesky |
4fc5a01f08e4e9fe55a03637bb69a727520e5c1b | lib/tesla/middleware/path_params.ex | lib/tesla/middleware/path_params.ex | defmodule Tesla.Middleware.PathParams do
@moduledoc """
Use templated URLs with separate params.
Useful when logging or reporting metric per URL.
## Example usage
```
defmodule MyClient do
use Tesla
plug Tesla.Middleware.BaseURl, "https://api.example.com"
plug Tesla.Middleware.Logger # or so... | defmodule Tesla.Middleware.PathParams do
@moduledoc """
Use templated URLs with separate params.
Useful when logging or reporting metric per URL.
## Example usage
```
defmodule MyClient do
use Tesla
plug Tesla.Middleware.BaseUrl, "https://api.example.com"
plug Tesla.Middleware.Logger # or so... | Fix typo in Middleware example | Fix typo in Middleware example | Elixir | mit | teamon/tesla,monterail/tesla |
8fc861d1a824ded81af1f634b115a4a2e84f4584 | lib/jumubase_web/views/helpers/auth_helpers.ex | lib/jumubase_web/views/helpers/auth_helpers.ex | defmodule JumubaseWeb.AuthHelpers do
@doc """
Returns whether the given user is an admin.
"""
def admin?(%User{role: role}), do: role === "admin"
end
| defmodule JumubaseWeb.AuthHelpers do
alias Jumubase.Accounts.User
@doc """
Returns whether the given user is an admin.
"""
def admin?(%User{role: role}), do: role === "admin"
end
| Fix missing alias that caused crash | Fix missing alias that caused crash
| Elixir | mit | richeterre/jumubase-phoenix,richeterre/jumubase-phoenix |
7192830130df2500bba1c99a3ac2fca7c7cc06f0 | web/models/annotation.ex | web/models/annotation.ex | defmodule Core.Annotation do
use Core.Web, :model
schema "annotations" do
belongs_to :article, Core.Article
belongs_to :user, Core.User, foreign_key: :author
timestamps()
end
@doc """
Builds a changeset based on the `struct` and `params`.
"""
def changeset(struct, params \\ %{}) do
stru... | defmodule Core.Annotation do
use Core.Web, :model
schema "annotations" do
belongs_to :article, Core.Article
belongs_to :user, Core.User, foreign_key: :author
timestamps()
end
@doc """
Builds a changeset based on the `struct` and `params`.
"""
def changeset(struct, params \\ %{}) do
stru... | Fix Annotation Model: require article_id | Fix Annotation Model: require article_id
| Elixir | mit | exacs/liqen-core,exacs/liqen-core |
926e8d00325bcdb2cc97fdf0b0472f2ddba626bf | priv/repo/migrations/20170323041850_create_accounts_user.exs | priv/repo/migrations/20170323041850_create_accounts_user.exs | defmodule MenuPlanner.Repo.Migrations.CreateMenuPlanner.Accounts.User do
use Ecto.Migration
def change do
create table(:accounts_users) do
add :email, :string
add :name, :string
add :password_hash, :string
timestamps()
end
end
end
| defmodule MenuPlanner.Repo.Migrations.CreateMenuPlanner.Accounts.User do
use Ecto.Migration
def change do
create table(:accounts_users) do
add :email, :string
add :name, :string
add :password_hash, :string
timestamps()
end
create unique_index(:accounts_users, [:email])
end
e... | Add unique index to email on users table | Add unique index to email on users table
| Elixir | mit | KZeillmann/MenuPlanner,KZeillmann/MenuPlanner |
6948ca425efd61d51c3290f4f8bf511a02ce600d | config/dev.exs | config/dev.exs | use Mix.Config
config :matrix, Matrix.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [
npm: ["run", "watch"]
]
# Watch static and templates for browser reloading.
config :matrix, Matrix.Endpoint,
live_reload: [
patterns: [
~r{priv/stat... | use Mix.Config
config :matrix, Matrix.Endpoint,
http: [port: System.get_env("PORT") || 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [
npm: ["run", "watch"]
]
# Watch static and templates for browser reloading.
config :matrix, Matrix.Endpoint,
live_reload: [
patt... | Set server port on startup | Set server port on startup
| Elixir | mit | nemanja-m/matrix,nemanja-m/matrix |
c8946411060497bb2f944c6b9ce2cc40b0f399ec | test/executor_test.exs | test/executor_test.exs | defmodule ExecuteTest do
use ExUnit.Case
test "passes a koan" do
assert :passed == Execute.run_module(PassingKoan)
end
test "stops at the first failing koan" do
{:failed, %{error: _, file: file, line: line}, SampleKoan, _name} = Execute.run_module(SampleKoan)
assert file == 'test/support/sample_ko... | defmodule ExecuteTest do
use ExUnit.Case
test "passes a koan" do
assert :passed == Execute.run_module(PassingKoan)
end
test "stops at the first failing koan" do
{:failed, %{file: file, line: line}, SampleKoan, _name} = Execute.run_module(SampleKoan)
assert file == 'test/support/sample_koan.ex'
... | Remove unneeded element from match | Remove unneeded element from match
Maps support partial matching, no need to include a key for an unneeded
value.
| Elixir | mit | samstarling/elixir-koans,elixirkoans/elixir-koans |
e818d40f2fa17ff7f2437abf48dac591c6db2fd4 | rustler_tests/test/binary_example_test.exs | rustler_tests/test/binary_example_test.exs | defmodule BinaryExampleTest do
use ExUnit.Case
test "binary is compiled" do
assert File.exists?("priv/native/binary_example")
assert File.exists?("priv/native/hello_rust")
assert File.exists?("priv/native/hello_rust2")
end
end
| defmodule BinaryExampleTest do
use ExUnit.Case
test "binary is compiled" do
bins = ~w(binary_example hello_rust hello_rust2)
for bin <- bins do
assert_exists(bin)
end
end
defp assert_exists(name) do
assert_exists(name, :os.type())
end
defp assert_exists(name, {:win32, _} = type) do... | Fix binary test for Windows | Fix binary test for Windows
| Elixir | apache-2.0 | hansihe/Rustler |
92298697827f30a2d6ba144004c1668fe70b760e | agents/map_reduce/slave.ex | agents/map_reduce/slave.ex | defmodule MapReduce.Slave do
use Matrix.Agent,
state: %{}
require Logger
alias Matrix.{AclMessage, MessageDispatcher, Agents}
def handle_message(message = %AclMessage{performative: :request}, state) do
Logger.warn "Agent: #{state.id.name} received #{message.performative} from #{message.sender}"
... | defmodule MapReduce.Slave do
use Matrix.Agent,
state: %{}
require Logger
alias Matrix.{AclMessage, MessageDispatcher, Agents}
def handle_message(message = %AclMessage{performative: :request}, state) do
Logger.warn "Agent: #{state.id.name} received #{message.performative} from #{message.sender}"
... | Add special characters to regex | Add special characters to regex
| Elixir | mit | nemanja-m/matrix,nemanja-m/matrix |
00a0eb5daf65f7e43341fe6abaca86dd99698358 | lib/slack.ex | lib/slack.ex | require IEx
defmodule Slack do
@moduledoc """
Functions for workig with the Github API
"""
@api_url "https://slack.com/api"
@api_token System.get_env("SLACK_TOKEN")
def add_reaction(%{name: name, channel_id: channel_id, timestamp: timestamp}) do
request = URI.encode_query([
token: @api_token,
... | defmodule Slack do
@moduledoc """
Functions for workig with the Github API
"""
@api_url "https://slack.com/api"
@api_token System.get_env("SLACK_TOKEN")
def add_reaction(%{name: name, channel_id: channel_id, timestamp: timestamp}) do
request = URI.encode_query([
token: @api_token,
name: na... | Remove IEx used for debugging | Remove IEx used for debugging
| Elixir | mit | revelrylabs/slax,revelrylabs/slax,revelrylabs/slax |
e043115be57cc7e5d52ca58231141fafc25b4f96 | lib/poxa/event.ex | lib/poxa/event.ex | defmodule Poxa.Event do
def notify(event, data), do: :gen_event.sync_notify(Poxa.Event, Map.put(data, :event, event))
def add_handler(handler, pid) do
GenEvent.add_mon_handler(Poxa.Event, handler, pid)
end
def remove_handler(handler, pid) do
GenEvent.remove_handler(Poxa.Event, handler, pid)
end
end
| defmodule Poxa.Event do
def notify(event, data), do: GenEvent.sync_notify(Poxa.Event, Map.put(data, :event, event))
def add_handler(handler, pid) do
GenEvent.add_mon_handler(Poxa.Event, handler, pid)
end
def remove_handler(handler, pid) do
GenEvent.remove_handler(Poxa.Event, handler, pid)
end
end
| Change Poxa.Event to use GenEvent everywhere | Change Poxa.Event to use GenEvent everywhere
It was probably due to a bug that :gen_event was being used insted of GenEvent.
There is no need for this anymore
| Elixir | mit | edgurgel/poxa,edgurgel/poxa,edgurgel/poxa |
bcc844b5c187918905c838be1a954423444d9bc1 | lib/annon_api/management_api/config_reloader_plug.ex | lib/annon_api/management_api/config_reloader_plug.ex | defmodule Annon.ManagementAPI.ConfigReloaderPlug do
@moduledoc """
This plugin
[invalidates Annons cache](http://docs.annon.apiary.io/#introduction/general-features/caching-and-perfomance)
whenever there was change triggered by a management API.
"""
alias Annon.AutoClustering
@destructive_methods ["POST"... | defmodule Annon.ManagementAPI.ConfigReloaderPlug do
@moduledoc """
This plugin
[invalidates Annons cache](http://docs.annon.apiary.io/#introduction/general-features/caching-and-perfomance)
whenever there was change triggered by a management API.
"""
alias Annon.AutoClustering
@destructive_methods ["POST"... | Drop cache on delete responses | Drop cache on delete responses
| Elixir | mit | Nebo15/annon.api,Nebo15/annon.api |
16f3bcfc027dca3dc3d62a4bdd170dddeb0463ac | lib/erlef/admins/notifications.ex | lib/erlef/admins/notifications.ex | defmodule Erlef.Admins.Notifications do
@moduledoc false
import Swoosh.Email
@type notification_type() :: :new_email_request
@type params() :: map()
@spec new(notification_type(), params()) :: Swoosh.Email.t()
def new(:new_email_request, _) do
msg = """
A new email request was created. Visit htt... | defmodule Erlef.Admins.Notifications do
@moduledoc false
import Swoosh.Email
@type notification_type() :: :new_email_request
@type params() :: map()
@spec new(notification_type(), params()) :: Swoosh.Email.t()
def new(:new_email_request, _) do
msg = """
A new email request was created. Visit htt... | Remove redundant (overloaded) spec from Admins.notify/2 | Remove redundant (overloaded) spec from Admins.notify/2
| Elixir | apache-2.0 | simplabs/website,simplabs/website |
5a90b032a424be9e9a32aac694cb8454bb0de3b7 | test/features/preexisting_retro_state_rendered_on_joining_retro_test.exs | test/features/preexisting_retro_state_rendered_on_joining_retro_test.exs | defmodule PreExistingRetroStateRenderedOnJoiningRetroTest do
use RemoteRetro.IntegrationCase, async: false
alias RemoteRetro.{Idea, User}
import ShorterMaps
test "the rendering of ideas submitted prior to the user joining", ~M{session, retro} do
user = Repo.get_by(User, email: "mrtestuser@one.com")
Re... | defmodule PreExistingRetroStateRenderedOnJoiningRetroTest do
use RemoteRetro.IntegrationCase, async: false
alias RemoteRetro.{Idea}
import ShorterMaps
test "the rendering of ideas submitted prior to the user joining", ~M{session, retro, facilitator} do
Repo.insert!(%Idea{ category: "happy", body: "continu... | Build enhancement: don't query for user when we already have one available on test context | Build enhancement: don't query for user when we already have one available on test context
| Elixir | mit | stride-nyc/remote_retro,stride-nyc/remote_retro,stride-nyc/remote_retro |
1f8dfb86a1d17401efddec7cbd84bfbbccba3ce6 | lib/credo/check/readability/double_boolean_negation.ex | lib/credo/check/readability/double_boolean_negation.ex | defmodule Credo.Check.Readability.DoubleBooleanNegation do
@moduledoc """
Having double negations in your code reduces readability.
# Double boolean negation:
!!var
# or:
not not var
Using `!!` will be inconsistent for some values like `nil`.
Try to be more explicit for handling boole... | defmodule Credo.Check.Readability.DoubleBooleanNegation do
@moduledoc """
Having double negations in your code reduces readability.
# Double boolean negation:
!!var
# or:
not not var
Using `!!` will be inconsistent for some values like `nil`.
Try to be more explicit for handling boole... | Fix indentation on new check | Fix indentation on new check
| Elixir | mit | rrrene/credo,rrrene/credo |
9e0f7320d10863f2a564b405b85a5ccba823e73f | test/controllers/proposal_controller_test.exs | test/controllers/proposal_controller_test.exs | defmodule TechForGoodHub.ProposalControllerTest do
use TechForGoodHub.ConnCase
alias TechForGoodHub.Proposal
test "lists all entries on index", %{conn: conn} do
conn = get conn, proposal_path(conn, :index)
assert html_response(conn, 200) =~ "Projects"
end
test "shows chosen resource", %{conn: conn}... | defmodule TechForGoodHub.ProposalControllerTest do
use TechForGoodHub.ConnCase
alias TechForGoodHub.Proposal
alias TechForGoodHub.Organisation
test "lists all entries on index", %{conn: conn} do
conn = get conn, proposal_path(conn, :index)
assert html_response(conn, 200) =~ "Projects"
end
test "s... | Add organisation to test model | Add organisation to test model
| Elixir | mit | TechforgoodCAST/tech_for_good_hub_data |
adb6daaccc3cc99b87a22d8bd64ab64a119e67e3 | lib/battleship/game/supervisor.ex | lib/battleship/game/supervisor.ex | defmodule Battleship.Game.Supervisor do
@moduledoc """
Game processes supervisor
"""
use Supervisor
alias Battleship.{Game, Player}
def start_link, do: Supervisor.start_link(__MODULE__, :ok, name: __MODULE__)
def init(:ok) do
children = [
worker(Game, [], restart: :temporary)
]
superv... | defmodule Battleship.Game.Supervisor do
@moduledoc """
Game processes supervisor
"""
use Supervisor
alias Battleship.{Game, Player}
@id_length Application.get_env(:battleship, :id_length)
def start_link, do: Supervisor.start_link(__MODULE__, :ok, name: __MODULE__)
def init(:ok) do
children = [
... | Use env variable for generating ids | Use env variable for generating ids
| Elixir | mit | bigardone/phoenix-battleship,bigardone/phoenix-battleship |
8ab49e4476294c07d7116c73be1dd3c7c76b1d87 | elixir/mix.exs | elixir/mix.exs | defmodule CucumberGherkin.MixProject do
use Mix.Project
@vsn "16.0.0"
@github "https://github.com/cucumber/cucumber/tree/master/gherkin/elixir"
@name "CucumberGherkin"
def project do
[
app: :cucumber_gherkin,
version: @vsn,
name: @name,
description: description(),
package: ... | defmodule CucumberGherkin.MixProject do
use Mix.Project
@vsn "16.0.0"
@github "https://github.com/cucumber/cucumber/tree/master/gherkin/elixir"
@name "CucumberGherkin"
def project do
[
app: :cucumber_gherkin,
version: @vsn,
name: @name,
description: description(),
package: ... | Update dependency cucumber_messages to v14 | Update dependency cucumber_messages to v14
| Elixir | mit | cucumber/gherkin,cucumber/gherkin,cucumber/gherkin,cucumber/gherkin,cucumber/gherkin,cucumber/gherkin,cucumber/gherkin,cucumber/gherkin,cucumber/gherkin,cucumber/gherkin,cucumber/gherkin,cucumber/gherkin |
a8ec1c446e85e21e763f93d26bdddb7e625637d8 | mix.exs | mix.exs | defmodule PlugGraphql.Mixfile do
use Mix.Project
@version "0.0.7"
@description "A Plug integration for the Elixir implementation of Facebook's GraphQL"
@repo_url "https://github.com/joshprice/plug_graphql"
def project do
[app: :plug_graphql,
description: @description,
version: @version,
... | defmodule PlugGraphql.Mixfile do
use Mix.Project
@version "0.0.7"
@description "A Plug integration for the Elixir implementation of Facebook's GraphQL"
@repo_url "https://github.com/joshprice/plug_graphql"
def project do
[app: :plug_graphql,
description: @description,
version: @version,
... | Make doc tasks available in dev env | Make doc tasks available in dev env
| Elixir | bsd-3-clause | joshprice/plug_graphql |
f273f8326c270b9de3434f159bab1698d845c055 | lib/phoenix.ex | lib/phoenix.ex | defmodule Phoenix do
@moduledoc """
This is documentation for the Phoenix project.
By default, Phoenix applications depend on other packages besides
Phoenix itself. Below we provide a short explanation with links to
their documentation for each of those projects:
* [Ecto](http://hexdocs.pm/ecto) - a lan... | defmodule Phoenix do
@moduledoc """
This is documentation for the Phoenix project.
By default, Phoenix applications depend on other packages besides
Phoenix itself. Below we provide a short explanation with links to
their documentation for each of those projects:
* [Ecto](http://hexdocs.pm/ecto) - a lan... | Fix PubSub Redis link in docs | Fix PubSub Redis link in docs | Elixir | mit | bdtomlin/phoenix,stevedomin/phoenix,jasond-s/phoenix,CultivateHQ/phoenix,rodrigues/phoenix,Ben-Evolently/phoenix,ericmj/phoenix,KazuCocoa/phoenix,jwarwick/phoenix,lancehalvorsen/phoenix,cas27/phoenix,seejee/phoenix,lono-devices/phoenix,esbullington/phoenix-1,rafbgarcia/phoenix,kevinold/phoenix,Joe-noh/phoenix,keathley/... |
589095a1637087e4c8dbaa15518e90c64d7eb4a3 | lib/elixir/macros.ex | lib/elixir/macros.ex | ns Elixir::Macros
defmacro unless: [clause, options] do
positive = Erlang.orddict.fetch(:do, options)
negative = Erlang.orddict.fetch(:else, options)
quote(if(unquote(clause), do: unquote(negative), else: unquote(positive)))
end
defmacro &&: [left, right] do
quote(
case unquote(left) do
match: false
... | ns Elixir::Macros
defmacro unless: [clause, options] do
quote(if(!unquote(clause), unquote(options)))
end
defmacro &&: [left, right] do
quote(
case unquote(left) do
match: false
false
match: nil
nil
match: _
unquote(right)
end
)
end
defmacro ||: [left, right] do
quote(
... | Simplify unless macro now that we have "!" | Simplify unless macro now that we have "!"
| Elixir | apache-2.0 | kimshrier/elixir,antipax/elixir,michalmuskala/elixir,gfvcastro/elixir,lexmag/elixir,beedub/elixir,kimshrier/elixir,elixir-lang/elixir,ggcampinho/elixir,pedrosnk/elixir,lexmag/elixir,pedrosnk/elixir,gfvcastro/elixir,ggcampinho/elixir,kelvinst/elixir,joshprice/elixir,antipax/elixir,beedub/elixir,kelvinst/elixir |
666863d3094820e8429c5cea2a91b270f415ab37 | apps/baumeister_web/lib/baumeister_web/web/endpoint.ex | apps/baumeister_web/lib/baumeister_web/web/endpoint.ex | defmodule BaumeisterWeb.Web.Endpoint do
use Phoenix.Endpoint, otp_app: :baumeister_web
socket "/socket", BaumeisterWeb.UserSocket
# Serve at "/" the static files from "priv/static" directory.
#
# You should set gzip to true if you are running phoenix.digest
# when deploying your static files in production... | defmodule BaumeisterWeb.Web.Endpoint do
use Phoenix.Endpoint, otp_app: :baumeister_web
socket "/socket", BaumeisterWeb.Web.UserSocket
# Serve at "/" the static files from "priv/static" directory.
#
# You should set gzip to true if you are running phoenix.digest
# when deploying your static files in produc... | Use new names user socket | Use new names user socket
| Elixir | apache-2.0 | alfert/baumeister,alfert/baumeister,alfert/baumeister |
ed3d05dcbc738ad975f2d162a0100bcab5e52eaf | lib/hound/json_driver/script_execution.ex | lib/hound/json_driver/script_execution.ex | defmodule Hound.JsonDriver.ScriptExecution do
import Hound.JsonDriver.Utils
@doc "Execute javascript synchoronously"
@spec execute_script(String.t, List.t) :: any
def execute_script(script_function, function_args) do
session_id = Hound.get_current_session_id
make_req(:post,
"session/#{session_id}... | defmodule Hound.JsonDriver.ScriptExecution do
import Hound.JsonDriver.Utils
@doc """
Execute javascript synchoronously.
* The first argument is the script to execute.
* The second argument is a list of arguments that is passed.
These arguments are accessible in the script via `arguments`.
"""
@spec ... | Add documentation for script execution | Add documentation for script execution
| Elixir | mit | esbullington/hound,jontonsoup/hound,oivoodoo/hound,HashNuke/hound,knewter/hound,manukall/hound,esbullington/hound,HashNuke/hound,manukall/hound,oivoodoo/hound,lowks/hound,lowks/hound,jontonsoup/hound |
15bb0e9a00a1c6bd924654b0354c05f1bb56a3ed | lib/beebee/router.ex | lib/beebee/router.ex | defmodule BeeBee.Router do
use Plug.Router
alias BeeBee.ShortenedURL
plug Plug.Logger
plug CORSPlug, origins: ["*"]
plug Plug.Parsers, parsers: [:json], json_decoder: Poison
plug :match
plug :dispatch
post "/_add" do
case ShortenedURL.add(conn.params) do
{:ok, short_tag} ->
conn
... | defmodule BeeBee.Router do
use Plug.Router
alias BeeBee.ShortenedURL
plug Plug.Logger
plug CORSPlug
plug Plug.Parsers, parsers: [:json], json_decoder: Poison
plug :match
plug :dispatch
post "/_add" do
case ShortenedURL.add(conn.params) do
{:ok, short_tag} ->
conn
|> put_resp... | Remove double cors accept entry | Remove double cors accept entry | Elixir | mit | system76/beebee |
a0852a51df24fd37a88071ccfff2a489f1e8524c | web/controllers/auth_controller.ex | web/controllers/auth_controller.ex | defmodule MyApp_7191136.AuthController do
use MyApp_7191136.Web, :controller
def index(conn, _params) do
redirect conn, external: "https://www.fitbit.com/oauth2/authorize"
end
end
| defmodule MyApp_7191136.AuthController do
use MyApp_7191136.Web, :controller
def index(conn, _params) do
redirect conn, external: Fitbit.authorize_url!(scope: "settings sleep")
end
end
| Remove hard-coded url and ask the strategy for the authorize url | Remove hard-coded url and ask the strategy for the authorize url
| Elixir | mit | wsmoak/my_app_7191136 |
118b88da3b4a415ac4a588351ec67bebf68f4562 | lib/slax_web/plugs/verify_token.ex | lib/slax_web/plugs/verify_token.ex | defmodule Slax.Plugs.VerifySlackToken do
import Phoenix.Controller, only: [text: 2]
import Plug.Conn, only: [halt: 1]
require Logger
def init(options) do
options
end
def call(%Plug.Conn{params: %{"token" => token}} = conn, app_var: app_var) do
tokens = Application.get_env(:slax, Slax.Slack)[:token... | defmodule Slax.Plugs.VerifySlackToken do
import Phoenix.Controller, only: [text: 2]
import Plug.Conn, only: [halt: 1]
def init(options) do
options
end
def call(%Plug.Conn{params: %{"token" => token}} = conn, app_var: app_var) do
tokens = Application.get_env(:slax, Slax.Slack)[:tokens]
local_toke... | Fix invalid slack token issues | Fix invalid slack token issues
| Elixir | mit | revelrylabs/slax,revelrylabs/slax,revelrylabs/slax |
f035a348456f22082be58a5e4196032b8d0cd5bd | lib/day_05.ex | lib/day_05.ex | defmodule Day0501 do
# slow version (~13 seconds on my laptop), using
# a regexp
def build_regexp() do
?A..?Z
|> Enum.map(&(<<&1, &1 + ?a - ?A>>))
|> Enum.map(&([&1, String.reverse(&1)]))
|> List.flatten
|> Enum.map(&("(#{&1})"))
|> Enum.join("|")
|> Regex.compile!
end
def solve(i... | defmodule Day0501 do
# slow version (~13 seconds on my laptop), using
# a regexp
def build_regexp() do
?A..?Z
|> Enum.map(&(<<&1, &1 + ?a - ?A>>))
|> Enum.map(&([&1, String.reverse(&1)]))
|> List.flatten
|> Enum.map(&("(#{&1})"))
|> Enum.join("|")
|> Regex.compile!
end
def solve(i... | Rework puzzle to allow injection of different computation | Rework puzzle to allow injection of different computation
| Elixir | mit | thbar/elixir-playground |
4cf64a9f552bd58d54ce29eb61697d2e8c03343b | lib/gn_server/headers.ex | lib/gn_server/headers.ex | defmodule GnServers.Headers.CORSRangePlug do
@behaviour Plug
@allowed_methods ~w(GET HEAD)
def init(opts) do
opts
end
def call(conn, _opts) do
if (Enum.empty?(Plug.Conn.get_req_header(conn, "range"))) do
conn
else
case File.stat("." <> conn.request_path) do
{:ok, %{size: size... | defmodule GnServers.Headers.CORSRangePlug do
@behaviour Plug
@allowed_methods ~w(GET HEAD)
def init(opts) do
opts
end
def call(conn, _opts) do
if (Enum.empty?(Plug.Conn.get_req_header(conn, "range"))) do
conn
else
case File.stat("." <> conn.request_path) do
{:ok, %{size: size... | Fix CORS Range header so it's lowercase | Fix CORS Range header so it's lowercase
| Elixir | agpl-3.0 | chfi/gn_server,genenetwork/gn_server |
744537052a8136f9f1aca0cb5283721c36b0d8bb | lib/ex_twilio/resources/dependent_phone_number.ex | lib/ex_twilio/resources/dependent_phone_number.ex | defmodule ExTwilio.DependentPhoneNumber do
@moduledoc """
Represents an DependentPhoneNumber resource in the Twilio API.
- [Twilio docs](https://www.twilio.com/docs/api/rest/dependent-phone-numbers)
## Examples
Since DependentPhoneNumbers are a nested resource in the Twilio API, you must
pass in a parent... | defmodule ExTwilio.DependentPhoneNumber do
@moduledoc """
Represents an DependentPhoneNumber resource in the Twilio API.
- [Twilio docs](https://www.twilio.com/docs/usage/api/address#list-dependent-pns)
## Examples
Since DependentPhoneNumbers are a nested resource in the Twilio API, you must
pass in a pa... | Update broken link to DependentPhoneNumber API | Update broken link to DependentPhoneNumber API
| Elixir | mit | danielberkompas/ex_twilio,danielberkompas/ex_twilio |
8c52d308768ae043d35a81b804d87b8842286704 | test/serum/inspect_test.exs | test/serum/inspect_test.exs | defmodule InspectTest do
use ExUnit.Case, async: true
test "inspect tag" do
tag = %Serum.Tag{name: "test-tag", list_url: "/test/tags/test-tag/"}
expected = "#Serum.Tag<\"test-tag\": \"/test/tags/test-tag/\">"
assert expected == inspect tag
end
test "inspect postinfo" do
info = %Serum.PostInfo{... | defmodule InspectTest do
use ExUnit.Case, async: true
test "inspect tag" do
tag = %Serum.Tag{name: "test-tag", list_url: "/test/tags/test-tag/"}
expected = "#Serum.Tag<\"test-tag\": \"/test/tags/test-tag/\">"
assert expected == inspect tag
end
test "inspect postinfo" do
info = %Serum.PostInfo{... | Write a test for Inspect | Write a test for Inspect
| Elixir | mit | Dalgona/Serum |
84a54f8ed40207368376979ec82120b6f3764af3 | web/router.ex | web/router.ex | defmodule MyApp_808732.Router do
use MyApp_808732.Web, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/", MyApp_808732 do... | defmodule MyApp_808732.Router do
use MyApp_808732.Web, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/", MyApp_808732 do... | Add users resources to browser scope | Add users resources to browser scope
| Elixir | mit | wsmoak/my_app_808732 |
96c93e56d01218ca71477bee0b9052feec75f01a | web/router.ex | web/router.ex | defmodule HelloPhoenix.Router do
use HelloPhoenix.Web, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/", HelloPhoenix do... | defmodule HelloPhoenix.Router do
use HelloPhoenix.Web, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/", HelloPhoenix do... | Add Users resource to browser scope | Add Users resource to browser scope
| Elixir | mit | victusfate/hello_phoenix |
51c24ea0835173a81c2935fa92eeaa10dfb14444 | test/crypto_helper_test.exs | test/crypto_helper_test.exs | defmodule Poxa.AuthenticationTest do
use ExUnit.Case
import Poxa.CryptoHelper
test "hmac256_to_string" do
assert hmac256_to_string("7ad3773142a6692b25b8", "1234.1234:private-foobar") == "58df8b0c36d6982b82c3ecf6b4662e34fe8c25bba48f5369f135bf843651c3a4"
end
test "md5_to_string" do
assert md5_to_strin... | defmodule Poxa.CryptoHelperTest do
use ExUnit.Case
import Poxa.CryptoHelper
test "hmac256_to_string" do
assert hmac256_to_string("7ad3773142a6692b25b8", "1234.1234:private-foobar") == "58df8b0c36d6982b82c3ecf6b4662e34fe8c25bba48f5369f135bf843651c3a4"
end
test "md5_to_string" do
assert md5_to_string(... | Fix copy and wrong paste | Fix copy and wrong paste
| Elixir | mit | RobertoSchneiders/poxa,joshk/poxa,joshk/poxa,theinventor/rs-poxa,edgurgel/poxa,waffleio/poxa,edgurgel/poxa,waffleio/poxa,RobertoSchneiders/poxa,edgurgel/poxa |
81073f1a3bde714aa854436426f7688806450986 | lib/web/gettext.ex | lib/web/gettext.ex | defmodule BorsNG.Gettext do
@moduledoc """
A module providing Internationalization with a gettext-based API.
By using [Gettext](https://hexdocs.pm/gettext),
your module gains a set of macros for translations, for example:
import BorsNG.Gettext
# Simple translation
gettext "Here is the strin... | defmodule BorsNG.Gettext do
@moduledoc """
A module providing Internationalization with a gettext-based API.
By using [Gettext](https://hexdocs.pm/gettext),
your module gains a set of macros for translations, for example:
import BorsNG.Gettext
# Simple translation
gettext "Here is the strin... | Remove no-longer-existing functions from Gettext allow list | Remove no-longer-existing functions from Gettext allow list
| Elixir | apache-2.0 | bors-ng/bors-ng,bors-ng/bors-ng,bors-ng/bors-ng |
70ba8464c9fb2745aaeb0f53783c1361b8db982e | lib/mix/lib/mix/tasks/do.ex | lib/mix/lib/mix/tasks/do.ex | defmodule Mix.Tasks.Do do
use Mix.Task
@shortdoc "Executes the tasks separated by comma"
@moduledoc """
Executes the tasks separated by comma.
## Examples
The example below prints the available compilers and
then the list of dependencies.
mix do compile --list, deps
"""
@spec run(OptionPa... | defmodule Mix.Tasks.Do do
use Mix.Task
@shortdoc "Executes the tasks separated by comma"
@moduledoc """
Executes the tasks separated by comma.
## Examples
The example below prints the available compilers and
then the list of dependencies.
mix do compile --list, deps
"""
@spec run(OptionPa... | Split command in 2 and put it back in the traversing list | Split command in 2 and put it back in the traversing list
| Elixir | apache-2.0 | gfvcastro/elixir,ggcampinho/elixir,pedrosnk/elixir,elixir-lang/elixir,lexmag/elixir,beedub/elixir,michalmuskala/elixir,lexmag/elixir,joshprice/elixir,antipax/elixir,kelvinst/elixir,ggcampinho/elixir,pedrosnk/elixir,kelvinst/elixir,kimshrier/elixir,antipax/elixir,beedub/elixir,kimshrier/elixir,gfvcastro/elixir |
67deceb9785a72afb39c3942634a1361931e80c5 | lib/mix/tasks/build_json.ex | lib/mix/tasks/build_json.ex | defmodule Mix.Tasks.BuildJson do
# Compiles the CSVs into a usable JSON file.
@moduledoc false
use Mix.Task
def run(_) do
all_subdivisions =
File.stream!(csv("subdivision-names.csv"))
|> CSV.decode!(strip_fields: true)
|> Enum.to_list()
File.stream!(csv("country-codes.csv"))
|> ... | defmodule Mix.Tasks.BuildJson do
# Compiles the CSVs into a usable JSON file.
@moduledoc false
use Mix.Task
def run(_) do
all_subdivisions =
File.stream!(csv("subdivision-names.csv"))
|> CSV.decode!(strip_fields: true)
|> Enum.to_list()
File.stream!(csv("country-codes.csv"))
|> ... | Include short name and full name in ISO data | Include short name and full name in ISO data
| Elixir | mit | whitepaperclip/shippex |
b7810ae58d85ecf2d3988815f77749e5c344fbef | lib/jumubase_web/views/error_view.ex | lib/jumubase_web/views/error_view.ex | defmodule JumubaseWeb.ErrorView do
use JumubaseWeb, :view
def render("404.html", assigns) do
render_error_layout(
assigns,
dgettext("errors", "The page was not found."),
dgettext("errors", "Maybe try one of the links above?")
)
end
def render("500.html", assigns) do
render_error_... | defmodule JumubaseWeb.ErrorView do
use JumubaseWeb, :view
alias JumubaseWeb.LayoutView
def render("404.html", assigns) do
render_error_layout(
assigns,
dgettext("errors", "The page was not found."),
dgettext("errors", "Maybe try one of the links above?")
)
end
def render("500.html"... | Use root layout to render errors | Use root layout to render errors
This is a bit risky as it can lead to recursion (if the layout itself contains errors), but looks a lot better to the user when hitting a 404.
| Elixir | mit | richeterre/jumubase-phoenix,richeterre/jumubase-phoenix |
3fca4874bc9393c240b2b3f4a3732be9ec478598 | web/controllers/twitter_controller.ex | web/controllers/twitter_controller.ex | defmodule TwitterGrapher.TwitterController do
use TwitterGrapher.Web, :controller
def new(conn, _params) do
render conn, "new.html"
end
def create(conn, %{"screen_name" => screen_name}) do
user = Twitter.UserRetriever.user(screen_name)
followers = Twitter.FollowerRetriever.followers(screen_name)
... | defmodule TwitterGrapher.TwitterController do
use TwitterGrapher.Web, :controller
def new(conn, _params) do
render conn, "new.html"
end
def create(conn, %{"screen_name" => screen_name}) do
user = Twitter.UserRetriever.user(screen_name)
followers = Twitter.FollowerRetriever.followers(screen_name)
... | Use update_relationship instead of query builder | Use update_relationship instead of query builder
| Elixir | mit | obahareth/twitter-relations-grapher,obahareth/twitter-relations-grapher |
2674f597f3c2a7e9b2e30edf4daff7c518ffb6ad | apps/ello_events/lib/ello_events/mark_notifications_as_read.ex | apps/ello_events/lib/ello_events/mark_notifications_as_read.ex | defmodule Ello.Events.MarkNotificationsAsRead do
use Ello.Events.Sidekiq
defstruct [
user_id: nil,
last_notification_time: 0,
]
def args(struct) do
[
user: struct.user_id,
last_notification_time: struct.last_notification_time,
]
end
end
| defmodule Ello.Events.MarkNotificationsAsRead do
use Ello.Events.Sidekiq
defstruct [
user_id: nil,
last_notification_time: 0,
]
def args(struct) do
[
%{
user: struct.user_id,
last_notification_time: struct.last_notification_time,
}
]
end
end
| Fix marking notifications as read take 2. | Fix marking notifications as read take 2.
| Elixir | mit | ello/apex,ello/apex,ello/apex |
6ccad1eb9d8e779d92517ac642dc0c8e4c899d49 | lib/web/views/api/room_view.ex | lib/web/views/api/room_view.ex | defmodule Web.API.RoomView do
use Web, :view
alias Web.Endpoint
alias Web.API.Link
def render("index.json", %{pagination: pagination, rooms: rooms, zone: zone}) do
%{
items: render_many(rooms, __MODULE__, "show.json"),
links: [
%Link{
rel: :self,
href: Routes.api_zo... | defmodule Web.API.RoomView do
use Web, :view
alias Web.Endpoint
alias Web.API.Link
def render("index.json", %{pagination: pagination, rooms: rooms, zone: zone}) do
%{
items: render_many(rooms, __MODULE__, "show.json"),
links: [
%Link{
rel: :self,
href: Routes.api_zo... | Add description to the room response | Add description to the room response
| Elixir | mit | oestrich/ex_venture,oestrich/ex_venture,oestrich/ex_venture |
beb1798ae2b93c0047d1d169eca1c926f89385bd | web/routers/river_router.ex | web/routers/river_router.ex | defmodule RiverRouter do
use Dynamo.Router
filter EventStreamHeader
filter TokenFilter
get "/" do
{:ok, _transistor} = Funnel.Transistors.add conn.params[:token]
conn = conn.send_chunked(200)
conn = Funnel.Transistor.add(conn, conn.params[:token], conn.params[:last_id])
await(conn, &on_wake_up(... | defmodule RiverRouter do
use Dynamo.Router
filter EventStreamHeader
filter TokenFilter
get "/" do
{:ok, _transistor} = Funnel.Transistors.add conn.assigns[:token]
conn = conn.send_chunked(200)
conn = Funnel.Transistor.add(conn, conn.assigns[:token], conn.params[:last_id])
await(conn, &on_wake_u... | Fix Authorization header for `/river` | Fix Authorization header for `/river`
Signed-off-by: chatgris <f9469d12bf3d131e7aae80be27ccfe58aa9db1f1@af83.com>
| Elixir | mit | chatgris/funnel |
742fcfacaf2c6ac771caabfe502fec1b8eafae40 | mix.exs | mix.exs | defmodule BencheeJSON.Mixfile do
use Mix.Project
def project do
[app: :benchee_json,
version: "0.1.0",
elixir: "~> 1.2",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps()]
end
def application do
[applications: [:logger]]
end
defp deps do
... | defmodule BencheeJSON.Mixfile do
use Mix.Project
@version "0.1.0"
def project do
[
app: :benchee_json,
version: @version,
elixir: "~> 1.2",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps(),
docs: [source_ref: @version],
package:... | Package updates to make ready for publishing | Package updates to make ready for publishing
| Elixir | mit | PragTob/benchee_json |
fe0115dcdbbad9ec83f468a721207addd3ad9944 | config/config.exs | config/config.exs | use Mix.Config
secrets_file = Path.expand(Path.join(__DIR__, "secrets.exs"))
if Mix.env() in [:dev, :test] and File.regular?(secrets_file) do
import_config secrets_file # For development of this library.
end
# These are configs for development/test/example
config :hipchat_elixir, [
# Set request body serializer m... | use Mix.Config
# These are configs for development/test/example
config :hipchat_elixir, [
# Set request body serializer module. Currently only accepts `Poison` or `:form`.
# If `:form`, it tries to send requests with `content-type: x-www-form-urlencoded` (Note that some HipChat APIs might reject them).
# Otherwi... | Drop secrets.exs import; just use env vars for dev | [master] Drop secrets.exs import; just use env vars for dev
| Elixir | mit | ymtszw/hipchat_elixir |
d4eb7efecf6a550d56a1589ec67271dbbeec717d | web/views/annotation_view.ex | web/views/annotation_view.ex | defmodule Core.AnnotationView do
use Core.Web, :view
def render("index.json", %{annotations: annotations}) do
render_many(annotations, Core.AnnotationView, "annotation.json")
end
def render("show.json", %{annotation: annotation}) do
render_one(annotation, Core.AnnotationView, "annotation.json")
end
... | defmodule Core.AnnotationView do
use Core.Web, :view
def render("index.json", %{annotations: annotations}) do
render_many(annotations, Core.AnnotationView, "summary.json")
end
def render("show.json", %{annotation: annotation}) do
render_one(annotation, Core.AnnotationView, "annotation.json")
end
... | Add "summary.json" in Annotation View | Add "summary.json" in Annotation View
| Elixir | mit | exacs/liqen-core,exacs/liqen-core |
556c75ac82516692053f2f1950b952b89de69168 | mix.exs | mix.exs | defmodule PlugGraphql.Mixfile do
use Mix.Project
def project do
[app: :plug_graphql,
version: "0.0.1",
elixir: "~> 1.1",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps]
end
# Configuration for the OTP application
#
# Type "mix help compile.app"... | defmodule PlugGraphql.Mixfile do
use Mix.Project
def project do
[app: :plug_graphql,
version: "0.0.1",
elixir: "~> 1.1",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps]
end
# Configuration for the OTP application
#
# Type "mix help compile.app"... | Update graphql dep to 0.0.4 | Update graphql dep to 0.0.4
| Elixir | bsd-3-clause | joshprice/plug_graphql |
3fd16c531c60acfb82ae6b0a1385c405377b60ba | mix.exs | mix.exs | defmodule Benchfella.Mixfile do
use Mix.Project
def project do
[app: :benchfella,
version: "0.0.2",
elixir: "~> 0.15"]
end
def application do
[applications: []]
end
# no deps
# --alco
end
| defmodule Benchfella.Mixfile do
use Mix.Project
def project do
[app: :benchfella,
version: "0.0.2",
elixir: ">= 0.15.0 and < 2.0.0"]
end
def application do
[applications: []]
end
# no deps
# --alco
end
| Update Elixir version req to support 1.x | Update Elixir version req to support 1.x | Elixir | mit | alco/benchfella,alco/benchfella,rossjones/benchfella,lexmag/benchfella |
cce746795625eac178a3840e4451cfebd3203b7d | lib/myhtmlex/safe.ex | lib/myhtmlex/safe.ex | defmodule Myhtmlex.Safe do
@moduledoc false
use Application
app = Mix.Project.config[:app]
def start(_type, _args) do
import Supervisor.Spec
unless Node.alive? do
Nodex.Distributed.up
end
myhtml_worker = Path.join(:code.priv_dir(unquote(app)), "myhtml_worker")
children = [
wor... | defmodule Myhtmlex.Safe do
@moduledoc false
use Application
app = Mix.Project.config[:app]
defp random_sname, do: :crypto.strong_rand_bytes(4) |> Base.encode16(case: :lower)
defp sname, do: :"myhtmlex_#{random_sname()}"
def start(_type, _args) do
import Supervisor.Spec
unless Node.alive? do
... | Use an identifiable prefix for snames | cnode: Use an identifiable prefix for snames
Swarm tries to include the cnode into the hash ring and fails,
interfering with the application startup. The solution is to give these
nodes indentifiable snames, so they can be blacklisted from the Swarm
hash ring.
| Elixir | lgpl-2.1 | Overbryd/myhtmlex,Overbryd/myhtmlex,Overbryd/myhtmlex |
0f5cc5e0e608d2200cee4ac8223d31c8b73d802d | lib/farmbot/celery_script/ast/node/factory_reset.ex | lib/farmbot/celery_script/ast/node/factory_reset.ex | defmodule Farmbot.CeleryScript.AST.Node.FactoryReset do
@moduledoc false
use Farmbot.CeleryScript.AST.Node
allow_args [:package]
use Farmbot.Logger
def execute(%{package: :farmbot_os}, _, env) do
env = mutate_env(env)
Farmbot.BotState.set_sync_status(:maintenance)
Farmbot.BotState.force_state_pus... | defmodule Farmbot.CeleryScript.AST.Node.FactoryReset do
@moduledoc false
use Farmbot.CeleryScript.AST.Node
allow_args [:package]
use Farmbot.Logger
def execute(%{package: :farmbot_os}, _, env) do
env = mutate_env(env)
Farmbot.BotState.set_sync_status(:maintenance)
Farmbot.BotState.force_state_pus... | Speed up factory resetting of fw params | Speed up factory resetting of fw params
| Elixir | mit | FarmBot/farmbot_os,FarmBot/farmbot_os,FarmBot/farmbot_os,FarmBot/farmbot_os |
75967e210931bb35585f01a24b98fe08aad340a2 | test/routers/register_router_test.exs | test/routers/register_router_test.exs | defmodule ReisterRouterTest do
use Funnel.TestCase, async: true
use Dynamo.HTTP.Case
@endpoint RegisterRouter
test "returns 201" do
conn = post("/")
assert conn.status == 201
end
test "returns json" do
conn = post("/")
assert conn.resp_headers["Content-Type"] == "application/json"
end
... | defmodule RegisterRouterTest do
use Funnel.TestCase, async: true
use Dynamo.HTTP.Case
@endpoint RegisterRouter
test "returns 201" do
conn = post("/")
assert conn.status == 201
end
test "returns json" do
conn = post("/")
assert conn.resp_headers["Content-Type"] == "application/json"
end
... | Fix a typo in tests. | Fix a typo in tests.
Signed-off-by: François de Metz <5187da0b934cc25eb2201a3ec9206c24b13cb23b@stormz.me>
| Elixir | mit | chatgris/funnel |
71c70e5ee02d67868557fe46d0ff2382516e3baf | lib/isbndbex.ex | lib/isbndbex.ex | defmodule Isbndbex do
use GenServer
alias Isbndbex.Api, as: Api
def start(key) do
GenServer.start_link(__MODULE__, key)
end
def get_book(pid, id) do
GenServer.call(pid, {:get_book, id})
end
def handle_call({:get_book, id}, _, key) do
{:reply, Api.get_book(key, id), key}
end
end
| defmodule Isbndbex do
use GenServer
alias Isbndbex.Api, as: Api
def start(key), do: GenServer.start_link(__MODULE__, key)
def get_book(pid, id) , do: GenServer.call(pid, {:get_book , id})
def get_author(pid, id) , do: GenServer.call(pid, {:get_author , id})
def get_publisher(pid, id), do: Gen... | Add more api methods to the Isbndbex server | Add more api methods to the Isbndbex server
| Elixir | mit | rcoedo/isbndbex |
18578edb55761559ff4dd432dda4f25488593a84 | web/controllers/api/developer_post_controller.ex | web/controllers/api/developer_post_controller.ex | defmodule Tilex.Api.DeveloperPostController do
use Tilex.Web, :controller
alias Tilex.Post
def index(conn, params) do
posts = Tilex.Posts.by_developer(params["username"], limit: 3)
render conn, "index.json", posts: posts
end
end
| defmodule Tilex.Api.DeveloperPostController do
use Tilex.Web, :controller
def index(conn, params) do
posts = Tilex.Posts.by_developer(params["username"], limit: 3)
render conn, "index.json", posts: posts
end
end
| Remove unused Post alias from api developer post controller | Remove unused Post alias from api developer post controller
| Elixir | mit | hashrocket/tilex,hashrocket/tilex,hashrocket/tilex |
c25cd0dd6b10ea9dbddac62902be2b2f8c5eb1af | lib/atom_tweaks_web/views/error_view.ex | lib/atom_tweaks_web/views/error_view.ex | defmodule AtomTweaksWeb.ErrorView do
@doc """
View functions for HTTP error states.
"""
use AtomTweaksWeb, :view
@doc """
Renders the page for the given template.
Since we don't have fancy error pages yet, we're just rendering the text of the status code.
"""
def render("400.html", _assigns), do: "B... | defmodule AtomTweaksWeb.ErrorView do
@doc """
View functions for HTTP error states.
"""
use AtomTweaksWeb, :view
require Logger
@doc """
Renders the page for the given template.
Since we don't have fancy error pages yet, we're just rendering the text of the status code.
"""
def render("400.html",... | Add logging for when a template isn't found | Add logging for when a template isn't found
| Elixir | mit | lee-dohm/atom-style-tweaks,lee-dohm/atom-style-tweaks,lee-dohm/atom-style-tweaks,lee-dohm/atom-style-tweaks |
33168d61f126e26079a076dbe4247f58499c8ff1 | lib/pixie/extensions/debug_extension.ex | lib/pixie/extensions/debug_extension.ex | defmodule Pixie.DebugExtension do
use Pixie.Extension
require Logger
def incoming event do
Logger.debug "#{inspect __MODULE__}.incoming: #{inspect event}"
event
end
def outgoing message do
Logger.debug "#{inspect __MODULE__}.outgoing: #{inspect message}"
message
end
end
| defmodule Pixie.DebugExtension do
use Pixie.Extension
require Logger
@moduledoc """
Use this extension for debugging only - it logs every event to `Logger`
which has the unfortunate side effect of exploding your VM when there's
logs of traffic.
"""
def incoming event do
Logger.debug "#{inspect __M... | Add moduledoc for debug extension. | Add moduledoc for debug extension.
| Elixir | mit | messagerocket/pixie,messagerocket/pixie |
10e5f5dac06064dfd7bf67b20e7057727b1f1f6e | apps/genomu/test/watcher_test.exs | apps/genomu/test/watcher_test.exs | Code.require_file "../test_helper.exs", __FILE__
defmodule Genomu.WatcherTest do
use Genomu.TestCase
alias Genomu.Client, as: C
alias Genomu.API, as: API
setup_all do
start_db
{:ok, [conn: connection]}
end
teardown_all do
stop_db
end
test "notifications for single-key transactions", con... | Code.require_file "../test_helper.exs", __FILE__
defmodule Genomu.WatcherTest do
use Genomu.TestCase
alias Genomu.Client, as: C
alias Genomu.API, as: API
setup_all do
start_db
{:ok, [conn: connection]}
end
teardown_all do
stop_db
end
test "notifications for single-key transactions", con... | Add a multi-key transaction test for watchers | Add a multi-key transaction test for watchers
| Elixir | apache-2.0 | genomu/genomu,genomu/genomu |
131023cfebe1efd6860c714d7b8301a00fb2d0ac | web/router.ex | web/router.ex | defmodule MyApp_802337.Router do
use MyApp_802337.Web, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/", MyApp_802337 do
pipe_through :browser # Use the ... | defmodule MyApp_802337.Router do
use MyApp_802337.Web, :router
pipeline :before do
plug TrailingFormatPlug
end
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
end
pipeline :api do
plug :accepts, ["json"]
end
scope ... | Introduce :before pipeline and the trailing_format_plug | Introduce :before pipeline and the trailing_format_plug
| Elixir | mit | wsmoak/my_app_802337 |
a8e8c97f646cf3a29722e587b9b7698b672ac705 | web/models/auth_handler.ex | web/models/auth_handler.ex | defmodule EspiDni.AuthHandler do
@moduledoc """
Create or retreive the team and user from an auth request
"""
alias Ueberauth.Auth
alias EspiDni.TeamFromAuth
alias EspiDni.UserFromAuth
def init_from_auth(%Auth{} = auth) do
with {:ok, team} <- TeamFromAuth.find_or_create(auth),
{:ok, user} <... | defmodule EspiDni.AuthHandler do
@moduledoc """
Create or retreive the team and user from an auth request
"""
alias Ueberauth.Auth
alias EspiDni.TeamFromAuth
alias EspiDni.UserFromAuth
def init_from_auth(%Auth{} = auth) do
with {:ok, team} <- TeamFromAuth.find_or_create(auth),
{:ok, user} <... | Send welcome message once user and team are added | Send welcome message once user and team are added
| Elixir | mit | edenspiekermann/espi-dni,edenspiekermann/espi-dni |
bc46f431f301c2ccd7f8cc5aaa8009d640135f98 | lib/ex_money.ex | lib/ex_money.ex | defmodule ExMoney do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
:ets.new(:ex_money_cache, [:set, :public, :named_table])
children = [
supervisor(ExMoney.Endpoint, []),
worker(ExMoney.Repo, []),
worker(ExMoney.Saltedge.TransactionsWorker, []),
... | defmodule ExMoney do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
:ets.new(:ex_money_cache, [:set, :public, :named_table])
children = [
supervisor(ExMoney.Endpoint, []),
worker(ExMoney.Repo, []),
worker(ExMoney.Saltedge.TransactionsWorker, []),
... | Bring back login refresh worker | Bring back login refresh worker
| Elixir | isc | gaynetdinov/ex_money,gaynetdinov/ex_money |
e0eca16ee1338e7026559543f944f4ab0696db55 | test/credo/check/warning/operation_on_same_values_test.exs | test/credo/check/warning/operation_on_same_values_test.exs | defmodule Credo.Check.Warning.OperationOnSameValuesTest do
use Credo.TestHelper
@described_check Credo.Check.Warning.OperationOnSameValues
test "it should NOT report expected code" do
"""
defmodule CredoSampleModule do
use ExUnit.Case
def some_fun do
assert x == x + 2
2 - 2+3
end
end
""" |> to_so... | defmodule Credo.Check.Warning.OperationOnSameValuesTest do
use Credo.TestHelper
@described_check Credo.Check.Warning.OperationOnSameValues
test "it should NOT report expected code" do
"""
defmodule CredoSampleModule do
use ExUnit.Case
def some_fun do
assert x == x + 2
end
end
""" |> to_source_file
... | Update OperationOnSameValuesTest to allow new case | Update OperationOnSameValuesTest to allow new case
As discussed in #218. Moving this case down to expected warning assertion
| Elixir | mit | rrrene/credo,rrrene/credo |
66f09e47458754ed1b2fa3a4568f596964ceff12 | web/models/league.ex | web/models/league.ex | defmodule Officetournament.League do
use Officetournament.Web, :model
schema "leagues" do
field :name, :string
timestamps
end
@required_fields ~w(name)
@optional_fields ~w()
@doc """
Creates a changeset based on the `model` and `params`.
If no params are provided, an invalid changeset is re... | defmodule Officetournament.League do
use Officetournament.Web, :model
schema "leagues" do
field :name, :string
has_many :memberships, Officetournament.Membership
timestamps
end
@required_fields ~w(name)
@optional_fields ~w()
@doc """
Creates a changeset based on the `model` and `params`.
... | Add has_many memberships for League | Add has_many memberships for League
| Elixir | mit | X0nic/officetournament,X0nic/officetournament |
f3a592e5fa7305b6fb0af2a463953c36a336fd8e | lib/not_found.ex | lib/not_found.ex | defmodule Trot.NotFound do
@moduledoc """
Plug for inserting a 404 not found response.
Use this module or plug it in at the end of the plug system. If the connection
has not been sent yet, it will be set to 404 with a not found message.
## Example
defmodule WhereIsIt.Router do
use Trot.Router
... | defmodule Trot.NotFound do
@moduledoc """
Plug for inserting a 404 not found response.
Use this module or plug it in at the end of the plug system. If the connection
has not been sent yet, it will be set to 404 with a not found message.
## Example
defmodule WhereIsIt.Router do
use Trot.Router
... | Add match funciton to NotFound module so it can be used with import_routes. | Add match funciton to NotFound module so it can be used with import_routes.
| Elixir | apache-2.0 | hexedpackets/trot |
de3d7ee46f313783b67119476e0f7050567a4b01 | mm/factorial.exs | mm/factorial.exs | defmodule Factorial do
def of(0), do: 1
def of(n), do: n * of(n-1)
end
| defmodule Factorial do
def of(0), do: 1
def of(n) when n > 0 do
n * of(n-1)
end
end
| Improve Factorial with guard clause | Improve Factorial with guard clause | Elixir | mit | gshaw/elixir |
9fd64246c9ffb1ebd77b1942e6dc91397ac57cf2 | apps/ello_v2/web/controllers/artist_invite_controller.ex | apps/ello_v2/web/controllers/artist_invite_controller.ex | defmodule Ello.V2.ArtistInviteController do
use Ello.V2.Web, :controller
alias Ello.Core.Contest
@doc """
GET /v2/artist_invites
"""
def index(conn, params) do
artist_invites = Contest.artist_invites(standard_params(conn, %{
preview: params["preview"]
}))
conn
|> add_pagination_header... | defmodule Ello.V2.ArtistInviteController do
use Ello.V2.Web, :controller
alias Ello.Core.Contest
@doc """
GET /v2/artist_invites
"""
def index(conn, params) do
artist_invites = Contest.artist_invites(standard_params(conn, %{
preview: params["preview"],
default: %{per_page: 20},
}))
... | Make artist invite pagination even. | Make artist invite pagination even.
| Elixir | mit | ello/apex,ello/apex,ello/apex |
841957a0d57bed89f8ade74b1b52a25758ee3abf | config/config.exs | config/config.exs | # This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.
use Mix.Config
# General application configuration
config :elixir_jobs,
ecto_repos: [ElixirJobs.Re... | # This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.
use Mix.Config
# General application configuration
config :elixir_jobs,
ecto_repos: [ElixirJobs.Re... | Add phoenix hooks for Appsignal | Add phoenix hooks for Appsignal
| Elixir | mit | odarriba/elixir_jobs,odarriba/elixir_jobs |
694342dc3987d04314280a091ece639de195cee7 | lib/rapport/report.ex | lib/rapport/report.ex | defmodule Rapport.Report do
defstruct paper_size: nil,
rotation: nil,
title: nil,
pages: nil,
template: nil,
padding: nil,
fields: nil,
page_number_opts: nil
end
| defmodule Rapport.Report do
defstruct paper_size: nil,
rotation: nil,
title: nil,
pages: nil,
template: nil,
padding: nil,
fields: nil,
page_number_opts: nil
@type t :: %Rapport.Report{
paper_size: :A4 | :A3 | :A5 | :half... | Add typespec for Report struct. | Add typespec for Report struct.
| Elixir | mit | ricn/rapport |
a13c2265643c25212c6112e7d147265d2ef19b15 | lib/sqlite_db_connection/error.ex | lib/sqlite_db_connection/error.ex | defmodule Sqlite.DbConnection.Error do
defexception [:message, :sqlite, :postgres]
# TODO: Retrofit to actual SQLite error schema.
@nonposix_errors [:closed, :timeout]
def message(e) do
if kw = e.postgres do
"#{kw[:severity]} (#{kw[:code]}): #{kw[:message]}"
else
e.message
end
end
... | defmodule Sqlite.DbConnection.Error do
defexception [:message, :sqlite, :postgres]
# TODO: Retrofit to actual SQLite error schema.
def message(e) do
if kw = e.postgres do
"#{kw[:severity]} (#{kw[:code]}): #{kw[:message]}"
else
e.message
end
end
def exception([postgres: fields]) do
... | Remove support for tagged exceptions. Not likely to be relevant for SQLite. | Remove support for tagged exceptions. Not likely to be relevant for SQLite.
| Elixir | mit | scouten/sqlite_ecto2 |
fa1596ab975c18fb0ae4941a9696818b619daa69 | mix.exs | mix.exs | defmodule Baumeister.Mixfile do
use Mix.Project
def project do
[apps_path: "apps",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps]
end
# Dependencies can be Hex packages:
#
# {:mydep, "~> 0.3.0"}
#
# Or git/path repositories:
#
# {:mydep, git... | defmodule BaumeisterUmbrella.Mixfile do
use Mix.Project
def project do
[apps_path: "apps",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps]
end
# Dependencies can be Hex packages:
#
# {:mydep, "~> 0.3.0"}
#
# Or git/path repositories:
#
# {:my... | Set the module name correct. | Set the module name correct.
| Elixir | apache-2.0 | alfert/baumeister,alfert/baumeister,alfert/baumeister |
8c94ccb7b5a5e3f7f55f3f8809bf9b7dd5b39b55 | lib/farmbot/celery_script/ast/node/toggle_pin.ex | lib/farmbot/celery_script/ast/node/toggle_pin.ex | defmodule Farmbot.CeleryScript.AST.Node.TogglePin do
@moduledoc false
use Farmbot.CeleryScript.AST.Node
alias Farmbot.CeleryScript.AST.Node
allow_args [:pin_number]
use Farmbot.Logger
def execute(%{pin_number: num}, _, env) do
env = mutate_env(env)
case Farmbot.BotState.get_pin_value(num) do
... | defmodule Farmbot.CeleryScript.AST.Node.TogglePin do
@moduledoc false
use Farmbot.CeleryScript.AST.Node
alias Farmbot.CeleryScript.AST.Node
allow_args [:pin_number]
use Farmbot.Logger
def execute(%{pin_number: num}, _, env) do
env = mutate_env(env)
case Farmbot.BotState.get_pin_value(num) do
... | Clean that up a bit. | Clean that up a bit.
| Elixir | mit | FarmBot/farmbot_os,FarmBot/farmbot_os,FarmBot/farmbot_os,FarmBot/farmbot_os |
0c060c1c3bf65cf08296557330a87c82c974430d | cards/lib/cards.ex | cards/lib/cards.ex | defmodule Cards do
@moduledoc """
Documentation for Cards.
"""
@doc """
Hello world.
## Examples
iex> Cards.hello
:world
"""
def hello do
:world
end
end
| defmodule Cards do
@doc "Hello method"
def hello do
"Hello!"
end
@doc "Array method"
def create_deck do
["Ace", "Two", "Three"]
end
@doc "Shuffle use the enum, your function shuffle is equal a Ramdom"
def shuffle(deck) do
Enum.shuffle(deck)
end
end
| Add shuffle method - Enum | Add shuffle method - Enum
| Elixir | mit | Alberto19/elixir,Alberto19/elixir |
8abfc6abae58a0745d419de6e155fe22480421b3 | lib/appsignal/demo.ex | lib/appsignal/demo.ex | defmodule TestError do
defexception message: "Hello world! This is an error used for demonstration purposes."
end
defmodule Appsignal.Demo do
import Appsignal, only: [instrument: 2]
@tracer Application.get_env(:appsignal, :appsignal_tracer, Appsignal.Tracer)
@span Application.get_env(:appsignal, :appsignal_spa... | defmodule TestError do
defexception message: "Hello world! This is an error used for demonstration purposes."
end
defmodule Appsignal.Demo do
import Appsignal, only: [instrument: 2]
@tracer Application.get_env(:appsignal, :appsignal_tracer, Appsignal.Tracer)
@span Application.get_env(:appsignal, :appsignal_spa... | Remove parens from function definitions without arguments in Appsignal.Demo | Remove parens from function definitions without arguments in Appsignal.Demo
| Elixir | mit | appsignal/appsignal-elixir,appsignal/appsignal-elixir,appsignal/appsignal-elixir,appsignal/appsignal-elixir |
8020c0c2135a15bc21b85080ce254106bdda7368 | web/models/google_auth_handler.ex | web/models/google_auth_handler.ex | defmodule EspiDni.GoogleAuthHandler do
@expected_param_count 3
@moduledoc """
Upadte a team with goole credentials from auth response
"""
alias EspiDni.Team
alias EspiDni.Repo
use Timex
def update_from_auth(team, %{credentials: credentials}) do
params = params_from_auth(credentials)
case map... | defmodule EspiDni.GoogleAuthHandler do
@expected_param_count 3
@moduledoc """
Upadte a team with goole credentials from auth response
"""
alias EspiDni.Team
alias EspiDni.Repo
use Timex
def update_from_auth(team, %{credentials: credentials}) do
params = params_from_auth(credentials)
case map... | Use new worker to queue refresh once token is added | Use new worker to queue refresh once token is added
| Elixir | mit | edenspiekermann/espi-dni,edenspiekermann/espi-dni |
86a2e3eaa250baf2cade9ae2642fe01c2fd9cba5 | blockytalky/config/config.exs | blockytalky/config/config.exs | # This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.
use Mix.Config
# Configures the endpoint
config :blockytalky, Blockytalky.Endpoint,
url: [host: "l... | # This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.
use Mix.Config
# Configures the endpoint
config :blockytalky, Blockytalky.Endpoint,
url: [host: "l... | Disable Check Origin (allow any host matching for web sockets | Disable Check Origin (allow any host matching for web sockets
| Elixir | unknown | LaboratoryForPlayfulComputation/blockytalky,LaboratoryForPlayfulComputation/blockytalky,tufts-LPC/blockytalky,tufts-LPC/blockytalky,LaboratoryForPlayfulComputation/blockytalky,LaboratoryForPlayfulComputation/blockytalky,tufts-LPC/blockytalky,tufts-LPC/blockytalky,tufts-LPC/blockytalky,LaboratoryForPlayfulComputation/bl... |
afc349173c1451282823801aa8f4545ed71d0507 | mix.exs | mix.exs | defmodule Shippex.Mixfile do
use Mix.Project
def project do
[
app: :shippex,
version: "0.6.8",
elixir: "~> 1.6",
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
description: description(),
package: package(),
deps: deps()
]
end
d... | defmodule Shippex.Mixfile do
use Mix.Project
def project do
[
app: :shippex,
version: "0.6.8",
elixir: "~> 1.6",
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
description: description(),
package: package(),
deps: deps()
]
end
d... | Include priv folder in release | Include priv folder in release
| Elixir | mit | whitepaperclip/shippex |
0f24ed894c2b250f2f9d301f2c62ec9b94b5a878 | farmbot_core/test/project_test.exs | farmbot_core/test/project_test.exs | defmodule FarmbotCore.ProjectTest do
use ExUnit.Case
test "arduino_commit" do
actual = FarmbotCore.Project.arduino_commit()
expected = "0c4b14eb1bec8d466fbb815bfd7ee13b0b2d8c91"
# Prevents me from accidentally releasing wrong firmware.
assert expected == actual
end
end
| defmodule FarmbotCore.ProjectTest do
use ExUnit.Case
@opts [cd: Path.join("c_src", "farmbot-arduino-firmware")]
test "arduino_commit" do
actual = FarmbotCore.Project.arduino_commit()
expected =
System.cmd("git", ~w"rev-parse --verify HEAD", @opts)
|> elem(0)
|> String.trim()
asser... | Revert easy win that was not so easy | Revert easy win that was not so easy
| Elixir | mit | FarmBot/farmbot_os,FarmBot/farmbot_os,FarmBot/farmbot_os,FarmBot/farmbot_os |
5eda85e2d9fb9351ff60bff4b107db25821b4ac9 | mix.exs | mix.exs | defmodule Talon.Mixfile do
use Mix.Project
def project do
[app: :talon,
version: "0.1.0",
elixir: "~> 1.4",
elixirc_paths: elixirc_paths(Mix.env),
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps()]
end
def application do
[extra_applications... | defmodule Talon.Mixfile do
use Mix.Project
def project do
[app: :talon,
version: "0.1.0",
elixir: "~> 1.4",
elixirc_paths: elixirc_paths(Mix.env),
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
compilers: compilers(Mix.env),
deps: deps()]
end
def a... | Add compilers for test env | Add compilers for test env | Elixir | mit | talonframework/talon,talonframework/talon |
7180a09c0ed1ebc58914b5584c6e188ed9e6bc72 | roosevelt/web/models/tweet_list.ex | roosevelt/web/models/tweet_list.ex | defmodule Roosevelt.TweetList do
use GenServer
def start_link(initial_state) do
GenServer.start_link __MODULE__, initial_state, name: __MODULE__
end
def init(initial_state) do
{:ok, client_sub} = Exredis.Sub.start_link
client_sub |> Exredis.Sub.subscribe "storm_tweet_feed", fn(msg) ->
case m... | defmodule Roosevelt.TweetList do
use GenServer
def start_link(initial_state) do
GenServer.start_link __MODULE__, initial_state, name: __MODULE__
end
def init(initial_state) do
{:ok, client_sub} = Exredis.Sub.start_link
client_sub |> Exredis.Sub.subscribe "storm_tweet_feed", fn(msg) ->
case m... | Insert tweets with tied popularity at end | Insert tweets with tied popularity at end
Previously if a to-be-inserted tweet's popularity was tied
for the lowest popularity, we would insert it at the
beginning. This change inserts it at the end.
| Elixir | mit | zdicesare/realtime-tweets,zdicesare/realtime-tweets |
f93f0e5b3eae5058e7f2840d32b4eaa000af4da4 | mix.exs | mix.exs | defmodule EnvConf.Mixfile do
use Mix.Project
def project do
[app: :env_conf,
version: "0.1.0",
elixir: "~> 0.15.0",
description: description,
package: package,
deps: deps(Mix.env)]
end
# Configuration for the OTP application
def application do
[mod: { EnvConf, [] }]
e... | defmodule EnvConf.Mixfile do
use Mix.Project
def project do
[app: :env_conf,
version: "0.2.0",
elixir: "~> 0.15.0",
description: description,
package: package,
deps: deps(Mix.env)]
end
# Configuration for the OTP application
def application do
[mod: { EnvConf, [] }]
e... | Bump version for Elixir upgrade. | Bump version for Elixir upgrade. | Elixir | mit | LeakyBucket/env_conf |
6a43ae244e25f800ee2157f75bf2d3474c6c1ef7 | exercises/acronym/acronym_test.exs | exercises/acronym/acronym_test.exs | if !System.get_env("EXERCISM_TEST_EXAMPLES") do
Code.load_file("acronym.exs", __DIR__)
end
ExUnit.start
ExUnit.configure exclude: :pending, trace: true
defmodule AcronymTest do
use ExUnit.Case
test "it produces acronyms from title case" do
assert Acronym.abbreviate("Portable Networks Graphic") === "PNG"
... | if !System.get_env("EXERCISM_TEST_EXAMPLES") do
Code.load_file("acronym.exs", __DIR__)
end
ExUnit.start
ExUnit.configure exclude: :pending, trace: true
defmodule AcronymTest do
use ExUnit.Case
test "it produces acronyms from title case" do
assert Acronym.abbreviate("Portable Networks Graphic") === "PNG"
... | Add `it` for consistency with other tests | Add `it` for consistency with other tests
| Elixir | mit | exercism/xelixir,cezarykosko/xelixir,parkerl/xelixir |
e6d8fd7c4afa0e757682aa9aca77d0b71281a87b | lib/mr_rebase/endpoint.ex | lib/mr_rebase/endpoint.ex | defmodule MrRebase.Endpoint do
use Phoenix.Endpoint, otp_app: :mr_rebase
socket "/socket", MrRebase.UserSocket
# Serve at "/" the static files from "priv/static" directory.
#
# You should set gzip to true if you are running phoenix.digest
# when deploying your static files in production.
plug Plug.Stati... | defmodule MrRebase.Endpoint do
use Phoenix.Endpoint, otp_app: :mr_rebase
socket "/socket", MrRebase.UserSocket
# Serve at "/" the static files from "priv/static" directory.
#
# You should set gzip to true if you are running phoenix.digest
# when deploying your static files in production.
plug Plug.Stati... | Revert "Bump version of session key name" | Revert "Bump version of session key name"
This reverts commit 0a1deb25ca4657eb66c47b13254434f041e99cfc.
| Elixir | mit | wojtekmach/mr-rebase,wojtekmach/mr-rebase |
996ad1f96fb14e76f3bba0f9a1d3e76431ef350d | web/models/question.ex | web/models/question.ex | defmodule Core.Question do
use Core.Web, :model
schema "questions" do
field :title, :string
many_to_many :question_tags, Core.Tag, join_through: Core.QuestionTag
timestamps()
end
@doc """
Builds a changeset based on the `struct` and `params`.
"""
def changeset(struct, params \\ %{}) do
... | defmodule Core.Question do
use Core.Web, :model
schema "questions" do
field :title, :string
field :tags, {:array, :map}, virtual: true
many_to_many :question_tags, Core.Tag, join_through: Core.QuestionTag
timestamps()
end
@doc """
Builds a changeset based on the `struct` and `params`.
""... | Add "tags" field to Core.Question | Add "tags" field to Core.Question
| Elixir | mit | exacs/liqen-core,exacs/liqen-core |
0cd51ee86774961a2a20e9cd1b2a83e6bbaef47f | rojak-api/web/views/index_view.ex | rojak-api/web/views/index_view.ex | defmodule RojakAPI.IndexView do
use RojakAPI.Web, :view
def render("index.json", _assigns) do
%{version: "0.0.0", message: "Selamat datang di rojak-api!"}
end
end
| defmodule RojakAPI.IndexView do
use RojakAPI.Web, :view
def render("index.json", _assigns) do
%{version: Mix.Project.config[:version], message: "Selamat datang di rojak-api!"}
end
end
| Use project version from mix for dummy route | Use project version from mix for dummy route
| Elixir | bsd-3-clause | pyk/rojak,rawgni/rojak,reinarduswindy/rojak,reinarduswindy/rojak,bobbypriambodo/rojak,pyk/rojak,reinarduswindy/rojak,bobbypriambodo/rojak,bobbypriambodo/rojak,CodeRiderz/rojak,reinarduswindy/rojak,pyk/rojak,CodeRiderz/rojak,CodeRiderz/rojak,CodeRiderz/rojak,pyk/rojak,bobbypriambodo/rojak,pyk/rojak,CodeRiderz/rojak,pyk/... |
08fdfe926c117bfd9135fe168e9ef6db40386e10 | web/controllers/auth_controller.ex | web/controllers/auth_controller.ex | defmodule OAuth2Example.AuthController do
use OAuth2Example.Web, :controller
plug :action
@doc """
This action is reached via `/auth` and redirects to the OAuth2 provider
based on the chosen strategy.
"""
def index(conn, _params) do
redirect conn, external: Fitbit.authorize_url! [{:scope, "sleep set... | require Logger
defmodule OAuth2Example.AuthController do
use OAuth2Example.Web, :controller
plug :action
@doc """
This action is reached via `/auth` and redirects to the OAuth2 provider
based on the chosen strategy.
"""
def index(conn, _params) do
redirect conn, external: Fitbit.authorize_url!(scop... | Simplify syntax for passing scope to authorize_url. Add logging. | Simplify syntax for passing scope to authorize_url. Add logging.
| Elixir | mit | wsmoak/phoenix_oauth2_example |
f15935d0f3076b57d0db1bd155d6ae50567e453f | test/benchee/statistics/percentile_test.exs | test/benchee/statistics/percentile_test.exs | defmodule Benchee.Statistics.PercentileTest do
use ExUnit.Case, async: true
alias Benchee.Statistics.Percentile
doctest Percentile
@nist_sample_data [
95.1772,
95.1567,
95.1937,
95.1959,
95.1442,
95.0610,
95.1591,
95.1195,
95.1065,
95.0925,
95.1990,
95.1682
]
... | defmodule Benchee.Statistics.PercentileTest do
use ExUnit.Case, async: true
alias Benchee.Statistics.Percentile
doctest Percentile
@nist_sample_data [
95.1772,
95.1567,
95.1937,
95.1959,
95.1442,
95.0610,
95.1591,
95.1195,
95.1065,
95.0925,
95.1990,
95.1682
]
... | Remove unused tag, add url reference | Remove unused tag, add url reference
| Elixir | mit | PragTob/benchee |
51ff54efdf7443f7a6967ceb8939d7fed4701665 | lib/trot/live_reload.ex | lib/trot/live_reload.ex | defmodule Trot.LiveReload do
@moduledoc """
Plug for reloading modules on every request, allowing fast iteration during
development.
Reloading only happens in dev, every other environment is a noop for this plug.
If a module is reloaded, a redirect is sent to the client for the same location,
allowing the ... | defmodule Trot.LiveReload do
@moduledoc """
Plug for reloading modules on every request, allowing fast iteration during
development.
Reloading only happens in dev, every other environment is a noop for this plug.
If a module is reloaded, a redirect is sent to the client for the same location,
allowing the ... | Make location header lowercase to conform with Plug. | Make location header lowercase to conform with Plug. | Elixir | apache-2.0 | hexedpackets/trot |
e9cf51e57fa7c9c8264f9a140d8c075249e5a6bb | test/features/registration_test.exs | test/features/registration_test.exs | defmodule Chess.RegistrationTest do
use ChessWeb.FeatureCase
import Wallaby.Query, only: [text_field: 1, link: 1, button: 1]
test "user can register", %{session: session} do
session
|> visit("/")
|> click(link("Register"))
|> fill_in(text_field("Name"), with: "Link")
|> fill_in(text_field("E... | defmodule Chess.RegistrationTest do
use ChessWeb.FeatureCase
import Wallaby.Query
test "user can register", %{session: session} do
session
|> visit("/")
|> click(link("Register"))
|> fill_in(text_field("Name"), with: "Link")
|> fill_in(text_field("Email"), with: "link@example.com")
|> fi... | Add some tests for unsuccessful registration | Add some tests for unsuccessful registration
| Elixir | mit | danbee/chess,danbee/chess,danbee/chess |
33a3cef4c873ab21e6c0a588924abdf640d5e4bb | mix.exs | mix.exs | defmodule PlugStaticLs.Mixfile do
use Mix.Project
@version "0.5.3"
def project do
[app: :plug_static_ls,
version: @version,
elixir: "~> 1.3",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps(),
package: package(),
description: "Directory Index f... | defmodule PlugStaticLs.Mixfile do
use Mix.Project
@version "0.5.3"
def project do
[app: :plug_static_ls,
version: @version,
elixir: "~> 1.3",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps(),
package: package(),
description: "Directory Index f... | Add plug dependency of dialyxir | Add plug dependency of dialyxir
| Elixir | apache-2.0 | jj1bdx/plug_static_ls |
eb06b0bcabf8ed79ffab1a3b0bd95e9e7dbd5a31 | mix.exs | mix.exs | defmodule NervesSystemBbb.Mixfile do
use Mix.Project
@version Path.join(__DIR__, "VERSION")
|> File.read!
|> String.strip
def project do
[app: :nerves_system_bbb,
version: @version,
elixir: "~> 1.2",
compilers: Mix.compilers ++ [:nerves_package],
description: description(),
... | defmodule NervesSystemBbb.Mixfile do
use Mix.Project
@version Path.join(__DIR__, "VERSION")
|> File.read!
|> String.strip
def project do
[app: :nerves_system_bbb,
version: @version,
elixir: "~> 1.2",
compilers: Mix.compilers ++ [:nerves_package],
description: description(),
... | Test build with new nerves_system_br | Test build with new nerves_system_br
| Elixir | apache-2.0 | nerves-project/nerves_system_bbb,uldza/nerves_system_zynq,nerves-project/nerves_system_bbb |
9b3beaf69a9b9c6450526c41d591a94d2eedf1e8 | mix.exs | mix.exs | defmodule Mix.Tasks.Compile.Hoedown do
@shortdoc "Compiles Hoedown"
def run(_) do
if match? {:win32, _}, :os.type do
{result, _error_code} = System.cmd("nmake", ["/F", "Makefile.win", "priv\\markdown.dll"], stderr_to_stdout: true)
Mix.shell.info result
else
{result, _error_code} = System.... | defmodule Mix.Tasks.Compile.Hoedown do
@shortdoc "Compiles Hoedown"
def run(_) do
if match? {:win32, _}, :os.type do
{result, _error_code} = System.cmd("nmake", ["/F", "Makefile.win", "priv\\markdown.dll"], stderr_to_stdout: true)
IO.binwrite result
else
{result, _error_code} = System.cmd... | Use IO.binwrite in hoedown compiler | Use IO.binwrite in hoedown compiler
That's because some systems will emit non-UTF-8 from their compiler
tools, so we just print the data back as we got it.
Closes #12 | Elixir | unlicense | devinus/markdown |
502edab4eba93921a6cb3ee1da7874374c95ef02 | apps/bors_frontend/lib/bors_ng/batcher/state.ex | apps/bors_frontend/lib/bors_ng/batcher/state.ex | defmodule BorsNG.Batcher.State do
@moduledoc """
The batcher state machine.
It takes a list of status states,
and emits a batch state.
"""
@typep n :: BorsNG.Status.state_n
@typep t :: BorsNG.Status.state
@spec summary_database_statuses([n]) :: t
def summary_database_statuses(statuses) do
status... | defmodule BorsNG.Batcher.State do
@moduledoc """
The batcher state machine.
It takes a list of status states,
and emits a batch state.
"""
@typep n :: BorsNG.Database.Status.state_n
@typep t :: BorsNG.Database.Status.state
@spec summary_database_statuses([n]) :: t
def summary_database_statuses(statu... | Fix Dialyzer references to types | Fix Dialyzer references to types
| Elixir | apache-2.0 | bors-ng/bors-ng,bors-ng/bors-ng,bors-ng/bors-ng |
ca8ca1f24915f8f083d4a8247f78b5fcf79a6672 | nerves/target/bootstrap/network/tzdata_task.ex | nerves/target/bootstrap/network/tzdata_task.ex | defmodule Farmbot.Target.Network.TzdataTask do
use GenServer
@fb_data_dir Path.join(Application.get_env(:farmbot, :data_path), "tmp_downloads")
@timer_ms round(1.2e+6) # 20 minutes
def start_link(_, _) do
GenServer.start_link(__MODULE__, [], [name: __MODULE__])
end
def init([]) do
send self(), :d... | defmodule Farmbot.Target.Network.TzdataTask do
use GenServer
@fb_data_dir Path.join(Application.get_env(:farmbot, :data_path), "tmp_downloads")
@timer_ms round(1.2e+6) # 20 minutes
def start_link(_, _) do
GenServer.start_link(__MODULE__, [], [name: __MODULE__])
end
def init([]) do
send self(), :d... | Fix trying to ls a nonexistant dir on boot | Fix trying to ls a nonexistant dir on boot
| Elixir | mit | FarmBot/farmbot_os,FarmBot/farmbot_os,FarmBot/farmbot_os,FarmBot/farmbot_os |
c4f2a2caed615526808ed7da25cb3faa85320ee3 | vivaldi/lib/experiment/logcentral.ex | vivaldi/lib/experiment/logcentral.ex | defmodule Vivaldi.Experiment.Logcentral do
use GenServer
require Logger
alias Vivaldi.Experiment.CoordinateUpdateEvent
def start_link(file_path) do
GenServer.start_link(__MODULE__, {file_path})
end
def init(args) do
:yes = :global.register_name(:logcentral, self)
{:ok, args}
end
def han... | defmodule Vivaldi.Experiment.Logcentral do
use GenServer
require Logger
alias Vivaldi.Experiment.CoordinateUpdateEvent
def start_link(file_path) do
GenServer.start_link(__MODULE__, {file_path})
end
def to_json(src, dst) do
{:ok, content} = File.read(src)
content
|> String.trim()
|> S... | Add function to convert events file to son. | Add function to convert events file to son.
| Elixir | mit | pixyj/vivaldi,pixyj/vivaldi |
1c1e49ec13177bb7f364073b5d418a7e9d5c5bc5 | lib/csv/defaults.ex | lib/csv/defaults.ex | defmodule CSV.Defaults do
@moduledoc ~S"""
The module defaults of CSV.
"""
defmacro __using__(_) do
quote do
@separator ?,
@newline ?\n
@carriage_return ?\r
@delimiter <<@carriage_return::utf8>> <> <<@newline::utf8>>
@double_quote ?"
@escape_max_lines 1000
@replace... | defmodule CSV.Defaults do
@moduledoc ~S"""
The module defaults of CSV.
"""
defmacro __using__(_) do
quote do
@separator ?,
@newline ?\n
@carriage_return ?\r
@delimiter <<@carriage_return::utf8>> <> <<@newline::utf8>>
@double_quote ?"
@escape_max_lines 1000
@replace... | Set force_quotes default to false. | Set force_quotes default to false. | Elixir | mit | beatrichartz/csv,beatrichartz/csv |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.