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 |
|---|---|---|---|---|
045987f3687db5fc9bb52b0e673efb4ea1d1f653 | 3,662 | [
756325358
] | [
"documented",
"ecto"
] | defmodule Vitali.Library do
@moduledoc """
The Library context.
"""
import Ecto.Query, warn: false
alias Vitali.{Board, Repo}
alias Vitali.Library.{Cell, Game}
@doc """
Returns the list of games.
## Examples
iex> list_games()
[%Game{}, ...]
"""
def list_games do
Repo.all(Game... |
045a22ebcb8005115b090332f1556549de8caabc | 1,710 | [
96891492
] | [
"ecto"
] | defmodule Elixir.Cryptofolio.Repo.Migrations.New_Coins do
use Ecto.Migration
use Cryptofolio.Web, :new_markets
def change do
Repo.insert! %Coin{
name: "Bitcoin",
symbol: "BTC"
}
Repo.insert! %Coin{
name: "Ethereum",
symbol: "ETH"
}
Repo.insert! %Coin{
name: "B... |
045a2de6281c07f4301a29f790f4a9e085130832 | 2,503 | [
583107024
] | [
"typespec",
"documented"
] | defmodule LSMT.Bloom do
@moduledoc """
A bare-bones bloom filter that uses integers and bitshifting.
## Hash Algorithms
Currently LSMT.Bloom is using `:erlang.phash/1` and `Murmur.hash_x64_128/1`
as it's default hashes.
"""
import Bitwise
@derive {Inspect, only: [:size, :capacity, :hashers]}
@def... |
045a659d46d90fa9b8823be528fd33dcc7a97fa8 | 1,667 | [
236372440
] | [
"phoenix"
] | defmodule BloomchainWeb.TagController do
use BloomchainWeb, :controller
alias Bloomchain.{Repo, Content.Tag}
alias Bloomchain.ElasticsearchCluster, as: ES
alias BloomchainWeb.Workflow.RecomendationPosts
def show(conn, %{slug: tag, scroll: scroll}) do
%{entries: articles, metadata: meta} = do_query(tag, ... |
045abe6ea5340091ef64e6a52cad1481b8098fb0 | 4,862 | [
100692582
] | [
"typespec",
"macro",
"documented"
] | defmodule Dextruct do
@moduledoc """
The operator `<~` imitates destructing assignment behavior like in Ruby or ES6.
It's so obvious that pattern matching with `=` is just awesome. But less then occasionally, we still want some destructing assignment, witout MatchError, works like in other languge. Dextruct libr... |
045ad5d4e42b3f13618a66511b42033d4d5a4bea | 1,910 | [
191584919
] | [
"genserver"
] | defmodule Convulse.Server do
use GenServer
@base_url "consul.service.consul:8500/v1/catalog/service/"
def start_link do
GenServer.start_link(__MODULE__, [], name: __MODULE__)
end
def discover(service_name) do
GenServer.call(__MODULE__, {:discover, service_name})
end
# callbacks
def handle_ca... |
045ae002272eaa7d0a13d4bfb4c5dda41da18ebe | 4,050 | [
575079608
] | [] | defmodule Day11 do
defp read_input() do
File.read!("lib/inputs/day_11.input")
|> to_string()
|> String.split("\n\n", trim: true)
end
def solve_1() do
monkeys =
read_input()
|> process_monkeys()
turns = Map.keys(monkeys) |> Enum.sort() |> List.duplicate(20) |> List.flatten()
... |
045aff720f17d6d4bbfe6cce9851c9529bea64f8 | 4,210 | [
204030855
] | [
"genserver",
"liveview"
] | defmodule LvtestWeb.Node do
alias LvtestWeb.Node
defstruct id: nil, counter: 0
def new(id), do: %Node{id: id}
end
defmodule LvtestWeb.Nodes do
alias LvtestWeb.Node
@ets_table_name :nodes
def create(id) do
node = Node.new(id)
put(node)
end
def get(id) do
[{_, node}] = :ets.lookup(@ets_t... |
045b1961607fef8aeb8e58a0a02193b1d10b5f54 | 2,693 | [
421520876
] | [] | defmodule Verifier.ProcessConverter do
alias Common.Indent, as: Indent
def convert_process(process_lines, function_name, indent_lvl) do
process_properties =
process_lines
|> Enum.with_index()
|> Enum.reduce(%{}, fn {line, idx}, acc ->
is_idx_inside_part =
Map.values(acc)
... |
045b3c442ad1cbe9749fc5f5895d347a244fa015 | 1,976 | [
979013721
] | [] | # 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
config :cym_app,
ecto_repos: [CymApp.Repo],
gener... |
045bcbde201ef04e2f8b60baf8952f690f018617 | 4,091 | [
567859866
] | [
"test",
"ecto"
] | defmodule Booksearch.SearchsTest do
use Booksearch.DataCase
use ExUnit.Case, async: true
use Mimic.DSL
alias Booksearch.Searchs
alias Booksearch.Searchs.Search
alias Support.Fixture.FixtureHelper
@auth_header {"Auth", "Fake"}
@headers [
{"Content-Type", "application/xml"},
{"Accept", "applicat... |
045c03381474287d703e9d494bf740cc1c91e471 | 1,520 | [
933250259,
843400835
] | [
"macro",
"documented"
] | defmodule PhoenixAnalytics.Queries.Analytics.Charts.Popular do
@moduledoc false
defmacro __using__(_opts) do
quote do
import PhoenixAnalytics.Queries.Helpers
@table PhoenixAnalytics.Queries.Table.name()
@app_domain Application.compile_env(:phoenix_analytics, :app_domain) ||
... |
045c8551614be6b90a4a8597fe521fca5ef91c87 | 5,431 | [
882663411
] | [
"liveview",
"documented",
"ecto"
] | defmodule StridentWeb.Components.PhotoGallery do
@moduledoc false
use StridentWeb, :live_component
alias Strident.Accounts.User
alias Strident.Multimedia
alias Strident.Multimedia.Photo
alias Strident.SimpleS3Upload
alias Phoenix.LiveView.JS
@impl true
def mount(socket) do
{:ok, socket}
end
... |
045c9c530e55e690a9496b412b7f76b7e5cd3c53 | 2,492 | [
938349679,
54749959
] | [
"test"
] | defmodule Commanded.ProcessManager.DynamicProcessManagerApplicationTest do
use ExUnit.Case
alias Commanded.ExampleDomain.BankAccount.Commands.OpenAccount
alias Commanded.ExampleDomain.BankAccount.Events.{BankAccountOpened, MoneyDeposited}
alias Commanded.ExampleDomain.BankApp
alias Commanded.Helpers.{Command... |
045ce545ee6e0077bab82d356b0b7e17d7a38d3f | 1,728 | [
715963273
] | [
"genserver",
"typespec"
] | defmodule LRUCache do
use GenServer
@spec init_(capacity :: integer) :: any
def init_(capacity), do: GenServer.start_link(__MODULE__, capacity, name: Module.concat(__MODULE__, H))
def init(capacity), do: {:ok, %{capacity: capacity, oc: capacity, cache: []}}
def put(key, value), do: GenServer.call(__MODULE_... |
045da90285b6da598f551cda434e71e8c0460ca2 | 2,969 | [
451293589
] | [
"phoenix"
] | defmodule SimpleAuthWeb.Router do
use SimpleAuthWeb, :router
import SimpleAuthWeb.AccountAuth
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, {SimpleAuthWeb.LayoutView, :root}
plug :protect_from_forgery
plug :put_secure_brows... |
045e0b8e42bf63ee5b36fd847eafcb081570ed32 | 4,963 | [
199356007
] | [] | defmodule HounddyWeb.Schema.ProfilesTypes do
use Absinthe.Schema.Notation
use Absinthe.Ecto, repo: Hounddy.Repo
alias HounddyWeb.Resolvers.Profiles
# alias HounddyWeb.Schema.Middleware
object :candidate do
field :id, :id
field :about_me, :string
field :city, :string
field :country, :string
... |
045e174fa9f9b70fc4a23c6e69c1c0be11694778 | 6,124 | [
119747156
] | [
"test",
"phoenix"
] | defmodule NervesHubWeb.API.DeploymentGroupControllerTest do
use NervesHubWeb.APIConnCase, async: true
alias NervesHub.AuditLogs
alias NervesHub.Fixtures
alias NervesHub.ManagedDeployments.DeploymentGroup
describe "index" do
test "lists all deployments", %{conn: conn, org: org, product: product} do
... |
045ec5215274583979027ba6e97cb766d956cc25 | 4,889 | [
532902843
] | [
"typespec",
"liveview"
] | defmodule ChirpCockroachWeb.IrcLive.IrcComponents do
use ChirpCockroachWeb, :component
def irc_room_list(%{rooms: _} = assigns) do
~H"""
<ul class="list" id="rooms-list" phx-update="stream">
<%= for {id, room} <- @rooms do %>
<li id={id}>
<.link navigate={~p"/irc/#{room.id}"}><%= ... |
045ed2a843db2c3c578b3dfd0724585fab1dac30 | 1,528 | [
63146996
] | [] | defmodule TokyoexHandsonDemo.Crawler.Storage do
require Logger
def start_link do
Agent.start_link(fn -> Map.new end, name: __MODULE__)
end
def has_page?(url) do
Agent.get __MODULE__, fn map ->
Map.has_key?(map, url)
end
end
def put_page(url, pages) do
Logger.debug "--- Put #{url} --... |
045fef2e93ce8194e6f60185e04e5dd3d6f5faa6 | 1,770 | [
615844525
] | [
"phoenix",
"ecto"
] | defmodule NPlusOneWeb.ProfileController do
use NPlusOneWeb, :controller
alias NPlusOne.Accounts
alias NPlusOne.Accounts.Profile
def index(conn, _params) do
profiles = Accounts.list_profiles()
render(conn, :index, profiles: profiles)
end
def new(conn, _params) do
changeset = Accounts.change_pr... |
0460ab1c6d9cb76193556ed4aad1f205ab14b47c | 2,966 | [
68166595
] | [] | %{"certifi": {:hex, :certifi, "0.7.0", "861a57f3808f7eb0c2d1802afeaae0fa5de813b0df0979153cbafcd853ababaf", [:rebar3], []},
"combine": {:hex, :combine, "0.9.3", "192e609b48b3f2210494e26f85db1712657be1a8f15795656710317ea43fc449", [:mix], []},
"excoveralls": {:hex, :excoveralls, "0.5.7", "5d26e4a7cdf08294217594a1b0643... |
0460db1a7203682a5edd73cc8abf093c743c4edd | 2,421 | [
318945858
] | [] | defmodule Pleroma.Config do
defmodule Error do
defexception [:message]
end
def get(key), do: get(key, nil)
def get([key], default), do: get(key, default)
def get([_ | _] = path, default) do
case fetch(path) do
{:ok, value} -> value
:error -> default
end
end
def get(key, default... |
04610818366e8cc97873dc7eb3a71214009ac5be | 1,904 | [
734376659,
526566426
] | [] | defmodule RentCars.Rentals.ReturnCar do
defstruct rental: nil, days: nil, delay: nil, total_fees: nil
import Ecto.Query
alias Ecto.Multi
alias RentCars.Cars.Car
alias RentCars.Rentals.Rental
alias RentCars.Repo
def execute(rental_id, user_id) do
with %__MODULE__{} = return_rental <- get_rental(renta... |
04613c3ad3e52fcf8209d1b391636a0d40cd5b12 | 2,704 | [
57101607
] | [] | defmodule Sonex.SubHandlerRender do
import SweetXml
alias Sonex.SubHelpers
alias Sonex.Network.State
def init(req, _opts) do
handle(req, %{})
{:ok, req, :no_state}
end
def handle(request, state) do
{:ok, data, _} = :cowboy_req.read_body(request, %{})
sub_info_base = SubHelpers.create_sub_... |
04614951af432eb9d60e53e41de21462ab8f4e85 | 3,462 | [
116092817
] | [
"test"
] | defmodule SimpleWeb.Plug.DataToAttributesTest do
use SimpleWeb.ConnCase
alias SimpleWeb.Plug.DataToAttributes
test "converts basic JSON API payload to params suitable for Ecto", %{conn: conn} do
payload = %{
"data" => %{
"attributes" => %{"foo" => "bar", "baz" => "bat"},
"id" => "1",
... |
0461af345960a53ad4bad3c33a8b19833a677cf9 | 9,370 | [
43914111,
202972284,
502454424
] | [
"typespec",
"macro",
"documented"
] | defmodule Thrift.Generator.Utils do
@moduledoc false
alias Thrift.AST.{
Constant,
Field,
Schema,
Struct,
TEnum,
TypeRef,
ValueRef
}
alias Thrift.NaN
alias Thrift.Parser.FileGroup
@doc """
When nesting a quote with multiple defs into another quote, the defs end up
wrapped i... |
0461c3541ebbd94eeb015dc940fdc20be9b11892 | 1,939 | [
294228875
] | [
"macro",
"documented",
"phoenix"
] | defmodule CodeChallengeWeb 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 CodeChallengeWeb, :controller
use CodeChallengeWeb, :view
The definitions below will be executed for every vi... |
0461d3cda2aaaaf312662ee0f2f3c743358653d6 | 2,339 | [
199046635
] | [
"typespec"
] | defmodule Hibiki.Command.Context do
defstruct client: nil,
messages: [],
event: nil,
replied: false,
command: nil,
args: %{},
start_time: nil
@type t :: %__MODULE__{
client: LineSDK.Client.t() | nil,
messages: [any],
... |
0461d489854845b34e4e2c9e0c892425eb6dc253 | 2,144 | [
815409358
] | [] | defmodule HiveforgeController.ProtectedRouter do
use Plug.Router
require Logger
plug(:log_protected_request)
plug(:log_headers)
plug(HiveforgeController.JWTAuthPlug)
plug(HiveforgeController.DebugPlug)
plug(HiveforgeController.GzipDecompressor)
plug(Plug.Parsers,
parsers: [:urlencoded, :multipart, ... |
0461d58945ff9ce051c29625f94e428656a46a37 | 2,185 | [
815481642
] | [
"documented"
] | defmodule Envoy.Api.V2.Ratelimit.RateLimitDescriptor.Entry do
use Protobuf, protoc_gen_elixir_version: "0.14.1", syntax: :proto3
field :key, 1, type: :string, deprecated: false
field :value, 2, type: :string, deprecated: false
end
defmodule Envoy.Api.V2.Ratelimit.RateLimitDescriptor do
@moduledoc """
A Rate... |
0461e1b842febf49ebb75f0e966c23796e7409c4 | 3,257 | [
296295613
] | [
"test"
] | defmodule MoonWeb.Examples.Table.WithPagingTest do
use MoonWeb.ConnCase, async: true
test "should change page with button", %{conn: conn} do
{:ok, view, _html} = live(conn, "/example/Design.TableExample.WithPaging")
assert view
|> element("#with_buttons nav[aria-label=pagination]")
|... |
0462a5b2b6fa306bd7ff866a960dcf72c25b5d8b | 2,401 | [
896186539
] | [] | # 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
config :stickerbooru,
ecto_repos: [Stickerbooru.Rep... |
0462a83b4259d1e13233be2b9e920e340597e880 | 2,566 | [
43093301
] | [
"genserver"
] | defmodule Torrent.Acceptor.Peer do
use GenServer
require Logger
alias :gen_tcp, as: TCP
alias __MODULE__, as: State
defstruct(
socket: nil,
peer_id: nil
)
# Client API
def start_link(accept_socket, peer_id) do
GenServer.start_link(__MODULE__, [accept_socket, peer_id])
end
# Server c... |
0462aa488ab298742f62abb39cad8edcd94b2bb2 | 1,662 | [
387892054
] | [
"typespec",
"liveview"
] | defmodule KamanskyWeb.CustomerLive.Show do
use KamanskyWeb, :live_view
use KamanskyWeb.Paginate, sort: {1, :desc}
import Kamansky.Helpers, only: [format_decimal_as_currency: 1, formatted_date: 1]
alias Kamansky.Sales.{Customers, Orders}
alias Kamansky.Sales.Orders.Order
@impl true
@spec mount(map, map,... |
0462cc1cefe3e0ae1b1c5e3cfe1f8e38409cd16e | 3,073 | [
260814743
] | [
"liveview",
"documented"
] | defmodule JeopardyWeb.Components do
@moduledoc false
use Phoenix.Component
use Phoenix.VerifiedRoutes, endpoint: JeopardyWeb.Endpoint, router: JeopardyWeb.Router
alias Phoenix.LiveView.JS
embed_templates "functional_components/*"
slot :inner_block, required: true
slot :timer
attr :contestants, :map, ... |
0462cd09e2653718d44730bb8cdb1391be37d073 | 1,702 | [
93765520,
71608796,
47486383,
99250164
] | [
"macro",
"test"
] | Code.require_file "../test_helper.exs", __DIR__
defmodule ExUnit.RegisterTest do
use ExUnit.Case
import ExUnit.CaptureIO
test "singular test types" do
on_exit fn ->
ExUnit.configure(plural_rules: %{})
end
ExUnit.plural_rule("property", "properties")
defmodule SingularTestTypeCase do
... |
0462edf131afafd764a7f2985265e058bafbc9ae | 2,787 | [
173249834
] | [
"phoenix",
"ecto"
] | defmodule TasksWeb.UserController do
use TasksWeb, :controller
alias Tasks.Users
alias Tasks.Users.User
alias Tasks.TodoItems
def index(conn, _params) do
users = Users.list_users()
render(conn, "index.html", users: users)
end
def new(conn, _params) do
changeset = Users.change_user(%User{})
... |
04642834729aa83918e3d16e2c12caaddebfeeda | 2,181 | [
395691379
] | [
"documented",
"ecto"
] | defmodule BlogPostApi.Accounts do
@moduledoc """
The Accounts context.
"""
import Ecto.Query, warn: false
alias BlogPostApi.Repo
alias BlogPostApi.Accounts.User
alias BlogPostApi.Pagination
@doc """
Returns the list of users.
## Examples
iex> list_users()
[%User{}, ...]
"""
de... |
046431cd3801b881137f973c79fb408e6e38af50 | 4,377 | [
584094958
] | [
"genserver",
"liveview"
] | import Ecto.Query, only: [from: 2]
defmodule AurigaWeb.RoomLive do
use AurigaWeb, :live_view
use Timex
require Logger
alias Auriga.Accounts
alias Auriga.Accounts.User
alias Auriga.Room
alias Auriga.Repo
alias Auriga.Message
defp find_current_user(session) do
with user_token when not is_nil(user... |
046584000991d9b62b1d3e84de78d767bab46f09 | 1,716 | [
852454363
] | [
"documented",
"ecto"
] | defmodule WarehouseManagement.Warehouse do
@moduledoc """
The Warehouse context.
"""
import Ecto.Query, warn: false
alias WarehouseManagement.Repo
alias WarehouseManagement.Warehouse.Area
@doc """
Returns the list of areas.
## Examples
iex> list_areas()
[%Area{}, ...]
"""
def lis... |
046587b62fbe1b50352ba286125b7aa47a8349e0 | 1,882 | [
60067859
] | [] | defmodule Workshop.Meta do
use Workshop.Info
@title "Elixir Workshop"
@version "0.0.1"
@generator_version "0.5.1"
@home "https://github.com/Tuxified/weert-workshop"
@shortdesc "A starter workshop to learn Elixir while making a game"
# The description should state what the user will learn from this works... |
0465999a63085057bd8a306309a5afefaf649b37 | 2,621 | [
46993688
] | [
"phoenix"
] | defmodule Micro.BarcodeController do
use Micro.Web, :controller
alias Micro.Barcode
plug :scrub_params, "barcode" when action in [:create, :update]
plug :assign_product
# def index(conn, _params) do
# barcodes = Repo.all(Barcode)
# render(conn, "index.html", barcodes: barcodes)
# end
def new(c... |
0465b1f09918817506df8f74b60492adb4261ebd | 21,243 | [
239822890,
459291087
] | [
"documented",
"ecto"
] | defmodule Oli.Institutions do
@moduledoc """
The Institutions context.
"""
import Ecto.Query, warn: false
alias Oli.Repo
alias Oli.Repo.{Paging, Sorting}
alias Oli.Institutions.{Institution, PendingRegistration, RegistrationBrowseOptions, SsoJwk}
alias Oli.Lti.Tool.Registration
alias Oli.Lti.Tool.D... |
0465d861c4b723502fa20b0c63c5df8274e65014 | 2,852 | [
874886877
] | [] | defmodule Mix.Tasks.GenerateData do
use Mix.Task
@shortdoc "Generate a test data from OKex API"
@requirements ["app.start"]
@endpoint "https://www.okx.com/api/v5/market/history-candles"
@attributes [:ts, :open, :high, :low, :close, :volCcyQuote, :volCcy, :vol, :confirm]
@impl Mix.Task
def run(args) do
... |
046648d2caf14a85e980cf04891727aa5f146cde | 1,919 | [
75447619
] | [] | defmodule DayFour.Solution do
def part_one(line) do
line
|> Enum.map(&Task.async(fn -> process_line(&1) end))
|> Enum.map(&Task.await(&1))
|> Enum.filter(&validate(&1))
end
def part_two(line) do
line
|> Enum.map(&Task.async(fn -> process_line(&1) end))
|> Enum.map(&Task.await(&1))
... |
04664bc01056dd333024ad966ae0b67556887e10 | 2,804 | [
835492298
] | [
"typespec",
"documented"
] | if Code.loaded?(Tesla) do
defmodule KineticLib.SFMC.TeslaMiddleware do
@moduledoc """
A `Tesla.Middleware` which handles requesting and caching authorization tokens
for SFMC APIs, adding them as a request header, and dynamically setting the
request base URL.
This is based on `KineticLib.AuthToken... |
0466f62faf3f5de1213ed00fa04b1748ec671cbb | 6,350 | [
437624993
] | [
"test",
"ecto"
] | defmodule PhoneBook.ContactsTest do
use PhoneBook.DataCase
alias PhoneBook.Accounts
alias PhoneBook.Accounts.User
alias PhoneBook.Contacts
alias PhoneBook.Contacts.{Contact, Phone}
import PhoneBook.ContactsFixtures
describe "contacts" do
@invalid_attrs %{name: nil, user_id: nil}
test "list_con... |
04685616ed27332af498b19bb189711528dc874b | 3,839 | [
160471092
] | [] | defmodule Thirteen do
def load(filename \\ "input.txt") do
File.stream!(filename)
|> Enum.zip(Stream.iterate(0, &(&1 + 1)))
|> Enum.flat_map(fn {line, lineno} ->
Enum.zip(String.to_charlist(line), Stream.iterate(0, &(&1 + 1)))
|> Enum.map(fn {c, colno} -> {{colno, lineno}, c} end)
end)
... |
04685e9140a4ae30e83a6074e541c2359303ac4a | 3,357 | [
116430934
] | [
"test"
] | defmodule RazorTestWeb.CardControllerTest do
use RazorTestWeb.ConnCase
import RazorTest.Factory
alias RazorTest.Cards
alias RazorTest.Repo
@create_attrs %{name: "Forest", number_owned: 4}
@update_attrs %{name: "some updated name", number_owned: 5}
@invalid_attrs %{name: nil, number_owned: nil}
def f... |
0468ae2705d1c75de2b8381a65b4c83be0045fee | 1,861 | [
120200943
] | [
"test",
"phoenix"
] | defmodule SocketProxyWeb.RoomChannelTest do
use SocketProxyWeb.ChannelCase
use SocketProxy
alias SocketProxyWeb.RoomChannel
alias SocketProxyWeb.UserSocket
describe "using the pids as identifiers" do
setup do
{:ok, proxy_pid} = start_proxy()
params = %{"name" => "alice"}
{:ok, socket} ... |
0469585b13fd39e24f47b1dfb96034e11389ad57 | 3,118 | [
119980054
] | [
"typespec",
"documented"
] | defmodule Envoy.Config.Filter.Network.ThriftProxy.V2alpha1.RouteConfiguration do
@moduledoc false
use Protobuf, syntax: :proto3
@type t :: %__MODULE__{
name: String.t(),
routes: [Envoy.Config.Filter.Network.ThriftProxy.V2alpha1.Route.t()]
}
defstruct [:name, :routes]
field :name,... |
0469a9a10c4499fe8bc312915f90871a3fad44b5 | 2,483 | [
153937532
] | [
"documented"
] | defmodule Aoc.Day8 do
@doc """
iex> "priv/day8/example.txt" |> Aoc.Day8.input() |> Aoc.Day8.part1()
4
iex> "priv/day8/example2.txt" |> Aoc.Day8.input() |> Aoc.Day8.part1()
14
"""
def part1(list) do
list
|> Enum.filter(fn {_, char} -> char != "." end)
|> Enum.group_by(fn {_, an... |
046a1a69e59e934ebfffbf948eed7937e300befb | 1,717 | [
845730823
] | [] | defmodule CookbookWeb.OnboardingLive.SwiftUI do
use CookbookNative, [:render_component, format: :swiftui]
def render(assigns) do
~LVN"""
<VStack style="padding();" spacing={32}>
<Text style="font(.largeTitle); bold();">What's New</Text>
<Grid alignment="leading" horizontalSpacing={16} verticalS... |
046a8ead582520fd566b3a16712057042f19a2dc | 9,704 | [
379678050
] | [
"documented"
] | defmodule Absinthe.Type.BuiltIns.Introspection do
@moduledoc false
use Absinthe.Schema.Notation
object :__schema do
description "Represents a schema"
field :types, list_of(:__type) do
resolve fn _, %{schema: schema} ->
types =
Absinthe.Schema.types(schema)
|> Enum.sort... |
046aa6c94b3fd4590dac26f6d09b5245af62a4e8 | 2,478 | [
351265914
] | [] | defmodule GlobalApi.MixProject do
use Mix.Project
def project do
[
app: :global_api,
version: "1.0.2",
elixir: "~> 1.14",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: Mix.compilers(),
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
... |
046ae7c70f06fc9903cdc48826a312e4fa2cef69 | 1,714 | [
398520125
] | [
"test"
] | defmodule GitHubActions.ConfigTest do
use ExUnit.Case, async: true
import Prove
alias GitHubActions.Config
doctest Config
setup do
Config.read("priv/config.exs")
:ok
end
describe "read/1" do
test "raises error" do
assert_raise File.Error, fn ->
Config.read("config/not/exists... |
046b0b8c7c6f887486a8328b108061b776036ff4 | 2,784 | [
711514210
] | [
"documented"
] | defmodule IslandsEngine.Impl.Island do
@moduledoc false
alias __MODULE__
alias IslandsEngine.Impl.Coordinate
@enforce_keys [:coordinates, :hit_coordinates]
defstruct [:coordinates, :hit_coordinates]
def new(shape, %Coordinate{} = island_position) when is_atom(shape) do
with {:ok, shape} <- check_valid... |
046ba9f2f713607a208d653f25d6c1c629468a9e | 2,135 | [
573192655
] | [] | defmodule Day14 do
def start() do
input = File.read!("input.txt") |> String.replace("\r", "") |> String.split()
|> Enum.map(&String.graphemes/1) |> Enum.map(&List.to_tuple/1) |> List.to_tuple()
IO.inspect(part_1(input), label: "Part 1: ")
IO.inspect(part_2(input), label: "Part 2: ")
end
def part... |
046bb779bda883f4d621ee96b3d9a48ff022c58a | 13,222 | [
743563485
] | [
"macro",
"test",
"documented"
] | defmodule Fluid.CircularityTest do
@moduledoc """
###########################################################################
Euler Algorithm
1. FeederNodes , UnconnectedNodes in world.
-> determinate
2. Everything else
-> indeterminate
3. Eliminate Feeder nodes and arrows away from them
4. => s... |
046be7837227cb19610079d03e1b4a9dc3daefe6 | 2,146 | [
133963088
] | [
"genserver",
"documented"
] | defmodule KV.Registry do
use GenServer
## Client API
@doc """
Starts the registry.
"""
def start_link(table, event_manager, buckets, opts \\ []) do
# 1. We now expect the table as argument and pass it to the server
GenServer.start_link(__MODULE__, {table, event_manager, buckets}, opts)
end
@d... |
046c3a512240b9d5fdc20d920690e8dc6e7e3b58 | 3,517 | [
253124027
] | [] | defmodule Racko.Game do
defstruct deck: [],
revealed: [],
players: %{},
winner: nil,
active_player: nil,
owner: nil,
started: false
alias Racko.{Player, Game}
@rack_size 10
def new(owner) do
%Game{}
|> Map.put(:players, %{owner.n... |
046c4fc613c5aba8713d2623fb29cce96b14c6b4 | 21,852 | [
744281225,
116826798,
313251367
] | [
"test"
] | defmodule AdminAPI.V1.AccountControllerTest do
use AdminAPI.ConnCase, async: true
alias EWalletDB.{Account, Membership, Repo, Role}
alias ActivityLogger.System
alias Utils.Helpers.DateFormatter
alias EWalletConfig.Config
describe "/account.all" do
test_with_auths "returns a list of accounts and paginat... |
046c6c029ae171d4d168214633b3c1fc0eec67ed | 3,129 | [
75388431
] | [] | # simplest function
sum = fn (a, b) -> a + b end
# invoking the above anonymous function
sum.(1, 2)
# We can omit parentheses in a function definition
f1 = fn a, b -> a * b end
f1.(5, 6)
# No arguments function
greet = fn -> IO.puts "Hello" end
greet.() #parentheses are required even if no arguments are passed
# We ... |
046e33ca352b636336e6d9d2e22091a8bb931c08 | 23,389 | [
325238698
] | [
"test"
] | defmodule Mjw.SeatTest do
use ExUnit.Case, async: true
describe "empty?" do
test "true if player_id is nil" do
seat = %Mjw.Seat{}
assert Mjw.Seat.empty?(seat)
end
test "false if player_id is present" do
seat = %Mjw.Seat{player_id: "123"}
refute Mjw.Seat.empty?(seat)
end
e... |
046e5a939464dfafff4ef829c689a7016fc4f809 | 6,437 | [
237945670
] | [] | use Timex
require Logger
require Math
defmodule Colins.Configs.ConfigGenerator do
def build_config_with_topology(sim_id,max_timepoint,_results_folder,network_topology,mesh_size,start_step_size \\ nil) do
%{
"sim_id" => sim_id,
"max_timepoint" => max_timepoint,
"node_type" => "parti... |
046ea0d97b4dd43ad956e05a2609a01c85f079de | 5,810 | [
941609941
] | [
"liveview",
"phoenix"
] | defmodule DukkadeeWeb.CustomerPortal.NewAppointmentLive do
use DukkadeeWeb, :live_view
alias Dukkadee.Appointments
alias Dukkadee.Customers
alias Dukkadee.Products
@impl true
def mount(_params, session, socket) do
case session["customer_id"] do
nil ->
{:ok,
socket
|> p... |
046f1ce0cb7e964c6c123be4fc86e494415df4a3 | 2,310 | [
400904412
] | [
"test"
] | defmodule OrganizationTest do
use ExUnit.Case
alias BuildkiteEx.Organization
setup do
Tesla.Mock.mock(fn env -> get_mock(env) end)
[client: BuildkiteEx.Client.new("token")]
end
test "get organization", %{client: client} do
assert {:ok, resp} = Organization.get(client, "my-org")
assert resp... |
046faff1cc22b753b4ea37ffeb13d717c6952e2b | 4,528 | [
898776424
] | [
"documented"
] | defmodule Aletopelta.Year2024.Day04 do
@moduledoc """
Day 4 of Year 2024
"""
defmodule Common do
@moduledoc """
Common part for Day 4
"""
end
defmodule Part1 do
@moduledoc """
Part 1 of Day 4
"""
def execute(input) do
result =
input
|> Enum.map(&count_horiz... |
046fc3aadf46b3b757983a4f7b2052cb71adc057 | 4,070 | [
323601241
] | [
"documented",
"ecto"
] | defmodule LoanSystem.Branch do
@moduledoc """
The Branch context.
"""
import Ecto.Query, warn: false
alias LoanSystem.Repo
alias LoanSystem.Branch.Branchs
@doc """
Returns the list of tbl_branchs.
## Examples
iex> list_tbl_branchs()
[%Branchs{}, ...]
"""
def list_tbl_branchs do
... |
0470087574ac5a7f1e3aeb8d308bbaf5c5fcc78a | 2,437 | [
266869063
] | [
"phoenix",
"ecto"
] | defmodule ChatAppWeb.RoomController do
use ChatAppWeb, :controller
alias ChatApp.Talk.Room
alias ChatApp.Talk
plug ChatAppWeb.Plugs.AuthUser when action not in [:index]
plug :authorise_user when action in [:edit, :update, :delete]
def index(conn, _params) do
rooms = Talk.l... |
04702f50ccdd9ba86683252b0e2388a235dfbc8a | 6,010 | [
100111402
] | [
"test"
] | defmodule ReleasePing.Workflows.PublishReleasesTest do
alias ReleasePing.Core
alias ReleasePing.Workflows.PublishReleases
alias ReleasePing.Incoming.Events.NewGithubReleasesFound
alias ReleasePing.Fixtures.GithubResponses
alias ReleasePing.Core.Commands.PublishRelease
use ReleasePing.DataCase
import Rel... |
0470abfad6992fb593d48e1678cb0fdcaf5d8494 | 2,342 | [
48644101
] | [
"phoenix"
] | defmodule Haypoll.PollController do
use Haypoll.Web, :controller
alias Haypoll.Poll
alias Haypoll.Entry
plug :scrub_params, "poll" when action in [:create, :update]
def index(conn, _params) do
polls = Repo.all(Poll)
render(conn, "index.html", polls: polls)
end
def new(conn, _params) do
cha... |
0470b0e8abdb6077fefbde7f883e9da35599c92b | 1,538 | [
167666779
] | [
"phoenix"
] | require IEx
defmodule BingoHallWeb.GameController do
use BingoHallWeb, :controller
alias Bingo.{GameServer, GameSupervisor}
action_fallback GeneralFallbackController
plug :require_player
def new(conn, _params) do
render(conn, "new.html")
end
def create(conn, %{"game" => %{"size" => size}}) do
... |
0470ce67300e055467f5a5029f6430a7bbe4b739 | 6,777 | [
965914483
] | [
"documented"
] | defmodule OptimumCredo.Check.Readability.ImportOrder do
@moduledoc """
A check that ensures imports are alphabetically ordered.
Alphabetically ordered imports are more easily scannable by the reader.
This check enforces that imports are ordered alphabetically within their groups.
"""
use Credo.Check,
... |
0471baad272e6da38da9215dce85db1acbb49d44 | 2,286 | [
491961474
] | [
"typespec",
"supervisor",
"documented"
] | defmodule SpawnSdk do
@moduledoc "README.md"
|> File.read!()
|> String.split("<!-- MDOC !-->")
|> Enum.fetch!(1)
defmodule ActorRef do
@enforce_keys [:name]
defstruct system: nil, name: nil, opts: []
@type t() :: %__MODULE__{
system: String.t(),
... |
0472228f29349965da06c73b5b019319d86e91bf | 2,451 | [
736944816
] | [
"liveview"
] | defmodule GalaxiesWeb.ShipyardLive do
use GalaxiesWeb, :live_view
alias Galaxies.Accounts
import GalaxiesWeb.CommonComponents
def mount(_params, _session, socket) do
socket = GalaxiesWeb.Common.mount_live_context(socket)
planet_ships = Accounts.get_planet_ship_units(socket.assigns.current_planet)
... |
0472b0520078df852fa7fec83db37457f41fabb2 | 2,777 | [
201769104,
672380245
] | [
"test"
] | defmodule BSV.SigTest do
use ExUnit.Case, async: true
alias BSV.Sig
alias BSV.{OutPoint, PrivKey, PubKey, Script, Tx, TxIn, TxOut, Util}
@prev_txout %TxOut{
satoshis: 50000,
script: %Script{chunks: [
:OP_DUP,
:OP_HASH160,
<<47, 105, 50, 137, 102, 179, 60, 141, 131, 76, 2, 71, 24, 254,... |
0472b890956babffa18efd252dfc2c47d91e7635 | 1,660 | [
658708181
] | [
"typespec",
"documented"
] | defmodule Azul.Game do
@moduledoc """
Provides functions for playing a game of Azul.
"""
alias Azul.Models
alias Azul.Models.TileColor
@doc """
A player takes tiles from a factory and places them on their pattern line.
"""
@spec take_from_factory(
Models.Game.t(),
1..9,
... |
0472c2e455e9a28999f47c93133b0435eced6664 | 3,423 | [
690601070
] | [
"typespec",
"supervisor"
] | defmodule WhipWhep.PeerSupervisor do
use DynamicSupervisor
require Logger
alias ExWebRTC.{MediaStreamTrack, PeerConnection, SessionDescription, RTPCodecParameters}
@audio_codecs [
%RTPCodecParameters{
payload_type: 111,
mime_type: "audio/opus",
clock_rate: 48_000,
channels: 2
... |
0472c893df6d4391550594fa9df52954e67dda7a | 5,739 | [
977324828
] | [
"genserver",
"documented"
] | defmodule Xombadill.IrcClient do
@moduledoc """
State and handler module for a single IRC client connection.
All real communication with the IRC network happens here, including login, joining,
disconnect handling, and dispatching messages to the HandlerRegistry.
Provides helpers to send messages, join/part c... |
047321fa55ba920f9843aa2671e3b1741a849d9e | 19,413 | [
673799532
] | [
"test"
] | defmodule AshUUIDTest do
use ExUnit.Case
doctest AshUUID
# alias Ash.Changeset
def checkout(_ctx \\ nil) do
Ecto.Adapters.SQL.Sandbox.checkout(AshUUID.Test.Repo)
end
setup :checkout
describe "AshUUID.PrefixedV4" do
test "testing avocados" do
avocado_smoothie =
AshUUID.Test.Avocad... |
04738aa0d256ff9727eb8633e63594aea160d160 | 13,461 | [
147991856
] | [] | %{
"bamboo": {:hex, :bamboo, "0.8.0", "573889a3efcb906bb9d25a1c4caa4ca22f479235e1b8cc3260d8b88dabeb4b14", [:mix], [{:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, ">= 1.5.0", [hex: :poison, repo: "hexpm", optional: false... |
0473d66934faffc07cae06df57d3e6866051cef2 | 1,683 | [
417369232
] | [
"documented",
"ecto"
] | defmodule ShoppingList.Lists do
@moduledoc """
The Lists context.
"""
import Ecto.Query, warn: false
alias ShoppingList.Repo
alias ShoppingList.Lists.List
@doc """
Returns the list of lists.
## Examples
iex> list_lists()
[%List{}, ...]
"""
def list_lists do
Repo.all(List)
e... |
04745cce236fc4c6d94ee822703199dcac8739c2 | 2,859 | [
218393177
] | [
"test",
"phoenix"
] | defmodule TimesheetsWeb.UserControllerTest do
use TimesheetsWeb.ConnCase
alias Timesheets.Users
@create_attrs %{email: "some email", group: "some group", manager_id: "some manager", name: "some name"}
@update_attrs %{email: "some updated email", group: "some updated group", manager_id: "some updated manager",... |
0474b58c80be9289e2b60a2c535631a3d9c3abe4 | 1,739 | [
1008678033
] | [
"liveview"
] | defmodule JumpWeb.HistoryLive.Index do
use JumpWeb, :live_view
alias Jump.Conversion
@impl true
def render(assigns) do
~H"""
<Layouts.app flash={@flash}>
<.header>
Listing Conversion histories
<:actions>
<.button variant="primary" navigate={~p"/conversion_histories/new"... |
04754f788e4b6b2fd273d2a09e90b6949942f776 | 1,936 | [
864560026,
603287696,
734113796,
314883753,
612257187,
627507754,
682153927
] | [] | use Mix.Config
watchers =
if System.get_env("CI") do
[]
else
[
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch",
"--watch-options-stdin",
cd: Path.expand("../assets", __DIR__)
]
]
end
# For development, we d... |
04761d5f80564af04dcabcea0fe867ab770609e6 | 1,703 | [
60193646
] | [
"macro",
"documented",
"ecto",
"phoenix"
] | defmodule Ecsample.Web do
@moduledoc """
A module that keeps using definitions for controllers,
views and so on.
This can be used in your application as:
use Ecsample.Web, :controller
use Ecsample.Web, :view
The definitions below will be executed for every view,
controller, etc, so keep them ... |
0476931d11d7126fd0b8a29a410f9993613c9947 | 9,351 | [
964808709
] | [] | %{
"castore": {:hex, :castore, "1.0.12", "053f0e32700cbec356280c0e835df425a3be4bc1e0627b714330ad9d0f05497f", [:mix], [], "hexpm", "3dca286b2186055ba0c9449b4e95b97bf1b57b47c1f2644555879e659960c224"},
"certifi": {:hex, :certifi, "2.15.0", "0e6e882fcdaaa0a5a9f2b3db55b1394dba07e8d6d9bcad08318fb604c6839712", [:rebar3], ... |
0476d180c2c25ef6a3d6f77ab30cda60d1d1bce5 | 2,458 | [
964805404
] | [
"test",
"phoenix"
] | defmodule ProptrackerWeb.ShowFavoritesTest do
use ProptrackerWeb.ConnCase
alias Proptracker.Accounts.{User, Advertisement}
alias Proptracker.Repo
@valid_user_attrs %{name: "John Doe", username: "john_doe", password: "secret123", date_of_birth: ~D[1990-01-01], phone_number: "123456789"}
@valid_advertisement_... |
04770b447b26c2b849abdb9c43e92271e23ca47b | 3,465 | [
38224694
] | [] | defmodule CodeComplete.ASTParser do
alias CodeComplete.CodeModule
alias CodeComplete.CodeStruct
alias CodeComplete.CodeMethod
alias CodeComplete.CodeMethodArgument
def parse_quoted(quoted) do
parse(quoted)
end
defp parse_inner_module(inner_module, code_module) when is_list(inner_module) do
Enum... |
04776609fba78538ad5e311b05d755626571e394 | 2,637 | [
270286908
] | [] | import Config
# Definition environment
config :policr_mini, :environment, :dev
config :policr_mini, opts: ["--allow-client-switch-grid"]
# Configure your database
config :policr_mini, PolicrMini.Repo,
username: "postgres",
password: "postgres",
database: "policr_mini_dev",
hostname: "localhost",
show_sensi... |
047787d1fdab717f7c53259bc50601e28ffbb68f | 2,078 | [
128476424,
235669159
] | [
"phoenix"
] | defmodule JeopardyWeb.UserController do
use JeopardyWeb, :controller
alias Jeopardy.Users
alias Jeopardy.Users.User
action_fallback(JeopardyWeb.FallbackController)
def index(conn, _params) do
users = Users.list_users()
render(conn, "index.json", users: users)
end
def get_profile(conn, %{"token... |
0477f388e92bb1be058895f67179a686aee9020c | 1,844 | [
90525404
] | [] | %{"certifi": {:hex, :certifi, "1.1.0", "c9b71a547016c2528a590ccfc28de786c7edb74aafa17446b84f54e04efc00ee", [:rebar3], []},
"earmark": {:hex, :earmark, "1.2.1", "7ad3f203ab84d31832814483c834e006cf88949f061a4b50d7e783147572280f", [:mix], []},
"ex_doc": {:hex, :ex_doc, "0.15.1", "d5f9d588fd802152516fccfdb96d6073753f77... |
04781c2d1a63cb7e27ba3b42fcfee975506df289 | 3,138 | [
127092221
] | [
"test"
] | defmodule Web.EventsChannelTest do
use Web.ChannelCase
alias Store.{FeedBuilder, Comments}
alias Web.EventsChannel
setup_all do
UserTestHelper.ddl()
events =
10
|> FeedTestHelper.create()
|> Enum.map(fn map ->
{:ok, event} = FeedBuilder.build(map)
{map, event}
en... |
047835d79a37080a66232ed7264d06415e607599 | 2,994 | [
67210941
] | [
"ecto"
] | defmodule HexWeb.AuditLog do
use HexWeb.Web, :model
schema "audit_logs" do
belongs_to :actor, User
field :user_agent, :string
field :action, :string
field :params, :map
timestamps(updated_at: false)
end
# NOTE: user_agent should be just "WEB" when action is from the web interface
def bu... |
0478408666ddbf555214964374ea41e67cf200fe | 9,784 | [
135299115
] | [
"test"
] | defmodule Raytracer.Geometry.Vector3Test do
use ExUnit.Case, async: true
use PropCheck
import Raytracer.{GeometryTestHelpers, Generators}
alias Raytracer.{Transform, Transformable}
alias Raytracer.Geometry.{Normal3, Point3, Vector3}
@delta 1.0e-7
doctest Vector3
describe "Raytracer.Geometry.Vector3.a... |
0478518bb6a438808774c8a07b4a1b5af4b7c9f6 | 2,141 | [
159991022
] | [] | defmodule Elixir2021.Day12.State do
alias Elixir2021.Day12
alias Elixir2021.Day12.State
defstruct path: [],
doubled_small?: false
def new(path, doubled_small?) do
%State{path: path, doubled_small?: doubled_small?}
end
def add_room(state = %State{}, room) do
if state.doubled_small? do
... |
047879e2a7a45d8d960fb003bbc28fbebb007bb1 | 2,688 | [
54638435
] | [
"test"
] | defmodule GreatStrides.EngagementControllerTest do
use GreatStrides.ConnCase
alias GreatStrides.Engagement
@valid_attrs %{end_date: "2010-04-17", location: "some content", name: "some content", start_date: "2010-04-17"}
@invalid_attrs %{}
test "lists all entries on index", %{conn: conn} do
conn = get co... |
04787c30946798d5c2dc8eac8da80422226da64a | 4,259 | [
300698298
] | [
"typespec",
"documented",
"ecto"
] | defmodule StreamsCore.CloudEvent do
@moduledoc """
External representation of an emited event
"""
require Logger
@parser StreamsCore.CloudEvent.Parser.DefaultParser
alias StreamsCore.CloudEvent.Extractor
@type specVersion() :: String.t()
@type type() :: String.t()
@type source() :: String.t()
@ty... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.