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 |
|---|---|---|---|---|
043d82b8eee96a78db1efea900fa80cfdf3d7ba3 | 1,531 | [
341685888
] | [
"phoenix"
] | defmodule SpiritpayWeb.Router do
use SpiritpayWeb, :router
import Plug.BasicAuth
pipeline :api do
plug :accepts, ["json"]
end
pipeline :auth do
plug :basic_auth, Application.compile_env(:spiritpay, :basic_auth)
end
#scope "/api", SpiritpayWeb do
# pipe_through :api
# get "/:filename", W... |
043da61a21b61e5341fa54ac96bff09fa4191aa6 | 1,552 | [
192407200
] | [
"documented",
"ecto"
] | defmodule Andi.InputSchemas.Ingestions.Transformations do
@moduledoc false
alias Andi.Repo
alias Ecto.Changeset
alias Andi.InputSchemas.Ingestions.Transformation
alias Andi.InputSchemas.StructTools
import Ecto.Query, only: [from: 2]
require Logger
def get(id), do: Repo.get(Transformation, id)
def... |
043dfb1e367331e8e1152eb54d398acc83081134 | 4,773 | [
87683657,
63800038
] | [
"typespec",
"documented"
] | defmodule BSON.Encoder do
@moduledoc false
use BSON.Utils
def encode(true),
do: 0x01
def encode(false),
do: 0x00
def encode(nil),
do: ""
def encode(:BSON_min),
do: ""
def encode(:BSON_max),
do: ""
def encode(%BSON.Binary{binary: binary, subtype: subtype}) do
subtype = subty... |
043e61bb07f92d8c5f35374c56954f0885daabb0 | 4,203 | [
257722996
] | [
"macro",
"documented"
] | defmodule Saxy.Encoder do
@moduledoc false
@doc """
Encode data into a iodata list (merge between list and binary data).
Example:
iex> Saxy.Encoder.encode_to_iodata({"foo", [], []})
[[[60, "foo"], 47, 62]]
iex> Saxy.Encoder.encode_to_iodata({"foo", [{"id", "10"}], []})
[[[60, "foo", 32, "id",... |
043e70f08687a810baeaf6b697e2388022cdddab | 1,688 | [
151891350
] | [
"genserver",
"typespec",
"documented"
] | defmodule LocalMessageQueue.Preloader do
@moduledoc """
The `Preloader` subscribes to new messages and optionally checks to see if those messages have
already been processed and stored in a `Cache` by a `Consumer`. Those cached results are
dispatched as new messages and uncached messages are concatenated to the... |
043e9b7f57738c7eb9cb587d24e04a175de438a4 | 3,136 | [
126724945
] | [
"typespec",
"documented"
] | defmodule Pushest.Socket.Data.Presence do
@moduledoc ~S"""
Structure representing presence information, connected user IDs and data of them.
"""
defstruct count: 0, hash: %{}, ids: [], me: %{}
@doc ~S"""
Merges current Presence struct with new presence data frame. Always keeps :me
part from current stat... |
043ef1e777abcf5114f039c8de64bb28c2ecd770 | 5,492 | [
96350285,
94315554,
96907899,
93758729
] | [
"typespec",
"documented"
] | defmodule Mix.Tasks.Phoenix.Gen.Html do
use Mix.Task
@shortdoc "Generates controller, model and views for an HTML based resource"
@moduledoc """
Generates a Phoenix resource.
mix phoenix.gen.html User users name:string age:integer
The first argument is the module name followed by
its plural name (... |
043f5d21aeb9909dc516c7836530e255efa710c6 | 1,835 | [
96479082
] | [
"documented"
] | defmodule Bolt.Router do
@moduledoc """
Serves an api for getting the status
"""
use Plug.Router
plug Plug.Parsers, parsers: [:json],
pass: ["text/*"],
json_decoder: Poison
plug Plug.Static,
at: "/",
from: Path.join([Application.app_dir(:bolt), "priv/static/"]... |
043f6536d747bc70875b5dcc867df6cb02a8c128 | 1,701 | [
1019126840,
997178529
] | [
"supervisor",
"documented"
] | defmodule ElixirML.Process.ProgramSupervisor do
@moduledoc """
Dynamic supervisor for managing program execution processes.
Each program runs in its own supervised process for isolation and fault tolerance.
"""
use DynamicSupervisor
def start_link(opts \\ []) do
DynamicSupervisor.start_link(__MODULE__... |
0440a0019c9e6355649b20402699aae23c7096f1 | 1,779 | [
96243673
] | [
"typespec",
"documented"
] | defmodule Kurasuta.Algorithms.Kmeans do
@moduledoc """
Implementation of k-means clustering algorithm.
"""
defstruct centers: [], clusters: []
alias Kurasuta.Algorithms.Kmeans
alias Kurasuta.Vector
@type data :: list(Vector.vector)
@type params :: map
@type centers :: list(Vector.vector)
@type cl... |
0440a260a80468200979e5e66a3b1d5e1260b14e | 2,308 | [
417908987,
34983055,
61451301
] | [
"test"
] | defmodule StrainTest do
use ExUnit.Case
defp is_odd?(n), do: rem(n, 2) == 1
defp is_even?(n), do: rem(n, 2) == 0
describe "keep" do
# @tag :pending
test "on empty list returns empty list" do
assert Strain.keep([], fn _ -> true end) == []
end
test "keep everything" do
assert Strain... |
04414ed7c686ba443c2fa23d9c359040945d80c4 | 4,766 | [
289007710
] | [
"typespec",
"documented"
] | defmodule DepMulti do
@moduledoc """
`DepMulti` is a data structure for performing dependant asynchronous
operations.
To demonstrate the problem, image you have three asynchronous tasks:
##
[
Task.async(fn -> do_some_work() end),
Task.async(fn -> do_some_other_work() end),
Task.async(f... |
0441d49f2a2dab38e7a0e8d8d3175b6bf660f96a | 2,406 | [
954784381
] | [
"liveview",
"ecto"
] | defmodule CdGigalixirWeb.CategoryLive.FormComponent do
use CdGigalixirWeb, :live_component
alias CdGigalixir.Categories
@impl true
def render(assigns) do
~H"""
<div>
<.header>
{@title}
<:subtitle>Use this form to manage category records in your database.</:subtitle>
</.head... |
0441ef6223242dc3414391f60676b7bda27d9d80 | 1,565 | [
122663592
] | [
"macro",
"documented",
"phoenix"
] | defmodule RaemWeb 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 RaemWeb, :controller
use RaemWeb, :view
The definitions below will be executed for every view,
controller, etc, so k... |
0442068320b7c75133044edb3d0799658c0940e3 | 4,805 | [
342871207
] | [
"test"
] | defmodule ParkingWeb.TerminateParkingTest do
use ParkingWeb.ConnCase
import Ecto.Query, warn: false
alias Parking.Bookings
alias Parking.Guardian
alias Parking.Account.User
alias Parking.Places.Parking_place
alias Parking.Repo
alias Parking.Invoices.Invoice
alias Parking.Account
setup_all do
... |
0442819bf97f70eeded8732b0ccbf44eb20fbaaf | 4,905 | [
1014452977
] | [
"liveview",
"test"
] | defmodule FlightLogWeb.AirplaneLiveTest do
use FlightLogWeb.ConnCase
import Phoenix.LiveViewTest
import FlightLog.AirplanesFixtures
@create_attrs %{year: 42, make: "some make", tail_number: "some tail_number", initial_hobbs_reading: "120.5", model: "some model"}
@update_attrs %{year: 43, make: "some updated... |
04430a6e93acc908ba0d215a09c0c18e8083951d | 1,505 | [
516223668
] | [] | defmodule Example.MixProject do
use Mix.Project
@app :example
@version "0.1.0"
@all_targets [:rpi4]
def project do
[
app: @app,
version: @version,
elixir: "~> 1.11",
archives: [nerves_bootstrap: "~> 1.11"],
start_permanent: Mix.env() == :prod,
build_embedded: true,
... |
044337c3b0e1c54fc355e5e00e72b726ce4f4d83 | 2,718 | [
595815766
] | [
"phoenix"
] | defmodule ShipWeb.Router do
use ShipWeb, :router
import ShipWeb.PlayerAuth
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, html: {ShipWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
plug :f... |
044402900502e6be2f8d3257750e09985e12eab3 | 9,083 | [
896951170
] | [] | defmodule Aoc2024.Day06Fast do
def part2() do
"./day_6_input.txt"
|> main()
|> Enum.reduce(0, &(&2 + cycle_count(&1)))
end
def part2_async() do
"./day_6_input.txt"
|> main()
|> Task.async_stream(&cycle_count/1, ordered: false)
|> Enum.reduce(0, fn {:ok, num}, sum -> sum + num end)
e... |
04443f0de6e1c540f2003894f67b35e0e346bd01 | 6,782 | [
289554975
] | [
"test"
] | defmodule TypeTest.TypeFunction.UsableAsTest do
use ExUnit.Case, async: true
@moduletag :usable_as
import Type, only: :macros
use Type.Operators
alias Type.{Function, Message}
@any %Type{name: :any}
@any_fn %Function{params: :any, return: @any}
@any_atom_fn %Function{params: :any, return: atom()}
... |
04447bfcc3c9cf08bc4603b70c1cb20132091b6e | 2,115 | [
49329100
] | [] | # Script for populating the database. You can run it as:
#
# mix run priv/repo/seeds.exs
#
# Inside the script, you can read and write to any of your
# repositories directly:
#
# IChing.Repo.insert!(%IChing.SomeModel{})
#
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as they will fa... |
0444c9bd0d2de0a6564d8700f91a8ef5d5040135 | 8,182 | [
434898411
] | [
"phoenix",
"ecto"
] | defmodule TrentoWeb.FallbackController do
use TrentoWeb, :controller
alias TrentoWeb.ErrorJSON
def call(conn, {:error, :activity_log_fetch_error}) do
conn
|> put_status(:bad_request)
|> put_view(json: ErrorJSON)
|> render(:"400", reason: "Activity Log fetch error.")
end
def call(conn, {:err... |
0444d39ebb3b56bea03f17baa7c7baacdee3ad60 | 2,972 | [
784953040
] | [
"test",
"phoenix"
] | defmodule PapaSysWeb.UserControllerTest do
use PapaSysWeb.ConnCase
import PapaSys.ClientFixtures
alias PapaSys.Client.User
@create_attrs %{
role: "member",
first_name: "some first_name",
last_name: "some last_name",
email_address: "some email_address",
account_minutes: 42
}
@update_at... |
04457a3d3adad84a9f1dc58e42793d180fea42c7 | 1,750 | [
882462584
] | [
"supervisor",
"documented"
] | defmodule ServerlogDaemon.ChildSupervisor do
@moduledoc false
use Supervisor
require Logger
@impl true
def init(init_arg) do
children = [
%{
id: String.to_atom("#{init_arg.id}_ftp"),
start: {
ServerlogDaemon.FtpWorker,
:start_link,
[
%{
... |
044587ac1d3f8f174ebb8d0acb459d98f8b0605a | 3,122 | [
206949495
] | [
"test",
"phoenix"
] | defmodule StipeWeb.OrganizationControllerTest do
use StipeWeb.ConnCase
alias Stipe.Company
@create_attrs %{name: "some name"}
@update_attrs %{name: "some updated name"}
@invalid_attrs %{name: nil}
def fixture(:organization) do
{:ok, organization} = Company.create_organization(@create_attrs)
organ... |
04458d38db8336cc8f636911d9b20a8fee26733d | 2,449 | [
582458693
] | [] | defmodule Awex.GitHub do
require Logger
@graphql_url Application.compile_env(:awex, :GITHUB_GRAPHQL_URL)
@gh_user_token Application.compile_env(:awex, :GITHUB_USER_TOKEN)
@graphql_query_headers [
Authorization: "Bearer #{@gh_user_token}",
Accept: "Application/json; Charset=utf-8"
]
@repo_query ~S""... |
0445a34463e1d40691b3a2b8cfc7f045baefd9a1 | 21,012 | [
589089007,
589866492,
215544723
] | [
"test"
] | defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
use Oban.Testing, repo: Pleroma.Repo
use Pleroma.DataCase
alias Pleroma.Activity
alias Pleroma.Object
alias Pleroma.Tests.ObanHelpers
alias Pleroma.User
alias Pleroma.Web.ActivityPub.Transmogrifier
alias Pleroma.Web.ActivityPub.Utils
alias Plero... |
0445b66e192310cbc4149c3bbd271fd9684b88ee | 8,928 | [
983137017
] | [] | %{
"backoff": {:hex, :backoff, "1.1.6", "83b72ed2108ba1ee8f7d1c22e0b4a00cfe3593a67dbc792799e8cce9f42f796b", [:rebar3], [], "hexpm", "cf0cfff8995fb20562f822e5cc47d8ccf664c5ecdc26a684cbe85c225f9d7c39"},
"bcrypt_elixir": {:hex, :bcrypt_elixir, "3.3.1", "9f2e7e00f661a6acfae1431f1bc590e28698aaecc962c2a7b33150dfe9289c3d"... |
0445bb9ae91a80d3d82ffac36892a53110eff837 | 4,273 | [
317769081
] | [] | defmodule XMASSolution do
def find_first_weak_number(xmas, preamble_length) do
length = length(xmas)
result = Stream.unfold(%{
found: false,
index: preamble_length,
end: false
}, fn acc ->
if acc.end do
nil
else
... |
0445fcd5e051916a5873362ece64b5e427b5e4d5 | 2,982 | [
367278931
] | [
"documented"
] | defmodule Google.Cloud.Discoveryengine.V1alpha.EstimateDataSizeRequest.WebsiteDataSource.EstimatorUriPattern do
@moduledoc false
use Protobuf, protoc_gen_elixir_version: "0.14.1", syntax: :proto3
field :provided_uri_pattern, 1, type: :string, json_name: "providedUriPattern"
field :exact_match, 2, type: :bool,... |
044606a880acc489b9cdc3fbb315deb58ad0eee1 | 8,023 | [
70354496
] | [
"documented"
] | defmodule Bible.Versions.ESV do
@moduledoc """
Contains the meta data for the English Standard Version (ESV) bible.
The format of a version file is as follows:
Line 1 : 'T tt bb ccc name'
Line 2 : vvv vvv vvv ...
Where: 'T' is either "O" or "N" for old or new testament book.
tt is the order of the book in it... |
044628797f6091e1f371a8ccaec88af23f7d423f | 2,218 | [
329643665
] | [
"documented",
"ecto"
] | defmodule Anne.Accounts do
@moduledoc """
The Accounts context.
"""
import Ecto.Query, warn: false
alias Anne.Repo
alias Anne.Accounts.{User, Credential}
@doc """
Returns the list of users.
## Examples
iex> list_users()
[%User{}, ...]
"""
def list_users do
User
|> Repo.al... |
044687a45e0c38dca299301b6fffa5b0527ad0e4 | 2,022 | [
487737996
] | [
"typespec",
"documented"
] | defmodule AbsintheClient.Utils do
@doc """
Configure supervisor children to be disabled if their configuration has a `enabled` option to false
"""
@spec configurable_children(
list(
process ::
atom()
| {process :: atom(), args :: list()}
| {process... |
04468b82dd139e49831d4ab0e6763e3d3a8835ef | 1,920 | [
72531106
] | [
"phoenix"
] | defmodule PriceCrawler.VendorController do
use PriceCrawler.Web, :controller
plug Coherence.Authentication.Session, [protected: true]
alias PriceCrawler.Vendor
def index(conn, _params) do
vendors = Repo.all(Vendor)
render(conn, "index.html", vendors: vendors)
end
def new(conn, _params) do
ch... |
044699398d24f0d8d98be5cecd31cbf8ca38719c | 2,762 | [
113502073
] | [] | defmodule Advent7 do
def get_weights(rows) do
tree = build_tree(rows)
investigate_unbalanced(find_root(tree), tree)
end
def get_root(rows), do: rows |> build_tree |> find_root
def build_tree(rows), do: Enum.map(rows, &parse_element/1)
def parse_element(row) do
[head | children_string] = String.... |
04476605f468bb592379a55c281951df7f2acc8d | 7,212 | [
616868442
] | [
"liveview"
] | defmodule FullCircleWeb.OrderLive.Index do
use FullCircleWeb, :live_view
alias FullCircle.Product
alias FullCircleWeb.OrderLive.IndexComponent
@per_page 25
@impl true
def render(assigns) do
~H"""
<div class="mx-auto w-10/12">
<p class="w-full text-3xl text-center font-medium">{@page_title}<... |
044770593a756e8d35ea17739ab1eb2b4583b25b | 3,035 | [
805014098
] | [] | defmodule AshSlug.MixProject do
use Mix.Project
@version "0.2.1"
def project do
[
app: :ash_slug,
version: @version,
elixir: "~> 1.14",
start_permanent: Mix.env() == :prod,
elixirc_paths: elixirc_paths(Mix.env()),
deps: deps(),
docs: &docs/0,
package: package(... |
044772abd1e5ac9f1c97883edf2aa8ee52f2ae8e | 3,944 | [
379678050,
372603056,
347043832,
349082708,
346794822,
712606134
] | [
"typespec",
"documented"
] | defmodule Absinthe do
@moduledoc """
Documentation for the Absinthe package, a toolkit for building GraphQL
APIs with Elixir.
For usage information, see [the documentation](http://hexdocs.pm/absinthe), which
includes guides, API information for important modules, and links to useful resources.
"""
defmo... |
044781e4a2843821219091d87cd30f29b794a568 | 2,227 | [
725675618
] | [
"typespec",
"documented"
] | defmodule RationalNumbers do
@type rational :: {integer, integer}
@doc """
Add two rational numbers
"""
@spec add(a :: rational, b :: rational) :: rational
def add({num_a, den_a}, {num_b, den_b}), do:
{num_a * den_b + num_b * den_a, den_a * den_b}
|> reduce()
@doc """
Subtract two rational nu... |
0447c5ac95c86561430901a97b35876e43df19ee | 2,462 | [
699182826
] | [
"typespec",
"documented"
] | defmodule LabLive.Data do
@moduledoc """
Agent id to hold data.
"""
@type content() :: any()
@type name() :: GenServer.name()
@type id() :: GenServer.server()
@type data_spec() ::
{:init, content()}
| {:label, String.t()}
| {:visible?, boolean()}
| {:timeout, timeo... |
0447e89541fbf70863561aaad064df881f9a097c | 3,011 | [
284446639
] | [
"macro",
"test"
] | defmodule Skuldaring.PermissionsTest do
use Skuldaring.DataCase, async: true
alias Skuldaring.Permissions
alias Skuldaring.Accounts.User
defmodule Article do
defstruct [
user_id: 1
]
end
@cfile "test/data/rbac.conf"
@pfile "test/data/policy.csv"
describe "permissions" do
setup do
... |
04484c0d6e39bbd7b55830861d98faf17a81bc62 | 9,449 | [
82943120
] | [] | %{
"bamboo": {:hex, :bamboo, "1.1.0", "ecbdc851d0127d369957e5ca7bcfb4c7fe7dbfaf4fa0b2e5cc2493dd8a9a600e", [:mix], [{:hackney, ">= 1.13.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, ">= 1.5.0", [hex: :poison, repo: "hexpm", optional: fa... |
04493673995471936b596d245b7cc2badf785f85 | 6,879 | [
812603976
] | [
"documented",
"ecto"
] | defmodule Ipdth.Agents do
@moduledoc """
The Agents context.
"""
import Ecto.Query, warn: false
alias Ipdth.Repo
alias Ipdth.Accounts.User
alias Ipdth.Agents.Agent
alias Ipdth.Agents.ConnectionError
alias Ipdth.Agents.ConnectionManager
alias Ipdth.Tournaments.Participation
@doc """
Returns ... |
04497458db970c53ff945f236e0e9de70af70a87 | 2,484 | [
789706378,
804638504
] | [
"documented"
] | defmodule SwaiWeb.ScapeDispatcher do
@moduledoc """
The ScapeHandler is used to broadcast messages to all clients
"""
alias Scape.Facts, as: ScapeFacts
alias Scape.Init, as: ScapeInit
alias Scapes.Service, as: Scapes
alias Phoenix.PubSub, as: PubSub
alias Swai.PubSub, as: SwaiPubSub
require Logger
... |
044984468015e3bb6215ac6567d84b5a2b207214 | 3,126 | [
286116474
] | [
"test",
"phoenix"
] | defmodule YicWeb.Api.Apis.ApiControllerTest do
use YicWeb.ConnCase
import Yic.ApisFixtures
alias Yic.Apis.Api
@create_attrs %{
definition: "some definition",
description: "some description",
name: "some name",
request: "some request",
version: "some version"
}
@update_attrs %{
def... |
044987292ca5e99f72e06e8c930837b2b242a234 | 1,597 | [
233668540
] | [] | defmodule Tetris do
alias Tetris.{ Brick, Bottom, Points }
def prepare(brick) do
brick
|> Brick.prepare
|> Points.move_to_location(brick.location)
end
def try_move(brick, bottom, f) do
new_brick = f.(brick)
if Bottom.collides?(bottom, prepare(new_brick)) do
brick
else
new_... |
0449b69620592a1999b145cb7541905c67139dc0 | 5,532 | [
259874396
] | [
"typespec",
"documented"
] | defmodule MonoRepo.Build do
@moduledoc """
This module holds a set of search path functions for convinient building of
paths to parent applications.
These functions take a parent application's name as argument and return a
string of unexpanded path to parent application relative to caller's directory
. For... |
0449e6016342bc750e56ebec42555c033badbd34 | 5,420 | [
1008670264
] | [
"documented"
] | defmodule EveDmv.Security.AuditLogger do
@moduledoc """
Security audit logging system.
Captures and logs security-relevant events for compliance and monitoring.
"""
require Logger
@doc """
Set up audit logging handlers.
"""
def setup_handlers do
# Set up telemetry handlers for security events
... |
044a31609dc2d827632dad6d3348a0af17d213b6 | 1,712 | [
191620425
] | [
"phoenix"
] | defmodule Uaddresses.Web.V1.RegionController do
use Uaddresses.Web, :controller
import Uaddresses.Web.V1Helper
alias Scrivener.Page
alias Uaddresses.Areas
alias Uaddresses.Areas.Area
alias Uaddresses.Regions
action_fallback(Uaddresses.Web.FallbackController)
def index(conn, params) do
with %Page... |
044a317782b833a1f3c5d5ce499bc8ab9a15fae6 | 2,061 | [
400644780
] | [
"typespec",
"documented"
] | defmodule Form do
@moduledoc """
A collection of loosely related functions helpful for filling out various forms at the city office.
"""
@doc """
Generates a string of a given length.
This string can be used to fill out a form field that is supposed to have no value.
Such fields cannot be left empty b... |
044ad5044e6fee2ca95c5f477624affca91b45ca | 1,975 | [
87705614
] | [
"documented"
] | defmodule Scout.Web.SurveyShowPlug do
use Plug.Builder
alias Plug.Conn
import Plug.Conn, only: [put_resp_content_type: 2]
plug(:put_resp_content_type, "application/json")
plug(:validate)
plug(:authorize)
plug(:query)
plug(:respond)
@doc "Function plug to validate a GET /surveys/:id request"
def va... |
044bc100e3e0fcfd7ae18d12feb1d31d65732279 | 13,435 | [
192407200
] | [
"test"
] | defmodule Transformers.DateTimeTest do
use ExUnit.Case
use Checkov
alias Transformers.DateTime
test "parses date and reformats onto a different field" do
params = %{
"sourceField" => "date1",
"targetField" => "date2",
"sourceFormat" => "{YYYY}-{0M}-{D} {h24}:{m}",
"targetFormat" =>... |
044bc9d338e969c26f30158dbeb5d397469ef3cd | 13,680 | [
529451757,
563730500
] | [
"typespec",
"documented",
"ecto"
] | defmodule Explorer.Chain.Import.Runner.Address.CurrentTokenBalances do
@moduledoc """
Bulk imports `t:Explorer.Chain.Address.CurrentTokenBalance.t/0`.
"""
require Ecto.Query
import Ecto.Query, only: [from: 2]
alias Ecto.{Changeset, Multi, Repo}
alias Explorer.Chain.Address.CurrentTokenBalance
alias E... |
044bef256ed7f546ab69952854feec7b59a53d4c | 1,636 | [
429575204
] | [
"test"
] | defmodule Aoe.Y19.Day4Test do
use ExUnit.Case, async: true
alias Aoe.Y19.Day4, as: Solution, warn: false
alias Aoe.Input, warn: false
# To run the test, run the following command:
#
# mix test test/2019/day_4_test.exs
#
# To run the solution
#
# mix aoe.run --year 2019 --day 4 --part 1
#... |
044c6ef9bee7a38311213748c41f928e4a303e15 | 11,219 | [
179535284
] | [
"typespec",
"documented"
] | defmodule Solarex.Sun do
import Solarex.Math
@moduledoc """
Solarex.Sun is module for calculating sunrise, sunset and solar noon for particular
date, latitude and longitude
"""
@doc """
Returns sunrise for passed Date, latitude, longitude.
iex> Solarex.Sun.rise(~D[2017-01-01], 50.0598054, 14.3251... |
044cffb6a1e27c1afd610394338b7f6b2a3cc942 | 14,382 | [
239822890,
459291087
] | [
"liveview"
] | defmodule OliWeb.Sections.AssessmentSettings.StudentExceptionsTableModel do
alias OliWeb.Common.Table.{ColumnSpec, SortableTableModel}
alias OliWeb.Common.FormatDateTime
alias OliWeb.Sections.AssessmentSettings.Tooltips
alias Phoenix.LiveView.JS
use Phoenix.Component
def new(
student_exceptions,
... |
044d73b7df38767c55cd44ef43058a0d82c0edbc | 9,946 | [
260844878
] | [
"test",
"ecto"
] | defmodule Eshop.MessengersTest do
use Eshop.DataCase
alias Eshop.Messengers
describe "chat_rooms" do
alias Eshop.Messengers.ChatRoom
@valid_attrs %{}
@update_attrs %{}
@invalid_attrs %{}
def chat_room_fixture(attrs \\ %{}) do
{:ok, chat_room} =
attrs
|> Enum.into(@val... |
044deb4770c347a7c01b234d9d4cbb7dd3d06f78 | 7,411 | [
1006213298
] | [
"genserver",
"documented"
] | defmodule PdfExtractor do
@moduledoc "README.md"
|> File.read!()
|> String.split("\n\n")
|> tl()
|> tl()
|> Enum.join("\n\n")
use GenServer
@external_resource "README.md"
# Client
def start_link([] = _opts \\ []) do
GenServer.start(__MODU... |
044e481c2c1f7ae5651e82a9822057ad20b62a88 | 2,302 | [
456097102
] | [] | defmodule Blunt.MixProject do
use Mix.Project
@version String.trim(File.read!("__VERSION"))
def project do
[
app: :blunt,
version: @version,
elixir: "~> 1.12",
#
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockf... |
044e67b310edfd8b55cfa956e12676fcb7f6baa6 | 1,567 | [
66628722
] | [
"test"
] | if !System.get_env("EXERCISM_TEST_EXAMPLES") do
Code.load_file("school.exs", __DIR__)
end
ExUnit.start
#ExUnit.configure exclude: :pending, trace: true
defmodule SchoolTest do
use ExUnit.Case
def db, do: %{}
@tag :pending
test "add student" do
actual = School.add(db, "Aimee", 2)
assert actual == %... |
044eb1645400324753b17c6f17e0b0c89dc21f5b | 3,025 | [
572737931
] | [] | defmodule Days.Day16 do
require IEx
@behaviour Days.Day
@impl Days.Day
def part_one(input) do
Grid.from_input(input)
|> count_energized({{0, 0}, :e})
end
@impl Days.Day
def part_two(input) do
grid = Grid.from_input(input)
for y <- 0..(grid.h - 1),
x <- 0..(grid.w - 1),
x... |
044f05a09e13f01acc68fc0ebc028af15818d4e8 | 3,484 | [
593099317
] | [
"liveview",
"test"
] | defmodule CityfoodWeb.CityLiveTest do
use CityfoodWeb.ConnCase
import Phoenix.LiveViewTest
import Cityfood.CitiesFixtures
@create_attrs %{country: "some country", name: "some name"}
@update_attrs %{country: "some updated country", name: "some updated name"}
@invalid_attrs %{country: nil, name: nil}
def... |
044f71172c8b265a572a3e730d6ee1fea2ad7ee3 | 2,371 | [
379726526
] | [] | defmodule AutomatedClient.Brain do
alias AutomatedClient.{State}
def make_move(state = %State{}) do
state
|> get_possible_words()
|> get_best_word()
|> get_best_guess()
|> apply_guess()
end
def get_possible_words(state = %State{ tally: %{ letters: letters }}) do
{
state,
le... |
044ffbfe060754b243c0ff84cc51666ec94041c5 | 3,955 | [
58221062
] | [] | %{"connection": {:hex, :connection, "1.0.2", "f4a06dd3ecae4141aa66f94ce92ea4c4b8753069472814932f1cadbc3078ab80", [:mix], []},
"cowboy": {:hex, :cowboy, "1.0.4", "a324a8df9f2316c833a470d918aaf73ae894278b8aa6226ce7a9bf699388f878", [:rebar, :make], [{:cowlib, "~> 1.0.0", [hex: :cowlib, optional: false]}, {:ranch, "~> 1.... |
04507da6fc5daa72c5eddc40dde0ab14545bf6a9 | 3,173 | [
563658041
] | [
"genserver",
"phoenix"
] | defmodule WebrtcL2L.Router do
use GenServer, restart: :transient
alias WebrtcL2L.Graph
@timeout 600_000
def start_link(options) do
# [name: {:via, Registry, {WebrtcL2L.RouterRegistry, name}}] = options
GenServer.start_link(__MODULE__, %Graph{}, options)
end
# Initialize the server state with an ... |
045199a56f37e78efbff418aed1f8191612d9665 | 4,795 | [
582469757
] | [
"typespec",
"documented",
"ecto"
] | defmodule ERWeb.Grpc.EventRelay.Metrics.Server do
@moduledoc """
GRPC Server implementation for Metrics Service
"""
use GRPC.Server, service: ERWeb.Grpc.Eventrelay.Metrics.Service
require Logger
alias ERWeb.Grpc.Eventrelay.{
GetMetricValueRequest,
GetMetricValueResponse,
CreateMetricResponse,
... |
0451d92d5f99c1a972a1599f0180e2bfe9f867a4 | 3,232 | [
425139415
] | [] | defmodule YourBotWeb.OAuth.Discord do
@client_id Application.get_env(:yourbot, __MODULE__)[:client_id]
@client_secret Application.get_env(:yourbot, __MODULE__)[:client_secret]
@redirect_url Application.get_env(:yourbot, __MODULE__)[:redirect_url]
@url Application.get_env(:yourbot, __MODULE__)[:url]
use Tesla... |
045201a9d7fc8e3e29dc91182efc8fc9d2e572b0 | 4,904 | [
989352999
] | [
"typespec",
"documented"
] | defmodule ElixirScope.Capture.TemporalBridgeEnhancement.EventProcessor do
@moduledoc """
Event processing utilities for TemporalBridgeEnhancement.
Handles event queries, filtering, enhancement, and correlation
with AST information.
"""
alias ElixirScope.Storage.EventStore
alias ElixirScope.ASTRepository... |
04522f0ae7590aeac77f71a5f299eca8de8f5efb | 3,290 | [
493636191
] | [
"liveview",
"documented"
] | defmodule SelphiDaisy.Form.LiveFileInput.Example02 do
@moduledoc """
LiveFileInput live view 文件上传示例,在 submit事件中,消费 entry(consume_uploaded_entry) 。
"""
use Surface.Catalogue.Example,
subject: SelphiDaisy.Form.LiveFileInput,
height: "2500px",
title: "LiveFileInput 组件 上传 "
# ???
alias Selp... |
045237bb6d606a584935991bfa1de485a85258ff | 1,859 | [
573193090
] | [
"test"
] | defmodule Adventofcode2022.Day11.MonkeyInTheMiddleTest do
use ExUnit.Case
alias Adventofcode2022.Day11.MonkeyInTheMiddle
# @tag :skip
# @tag timeout: :infinity
test "foo" do
input = File.read!(Path.join(__DIR__, "./input_1.txt"))
MonkeyInTheMiddle.parse(input)
|> MonkeyInTheMiddle.play(10000, f... |
045263792b95b33e9f1977734548b563cbb62aa7 | 5,521 | [
727007324
] | [
"documented"
] | defmodule Day3 do
@moduledoc """
Documentation for `Day3`.
"""
def load_file(path) do
String.trim(File.read!(path))
end
##############
# PART 1
##############
# parses lines of input into 2d list "matrix" of characters
def parse_input_to_matrix(input) do
String.split(input, "\n") |> Enum.... |
04527f4f299f474b4eb841588655851f5f7c9076 | 1,959 | [
188139103
] | [] | defmodule Isp.Mixfile do
use Mix.Project
def project do
[
app: :isp,
version: "0.0.1",
elixir: "~> 1.8",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: de... |
0452c9534c55dd289ad32a2772a2cb41b9cc8718 | 2,176 | [
16328245
] | [
"phoenix",
"test",
"ecto",
"macro",
"documented"
] | defmodule HexpmWeb.ConnCase do
@moduledoc """
This module defines the test case to be used by
tests that require setting up a connection.
Such tests rely on `Phoenix.ConnTest` and also
imports other functionality to make it easier
to build and query models.
Finally, if the test case interacts with the d... |
04530b071e9e74776083c097686998da1bccd2c1 | 4,085 | [
477169210
] | [
"documented"
] | defmodule Servy.Handler do
@moduledoc """
Handles HTTP requests.
"""
alias Servy.Utils.RequestHandlerSamples.Sample
alias Servy.{Conv, BearController, PledgeController, VideoCam, FourOhFourCounter, Tracker}
require Logger
import Servy.Plugins, only: [rewrite_path: 1, track: 1, emojify: 1]
import Se... |
045380cfa4ab3a82f9f50d2b61740ad2ced12796 | 2,479 | [
480152162,
796060990,
600722528
] | [
"macro",
"documented"
] | defmodule Image.Exif.FieldNames do
@moduledoc false
# Defines the field names with mapping to the relevant
# EXIF IFD.
#
# This is useful for mapping developer and user friendly
# names to theinternal header names in `libvips`.
@field_names [
["ifd3", "GPSDateStamp"],
["ifd3", "GPSMapDatum"],
... |
045410a6cf8b47076f992fcb63a8f3f7be948c45 | 2,524 | [
56935964
] | [
"documented"
] | defmodule Ralitobu.Bucket do
@moduledoc """
Server bucket logic
"""
alias Ralitobu.Bucket.State
alias Ralitobu.Utils
@doc false
def checkout(table, id, limit, lifetime),
do: call(:checkout, table, id, limit, lifetime)
@doc false
def inspect(table, id, limit, lifetime),
do: call(:inspect, ta... |
04545c6a350202b3f8da8726a1afc53f0ae7dcf7 | 1,803 | [
112772516
] | [] | defmodule Day8 do
def largest_register(file) do
{values, _} = process_file(file)
Enum.at(values, -1)
end
def largest_register_ever(file) do
{values, _} = process_file(file)
Enum.filter(values, &(&1))
|> Enum.max
end
defp process_file(file) do
{:ok, contents} = File.read(file)
reg... |
04546f5494bfb0b6a88de5cafb10a1f75fda509c | 1,640 | [
79281016
] | [
"test",
"phoenix"
] | defmodule DocdogWeb.ProjectInviteControllerTest do
use DocdogWeb.ConnCase
import Docdog.Factory
setup do
user = insert(:user)
another_user = insert(:user)
conn_with_another_user =
build_conn()
|> assign(:current_user, another_user)
project =
insert(
:project,
... |
0454a693957c4dddb8da22e39c39ab794ba5dd97 | 1,823 | [
404245398
] | [
"phoenix"
] | defmodule Pidro2lvWeb.PlayerConfirmationController do
use Pidro2lvWeb, :controller
alias Pidro2lv.Accounts
def new(conn, _params) do
render(conn, "new.html")
end
def create(conn, %{"player" => %{"email" => email}}) do
if player = Accounts.get_player_by_email(email) do
Accounts.deliver_player_... |
04558c60d44d9f19ae0bdbae3b22af3782acd051 | 2,497 | [
365640043
] | [
"typespec",
"documented"
] | defmodule Streamline.Media.MP4.Box.Stsc do
@moduledoc """
`stsc` Sample to Chunk, partial data-offset information
Samples within the media data are grouped into chunks. Chunks can be of different sizes,
and the samples within a chunk can have different sizes. This table can be used to find
the chunk that con... |
045597397152f7982d2beb5accd946a8d0b7533f | 1,633 | [
578153813
] | [] | import AOC
aoc 2024, 13 do
def p1(input) do
input
|> String.split("\n")
|> Enum.chunk_every(3, 4)
|> Enum.map(&play/1)
|> Enum.sum()
end
def play([a, b, prize], add_to_prize \\ 0) do
{ax, ay} = button_a = button(a)
{bx, by} = button_b = button(b)
{x, y} = prize(prize)
x = x ... |
0455c7544624987518749f98ab77595bad4242d0 | 3,720 | [
433034488
] | [] | defmodule Y2024.Day16 do
use Advent.Day, no: 16
alias Advent.PathGrid
def part1(path_grid) do
do_parts(path_grid) |> elem(0)
end
def part2(path_grid) do
do_parts(path_grid)
|> elem(1)
|> MapSet.size()
end
defp do_parts(path_grid) do
from = Enum.find(path_grid.units, &(&1.identifier... |
0455c7be758373c94943592abd1fc4fb9ffc085b | 2,283 | [
816126800
] | [] | # 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 :phoenix_vault, PhoenixVault.Repo, types: Phoe... |
0455cdcee01a6d18c6a3592ffca2f3cdc463284e | 5,868 | [
303360415
] | [] | %{
"certifi": {:hex, :certifi, "2.5.2", "b7cfeae9d2ed395695dd8201c57a2d019c0c43ecaf8b8bcb9320b40d6662f340", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "3b3b5f36493004ac3455966991eaf6e768ce9884693d9968055aeeeb1e575040"},
"ex_aws": {:hex, :ex_aws, "2.1.5", "f0f... |
0455e273524232148eeead590246121d4ae8a19c | 1,803 | [
434022091
] | [
"documented"
] | defmodule AdventOfCode2021.Eleven do
@moduledoc """
Day 11: Dumbo Octopus
https://adventofcode.com/2021/day/11
"""
alias AdventOfCode2021.Utils.Grid
def one(input_file, steps \\ 100) do
grid = parse_input(input_file)
{flash_count, grid} = Enum.reduce(1..steps, {0, grid}, fn _, {count, grid} ->
... |
04562b772043e72cdc76a7e5a3b47648896450e5 | 3,310 | [
189689006
] | [
"test"
] | defmodule Tabular.TestSupportTest do
use ExUnit.Case, async: true
doctest Tabular.TestSupport
describe "assert_equal" do
test "passes when tables are equal" do
result_table = [
["name", "dob"],
["Malcolm", "September 20, 2468"],
["Zoe", "February 15, 2484"]
]
asser... |
04566d2dc254d42ff0315439bdb7ccf9cec8b168 | 17,846 | [
581513226
] | [
"typespec",
"test"
] | defmodule Meeseeks.Selector.XPath.ParserTest do
use ExUnit.Case
alias Meeseeks.Selector.{Combinator, XPath}
alias Meeseeks.Selector.XPath.{Expr, Parser, Tokenizer}
# abs
test "root only" do
tokens = Tokenizer.tokenize("/")
assert_raise ErlangError, fn ->
Parser.parse_expression(tokens)
e... |
045691c20ae3fa96b3222c28d07053979f8b558c | 1,983 | [
161306716,
160467698,
157476350
] | [
"phoenix",
"ecto"
] | defmodule LaniWeb.GuideController do
use LaniWeb, :controller
alias Lani.Events
alias Lani.Events.Guide
plug :authenticate_editor when action in [:new, :create, :edit, :update, :delete]
plug :load_categories when action in [:new, :edit, :index]
defp load_categories(conn, _) do
assign(conn, :categorie... |
04569498d2631e20688e0af46a4924af2f3442b3 | 1,882 | [
872158763
] | [
"test"
] | defmodule ReteTest do
use ExUnit.Case
doctest Rete
import Rete.Sigils
alias Rete.Network2
require Rete.Syntax
test "greets the world" do
assert Rete.hello() == :world
end
test "alpha" do
rules =
[
{~v<x>, :on, ~v<y>},
{~v<y>, :left_of, ~v<z>},
{~v<z>, :color, :red... |
045695660444fcbe775babd0c3569490fbc90d1a | 5,703 | [
550879823,
215270639
] | [
"documented"
] | defmodule CucumberGherkin do
alias CucumberMessages.{Envelope, Source}
alias CucumberGherkin.{Parser, ParserContext, TokenWriter}
@moduledoc """
`CucumberGherkin` allows you to parse Gherkin files to pickles (or tokens). These pickles can be used in a cucumber implementation.
The CucumberMessages library is... |
045709688d0a853b8ca157be79eed44a6ea43a07 | 1,667 | [
96312779
] | [] | defmodule CountCats do
def count(scheduler) do
send scheduler, { :ready, self() }
receive do
{ :count, file, client } ->
send client, { :answer, file, count_cats(file), self() }
count(scheduler)
{ :shutdown } ->
exit(:normal)
end
end
def count_cats(file) do
Fi... |
04573608fd4d3ff021643c0c8ba94727ce1e91ab | 2,886 | [
922694954
] | [
"test"
] | defmodule Ecto.Adapters.LibSQL.Connection.JsonExtractPathTest do
use ExUnit.Case, async: true
import Ecto.Query
import Ecto.Adapters.LibSQL.TestHelpers
alias EctoLibSQL.Schemas.Schema
test "with array access" do
query =
Schema
|> select([s], json_extract_path(s.meta, [0, 1]))
|> plan(... |
0457443a53a4d38a94adf1cd539841cb9048f172 | 13,140 | [
76759318
] | [
"test"
] | defmodule Hangman.Game.Server.Stub.Test do
use ExUnit.Case, async: true
alias Hangman.{Game}
setup_all do
IO.puts("Game Stub Test")
# initialize params map for test cases
# each test just needs to grab the current player pid
map = %{
:current_player_key => nil,
:current_game_pid => ... |
0457597fd1c4fcd5d5dc58512d411f53d1bb6432 | 2,202 | [
494653791
] | [
"documented"
] | defmodule Rockelivery.Utils.Map do
@moduledoc """
Functions to transform maps
"""
@doc """
Convert map string camelCase keys to underscore_keys
"""
def underscore_keys(nil), do: nil
def underscore_keys(map = %{}) do
map
|> Enum.map(fn {k, v} -> {Macro.underscore(k), underscore_keys(v)} end)
... |
04578c6a77206721a5b2c23d5d6ab96cff3a03c9 | 5,668 | [
564514099
] | [
"genserver",
"typespec",
"documented"
] | defmodule WhiteRabbit.Connection do
@moduledoc """
GenServer to open a `%AMQP.Connection{}` and monitors it to allow for `:stop` events and restarts from Supervisor.
"""
use GenServer
alias AMQP.{Connection}
require Logger
@enforce_keys [:connection_name, :conn_opts, :channels]
defstruct connection_... |
0457a21d1c9e55769d97099ce756e8a37ecf2bff | 2,405 | [
912296145
] | [
"liveview"
] | defmodule WeltFactoWeb.UserLive.Confirmation do
use WeltFactoWeb, :live_view
alias WeltFacto.Accounts
def render(assigns) do
~H"""
<Layouts.app flash={@flash} current_scope={@current_scope}>
<div class="mx-auto max-w-sm">
<.header class="text-center">Welcome {@user.email}</.header>
... |
0457ad25bcdfc3a12c261d8e42f3b711c655f7a2 | 5,379 | [
757463973,
768011158,
279895213,
610994830,
792554244,
493445187,
644559297,
895439861,
756299391
] | [] | import Config
require_db_ssl =
case System.get_env("REQUIRE_DB_SSL") do
"true" -> true
"false" -> false
_ -> true
end
socket_options =
case System.get_env("USE_IP_V6") do
"true" -> [:inet6]
"false" -> [:inet]
_ -> [:inet]
end
pool_size = String.to_integer(System.get_env("POOL_SIZE") |... |
0457cad8732cc724eb693888c41e86c1f3cac30b | 1,571 | [
121887418
] | [
"phoenix"
] | defmodule TasktrackerWeb.PageController do
use TasktrackerWeb, :controller
alias Tasktracker.TaskManager.Timetracker
alias Tasktracker.TaskManager.Task
alias Tasktracker.Accounts.User
def index(conn, _params) do
render conn, "index.html"
end
def feed(conn, params) do
tasks = Tasktracker.TaskMana... |
0458ccda10b310065dbdd62ac40edd3c251d82f3 | 7,686 | [
739262096,
223255738,
1234714,
742840268,
139261729
] | [
"documented"
] | defmodule Mix.CLI do
@moduledoc false
@doc """
Runs Mix according to the command line arguments.
"""
def main(args \\ System.argv()) do
if env_variable_activated?("MIX_DEBUG") do
IO.puts("-> Running mix CLI")
{time, res} = :timer.tc(&main/2, [args, true])
IO.puts(["<- Ran mix CLI in ", ... |
04597e6879437add891c2d3033bdbe8245b604c3 | 9,217 | [
456875507
] | [
"liveview"
] | defmodule MiniModulesWeb.YieldParserLive do
use MiniModulesWeb, {:live_view, container: {:div, []}}
alias Phoenix.LiveView.Socket
alias MiniModules.{UniversalModules, Fetch}
alias MiniModulesWeb.Input.CodeEditorComponent
@example_ip_address {~S"""
function* Digit() {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.