content_id large_stringlengths 40 40 | size_bytes int64 1.5k 25k | repo_ids large listlengths 1 410 | tags large listlengths 0 7 | content large_stringlengths 681 25k |
|---|---|---|---|---|
0053a117cbaf54086730a9068cb9eada4825dec3 | 4,404 | [
96388904
] | [
"test"
] | defmodule TruFace.DetectiveTest do
use ExUnit.Case
alias TruFace.Detective
import TestHelper
import Mock
test "enrolls 3 images" do
with_mocks([
{HTTPoison, [], [post!: fn(_, _, _, _) -> mocked_enroll() end]},
{HTTPoison, [], [put!: fn(_, _, _, _) -> mocked_update_enroll() end]}
]) do
... |
005419894e1392090695df7e9d5c04486e24f8f6 | 2,579 | [
568031766
] | [
"test"
] | defmodule ExBanking.Actors.ProcessLimiterTest do
use ExUnit.Case, async: true
alias ExBanking.ProcessLimiter
setup do
Application.stop(:ex_banking)
Application.start(:ex_banking)
end
describe "check_free_space" do
test "returns true if there is free space" do
{:ok, user} = ExBanking.User.i... |
0054b0344933255afca56be07467759c75c2c2db | 4,167 | [
320293998
] | [
"test"
] | defmodule Day2 do
def parse_line(line) do
pattern = :binary.compile_pattern(["-", " ", ": "])
splited = String.split(line, pattern)
%{
rule: %{
min: String.to_integer(Enum.at(splited, 0)),
max: String.to_integer(Enum.at(splited, 1))
},
letter: Enum.at(splited, 2),
... |
0054c0e038d2e944980ab2848033ba5ce70a76b0 | 3,077 | [
131029987
] | [
"phoenix"
] | defmodule Bot.Message do
use BotWeb, :controller
def type_message(message) do
cond do
String.match?(message, ~r/contraseña|password/) ->
message_password()
String.match?(message, ~r/puntos/) ->
message_points()
String.match?(message, ~r/esto|advocates/) ->
message_info... |
005523259023450a21d1920f4c012ef8980b613e | 2,140 | [
785085355
] | [
"test",
"ecto"
] | defmodule DaeEcommerceBe.AccountsTest do
use DaeEcommerceBe.DataCase
alias DaeEcommerceBe.Accounts
describe "accounts" do
alias DaeEcommerceBe.Accounts.Account
import DaeEcommerceBe.AccountsFixtures
@invalid_attrs %{password: nil, email: nil}
test "list_accounts/0 returns all accounts" do
... |
0055713f330f33ab845f5cfb5cb8922a67385c48 | 13,942 | [
957831399
] | [
"genserver",
"macro",
"documented"
] | # comprehensive_elixir_demo.ex
# FINAL VERSION: Added underscores to silence unused variable warnings.
defmodule ComprehensiveElixirDemo do
@moduledoc """
This module showcases various Elixir features.
The module body now contains only definitions.
Call ComprehensiveElixirDemo.run() to execute the examples.
... |
00558e38ea545dfe03f73be77d9ef604f2a151a2 | 4,939 | [
511807087
] | [
"test",
"phoenix"
] | defmodule AdminWeb.UserSettingsControllerTest do
use AdminWeb.ConnCase
alias Admin.Accounts
import Admin.AccountsFixtures
setup :register_and_log_in_user
describe "GET /users/settings" do
test "renders settings page", %{conn: conn} do
conn = get(conn, Routes.user_settings_path(conn, :edit))
... |
005686ad7a8f50e70e09363d7bdc10fbc8494b40 | 2,932 | [
131022944
] | [
"test"
] | defmodule MeshingtonWeb.SecretControllerTest do
use MeshingtonWeb.ConnCase
alias Meshington.Vault
@create_attrs %{name: "some name", notes: "some notes", password: "some password", url: "some url", username: "some username"}
@update_attrs %{name: "some updated name", notes: "some updated notes", password: "so... |
0056cba1489d1b6ab37ab6b57d19c553f53d3916 | 6,030 | [
191423461
] | [
"genserver",
"documented",
"ecto"
] | defmodule Meadow.Data.IndexBatcher do
@moduledoc """
The IndexBatcher is a GenServer that batches documents for reindexing.
"""
use GenServer
use Meadow.Utils.Logging
import Ecto.Query
alias Meadow.Data.{Collections, Works}
alias Meadow.Data.Schemas.{Collection, Work}
alias Meadow.Search.Bulk
al... |
00578a5372e996d93462ae5bc6f257d15e4191d1 | 1,790 | [
330155553
] | [
"phoenix"
] | defmodule ToiaWeb.StreamViewPermissionController do
use ToiaWeb, :controller
alias Toia.StreamViewPermissions
alias Toia.StreamViewPermissions.StreamViewPermission
action_fallback ToiaWeb.FallbackController
def index(conn, _params) do
stream_view_permission = StreamViewPermissions.list_stream_view_perm... |
00578cdaab682a1cfb3f379b628928cc48365a2d | 1,740 | [
791099453
] | [
"macro",
"documented"
] | defmodule Fastrepl.Retrieval.Embedding.Cache do
@moduledoc """
Expects a module to implement `generate_without_cache/1`.
"""
defmacro __using__(_opts) do
quote do
def generate(texts) do
{cached, not_cached} =
texts
|> Enum.map(&get_cache/1)
|> Enum.with_index()
... |
005797296f4e491c12afc0fc11a3a15a6e9be15e | 7,605 | [
434869305
] | [] | %{
"benchee": {:hex, :benchee, "1.3.1", "c786e6a76321121a44229dde3988fc772bca73ea75170a73fd5f4ddf1af95ccf", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}, {:statistex, "~> 1.0", [hex: :statistex, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm",... |
00584c91e7435c51bf99aad685983e2708174e76 | 6,435 | [
632406466
] | [] | %{
"boundary": {:hex, :boundary, "0.9.4", "11f66efc6deeaae7637252b05c4f80ee73495ed96981038f83c840c0ee9f2755", [:mix], [], "hexpm", "3532aeb49fd2fdcb8f5762f3b1964d89832ef81b224dae2852a8a6dba3dec893"},
"bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexp... |
00587f962d2c3c95a2103964084d71159cda4938 | 11,365 | [
41922638
] | [
"documented"
] | require Telebot.Macro
defmodule Telebot.Api do
use HTTPoison.Base
@endpoint "https://api.telegram.org/bot"
@doc """
Method for testing your bot's auth token
Info: https://core.telegram.org/bots/api#getme
"""
def get_me, do: execute("getMe")
@doc """
Use this method to send text messages.
On succ... |
00589e1cbe0a2259ffe7139919260ece7f292faf | 4,275 | [
383838765
] | [
"documented",
"ecto"
] | defmodule Rafiyol do
@moduledoc """
Rafiyol keeps the contexts that define your domain
and business logic.
Contexts are also responsible for managing your data, regardless
if it comes from the database, an external API or others.
"""
alias Rafiyol.{User, Word, Repo, Password, LearnSession}
import Ecto... |
0058bd1d11321c992a0214239b5224afde811b82 | 3,900 | [
18573162,
510809929
] | [
"test"
] | defmodule Faker.DateTimeTest do
use ExUnit.Case, async: true
test "forward/1" do
now = DateTime.utc_now()
forwarded_date = Faker.DateTime.forward(10)
assert %DateTime{
year: year,
month: month,
day: day,
hour: hour,
minute: minute,
... |
0058dbb01ba3553088bf6d83c6850c015664a5de | 1,738 | [
784912795
] | [] | defmodule Mix.Tasks.TransformAndExport do
use Mix.Task
@shortdoc "Scrapes text from Amazon book pages listed in a CSV file and exports each to a separate CSV file."
def run(args) do
{opts, args, _} = OptionParser.parse(args, switches: [debug: :boolean])
debug_mode = opts[:debug] || false
if debug_... |
005942d4d1f1afd15a9410560fb9e06857ec0054 | 13,839 | [
605715389
] | [
"typespec",
"macro",
"documented"
] | defmodule Faker.Core.Text do
use Faker.Core.Generator
defmacro __using__(_) do
quote do
@base_text """
The Beginning of Knowledge
The proverbs of Solomon the son of David, king of Israel:
To know wisdom and instruction,To [a]perceive the words of understanding,
To receive the ins... |
0059bea142f708acc58317113df6846ec4f2c88a | 2,878 | [
42186115
] | [
"macro",
"test",
"documented"
] | defmodule ExUnit.Parameterized do
@moduledoc """
ExUnit.Parameterized support parameterized test with ExUnit.
Macro of `test_with_params` run standard `test` macro in it.
## Examples
You can run parameterized test with a `test_with_params` macro:
defmodule MyExample.Test do
use ExUnit.Case, a... |
0059d35a2dbf0c45c399051616a5a0cf19f48970 | 3,587 | [
121318872
] | [] | defmodule Memory.Game do
def new do
%{
cards: listShuffle(),
matches: 0,
clicks: 0,
flipped: 0,
current: nil,
prev: nil,
ready: true,
}
end
def client_view(game) do
%{
cards: game.cards,
matches: game.matches,
clicks: game.clicks,
fli... |
005a9cb71012d48bce2af0495cbb1b24c248a214 | 2,374 | [
342484186
] | [
"typespec",
"documented"
] | defmodule MBS.Manifest.BuildDeploy.Type do
@moduledoc false
@type type :: :build | :deploy
@type t :: MBS.Manifest.BuildDeploy.Component.t() | MBS.Manifest.BuildDeploy.Toolchain.t()
end
defmodule MBS.Manifest.BuildDeploy.Component do
@moduledoc false
defmodule Target do
@moduledoc false
defstruct ... |
005aa1f7cb4fb94b1eaed48a0a8b295ce3ce407a | 9,149 | [
359540799
] | [] | %{
"acceptor_pool": {:hex, :acceptor_pool, "1.0.0", "43c20d2acae35f0c2bcd64f9d2bde267e459f0f3fd23dab26485bf518c281b21", [:rebar3], [], "hexpm", "0cbcd83fdc8b9ad2eee2067ef8b91a14858a5883cb7cd800e6fcd5803e158788"},
"chatterbox": {:hex, :ts_chatterbox, "0.15.1", "5cac4d15dd7ad61fc3c4415ce4826fc563d4643dee897a558ec4ea0... |
005abe5a61133f59ce9e8d5c1c22fc5f4f576e02 | 2,664 | [
198640092
] | [] | defmodule Sdif.Field do
def parse({:unknown,[]}, line) when is_binary(line) do
{:unknown, line}
end
def parse({kind, fields}, line) do
{line, items} =
Enum.reduce(fields, {line, %{}}, fn f, {rest, parsed} ->
{f_key, f_type, f_length} = f
case rest do
<<f_val::binary-size... |
005aeae092752b73da10af5fb11a8d579fc1ec37 | 1,883 | [
225231940
] | [
"macro",
"documented",
"phoenix"
] | defmodule RbaxWeb do
@moduledoc """
The entrypoint for defining your web interface, such
as controllers, views, channels and so on.
This can be used in your application as:
use RbaxWeb, :controller
use RbaxWeb, :view
The definitions below will be executed for every view,
controller, etc, so k... |
005afab72aa94a83f2e5cb9b664170138956db75 | 9,555 | [
196883108
] | [
"typespec",
"documented"
] | defmodule IniParser do
@moduledoc """
Parses an Ini into structured data.
"""
require Logger
@typedoc "Record under a header"
@type record() :: {String.t(), [String.t() | float() | {:eval, String.t()}]}
@type header() :: String.t()
@type t() :: [{header(), [record()]}]
@doc "Parse a file on the di... |
005b1d8b57e883183cac9b71d5f5489d8f22cce4 | 4,965 | [
256314468
] | [
"test",
"phoenix"
] | defmodule ReflectionsWeb.UserReflectionControllerTest do
use ReflectionsWeb.ConnCase
alias Reflections.Auth
alias Reflections.Reflection
alias Reflections.Reflection.UserReflection
alias Plug.Test
@create_attrs %{
public: true,
text: "some text"
}
@update_attrs %{
public: false,
text: ... |
005b270192df06c4144d0dffe66d4f2a7b0f358d | 1,658 | [
69889999
] | [
"macro",
"documented",
"ecto",
"phoenix"
] | defmodule Mattvanhorn.Web do
@moduledoc """
A module that keeps using definitions for controllers,
views and so on.
This can be used in your application as:
use Mattvanhorn.Web, :controller
use Mattvanhorn.Web, :view
The definitions below will be executed for every view,
controller, etc, so k... |
005b49779e4f7e1b2b5995dbf2181d96b2d33d50 | 2,288 | [
550868013
] | [
"phoenix"
] | defmodule GeneratorWeb.UserSettingsController do
use GeneratorWeb, :controller
alias Generator.Accounts
alias GeneratorWeb.UserAuth
plug :assign_email_and_password_changesets
def edit(conn, _params) do
render(conn, "edit.html")
end
def update(conn, %{"action" => "update_email"} = params) do
%{... |
005bcce47c6d8bffd0a966ef272448ba74cf292b | 1,683 | [
1014691706
] | [] | defmodule Demo.TimeTracking.Photo do
use Ash.Resource,
otp_app: :demo,
domain: Demo.TimeTracking,
extensions: [AshGraphql.Resource],
data_layer: AshPostgres.DataLayer
actions do
defaults [
:read,
:destroy,
create: [
:timestamp,
:timezone,
:comment,
... |
005bdc59761cde3f4cba8b6a9fc2cc0f07e7214e | 4,231 | [
49910665
] | [] | defmodule MisraToken do
def propagate(rcpt, values) when values != [] do
[h|t] = values
send rcpt, h
propagate rcpt, t
end
def propagate(_, values) when values == [], do: :ok
def cs(i, parent, value) do
IO.puts "node " <> to_string(i) <> ": entering CS"
:timer.sleep 2000
IO.puts "node... |
005bdc98be4f1e0ab3dd9ffcf4caff58c0bcfa11 | 3,836 | [
297293200
] | [
"test",
"phoenix"
] | defmodule LocallyWeb.UserResetPasswordControllerTest do
use LocallyWeb.ConnCase, async: true
alias Locally.Accounts
alias Locally.Repo
import Locally.AccountsFixtures
setup do
%{user: user_fixture()}
end
describe "GET /users/reset_password" do
test "renders the reset password page", %{conn: con... |
005c279a39a4e2c448d47c5693b765775755bd2c | 1,901 | [
741183345
] | [
"typespec",
"documented"
] | defmodule Nullables do
@moduledoc """
Helpers and conversions between the different nullable types.
"""
alias Nullables.Result
alias Nullables.Fallible
@type null(e) :: {:error, e} | :error | nil
@type nullable(t, e) :: {:ok, t} | null(e)
@type nullable(t) :: nullable(t, any())
@type nullable() :: n... |
005c4be39a8b4d5bce27d6c6c692eb12d669f459 | 2,078 | [
160069062
] | [
"documented"
] | defmodule Inventory do
@moduledoc """
Documentation for Inventory.
NOTE solution assumes all box IDs will be the same length
"""
@doc """
Return index of the only pair in list with different values.
(Return `nil` if more or less than one differing pair exists.)
"""
def compare_pairs(pairs) do
di... |
005c96211de0aff2cc7053901de07affb050e99e | 1,581 | [
311125833,
306900276
] | [] | defmodule ExApp.SimpleMailController do
import Plug.Conn
use Plug.Router
use ExApp.BasicController
alias ExApp.NumberUtil
alias ExApp.SimpleMailHandler, as: Handler
alias ExApp.SimpleMailService, as: Service
alias ExApp.AuthHandler, as: AuthHandler
plug(Plug.Logger, log: :debug)
plug(Plug.Parser... |
005ca1292bf5c41f798eb8597f4a3f2c9b8a130f | 2,405 | [
84236461
] | [] | %{"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], []},
"certifi": {:hex, :certifi, "1.0.0", "1c787a85b1855ba354f0b8920392c19aa1d06b0ee1362f9141279620a5be2039", [:rebar3], []},
"credo": {:hex, :credo, "0.6.1", "a941e2591bd2bd2055dc92b810c174650b40b8290459c89... |
005cc17feb4669166717664c2c7d673882163123 | 17,128 | [
800248790
] | [
"test",
"ecto"
] | defmodule Datcord.AccountsTest do
use Datcord.DataCase
alias Datcord.Accounts
import Datcord.AccountsFixtures
alias Datcord.Accounts.{User, UserToken}
describe "get_user_by_email/1" do
test "does not return the user if the email does not exist" do
refute Accounts.get_user_by_email("<EMAIL>")
... |
005ce3b3b7884fb034fce25368301431f894d952 | 7,139 | [
98653349
] | [
"genserver"
] | defmodule MnesiaTab do
use GenServer
require Logger
@save_data_interval_sec 300
## =================================================================
## api
## =================================================================
def start_link(table_name, table_opts) do
GenServer.start_link(__MODULE__,... |
005cedc124cd6a331fd906c3bf4a3c455f383425 | 3,888 | [
73467784,
73378020
] | [
"typespec",
"documented"
] | defmodule ExDoc do
@moduledoc """
Elixir Documentation System. ExDoc produces documentation for Elixir projects
"""
defmodule Config do
@moduledoc """
Configuration structure that holds all the available options for ExDoc
You can find more details about this options in the `ExDoc.CLI` module.
... |
005d4970237949077e4f8fe5531d624a7164ddb1 | 2,251 | [
67077833
] | [
"typespec",
"documented"
] | defmodule(Thrift.Generated.Decimal) do
_ = "Auto-generated Thrift struct snappydata.Decimal"
_ = "1: i8 signum"
_ = "2: i32 scale"
_ = "3: binary magnitude"
defstruct(signum: nil, scale: nil, magnitude: nil)
@type(t :: %__MODULE__{})
def(new) do
%__MODULE__{}
end
defmodule(BinaryProtocol) do
@... |
005dc9f1c42069fc00ffec38e0d67eb99d0403d6 | 1,841 | [
163732378
] | [] | # This file is responsible for configuring your application
# and its dependencies with the aid of the Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.
# General application configuration
import Config
# Set timezone database
config :elixir, :time_zone_da... |
005de5cfe11ddcff26323915eac7954d235985b0 | 8,493 | [
576873581
] | [
"typespec",
"macro",
"documented"
] | defmodule UspsEx.Address do
@moduledoc """
Represents an address that can be passed to other `UspsEx` functions. Do
*not* initialize this struct directly. Instead, use `address/1`.
"""
@enforce_keys ~w(first_name last_name name phone address address_line_2 address_line_3 city
state postal_... |
005e2b1eb35c48f517a4dd8fe81657d8f7eef9c2 | 1,687 | [
598655690
] | [
"liveview"
] | defmodule UtilsWeb.UserConfirmationInstructionsLive do
use UtilsWeb, :live_view
alias Utils.Accounts
alias Helpers.Cube
def render(assigns) do
~H"""
<.header><%= gettext("resend confirmation instructions") %></.header>
<.simple_form :let={f} for={:user} id="resend_confirmation_form" phx-submit="s... |
005e41d6ccc8f6d319eb9524eb28c0f531fb0914 | 4,903 | [
811022856
] | [
"typespec",
"macro",
"documented"
] | defmodule Tux.Command do
@moduledoc """
A command module provides the implementation for a given command,
and it can be registered on a given dispatcher using the
`Tux.Dispatcher.cmd/2` macro.
At a minimum, a command module needs to implement only the `c:main/2` callback.
The full list of callbacks is as f... |
005e4c9a3dc13235845dca22169233d43f0df912 | 4,761 | [
104223581
] | [] | defmodule IcdCode.ICDCode.Codes_X06 do
alias IcdCode.ICDCode
def _X060XXA do
%ICDCode{full_code: "X060XXA",
category_code: "X06",
short_code: "0XXA",
full_name: "Exposure to ignition of plastic jewelry, initial encounter",
short_name: "Exposure to ignition of plastic jewel... |
005e5bb68e2d15837aaf14705e69e87333d766a5 | 2,937 | [
536569024
] | [
"liveview",
"macro",
"documented",
"phoenix"
] | defmodule QuickNoteWeb do
@moduledoc """
The entrypoint for defining your web interface, such
as controllers, views, channels and so on.
This can be used in your application as:
use QuickNoteWeb, :controller
use QuickNoteWeb, :view
The definitions below will be executed for every view,
contro... |
005ec06bd45a430cf721a12c4305e86297041939 | 1,596 | [
445027460
] | [] | defmodule ElixirJsonRestfullApi.MixProject do
use Mix.Project
def aliases do
[
test_ci: [
"test",
"coveralls"
],
code_review: [
"dialyzer",
"credo --strict"
],
generate_docs: [
"docs",
"inch"
]
]
end
# Run "mix help de... |
005ed3bf0977063a839ef7cb94910e7f0074f5f0 | 2,245 | [
250904436,
101825365,
995397072,
1008579275,
1018310553,
951535898,
933455501
] | [
"macro",
"documented"
] | defmodule Makeup.Lexers.ElixirLexer.Helper do
@moduledoc false
import NimbleParsec
alias Makeup.Lexer.Combinators
def with_optional_separator(combinator, separator) when is_binary(separator) do
combinator |> repeat(string(separator) |> concat(combinator))
end
# Allows escaping of the first character o... |
005f135d8deb4244ccb1a75d448b1c9bea6cc2b5 | 1,645 | [
43903016
] | [] | defmodule Riffed.Mixfile do
use Mix.Project
@project_url "https://github.com/pinterest/riffed"
def project do
[app: :riffed,
name: "Riffed",
version: "1.0.0",
elixir: "~> 1.2",
deps: deps(),
compilers: compilers(Mix.env),
erlc_paths: ["src", "ext/thrift/lib/erl/src"],
erlc... |
005f4dea158f615bafa50eb28de61b79fd78486a | 1,889 | [
636941826
] | [
"documented",
"ecto"
] | defmodule HumanResources.Entry do
@moduledoc """
The Entry context.
"""
import Ecto.Query, warn: false
alias HumanResources.Repo
alias HumanResources.Entry.Employee
@doc """
Returns the list of employees.
## Examples
iex> list_employees()
[%Employee{}, ...]
"""
def list_employees... |
005f98f950841c3d4888dc3f2bc58ad20010f291 | 13,814 | [
567653956,
437906643
] | [
"test"
] | Code.require_file("test_helper.exs", __DIR__)
defmodule PathTest do
use ExUnit.Case, async: true
doctest Path
if :file.native_name_encoding() == :utf8 do
@tag :tmp_dir
test "wildcard with UTF-8", config do
File.mkdir_p(Path.join(config.tmp_dir, "héllò"))
assert Path.wildcard(Path.join(confi... |
00602bd585ed8bdc7676890d061f1828b02854e5 | 1,634 | [
77298421
] | [] | # Sometimes you want modules to share a public API,
# the solution for this in Elixir is behaviours.
#
# Behaviours perform two primary roles:
# * Defining a set of function that must be implemented
# * Checking whether that set was actually implemented
# Defining a behaviour
defmodule Example.Worker do
@callbac... |
006071dc3931881e2383f84a054031cfe9493d91 | 1,550 | [
795372264
] | [
"liveview"
] | defmodule DataVisulalizerWeb.UserConfirmationInstructionsLive do
use DataVisulalizerWeb, :live_view
alias DataVisulalizer.Accounts
def render(assigns) do
~H"""
<div class="mx-auto max-w-sm">
<.header class="text-center">
No confirmation instructions received?
<:subtitle>We'll send ... |
0060867822e343fcab0d025f4a4ebaf3f71de8d1 | 1,551 | [
430238401
] | [
"phoenix"
] | defmodule AppWeb.Router do
use AppWeb, :router
alias AppWeb.Plugs.UUIDChecker
pipeline :api do
plug :accepts, ["json"]
plug UUIDChecker
end
pipeline :auth do
plug AppWeb.Auth.Pipeline
end
scope "/api", AppWeb do
pipe_through [:api, :auth]
resources "/users", UsersController, excep... |
0060bcbcf63adc24bd0817a1f454ece5dc84ca93 | 2,224 | [
62048541
] | [
"test"
] | defmodule Abex.APITest do
use ExUnit.Case
doctest Abex.API
use ConnCase
test "it creates a seed and sets a cookie with the key" do
conn =
fresh_conn
|> Abex.API.seed
cookies = fetch_conn_cookies(conn)
assert cookies["abex_seed_key"]
end
test "it raises error when calling seed agai... |
00611d72d8574a611dce27a693f2eab05c1910db | 3,690 | [
315449524
] | [
"genserver",
"liveview"
] | defmodule MultichessWeb.PageLive do
use MultichessWeb, :live_view
alias Multichess.Game
alias Multichess.Game.Position
alias MultichessWeb.Util.Convert
alias MultichessWeb.GameLobby
@impl true
def mount(_params, _session, socket) do
socket =
assign(socket, state: Game.initial(), selected_pos: n... |
00612b4b30c66de0b1c66fd982ca663b394b3a5f | 6,433 | [
590950624
] | [
"test"
] | defmodule Mneme.Assertion.PatternBuilderTest do
use ExUnit.Case, async: true
use Mneme
use ExUnitProperties
alias Mneme.Assertion.Context
alias Mneme.Assertion.Pattern
alias Mneme.Assertion.PatternBuilder
alias Mneme.Versions
{_formatter, opts} = Mix.Tasks.Format.formatter_for_file(__ENV__.file)
@fo... |
00613da8a22fa441c9bb7902a38ea8905663cb78 | 5,889 | [
277735275
] | [
"test",
"phoenix"
] | defmodule SamWeb.UserAuthTest do
use SamWeb.ConnCase, async: true
alias Sam.Accounts
alias SamWeb.UserAuth
import Sam.AccountsFixtures
setup %{conn: conn} do
conn =
conn
|> Map.replace!(:secret_key_base, SamWeb.Endpoint.config(:secret_key_base))
|> init_test_session(%{})
%{user: u... |
00614d164d0104eabef4d371d0bf521c2cafa4da | 1,700 | [
408030046
] | [
"genserver",
"documented",
"ecto"
] | defmodule StoneMarkets.Orders.TransactionsWorker do
@moduledoc """
This module is responsible for executing all necessary transactions
after a newly created order and is also responsible for executing background
work runner that finds all requested orders that have not yet been processed for some
reason and p... |
00616abaffc3edd203998ff306efe933e3080a17 | 13,117 | [
44419624,
765390321
] | [
"test",
"phoenix"
] | defmodule Absinthe.SchemaTest do
# can't async due to capture io
use Absinthe.Case
import ExUnit.CaptureIO
alias Absinthe.Schema
alias Absinthe.Type
describe "built-in types" do
defmodule ValidSchema do
use Absinthe.Schema
query do
field :foo, :string
end
object :pers... |
0061b45937e7931f112ba073722ffba1208437eb | 2,903 | [
5322389
] | [
"test"
] | defmodule GridTest do
use ExUnit.Case
doctest Grid
test "creation of a new grid sets the rows and columns appropriately" do
assert %Grid{rows: 1, cols: 1} = Grid.new(1, 1)
assert %Grid{rows: 5, cols: 7} = Grid.new(5, 7)
end
test "creation of a new grid creates a map of cells to grid spaces" do
a... |
0061bd349b4900595442cc7831260fa2781dd389 | 5,606 | [
436553571
] | [
"genserver"
] | defmodule Realtime.RLS.ReplicationPoller do
use GenServer
require Logger
alias DBConnection.Backoff
alias Realtime.Adapters.Changes.{
DeletedRecord,
NewRecord,
UpdatedRecord
}
alias Realtime.SubscribersNotification
alias Realtime.RLS.Replications
def start_link(opts) do
GenServer.st... |
00627ed6dde1777c0c1897269c8030698b64e360 | 3,807 | [
149272124
] | [] | defmodule ElixirList do
require Logger
@url_for_elixir_list "https://raw.githubusercontent.com/h4cc/awesome-elixir/master/README.md"
def update_lib_data do
parse_awesome_elixir() |> raw_contents() |> parse_contents()
end
def parse_awesome_elixir do
HTTPoison.get!(@url_for_elixir_list).body
end
... |
0062ff21fc59fbc60f01b5a9d09247e61655f448 | 2,862 | [
795406055
] | [
"liveview",
"ecto"
] | defmodule BankingAppWeb.AccountLive.FormComponent do
use BankingAppWeb, :live_component
alias BankingApp.Accounts
@impl true
def render(assigns) do
~H"""
<div>
<.header>
<%= @title %>
<:subtitle></:subtitle>
</.header>
<.simple_form
for={@form}
id="ac... |
00632b0123c640b87e7da4f9026b372f3d3ed097 | 1,710 | [
419820423
] | [
"test",
"ecto"
] | defmodule Velocity.Contexts.TeamsTest do
use Velocity.DataCase
alias Velocity.Contexts.Teams
describe "teams" do
alias Velocity.Schema.Team
@valid_attrs %{name: "some name"}
@update_attrs %{name: "some updated name"}
@invalid_attrs %{name: nil}
def team_fixture(attrs \\ %{}) do
{:ok,... |
00634addfa72ca27312683e9aba37f92887cc25d | 2,345 | [
102048685
] | [] | defmodule Converter do
def to_nearest_tenth(val) do
round_to(val, 1)
end
def to_km(val) do
val / 1000
end
def to_meters(val) do
val * 1000
end
def to_light_seconds({:miles, miles}, precision: precision) do
(miles * 5.36819e-6) |> round_to(precision)
end
def to_light_seconds({:meter... |
00635dec6547753dbd64d8b556214b61a2a89e76 | 2,144 | [
902059841
] | [
"documented"
] | defmodule Southdown.Term do
@moduledoc false
import Southdown.Utils, only: [map_to_pairs: 1]
alias Southdown.Async
alias Southdown.Basic
def get(key) do
with {:ok, binary} <- Basic.get(key) do
load(binary)
end
end
def hget(key, field) do
with {:ok, binary} <- Basic.hget(key, field) do
... |
0063b6eb22ee22662af588dbbf091cd267a8211c | 1,686 | [
143812440
] | [
"macro",
"documented",
"phoenix"
] | defmodule PhoenixDiscussWeb do
@moduledoc """
The entrypoint for defining your web interface, such
as controllers, views, channels and so on.
This can be used in your application as:
use PhoenixDiscussWeb, :controller
use PhoenixDiscussWeb, :view
The definitions below will be executed for every... |
0063c141f72c1577213bea487ffb4e8b7b8b854e | 2,416 | [
168753881,
333694281
] | [
"test",
"ecto"
] | defmodule Cforum.BadgesTest do
use Cforum.DataCase
alias Cforum.Badges
alias Cforum.Badges.Badge
test "list_badges/2 returns all badges" do
badge = insert(:badge)
badges = Badges.list_badges()
assert length(badges) == 1
assert [%Badge{}] = badges
assert Enum.map(badges, & &1.badge_id) == [... |
0063f34ae2f705d10ccedc3469580a2af5578e8e | 3,908 | [
451567660
] | [
"genserver",
"supervisor"
] | defmodule Wordual.GameServer do
use GenServer
require Logger
alias Wordual.Game
alias Wordual.Words
@registry Wordual.GameRegistry
@supervisor Wordual.GameSupervisor
@pubsub Wordual.PubSub
@impl true
def init(opts) do
{:ok, Game.init(Keyword.fetch!(opts, :game_id), Words.random_word())}
end
... |
00640c6210ec7b2a228257ec461ba7b88b8d7451 | 3,376 | [
105783894
] | [
"test"
] | defmodule PigLatinTest do
use ExUnit.Case
describe "ay is added to words that start with vowels" do
#@tag :pending
test "word beginning with a" do
assert PigLatin.translate("apple") == "appleay"
end
# @tag :pending
test "word beginning with e" do
assert PigLatin.translate("ear") ==... |
00641d76f4820fdda594158f573712bc4ef95249 | 15,803 | [
719315856
] | [] | %{
"auth_plug": {:hex, :auth_plug, "1.5.2", "3e330cd9c231a29dc9e0524ac4bf81444168dc3ab09bfe789048d88a06e4908a", [:mix], [{:envar, "~> 1.1.0", [hex: :envar, repo: "hexpm", optional: false]}, {:httpoison, "~> 1.8.0", [hex: :httpoison, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", op... |
00643269cea4b3ec2bcc2f653b6310d096e7ec0c | 2,161 | [
114698312
] | [] | %{
"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [], [], "hexpm"},
"excheck": {:hex, :excheck, "0.5.3", "7326a29cc5fdb6900e66dac205a6a70cc994e2fe037d39136817d7dab13cdabf", [], [], "hexpm"},
"excoveralls": {:hex, :excoveralls, "0.8.1", "0bbf67f22c7dbf75039... |
0064607a6a95e8ba44ddd59599f58d557de9ae23 | 2,380 | [
344854457
] | [
"phoenix",
"ecto"
] | defmodule EventsWeb.UserController do
use EventsWeb, :controller
alias Events.Users
alias Events.Users.User
alias Events.Photos
alias EventsWeb.Plugs
plug Plugs.RequireUser when action in [:edit, :update]
plug :require_owner when action in [:edit, :update]
def require_owner(conn, _args) do
{id, ... |
006477ab2af0fb3102b506acb39a92f09176f13a | 1,513 | [
96350285
] | [] | # 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 :channel,
ecto_repos: [Channel.Repo]
# ... |
0064a2abe05cd317048c2d3992960231e8b14256 | 2,700 | [
250904436,
448948658,
452045121,
459182862,
463612034,
475343077,
559744925,
789802355,
803502084,
856324570,
872091867,
913995146,
915448704,
934044764,
962529983,
999002987,
1017248001,
495424310,
610034669,
744142491,
823294387,
828087786,
829435121,
531890950,
599... | [
"typespec",
"documented"
] | defmodule Jason.OrderedObject do
@doc """
Struct implementing a JSON object retaining order of properties.
A wrapper around a keyword (that supports non-atom keys) allowing for
proper protocol implementations.
Implements the `Access` behaviour and `Enumerable` protocol with
complexity similar to keywords/... |
00654097dcd3d7b50f93d2f8ba8f6c1225a05d31 | 1,744 | [
138116902
] | [
"typespec",
"documented"
] | defmodule Bunyan.Shared.Options do
alias Bunyan.Shared.Level
@doc """
If `key` is present in `options`, add it to `config` under `internal_key`
"""
@spec maybe_add(struct(), keyword(), atom(), atom()) :: struct()
def maybe_add(config, options, key, internal_key \\ nil) do
case options[key] do
n... |
00658d04ee483fe3e691b2b686dc597ae1f55c60 | 1,650 | [
193244709,
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.HealthCare.V1.Model.GoogleCloudHealthcareV1DicomGcsSource do
@moduledoc """
Specifies the configuration for importing data from Cloud Storage.
## Attributes
* `uri` (*type:* `String.t`, *default:* `nil`) - Points to a Cloud Storage URI containing file(s) with content only. The URI must b... |
0065a120cea1e31d8dab94351838429ca36cc4e6 | 18,975 | [
350887529
] | [
"typespec",
"documented"
] | defmodule ExDoc.Autolink do
@moduledoc false
# * `:apps` - the app that the docs are being generated for. When linking modules they are
# checked if they are part of the app and based on that the links are relative or absolute.
#
# * `:current_module` - the module that the docs are being generated for. Use... |
0065c60b20d97df394d87f87bdc216d5ff6501b7 | 1,607 | [
225247204
] | [] | defmodule Day3 do
def input do
File.stream!("input.txt")
|> Enum.map(&parse/1)
end
def parse line do
line
|> String.trim
|> String.graphemes
|> Enum.map(&String.to_integer/1)
end
def transpose rows do
rows
|> List.zip
|> Enum.map(&Tuple.to_list/1)
end
def example do
["00100",
"11110",
"10... |
0065c8c5e2144cca3389bc13edd8092a26388494 | 10,330 | [
146480908
] | [
"typespec",
"documented"
] | defmodule Blockchain do
import Bitwise
@coin 1_000_000
@interval_target 5
@block_size 20_000
defmodule Mempool do
defstruct tx: %Transaction{}, fee: 0
@type t :: %{required(Crypto.hash256) => %Mempool{}}
@spec insert(t, Transaction.t, non_neg_integer) :: t
def insert(mempool, tx, fee), do... |
0066bba25f3c9914b49045f3f2141f82e52424a9 | 3,120 | [
158502872
] | [
"documented",
"ecto"
] | defmodule Iclog.Observable.ObservationMeta do
use Ecto.Schema
import Ecto.Changeset
import Ecto.Query, warn: false
alias Iclog.Repo
alias Iclog.Observable.ObservationMeta
alias Iclog.Observable.Observation
schema "observation_metas" do
field :intro, :string
field :title, :string
has_many :o... |
0066d170ad4f2364919695bbdaea4109c1dff5a4 | 8,567 | [
220055365,
223778392
] | [
"test",
"supervisor"
] | defmodule PROJ4Test do
use ExUnit.Case
doctest PROJ4
describe "Register" do
test "Register a new user with people(3) in the database" do
# User1 registring with username - "TA"
name = "TA"
pass = "p"
{password_list, total_users} = Register.reg(name, pass)
assert total_users == [... |
0067268942e7b53ba721a238a40af5ec57aca6a0 | 2,171 | [
804042562
] | [
"documented",
"ecto"
] | defmodule SwapListener.ChatSubscription.ChatSubscription do
@moduledoc false
use Ecto.Schema
import Ecto.Changeset
schema "chat_subscriptions" do
field :chat_id, :integer
field :chat_title, :string
field :token_address, :string
field :chain_id, :integer
field :min_buy_amount, :decimal, def... |
0067518d7f8321c81ddcb3cf36c33f49206e7c9e | 1,889 | [
41062594
] | [
"genserver"
] | defmodule TwitchStream.Api do
use GenServer
def start_link do
GenServer.start_link(__MODULE__, [], [name: __MODULE__])
end
def get_stream_playlist(channel) do
GenServer.call(__MODULE__, {:stream_url, channel})
end
def get_top_games do
GenServer.call(__MODULE__, :top_games)
end
def get_streams(game) do... |
00676e2da5b3df90f94b680775a08e16d1a231d1 | 3,273 | [
644902367
] | [
"liveview",
"test"
] | defmodule AlgoThinkWeb.ClassroomLiveTest do
use AlgoThinkWeb.ConnCase
import Phoenix.LiveViewTest
import AlgoThink.ClassroomsFixtures
@create_attrs %{}
@update_attrs %{}
@invalid_attrs %{}
defp create_classroom(_) do
classroom = classroom_fixture()
%{classroom: classroom}
end
describe "Ind... |
0067773e8e27bac588e49bdcca565e092d250962 | 8,880 | [
92519184
] | [] | defmodule Routemaster.PublisherSpec do
use ESpec
import Routemaster.TestUtils
alias Routemaster.Publisher
alias Plug.Conn
let :frozen_time, do: now()
before do
allow Routemaster.Utils |> to(accept :now, fn() -> frozen_time() end)
bypass = Bypass.open(port: 4567)
{:shared, bypass: bypass}
en... |
00679b75ff90515bc4824c94865c7bf59dcadd1e | 2,073 | [
960301463
] | [
"typespec",
"documented"
] | defmodule TaskSystem.TaskApi do
@moduledoc """
This plug allows interaction with the business logic of the `task_system` project
by providing an API which is available from the url **http://localhost:4000/tasks**.
It provides 3 endpoints with the following methods:
**POST**: To create a new task to be put i... |
0067b55ae1edd111d0a1c67831f60d875e11ba5e | 3,925 | [
828087786,
882758430,
875852258
] | [
"documented"
] | defmodule ElixirMake.Downloader.Httpc do
@moduledoc false
@behaviour ElixirMake.Downloader
@impl ElixirMake.Downloader
def download(url) do
url_charlist = String.to_charlist(url)
# TODO: Remove me when we require Elixir v1.15
{:ok, _} = Application.ensure_all_started(:inets)
{:ok, _} = Applic... |
00682df3d3406866b203ca84d3a4f206a1115c6e | 3,539 | [
839449908
] | [
"test"
] | defmodule HangmanImplGameTest do
use ExUnit.Case
alias Hangman.Impl.Game
test "new game returns structure" do
game = Game.new_game
assert game.turns_left == 7
assert game.game_state == :initializing
assert length(game.letters) > 0
end
test "new game returns correct word" do
game = Game.... |
0068a453626c0e03306e80809c51775c79d5b38a | 15,120 | [
815481642
] | [
"documented"
] | defmodule Envoy.Data.Accesslog.V3.AccessLogType do
@moduledoc """
[#protodoc-title: gRPC access logs]
Envoy access logs describe incoming interaction with Envoy over a fixed
period of time, and typically cover a single request/response exchange,
(e.g. HTTP), stream (e.g. over HTTP/gRPC), or proxied connection... |
00695fae4fcd6ce905c63abdeab4ca6653ff7760 | 2,008 | [
409711713
] | [
"typespec"
] | defmodule KitchenCalculator do
@spec get_volume(tuple) :: any
def get_volume(volume_pair) do
elem(volume_pair, 1)
end
@spec to_milliliter(
{:cup, number}
| {:fluid_ounce, number}
| {:milliliter, number}
| {:tablespoon, number}
| {:teaspoon, number}
... |
00697da92dbd2062eac53d19dac7b62984ab0661 | 4,434 | [
77198684
] | [
"documented"
] | defmodule EcCart.Cart do
@moduledoc """
Module to handle `EcCart` structures.
"""
defstruct items: [], adjustments: []
@doc """
Creates an empty %EcCart.Cart{} structure, this strucure has by default
and empty list of items and and empty list of adjustments
## Examples
iex> EcCart.Ca... |
006a592fef9d9b098415548da7b755d1d285d03b | 3,266 | [
419435907
] | [
"documented"
] | defmodule Oli.Delivery.PreviousNextIndex do
alias Oli.Delivery.Sections.Section
alias Oli.Delivery.Sections
alias Oli.Publishing.DeliveryResolver
alias Oli.Delivery.Hierarchy
alias Oli.Repo
@doc """
For a given section slug and a resource id of a page or container within the section hierarchy, returns th... |
006a70abe1a7bf7d3f880b9593ee6b18156f6ee2 | 1,856 | [
694298737
] | [
"test"
] | defmodule ElixirUserApiWeb.Schema.Queries.UserTest do
# use ExUnit.Case
use ElixirUserApiWeb.ConnCase
alias ElixirUserApi.Accounts
@find_user_doc """
query User($id: ID!){
user(id: $id){
id
name
email
preferences{
likesEmails
likesPhoneCalls
likesFaxes
... |
006a725cff8751d0edfc03358870992ec1f7b8eb | 3,551 | [
681964719
] | [
"liveview",
"test"
] | defmodule RiseShopWeb.AdminResetPasswordLiveTest do
use RiseShopWeb.ConnCase
import Phoenix.LiveViewTest
import RiseShop.BackofficeFixtures
alias RiseShop.Backoffice
setup do
admin = admin_fixture()
token =
extract_admin_token(fn url ->
Backoffice.deliver_admin_reset_password_instruc... |
006a97a1f77a517882fc9cd9183cb83de61fdfab | 3,000 | [
174749587
] | [] | %{
"certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"},
"earmark": {:hex, :earmark, "1.3.1", "73812f447f7a42358d3ba79283cfa3075a7580a3a2ed457616d6517ac3738cb9", [:... |
006ba654f7be318cd908af8020d93b6322af7dd7 | 3,702 | [
49995126
] | [
"typespec",
"documented"
] | defmodule Monzo.Client do
@moduledoc """
"""
defstruct access_token: nil, client_id: nil, client_secret: nil,
expires_in: nil, refresh_token: nil, token_type: nil, user_id: nil
@type t :: %__MODULE__{
access_token: String.t,
client_id: String.t,
client_secret: String.t,
expires_in:... |
006bc802b378b842299a3ba3c07e5a76cccbc3e1 | 2,213 | [
250784293
] | [
"supervisor"
] | "test/support/**/*.exs"
|> Path.wildcard()
|> Enum.each(&Code.require_file/1)
Mox.defmock(TimeZoneInfo.DataPersistenceMock, for: TimeZoneInfo.DataPersistence)
Mox.defmock(TimeZoneInfo.DataStoreMock, for: TimeZoneInfo.DataStore)
Mox.defmock(TimeZoneInfo.DownloaderMock, for: TimeZoneInfo.Downloader)
Mox.defmock(TimeZone... |
006bf57de0ad036d3016ac39306c25ad60d987ee | 2,880 | [
163965238
] | [
"genserver"
] | defmodule CredoCoreNode.Workers.BlockSyncer do
use GenServer
require Logger
import Process, only: [send_after: 3]
alias CredoCoreNode.Network
alias CredoCoreNode.Blockchain
@default_interval 10_000
def start_link(opts \\ []) do
GenServer.start_link(__MODULE__, opts)
end
def init(opts) do
... |
006c64ee5f7bf29cbd2ceebe3f61c6ff8bcd1b5b | 4,509 | [
153937532
] | [
"documented"
] | defmodule Aoc.Day19 do
def input(filename) do
filename
|> File.read!()
|> String.split("\n", trim: true)
|> Enum.map(fn
line ->
matches =
~r/Blueprint (?<blueprint>\d+): Each ore robot costs (?<ore_ore>\d+) ore\. Each clay robot costs (?<clay_ore>\d+) ore\. Each obsidian robot ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.