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
02585e0644d59b89cab1a766e1baf894488366ca
3,576
[ 318080976 ]
[]
defmodule Aoc2020.Day14 do def parse("mask = " <> mask) do mask |> String.graphemes() |> Enum.map( fn "X" -> :noop x -> String.to_integer(x) end ) end def parse("mem" <> line) do [address, value] = Regex.scan(~r/\d+/, line) |> ...
02587b9c80c85c26db2076430c2ac5aa6ba82add
3,496
[ 217036955 ]
[ "typespec", "documented", "ecto" ]
defmodule ClickhouseEcto.Query do alias ClickhouseEcto.QueryString import ClickhouseEcto.Helpers require IEx @doc """ Receives a query and must return a SELECT query. """ @spec all(query :: Ecto.Query.t) :: String.t def all(query) do sources = QueryString.create_names(query) {select_distinct...
02587c28869b0ba75418c1c51bab16e1284018d4
1,651
[ 586428759 ]
[ "test" ]
defmodule TableTest do use ExUnit.Case doctest Issues import Issues.Table, only: [generate_issue_table: 1, issue_rows: 1] test "generate an issue table with no issues" do issues = fake_issues([]) assert generate_issue_table(issues) == """ # | created_at | title --+------------+-...
0258f321f840703e8751cb374b5c8fd0d8f5db01
6,038
[ 730068397 ]
[]
#!/usr/bin/env elixir defmodule Cache do def setup() do if :ets.info(:cache) != :undefined do :ets.delete(:cache) end :ets.new(:cache, [:named_table]) end def cache(key, func) do case :ets.lookup(:cache, key) do [{_, val}] -> add_hit() val [] -> val = ...
025936225a07bca1ca9f9e859199b8ed03d1a263
2,705
[ 34071899 ]
[ "test" ]
defmodule StreamTest do use ExUnit.Case import Adap.Piper defmodule EmitterMock do use Adap.Stream.Emitter def do_emit(sink,{:t1,e}) do :random.seed(:erlang.now) Stream.cycle([ fn->emit(sink,[{:t2,e}]) end, fn->:timer.sleep(:random.uniform(200)) end, fn->done(sink,{:t1...
02599334f3a5420d1b77d3951a2cef6712453edd
2,943
[ 291510830 ]
[ "typespec", "documented" ]
defmodule DarkEcto.Projections.Types do @moduledoc """ Type conversions """ alias DarkEcto.Projections.PermuteConversions # @types [:ecto, :postgrex, :typespec, :cli, :typescript, :absinthe, :prop_schema] # @types [:ecto, :absinthe, :typespec, :typescript, :cli] @types [:ecto, :absinthe, :typespec, :ty...
0259956f10f494ffcdabd27c6f89f11d0bf20161
5,792
[ 96147306 ]
[ "typespec", "macro", "documented" ]
defmodule Chronik.Store do @moduledoc """ Chronik event Store API """ @typedoc "The options given for reading events from the stream" @type options :: Keyword.t() @typedoc """ The version of a given event record in the Store. A simple implementation is a integer starting from 0. The atom `:empty` i...
0259a1edee9836ab535e6f4ab63b1c36da4a5a94
7,002
[ 170975365 ]
[]
defmodule Othello.Game do # Return a list of the indices in the board that are not border spaces. def valid_indices do Enum.map(11..89, fn(x) -> if 1 <= rem(x, 10) and rem(x, 10) <= 8 do x end end) |> Enum.filter(& !is_nil(&1)) end # If we have nothing left to fill, return the board. def fill_valid_i...
0259f5354fc2ad43b17eca5df592bf98f1a49c37
5,836
[ 229432373 ]
[ "test", "ecto" ]
defmodule Habitus.CoreTest do use Habitus.DataCase, async: true alias Habitus.{Core, Repo} alias Habitus.Core.ObjectiveEvent @time_zone "Europe/Paris" describe "objectives" do alias Habitus.Core.Objective @valid_attrs %{description: "quit smoking", threshold: 0} @invalid_attrs %{} test "l...
025a43d95576128f82ea4c59b999e1f62ed50293
2,175
[ 205244286 ]
[ "genserver", "test" ]
defmodule StateServerTest.Callbacks.HandleInfoTest do use ExUnit.Case, async: true defmodule Instrumented do use StateServer, [start: [tr: :end], end: []] def start_link(fun), do: StateServer.start_link(__MODULE__, fun) @impl true def init(fun), do: {:ok, fun} def state(srv), do: StateServe...
025a5b0ccde94bce18b973958e44b879538dcc28
8,415
[ 902141648 ]
[]
%{ "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, "castore": {:hex, :castore, "1.0.10", "43bbeeac820f16c89f79721af1b3e092399b3a1ecc8df1a472738fd853574911", [:mix], [], "hexpm...
025addb7373f4a238015b0f869d235ac523be92d
6,292
[ 972810178, 390166925 ]
[ "typespec", "documented" ]
defmodule Game.Format.Items do @moduledoc """ Format functions for items """ use Game.Currency import Game.Format.Context alias Data.Item alias Game.Format @doc """ Format an items name, cyan iex> Items.item_name(%{name: "Potion"}) "{item}Potion{/item}" """ @spec item_name(Item.t()) :...
025c5114dfb4ee5f98d6dc358a5417c233cc1fab
3,690
[ 476843035 ]
[ "liveview" ]
defmodule ArslaneToNarniaWeb.UserOnboardingLive do use ArslaneToNarniaWeb, :live_view alias ArslaneToNarnia.Accounts def mount(_params, _session, socket) do {:ok, assign(socket, %{changeset: Accounts.change_profile(socket.assigns.current_user)})} end def render(assigns) do ~H""" <div class="fixe...
025c79463a132117086efd4c17aaa42894b7e530
2,582
[ 991419873 ]
[ "test", "documented" ]
defmodule AshSvg.Test.TimelineHelpers do @moduledoc """ Helper functions for timeline-related tests. """ alias AshSvg.{Timeline, Keyframe} @doc """ Creates a simple timeline with two keyframes for testing. """ def simple_timeline(opts \\ []) do duration = Keyword.get(opts, :duration, 1000) ...
025c90629c8360abf59b61fc547d187715603b8e
2,889
[ 498675807 ]
[ "test" ]
defmodule AppCount.Maintenance.InsightReports.TechLowCompletionProbeTest do use AppCount.ProbeCase alias AppCount.Maintenance.Assignment alias AppCount.Maintenance.Tech alias AppCount.Maintenance.InsightReports.TechLowCompletionProbe def build_assignments(count, tech_name, completed_at) do 1..count |...
025c94c73575e075a1f356087867809cdeb4bf42
2,251
[ 56946191 ]
[ "test", "supervisor" ]
defmodule MessageScrubberTest do use ExUnit.Case setup_all do Supervisor.stop(RavenexSupervisor) # Need to set max_restarts, otherwise the supervisor will be shutdown # because of the numerous stop/start of the MessageScrubber. RavenexSupervisor.start_link([max_restarts: 20]) :ok end test ...
025cac416cf9870886c1a43f63b746bbb3141a71
3,206
[ 159991022 ]
[]
defmodule ElixirDay23.PainterRobot do alias ElixirDay23.{PainterRobot, ComputerServer} defstruct [ :program, :location, :direction, :grid, :computer_pid ] def new(program, initial_square_color) do {:ok, pid} = ComputerServer.start(program, []) %PainterRobot{ program: program...
025d2f364879134a71160f63d5c2889281f1ff75
3,397
[ 104735379 ]
[ "genserver", "typespec", "documented" ]
defmodule RabbitsManager.Producer.Worker do @moduledoc """ Producer Worker. A producer worker is started with a producer_pattern as arguments wich is all informations defined in config file for the given consumers. """ require Logger use GenServer use AMQP alias RabbitsManager.{ConnectionManager, Co...
025d931490a88dc95a0ac027d20a6bc02ac71953
2,226
[ 138562706, 143033534, 136571370, 786846015, 232343282 ]
[ "documented" ]
defmodule Credo.CLI.Command.GenCheck do use Credo.CLI.Command alias Credo.CLI.Output.UI @shortdoc "Create a new custom check" @moduledoc @shortdoc @check_template_filename ".template.check.ex" @default_check_template_file File.read!(@check_template_filename) @doc false def call(exec, _opts) do e...
025e7b10865f081e83fa10182ff8b4685cad38fb
2,520
[ 365177219 ]
[ "typespec", "documented" ]
defmodule Api.DeviceQueueItem do @moduledoc false use Protobuf, syntax: :proto3 @type t :: %__MODULE__{ dev_eui: String.t(), confirmed: boolean, f_cnt: non_neg_integer, f_port: non_neg_integer, data: binary, json_object: String.t() } defstruc...
025e932c69d7896a676e7c9b6fef8744c34276e2
2,979
[ 240326577 ]
[ "test", "ecto" ]
defmodule Rumbl.MultimediaTest do use Rumbl.DataCase, async: true alias Rumbl.Multimedia alias Rumbl.Multimedia.Category describe "categories" do test "list_alphabetical_categories/0" do for name <- ~w(Z A B E C) do Multimedia.create_category!(name) end names = for %Cate...
025f13af7c07b4c18427c87501598c047bfccd12
2,773
[ 160471092 ]
[]
defmodule Asteroids do def load!(filename) do File.stream!(filename) |> Enum.map(&String.trim/1) |> Enum.map(&String.split(&1, "", trim: true)) |> Enum.with_index() |> Enum.flat_map(fn {line, y} -> Enum.with_index(line) |> Enum.flat_map(fn {"#", x} -> [{x, y}] _ -> [] ...
025fc16e3d055b83cc1e17dcf92974895a18771a
2,125
[ 348017877 ]
[ "phoenix", "ecto" ]
defmodule ForumWeb.CommentController do use ForumWeb, :controller alias Forum.Post alias Forum.Post.Comment def index(conn, %{"thread_id" => thread_id}) do comments = Post.list_comments() render(conn, "index.html", comments: comments, thread_id: thread_id) end def new(conn, %{"thread_id" => threa...
025fccfc049932ac871f37db65e84c0fd7924d79
3,148
[ 895114206 ]
[]
defmodule AdventOfCode.Day14 do def part1(args, width \\ 101, height \\ 103) do {robots, _variances} = args |> parse() |> move_robots(100, width, height, []) robots |> count_quadrants(width, height) |> Enum.product() end def part2(args, width \\ 101, height \\ 103) do {_rob...
025ffc72b32b744c22f0a7d02cc8657416e11dd0
14,821
[ 411722524 ]
[ "typespec", "documented" ]
defmodule Envoy.Admin.V3.ClientResourceStatus do @moduledoc false use Protobuf, enum: true, syntax: :proto3 @type t :: integer | :UNKNOWN | :REQUESTED | :DOES_NOT_EXIST | :ACKED | :NACKED field(:UNKNOWN, 0) field(:REQUESTED, 1) field(:DOES_NOT_EXIST, 2) field(:ACKED, 3) field(:NACKED, 4) end defmodul...
026015a1370153d4d39968861ca84b6a456f87f7
4,142
[ 88078393 ]
[ "documented" ]
defmodule Mix.Tasks.Shipit do use Mix.Task @shortdoc "Publishes new Hex package version" @moduledoc """ ShipIt automates Hex package publishing to avoid common mistakes. mix shipit BRANCH VERSION It automates these steps: * ensure there are no uncommited changes in the working tree * ensure cur...
0260605082b8665f24bd46d29adb108ec45fbffb
2,862
[ 50638633 ]
[ "test", "ecto" ]
defmodule AfterRegistratorTest do use Sentinel.UnitCase use Bamboo.Test, shared: true alias Mix.Config alias Sentinel.AfterRegistrator alias Sentinel.Mailer.Invite alias Sentinel.Mailer.Welcome import Mock setup do on_exit fn -> Config.persist([sentinel: [confirmable: :optional]]) Con...
0260816ec6fd99c123a5af08fb7cb8bcb52a1d2d
5,680
[ 243317091 ]
[ "phoenix" ]
defmodule Web.LayoutView do use Web, :view alias ChallengeGov.Accounts alias ChallengeGov.MessageContextStatuses alias ChallengeGov.Recaptcha alias Web.AccountView alias Web.PageTitle def page_title(conn) do view = Phoenix.Controller.view_module(conn) action = case view do Web.Err...
0260a8ea1d8bba49e21fc64aaaac21850353eb83
2,195
[ 114140682 ]
[ "documented" ]
defmodule Account.Access do use Amnesia @moduledoc """ Access to account data, stored as records in Amnesia. """ def create(name, password, email) do Amnesia.transaction do case Amnesia.Table.read_at(Accounts.Account, name, :name) do nil -> case Amnesia.Table.read_at(Accounts.Acc...
0260e734c484c38f2b0a75d5421913d156990a75
13,144
[ 969167441 ]
[ "test", "documented" ]
defmodule Pythelix.Scripting.Namespace.StringTest do @moduledoc """ Module to test the string API. """ use Pythelix.ScriptingCase describe "__contains__" do test "in is True" do value = expr_ok("'a' in 'mardi'") assert value == true end test "in is False" do value = expr_ok("'...
026102322e6a3e8efaa9ec0910c25215089ab63f
1,957
[ 214701959 ]
[ "typespec", "documented", "ecto" ]
defmodule UrlShortener.UrlShortenerContext do @moduledoc """ The UrlShortenerContext context. """ import Ecto.Query, warn: false alias UrlShortener.Repo alias UrlShortener.UrlShortenerContext.Url @doc """ Returns the list of urls. ## Examples iex> list_urls() [%Url{}, ...] """ de...
02612cc74cb1ed691005d842f1443e28a119a3eb
3,097
[ 746648888 ]
[ "typespec", "documented", "ecto", "phoenix" ]
defmodule TwitchStory.Twitch.Channels.Clip do @moduledoc false use TwitchStory.Schema @type t() :: %__MODULE__{ twitch_id: String.t(), video_id: String.t(), title: String.t(), created_at: NaiveDateTime.t(), broadcaster_id: String.t(), stats: map(), ...
0261323a7a8afc8f6779f41172a2599c4896b4bc
2,161
[ 870579889 ]
[ "genserver", "typespec", "documented" ]
defmodule Whepper.Client do @moduledoc false use GenServer, restart: :temporary alias ExWebRTC.{ICECandidate, PeerConnection, SessionDescription} alias Whepper.Client.ConnectionManager @pc_opts [ ice_servers: [%{urls: "stun:stun.l.google.com:19302"}] ] @spec start_link(URI.t()) :: GenServer.on_sta...
02613a62cc35d97c6a70b7ce0ae5ad493e5dfa01
1,795
[ 814869922 ]
[ "typespec", "documented", "ecto" ]
defmodule Fhir.SubstancePolymerStartingMaterial do @moduledoc """ Properties of a substance specific to it being a polymer. """ use Ecto.Schema import Ecto.Changeset @derive Jason.Encoder @primary_key false embedded_schema do field(:id, :string) field(:isDefining, :boolean) embeds_one(:_isD...
0261ca5016b4aca5c68f6d87365ec833a5505ba4
3,275
[ 249233521 ]
[]
use Mix.Config # For production, don't forget to configure the url host # to something meaningful, Phoenix uses this information # when generating URLs. # # Note we also include the path to a cache manifest # containing the digested version of static files. This # manifest is generated by the `mix phx.digest` task, # ...
02623144d0d17bee149a63119624a450a5d534d0
1,710
[ 883827011 ]
[ "macro", "documented" ]
defmodule EnvConfig.Macros do @moduledoc """ Defines macros to create assertions. """ defmacro required(env_name, type, constraints \\ []) do quote do case EnvConfig.test_var(unquote(env_name), unquote(type), unquote(constraints)) do {:ok, value} -> value {:error, :env_var_...
02626ad8a396eb48754e39d81a6e8b7e22dd513e
3,076
[ 316615216 ]
[ "typespec" ]
defmodule Kconnectex.CLI.Help do @spec help(:cluster | :config | :connectors | :loggers | :plugins | :tasks | :usage) :: :ok def help(:usage) do IO.puts(""" #{help_header()} Global options: --url URL to Kafka Connect Cluster --cluster NAME Use NAME configured cluster -...
0262e767394bcc84b65a51076209924a6955bda7
3,604
[ 154659583 ]
[ "documented" ]
defmodule Ibanity.Consent.Consent do @moduledoc """ """ use Ibanity.Resource @api_schema_path ~w(consent consents) @validate_api_schema_path ~w(consent consent validations) @revoke_api_schema_path ~w(consent consent revocations) @resource_type "consent" defstruct id: nil, validated_at: n...
0263697c0b05f5b5246ed930960de3e1159089d6
5,028
[ 120061759 ]
[]
defmodule CalculateWithThreeTokensRecursivelyClass do def tokenToInteger(twoNumberStringsInsideFn, index) do String.to_integer(Enum.at(twoNumberStringsInsideFn, index)) end def getOperator(token) do add = fn (num1, num2) -> num1 + num2 end multiply = fn (num1, num2) -> num1 * num...
0263f3eae900859d6e14f2b7ede953a63b4374ee
2,716
[ 642692337 ]
[ "test" ]
defmodule ProbuildEx.AppTest do use ExUnit.Case, async: true use ProbuildEx.DataCase import ProbuildEx.GamesFixtures alias ProbuildEx.{App, Games} alias ProbuildEx.GameDataFixtures describe "search" do test "validate/1 should validate query" do query = %{"search" => "faker", "platform_id" => "e...
026431467600a79bde6538098559b150ce141625
7,371
[ 89028700 ]
[]
defmodule Match4 do defmodule AI do def minimax(map, depth, player) do minimax(map, nil, depth, player) end defp minimax(map, move, depth, player) do cond do Match4.is_winning_move(map, move, -player) -> case player do 1 -> depth * 100 -1 -> depth * -...
02646e5d974235b89460c691f36d3e5782b2b833
5,830
[ 318130505 ]
[ "phoenix" ]
# Initially I planned to implement all this in LiveView. But when I tried to do so, it # felt conceptually jumbled. So I'm starting with the traditional CRUD approach and might # shoehorn this all into a liveview once the core logic is worked out. # defmodule TriggersWeb.TriggerController do use TriggersWeb, :control...
0264c826d07beaad6101a76166b19dd911e3ce9c
2,567
[ 25072820 ]
[ "ecto" ]
defmodule PhMicroblog.User do use PhMicroblog.Web, :model import Ecto.Query alias PhMicroblog.{Micropost, Relationship, Repo} schema "users" do field :name, :string field :email, :string field :password_digest, :string field :admin, :boolean, default: false field :password, :string, virtu...
0265334cda2080c3296253a6e4b1fa3ec14a2657
1,517
[ 530416467 ]
[ "typespec", "documented", "ecto" ]
defmodule EpochtalkServer.Models.TrustMaxDepth do use Ecto.Schema import Ecto.Changeset import Ecto.Query alias EpochtalkServer.Repo alias EpochtalkServer.Models.User alias EpochtalkServer.Models.TrustMaxDepth @default_max_depth 2 @moduledoc """ `TrustMaxDepth` model, for performing actions relating...
026542b4f7e3e43cae3753fc5d9c5a54f6f08f63
11,068
[ 881997096 ]
[ "test", "ecto" ]
defmodule ChessMate.RosterTest do use ChessMate.DataCase alias ChessMate.Roster describe "players" do alias ChessMate.Roster.Player import ChessMate.RosterFixtures @invalid_attrs %{name: nil, fide: nil} test "list_players/0 returns all players" do player = player_fixture() assert ...
026573e5cfda4ea26805e88940926ee070b637e3
2,264
[ 762400163 ]
[ "documented" ]
defmodule Chunker.TestHelpers do @moduledoc false @doc """ Extracts the text content from a single `Chunk` struct. """ def chunk_text(%Chunker.Chunk{} = chunk), do: chunk.text @doc """ Extracts the text content from a list of `Chunk` structs. """ def extract_text_from_chunks(chunks) do Enum.map(c...
0265ad71cfcd798d58c25dcf83a3e4c65becd775
4,130
[ 172807657 ]
[ "test", "ecto" ]
defmodule Hw06.TasksTest do use Hw06.DataCase alias Hw06.Tasks describe "tasks" do alias Hw06.Tasks.Task @valid_attrs %{completed: true, description: "some description", title: "some title"} @update_attrs %{completed: false, description: "some updated description", title: "some updated title"} ...
02663a9fc044bf766db2e7f770e39f3f52b458c2
2,218
[ 233548908 ]
[ "phoenix" ]
defmodule Rumbl.VideoController do use Rumbl.Web, :controller alias Rumbl.Video defp user_videos(user) do assoc(user, :videos) end def action(conn, _) do apply(__MODULE__, action_name(conn), [conn, conn.params, conn.assigns.current_user]) end def delete(conn, %{"id" => id}, user) do video = Repo.get...
02666276e9b4e54f371431e50e3fbd5a40fedead
2,064
[ 300698298 ]
[ "documented", "ecto" ]
defmodule StreamsRabbitmq.MessageProcessor do @moduledoc """ Process messages received via event bus. """ alias StreamsCore.CloudEvent alias StreamsCore.CloudEvent.Parser.DefaultParser alias StreamsCore.CloudEvent.RoutingError require Logger @doc """ Receives the raw mesages from the event bus and...
0266708f416753c518991a2dddf089f16a78368e
5,015
[ 160871906 ]
[]
defmodule Main do defmodule Matrix do defstruct input: [], minx: 0, miny: 0, maxx: 0, maxy: 0, data: Map.new, left: 0 end def read_lines() do IO.read(:all) |> String.split("\n", trim: true) end def parse_coord(str) do str |> String.split(", ", trim: true) |> Enum.map(&String.to...
02669bdc0f7ce54f7caa4d9c225c778056191cfd
1,510
[ 732500090 ]
[ "documented" ]
defmodule Aoc2023.Day7 do alias __MODULE__.{ Hand, Parser } @doc """ Part 1 I'm getting lazy about copying the instructions. Hopefully the naming and comments make it clear what's happening here. iex> Aoc2023.Day7.part_1(:test) 6440 iex> Aoc2023.Day7.part_1(:real) 252656917 """ def p...
0266ca17e2ab4df654e5711c4dc05fce099f6a82
6,067
[ 529451757, 463405209, 567369526, 455872535, 588790131, 712696481, 563730500 ]
[ "typespec", "macro", "documented" ]
defmodule Explorer.Chain.MapCache do @moduledoc """ Behaviour for a map-like cache of elements. A macro based on `ConCache` is provided as well, at its minimum it can be used as; ``` use Explorer.Chain.MapCache, name: :name, keys: [:fst, :snd] ``` Note: `keys` can also be set singularly wit...
0266d17d71f1251a92beac8854d30a0953affc22
3,234
[ 69686291 ]
[]
alias Experimental.{GenStage} defmodule GcodeMessageHandler do use GenStage require Logger def start_link() do GenStage.start_link(__MODULE__, :ok) end def init(:ok) do {:consumer, :ok, subscribe_to: [SerialMessageManager]} end def handle_events(events, _from, state) do for event <- events ...
0266fc4bd0c57077a9fe618218e704b6b1c74465
3,075
[ 977324828 ]
[ "documented" ]
defmodule Xombadill.Handlers.LinkExplainHandler do @moduledoc """ Handler that recognizes YouTube links in channel messages and fetches their titles. Looks for YouTube URLs (various types) in incoming channel messages, fetches the webpage, extracts and relays the video title to the channel for context. """ ...
026729a893f679b6225d27010e86cf42e51fc6dc
1,625
[ 334387837 ]
[ "typespec", "documented" ]
defmodule Teiserver.Config.SiteConfigTypes.SystemConfigs do @moduledoc false import Teiserver.Config, only: [add_site_config_type: 1] @spec create() :: :ok def create() do add_site_config_type(%{ key: "system.Redirect url", section: "System", type: "string", permissions: ["Admin"], ...
02675feb5cda42f212f36c80044c2241983615fc
3,552
[ 867481788 ]
[ "test", "phoenix" ]
defmodule TodoWeb.PathSessionControllerTest do use TodoWeb.ConnCase, async: true import Todo.RouteFixtures setup do %{path: path_fixture()} end describe "POST /path/log_in" do test "logs the path in", %{conn: conn, path: path} do conn = post(conn, ~p"/path/log_in", %{ "path"...
026770fff22a23c6936b29fae209ba6c884552f9
15,784
[ 517288695, 513636666, 505415834 ]
[ "liveview" ]
defmodule PetalBoilerplateWeb.PageLive do use PetalBoilerplateWeb, :live_view @impl true def mount(_params, session, socket) do {:ok, assign(socket, modal: false, slide_over: false, pagination_page: 1, color_scheme: session["color_scheme"] )} end @impl true def ha...
026784d70dfccf5822b53e07e0eaae8e32f105a2
5,771
[ 942573615 ]
[ "genserver", "liveview" ]
defmodule MySuperAppWeb.DocumentUploadLive do use MySuperAppWeb, :live_view alias MySuperApp.DocumentRequests require Logger @bucket Application.get_env(:my_super_app, :aws)[:bucket] @s3_region Application.get_env(:my_super_app, :aws)[:s3_region] @access_key_id Application.get_env(:my_super_app, :aws)[:ac...
0267d8568fa45b815e81832646daaceac5a3663c
5,727
[ 98715353 ]
[ "genserver", "documented" ]
defmodule RiotApi do use GenServer require Logger @moduledoc """ Documentation for RiotApi. """ @doc """ Handles querying of playing summoners and all other method that correspond to the RiotApi """ def start_link(summoner_file) do champions = File.read!("champions.txt") |> Pois...
0268704c7acf7b2bb3168694621f751ecf70e41f
2,960
[ 193244709, 101434552, 198908023 ]
[ "typespec", "documented" ]
defmodule GoogleApi.DocumentAI.V1.Model.GoogleCloudDocumentaiV1Evaluation do @moduledoc """ An evaluation of a ProcessorVersion's performance. ## Attributes * `allEntitiesMetrics` (*type:* `GoogleApi.DocumentAI.V1.Model.GoogleCloudDocumentaiV1EvaluationMultiConfidenceMetrics.t`, *default:* `nil`) - Metrics ...
0268794269a9a7d0e55539c2c53f69da5a3039d7
2,057
[ 145328533 ]
[]
defmodule Vaporstring.Graphemes do def glyph(letter) do case letter do "a" -> "a" "b" -> "b" "c" -> "c" "d" -> "d" "e" -> "e" "f" -> "f" "g" -> "g" "h" -> "h" "i" -> "i" "j" -> "j" "k" -> "k" "l" -> "l" "m" -> "m" "n" -> "n" ...
0268b8a82e622ac0128812fc0d70982a02c7bb56
2,518
[ 882724830 ]
[ "test", "phoenix" ]
defmodule TimemanagerWeb.ClockControllerTest do use TimemanagerWeb.ConnCase import Timemanager.ClockingFixtures alias Timemanager.Clocking.Clock @create_attrs %{ status: true, user: "some user", times: ~D[2024-10-07] } @update_attrs %{ status: false, user: "some updated user", tim...
0268bcc077d1336452826ad7721c0a912dd6c9dd
1,680
[ 211097139, 180274417 ]
[ "supervisor" ]
# Returns config for Elixir docs [ extras: Path.wildcard("lib/elixir/pages/*.md"), groups_for_functions: [ Guards: & &1[:guard] == true ], skip_undefined_reference_warnings_on: ["compatibility-and-deprecations"], groups_for_modules: [ # [Kernel, Kernel.SpecialForms], "Basic Types": [ Atom, ...
026950b494111668b1d656b998dbc9fad3206e41
1,853
[ 42551534 ]
[ "documented", "ecto" ]
defmodule Roxie.User do use Roxie.Web, :model use Pipe schema "users" do field :email, :string field :remember_token, :string field :password_hash, :string field :recovery_hash, :string field :password, :string, virtual: true field :password_confirmation, :string, virtual: true timest...
026955b3f9201b1389aec18551ff73ef09bfdc78
2,310
[ 87464330 ]
[]
%{"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], []}, "certifi": {:hex, :certifi, "1.0.0", "1c787a85b1855ba354f0b8920392c19aa1d06b0ee1362f9141279620a5be2039", [:rebar3], []}, "combine": {:hex, :combine, "0.9.6", "8d1034a127d4cbf6924c8a5010d3534d958085575fa...
0269e7cc7d9bbfa959a81c7deee757bd36f44615
1,600
[ 736142941 ]
[ "ecto" ]
defmodule Rocketsized.Repo.Migrations.SearchView do use Ecto.Migration def change do alter table(:countries) do add :short_name, :string end execute("UPDATE countries SET short_name = name", "") create index(:vehicles, [:is_published]) create index( :vehicles, ...
026a24cf411a8e8253513382121bae15cdc8cf83
10,564
[ 259741560 ]
[ "documented" ]
defmodule Gateway.Router.Portal.Commands.V1.Receiver.Auth do @moduledoc ~S""" Processes the HTTP based requests and sends them to the correct handler. The handler or business logic is broken out of http request so I can change API versions later on but still keep backwards compatability support if possible ...
026a85042fb868c03370f165b3ed966d748f6c74
3,976
[ 138649219 ]
[ "genserver", "documented" ]
defmodule Farmbot.Target.Leds.AleHandler do alias ElixirALE.GPIO @behaviour Farmbot.Leds.Handler @slow_blink_speed 200 @fast_blink_speed 50 # @valid_status [:off, :solid, :slow_blink, :fast_blink] @moduledoc false def red(status), do: GenServer.call(__MODULE__, {:red, status}) def blue(status), do: G...
026b42c76bcf8dd6c1d1244b64b21c6f9dab7903
2,151
[ 107060235 ]
[ "liveview", "macro", "documented", "phoenix" ]
defmodule TicTacToeChannelWeb 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 TicTacToeChannelWeb, :controller use TicTacToeChannelWeb, :view The definitions below will be executed for...
026b7305e521bf0d780465a7fc7c5e8ead1f9e12
7,851
[ 840527879 ]
[ "typespec", "supervisor", "documented" ]
defmodule Modbuzz do @moduledoc """ `Modbuzz` is yet another MODBUS library, supporting both TCP and RTU. """ @type request :: Modbuzz.PDU.Protocol.t() @type response :: Modbuzz.PDU.Protocol.t() @type error :: Modbuzz.PDU.Protocol.t() @type callback :: (request() -> response()) @type client :: GenServe...
026b86b992f842f53312a27ad7c4db3dd3a5d7b5
4,966
[ 30160313 ]
[ "typespec", "documented" ]
defmodule ElixirScript.Compiler do @moduledoc """ The entry point for the ElixirScript compilation process. Takes the given module(s) and compiles them and all modules and functions they use into JavaScript. Will also take a path to Elixir files """ @doc """ Takes either a module name, list of module ...
026c1d982a20dd4c99b4e712298ec5549c4a8131
1,855
[ 12017779 ]
[ "test" ]
if System.get_env("EXERCISM_TEST_EXAMPLES") do Code.load_file("example.exs") else Code.load_file("account.exs") end ExUnit.start # The BankAccount module should support four calls: # # open_bank() # Called at the start of each test. Returns an account handle. # # close_bank(account) # Called at the end of eac...
026c362dca98c54609179d43660be14276d6759c
1,804
[ 887925291 ]
[ "test" ]
defmodule Finix.IdentitiesTest do use ExUnit.Case use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney describe "create an identity for a buyer" do test "create an identity for a buyer" do use_cassette "identities/create" do {:ok, response} = Finix.Identities.create(%{ tags: %{ ...
026c77a9ff8928c575d6cd13bdad38cd2d391f0b
1,798
[ 101434552, 198908023 ]
[ "typespec", "documented" ]
defmodule GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1betaAdvancedCompleteQueryRequestBoostSpec do @moduledoc """ Specification to boost suggestions based on the condtion of the suggestion. ## Attributes * `conditionBoostSpecs` (*type:* `list(GoogleApi.DiscoveryEngine.V1beta.Model.Goo...
026d32b5583573d19f8db8f372ba3af8a66af17a
2,249
[ 959066583 ]
[ "liveview", "ecto" ]
defmodule IotHubWeb.CodecHubLive.FormComponent do use IotHubWeb, :live_component alias IotHub.Hubs @impl true def render(assigns) do ~H""" <div> <.header> {@title} <:subtitle>Use this form to manage codec_hub records in your database.</:subtitle> </.header> <.simple_...
026d56879fa928809dff358c97278cce97de5b25
4,997
[ 105644129 ]
[ "typespec" ]
defmodule Ldap.Ecto.Converter do @spec from_erlang(any) :: any def from_erlang(list=[head|_]) when is_list(head), do: Enum.map(list, &from_erlang/1) # def from_erlang(list) when is_list(list), do: Enum.map(list, &from_erlang/1) def from_erlang(string) when is_list(string), do: :binary.list_to_bin(string) def ...
026d5d30d211ae90285d5cefd9a1157bd337e2d1
6,825
[ 715931790 ]
[ "test" ]
defmodule DeleteServerMimicTest do use ExUnit.Case use Mimic setup_all do success = %Tesla.Env{ method: :delete, url: "https://api.latitude.sh/servers/18_912", query: [], headers: [ {"cache-control", "max-age=0, private, must-revalidate"}, {"connection", "keep-alive"},...
026d62b8be77f8ca632bdca2a549a3e40605fea1
5,114
[ 367278931 ]
[ "documented" ]
defmodule Google.Cloud.Automl.V1beta1.DataStats do @moduledoc false use Protobuf, protoc_gen_elixir_version: "0.14.1", syntax: :proto3 oneof :stats, 0 field :float64_stats, 3, type: Google.Cloud.Automl.V1beta1.Float64Stats, json_name: "float64Stats", oneof: 0 field :string_stats, 4, type: ...
026da3ebb9a6f56aa8654d0844dd0f553608bd19
1,816
[ 116039078 ]
[ "typespec", "macro", "documented", "ecto" ]
defmodule Passport.Activatable do @moduledoc """ Affects a Record's 'active' state """ import Ecto.Changeset defmacro schema_fields(options \\ []) do timestamp_type = Keyword.get(options, :timestamp_type, :utc_datetime_usec) quote do if Passport.Config.activatable_is_flag(__MODULE__) do ...
026e237fa5992bcc45dd98ae358963000a3f3f8b
2,611
[ 529451757, 744421640, 567369526, 455872535, 712696481, 563730500 ]
[ "phoenix" ]
defmodule BlockScoutWeb.API.RPC.TransactionView do use BlockScoutWeb, :view alias BlockScoutWeb.API.RPC.RPCView def render("gettxinfo.json", %{ transaction: transaction, block_height: block_height, logs: logs, next_page_params: next_page_params }) do data = prepare_tran...
026e492105c63d41ad91478aa10bdb324e04f241
11,717
[ 997214727 ]
[ "documented" ]
defmodule Aiex.Performance.MnesiaOptimizer do @moduledoc """ Mnesia performance optimization utilities. Provides tools for optimizing Mnesia table configuration, analyzing table performance, and implementing best practices for distributed Mnesia deployments. """ require Logger @doc """ Analyzes a...
026e6cfd2a263a8650598aa6dc03c125c5159c24
1,864
[ 193244709, 101434552, 198908023 ]
[ "typespec", "documented" ]
defmodule GoogleApi.ServiceNetworking.V1.Model.Method do @moduledoc """ Method represents a method of an API interface. ## Attributes * `name` (*type:* `String.t`, *default:* `nil`) - The simple name of this method. * `options` (*type:* `list(GoogleApi.ServiceNetworking.V1.Model.Option.t)`, *default:* `...
026efddcda1b44f6bc59aa378e92d2038d1409ff
2,496
[ 423313665 ]
[ "genserver", "liveview" ]
defmodule RealTimeWeb.ServersLive do use RealTimeWeb, :live_view alias RealTime.Servers def mount(_params, _session, socket) do if connected?(socket), do: Servers.subscribe() servers = Servers.list_servers() {:ok, assign(socket, servers: servers)} end def handle_params(%{"id" => id}, _url, so...
026f2218916210b4ef87b2d962094a945b85cf34
3,086
[ 992008923 ]
[ "phoenix" ]
defmodule SlackCloneWeb.Router do use SlackCloneWeb, :router import SlackCloneWeb.UserAuth pipeline :browser do plug :accepts, ["html"] plug :fetch_session plug :fetch_live_flash plug :put_root_layout, html: {SlackCloneWeb.Layouts, :root} plug :protect_from_forgery plug :put_secure_brows...
026f4e955fa5e971c9a1987662ca98ed8446f771
5,195
[ 572662601 ]
[]
defmodule AOC2022.Day23 do require Util @directions %{ N: {0, 1}, NE: {1, 1}, E: {1, 0}, SE: {1, -1}, S: {0, -1}, SW: {-1, -1}, W: {-1, 0}, NW: {-1, 1} } @considerations %{ northish: {[:N, :NE, :NW], :N}, southish: {[:S, :SE, :SW], :S}, eastish: {[:E, :SE, :NE], :E}...
026f7c7fcd3772a0cd2133da6fd92c5fa84a60ec
1,765
[ 650741123 ]
[ "typespec" ]
defmodule ActivityStream.Type.Activity.Properties.Actor do use GuardedStruct @types ["Application", "Group", "Organization", "Person", "Service"] # URI: https://www.w3.org/ns/activitystreams#actor # Describes one or more entities that either performed or are expected to perform the activity. # Any single ac...
026fa5de153949e50f789c4db3fadca3b5a99908
1,500
[ 370459886 ]
[]
defmodule ConfigClients.Mixfile do use Mix.Project def project do [ app: :ConfigClients, version: "0.1.1", elixir: "~> 1.7", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:gettext] ++ Mix.compilers(), # start_permanent: Mix.env() == :prod, aliases: aliases(), ...
026fb1af46abbabc300b6cc3f9512af3c1ee8d1b
3,098
[ 84195779 ]
[ "phoenix", "ecto" ]
defmodule Pet.UserController do use Pet.Web, :controller alias Pet.User def index(conn, _params) do users = Repo.all(User) changeset = User.changeset(%User{}) render(conn, "index.html", users: users, changeset: changeset) end def new(conn, _params) do changeset = User.changeset(%User{}) ...
026fb463565a2c643c5085779364241c3a632889
2,767
[ 463612034 ]
[ "typespec" ]
# Game engine implementation for Hangman defmodule Hangman.Impl.Game do alias Hangman.Type @type t :: %__MODULE__{ turns_left: integer, game_state: Hangman.state, letters: list(String.t), used: MapSet.t(String.t) } defstruct( turns_left: 7, game_state: :initializing, letters: [], ...
02702451e840169b3d2ec4c0cedfb34b9ae837f2
3,020
[ 937177350 ]
[ "phoenix" ]
defmodule Helpcenter.KnowledgeBase.Article do use Ash.Resource, otp_app: :helpcenter, domain: Helpcenter.KnowledgeBase, data_layer: AshPostgres.DataLayer postgres do table "articles" repo Helpcenter.Repo # Delete this article if related category is deleted references do reference...
027106677ad095f5f7815558f77eb5686597a17a
2,156
[ 180479110 ]
[]
defmodule Playground.Scenario.ETS do use Playground.Scenario def scenario_type do {:iterations, Stream.map(10..20, &round(:math.pow(2, &1)))} end def scenario_banner do """ Scenario: use an ETS table. Data: {integer} Tasks: - Bulk Load of <count> items (in one go) - Concurrent...
0271aae2fc78ce0d5994b9e74390a397666291f4
1,575
[ 88876628 ]
[ "phoenix" ]
defmodule CheckListApi.ItemController do alias CheckListApi.Project alias CheckListApi.Item alias CheckListApi.Repo require Logger use CheckListApi.Web, :controller def items(conn, %{"checklist_id" => checklist_id}) do items = Repo.all(from i in Item, where: i.checklist_id == ...
02722969d61be4ec596b232aadb04c312c39ae29
2,444
[ 863118743, 863118926 ]
[]
defmodule Astarte.TriggerEngine.Mixfile do use Mix.Project def project do [ app: :astarte_trigger_engine, elixir: "~> 1.15", version: "1.2.0-dev", elixirc_paths: elixirc_paths(Mix.env()), build_embedded: Mix.env() == :prod, start_permanent: Mix.env() == :prod, test_cov...
0272862289d9dfdc22702fe612c136db8de92cb1
7,719
[ 681562892, 344533650 ]
[ "test" ]
defmodule CurvyTest do use ExUnit.Case, async: true alias Curvy.Key @test_key %Key{ point: %Curvy.Point{ x: 4118631015477382459373946646660315625074350024199250279717429272329062331319, y: 66793862366389912668178571190474290679389778848647827908619288257874616811393 }, privkey: <<94, 192,...
0272b325a5c9712eed02eff3ee9d1318a52e66e3
1,741
[ 101330186 ]
[ "genserver", "documented" ]
defmodule WaitForIt.V1.ConditionVariable do @moduledoc false use GenServer, restart: :temporary @default_idle_timeout 60_000 defstruct waiters: [], idle_timeout: @default_idle_timeout def start_link, do: start_link([]) def start_link(opts) when is_list(opts) do name_opt = case...
0272b5e77dff5d53e75478d9a982465f63ba28e7
3,088
[ 959817494 ]
[ "liveview", "test" ]
defmodule PourWeb.UserLive.ConfirmationTest do use PourWeb.ConnCase, async: true import Phoenix.LiveViewTest import Pour.AccountsFixtures alias Pour.Accounts setup do %{unconfirmed_user: unconfirmed_user_fixture(), confirmed_user: user_fixture()} end describe "Confirm user" do test "renders co...
02732f508e2099297d4807c8029cc10e4bcb549b
9,656
[ 985853139 ]
[]
# Generated by Mochi compiler v0.10.26 on 2025-07-16T17:34:35Z defmodule Main do def main do # store_sales :: list(map()) store_sales = [ %{ ss_sold_date_sk: 1, ss_item_sk: 1, ss_customer_sk: 1, ss_store_sk: 1, ss_ext_sales_price: 100 } ] # date_dim...
0273bcd8b93fed41f1fe8e00bea3fdf66970c5fc
3,813
[ 913995146, 915448704, 934044764, 962529983, 1017248001, 1019465249, 1010134902, 924963573, 1008010336, 1018026088, 936927438, 973282597, 994710780, 1008064659, 1011149314, 1013128869, 220852206, 983213709, 982459127, 981152162, 993081259, 997457369, 1006623189, 90863001...
[ "typespec", "documented" ]
defmodule Bandit.Compression do @moduledoc false defstruct method: nil, bytes_in: 0, lib_context: nil @typedoc "A struct containing the context for response compression" @type t :: %__MODULE__{ method: :deflate | :gzip | :identity, bytes_in: non_neg_integer(), lib_context: term()...
0273f82d0c70a80394cd5fb9c1a72fefac5d2998
2,226
[ 780461734 ]
[ "typespec" ]
defmodule MyCalendar.Model.EventStruct do defmodule Place do @behaviour Access @enforce_keys [:office, :room] defstruct [:office, :room] @impl true def fetch(place, :office), do: {:ok, place.office} def fetch(place, :room), do: {:ok, place.room} def fetch(_place, _), do: :error @imp...
027471e1a8322fd5d49a83f67200783d3d05a88e
6,965
[ 767052093 ]
[ "test", "ecto" ]
defmodule EctoModel.SoftDeleteTest do use ExUnit.Case, async: true import EctoModel.Factory alias EctoModel.Dog alias EctoModel.Owner alias EctoModel.Vaccination alias EctoModel.Repo setup tags do :ok = Ecto.Adapters.SQL.Sandbox.checkout(EctoModel.Repo) unless tags[:async] do Ecto.Adapte...