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
0626ccbd041e751715914deccbdac54ec6553819
1,666
[ 540666245 ]
[]
# 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 # Configures the endpoint config :baby_steps, BabySte...
06270371d47d8be29312d1cdb44b6c856282b661
2,347
[ 755379487 ]
[ "test", "phoenix" ]
defmodule PhooeyWeb.PostControllerTest do use PhooeyWeb.ConnCase import Phooey.PostsFixtures alias Phooey.Posts.Post @create_attrs %{ title: "some title", body: "some body" } @update_attrs %{ title: "some updated title", body: "some updated body" } @invalid_attrs %{title: nil, body: n...
06276280126c181b81c0df2e31dd274cd2b78046
3,233
[ 665603867 ]
[ "liveview", "test" ]
defmodule TodoAppWeb.TaskLiveTest do use TodoAppWeb.ConnCase import Phoenix.LiveViewTest import TodoApp.TasksFixtures @create_attrs %{name: "some name", status: true} @update_attrs %{name: "some updated name", status: false} @invalid_attrs %{name: nil, status: false} defp create_task(_) do task = t...
062763bbad14c89effeffd052d740e1a2a557d40
1,686
[ 512056714 ]
[ "macro", "test" ]
defmodule NxColor.ColorspaceTestHelper do defmacro __using__(_env) do module = __MODULE__ quote do require unquote(module) import unquote(module) import NxColor.NxTestHelper alias NxColor.Colorspace end end defmacro colorspacetest(colorspace, opts \\ []) do quote bind_qu...
0627cc9984c532b8b06b5cecae2d955ed7280100
1,761
[ 22191596 ]
[ "test" ]
defmodule Issue71Test do use ExUnit.Case test "raise on reading /etc/passwd with dtd: :none" do sneaky_xml = File.read!("./test/files/xxe.xml") assert {:fatal, {{:error_fetching_DTD, {_, _}}, _file, _line, _col}} = catch_exit(SweetXml.parse(sneaky_xml, dtd: :none, quiet: true)) end test "raise ...
0627e3d6664676ea3e6649c95ac81a8a8201f027
2,351
[ 783633140 ]
[]
# This file is responsible for configuring your umbrella # and **all applications** and their dependencies with the # help of the Config module. # # Note that all applications in your umbrella share the # same configuration and dependencies, which is why they # all use the same configuration file. If you want different...
06282d06f21a99a10a478f8b66ccb2690f6cc059
7,230
[ 193244709, 101434552, 198908023 ]
[ "typespec", "documented" ]
defmodule GoogleApi.Language.V1.Model.XPSEvaluationMetrics do @moduledoc """ Contains xPS-specific model evaluation metrics either for a single annotation spec (label), or for the model overall. Next tag: 18. ## Attributes * `annotationSpecIdToken` (*type:* `String.t`, *default:* `nil`) - The annotation_spe...
062837209054f205225a63cfcfef17d31ac88419
3,527
[ 80005383 ]
[ "typespec", "documented" ]
defmodule Zuppler.Utilities.DataConvertor do @moduledoc """ Data Convertor module Used to convert from map to Restaurant struct """ @doc """ Convert a map to struct to enforce keys validation ## Example %{ name: "demo", permalink: "demorestaurant", amenities: "Online Orders, Cockt...
0628461cb20afa2a0dbb246a864f4e230bcb8c27
1,601
[ 159979201 ]
[ "test" ]
Code.require_file("chronal_charge.exs") ExUnit.start() defmodule ChronalChargeTest do use ExUnit.Case import ChronalCharge test "new" do assert Cell.new(122, 79, 57) == %Cell{x: 122, y: 79, value: -5} assert Cell.new(217, 196, 39) == %Cell{x: 217, y: 196, value: 0} assert Cell.new(101, 153, 71) == ...
0628d99660dbe0d6cb6516eef0de49c8925a263c
2,833
[ 650701811 ]
[ "documented" ]
defmodule MainWeb.Intents.InstructorSchedule do @moduledoc """ This handles instructor schedule responses """ alias Main.Integrations.Mindbody alias Data.{ ClassSchedule, Location } @behaviour MainWeb.Intents @keys [:instructor] @no_classes "It doesn't look like we have an instructor here b...
0628ebcde39719732d981ed43e2f77555d78d531
2,795
[ 121569378 ]
[]
%{ "certifi": {:hex, :certifi, "2.4.2", "75424ff0f3baaccfd34b1214184b6ef616d89e420b258bb0a5ea7d7bc628f7f0", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, optional: false]}]}, "earmark": {:hex, :earmark, "1.2.6", "b6da42b3831458d3ecc57314dff3051b080b9b2be88c2e5aa41cd642a5b044ed", [:mix], []}, "ex_doc": {...
062a140d701cccc6159112a770ca485734e41f2e
1,538
[ 97330029 ]
[]
# This file is responsible for configuring your application # and its dependencies with the aid of the Mix.Config module. # # This configuration file is loaded before any dependency and # is restricted to this project. use Mix.Config # General application configuration config :ff_reader, ecto_repos: [FfReader.Repo] ...
062a4f9d1352fa2c16e46d125810dd691ef20e9d
4,131
[ 159886248 ]
[ "documented" ]
defmodule Aoc.Year2021.Day03.BinaryDiagnostic do @moduledoc """ ## --- Day 3: Binary Diagnostic --- The submarine has been making some odd creaking noises, so you ask it to produce a diagnostic report just in case. The diagnostic report (your puzzle input) consists of a list of binary numbers which, when ...
062ad35328311cd4994a8388fba15ef3fc3264b5
2,178
[ 620053150 ]
[]
# 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 :social_networks, ecto_repos: [SocialNetwork...
062b40ca7f773b4836c7d1759df57c555e0600c8
4,268
[ 714807717 ]
[ "documented", "ecto" ]
defmodule MtgFriends.Participants do @moduledoc """ The Participants context. """ import Ecto.Query, warn: false alias MtgFriends.Repo alias MtgFriends.Participants.Participant @doc """ Returns the list of participants. ## Examples iex> list_participants() [%Participant{}, ...] """...
062b5690676ca118d0cd4d3abac39bd53ba371ed
4,375
[ 676414070 ]
[ "documented", "ecto" ]
defmodule Schematic.GeneratedColumns do @moduledoc """ The GeneratedColumns context. """ import Ecto.Query, warn: false alias Schematic.Repo alias Schematic.GeneratedColumns.GeneratedColumn alias Schematic.GeneratedColumns.GeneratedInput @doc """ Returns the list of generated_columns. ## Example...
062bc3506fb4891360d0feb6cf3d329e7b6884f8
10,037
[ 81755381 ]
[ "typespec", "macro", "documented", "ecto" ]
defmodule Rummage.Ecto do @moduledoc """ Rummage.Ecto is a light weight, but powerful framework that can be used to alter Ecto queries with Search, Sort and Paginate operations. It accomplishes the above operations by using `Hooks`, which are modules that implement `Rummage.Ecto.Hook` behavior. Each operatio...
062be89944ee0cebe10c42999cb38878bab5e169
1,902
[ 390015246 ]
[ "liveview", "test" ]
defmodule Sneakers23Web.ProductPageLiveTest do use Sneakers23Web.ConnCase, async: :false import Phoenix.LiveViewTest alias Sneakers23.Inventory setup _ do {inventory, _datat} = Test.Factory.InventoryFactory.complete_products() {:ok, _} = GenServer.call(Inventory, {:test_set_inventory, inventory}) ...
062c05368ddde33ff4764537011bc242c5ef0b01
3,728
[ 753092614 ]
[ "liveview", "ecto" ]
defmodule CompanyCommanderWeb.TaskLive.FormComponent do use CompanyCommanderWeb, :live_component alias CompanyCommander.Tasks @impl true def render(assigns) do ~H""" <div> <.header> <%= @title %> <:subtitle>Use this form to manage tasks records in your database.</:subtitle> ...
062c0ad8add34dff29818826d0b404f0955d31cc
2,023
[ 636601411 ]
[ "test" ]
defmodule AddMultMinusTest do use ExUnit.Case use Plug.Test alias Kraken.Api.Router alias Kraken.{Pipelines, Routes} @path Path.expand("../..", __ENV__.file) <> "/add_mult_minus" setup do on_exit(fn -> Octopus.delete("add-mult-minus") Pipelines.delete("add-mult-minus-pipeline") Route...
062c67e57f69f875a7f86130347656bde63a3256
16,243
[ 437386680 ]
[ "typespec", "documented" ]
defmodule Erlex do @moduledoc """ Convert Erlang style structs and error messages to equivalent Elixir. Lexes and parses the Erlang output, then runs through pretty printer. ## Usage Invoke `Erlex.pretty_print/1` wuth the input string. ```elixir iex> str = ~S"('Elixir.Plug.Conn':t(),binary() | atom(...
062c9f6ac29c51dd65ca3af05ca71a55273c9254
2,320
[ 433484844 ]
[ "test" ]
defmodule ExAws.HelpersTest do use ExCubicIngestion.DataCase, async: true describe "move/5" do test "already copied but there is still a source object" do assert {:ok, _} = ExAws.Helpers.move( MockExAws, # incoming bucket "incoming", ...
062cb9d24617dcd180c73972449bab9762ca2e71
2,382
[ 108114866 ]
[ "test" ]
defmodule ApiWeb.PostControllerTest do use ApiWeb.ConnCase alias Api.Json alias Api.Json.Post @create_attrs %{body: "some body", title: "some title"} @update_attrs %{body: "some updated body", title: "some updated title"} @invalid_attrs %{body: nil, title: nil} def fixture(:post) do {:ok, post} = J...
062cc5f421279d6aef02f3eb7ddd6601db767f4f
1,518
[ 404514242 ]
[]
defmodule Proximal.MixProject do use Mix.Project def project do [ app: :proximal, version: "0.2.3", description: "proXiMaL is an advanced library for XML on top of Saxy", elixir: "~> 1.11", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, c...
062cd23122ad2f0559abef7c30b9d83092341650
12,099
[ 667564517 ]
[ "liveview", "test" ]
defmodule RecipesWeb.RecipeLiveTest do use RecipesWeb.ConnCase import Phoenix.LiveViewTest import Recipes.AccountsFixtures import Recipes.DataFixtures setup do %{user: user_fixture()} end describe "The recipes detail view" do test "Redirects to login if user is not logged in ", %{conn: conn} do...
062d102826b598478e15dd3e495a43c1ad170be4
4,518
[ 335259817 ]
[ "test" ]
defmodule Bets.BetsTest do use ExUnit.Case alias Bets.Bets doctest Game test "create bet when given valid suit-player" do {:ok, bet} = Bets.create_bet(%{"suit-player": "diamond"}) assert bet."suit-player" == "diamond" {:ok, bet} = Bets.create_bet(%{"suit-player": "heart"}) assert bet."suit-pla...
062d2dbfc695337197063a6db6c7e56a99d1c11c
3,024
[ 119051773 ]
[ "test" ]
defmodule Tictactoe.Game.State.JoinedPlayersTest do use ExUnit.Case, async: true alias Tictactoe.Game.State.JoinedPlayers describe ".add_player" do test "adds X to an empty player set" do {:ok, added_player, _} = JoinedPlayers.add_player(JoinedPlayers.none()) assert(added_player == "X") end...
062d30a2f042a16bc8ead202ece0ccdcb316986f
1,723
[ 518895899 ]
[]
defmodule InfoSys do alias InfoSys.Cache @backends [InfoSys.Wolfram] defmodule Result do defstruct score: 0, text: nil, backend: nil end def compute(query, opts \\ []) do timeout = opts[:timeout] || 10_000 opts = Keyword.put_new(opts, :limit, 10) backends = opts[:backends] || @backends ...
062d4bfd6588075ef71de395b9c90fe772bb72ab
10,159
[ 993683204 ]
[ "macro", "documented" ]
defmodule Xinesis do @moduledoc """ Basic AWS Kinesis client. """ require Logger alias Mint.HTTP1, as: HTTP defmodule Error do @moduledoc "TODO" defexception [:type, :message] def message(%{type: nil, message: message}) do message end def message(%{type: type, message: message}...
062eafd1d3a909c244fb51918d4ebbb00e580164
1,924
[ 163994169 ]
[ "phoenix", "ecto" ]
defmodule PonbotWeb.SettingController do use PonbotWeb, :controller alias Ponbot.Configurations alias Ponbot.Configurations.Setting def index(conn, _params) do settings = Configurations.list_settings() render(conn, "index.html", settings: settings) end def new(conn, _params) do changeset = Co...
062edb1f3d5252e38c0ac9e4107cef1b3eaa3970
2,697
[ 193244709, 101434552, 198908023 ]
[ "typespec", "documented" ]
defmodule GoogleApi.RealTimeBidding.V1.Model.UserList do @moduledoc """ Represents an Authorized Buyers user list. Authorized Buyers can create/update/list user lists. Once a user list is created in the system, Authorized Buyers can add users to the user list using the bulk uploader API. Alternatively, users can be...
062ef43177e03c9fe82078c559bd137dd80dc1e9
1,670
[ 176131214 ]
[ "phoenix", "ecto" ]
defmodule Hw07Web.TaskController do use Hw07Web, :controller alias Hw07.Tasks alias Hw07.Tasks.Task def index(conn, _params) do tasks = Tasks.list_tasks() render(conn, "index.html", tasks: tasks) end def new(conn, _params) do changeset = Tasks.change_task(%Task{}) render(conn, "new.html",...
062f801ca63c213cd2603429152cf63fea39ceab
2,181
[ 338131945 ]
[ "documented", "ecto" ]
defmodule NoozoWeb.Admin.Todo.Components.Item do @moduledoc """ Item component """ use NoozoWeb, :surface_component alias Noozo.Repo alias Noozo.Todo import Ecto.Query, warn: false prop item, :struct prop search_result_ids, :list data opacity, :integer, default: 100 @impl true def update(%{i...
062f9826102781523ea6b680efd872cc69a9b07d
3,153
[ 3642931 ]
[ "macro", "documented" ]
defmodule ExDoc.Formatter.EPUB.Templates do @moduledoc false require EEx import ExDoc.Utils, only: [before_closing_body_tag: 2, before_closing_head_tag: 2, h: 1, text_to_id: 1] alias ExDoc.Formatter.HTML.Templates, as: H alias ExDoc.Formatter.EPUB.Assets # The actual rendering happens here defp re...
062fe92deff2979229731979c13086a4c67e37f0
4,340
[ 571776611 ]
[ "test" ]
defmodule Pleroma.Web.AdminAPI.ModerationLogViewTest do use Pleroma.DataCase, async: true alias Pleroma.Web.AdminAPI.ModerationLogView describe "renders `report_note_delete` log messages" do setup do log1 = %Pleroma.ModerationLog{ id: 1, data: %{ "action" => "report...
06301f3767fe65726f1f1a552bb6fab16f53a7d2
5,143
[ 137688039 ]
[ "documented" ]
defmodule Helpers.Images do @moduledoc false require Plug.Upload alias Helpers.Files require IEx def get_admin_avatar_url(user) do String.trim_leading(user.avatar_img, "priv/static") end def get_user_avatar_url(user) do String.trim_leading(user.avatar_img, "/priv/static") end def show_admin_...
0630314bb1515ece484056c004aba6b6e1dba3a3
8,687
[ 72841254, 80811189 ]
[]
%{"base64url": {:hex, :base64url, "0.0.1", "36a90125f5948e3afd7be97662a1504b934dd5dac78451ca6e9abf85a10286be", [:rebar], []}, "bbmustache": {:hex, :bbmustache, "1.0.4", "7ba94f971c5afd7b6617918a4bb74705e36cab36eb84b19b6a1b7ee06427aa38", [:rebar], []}, "certifi": {:hex, :certifi, "0.4.0", "a7966efb868b179023618d29a4...
063034257ec2293e79a2af570967d1dff8ecba7b
14,395
[ 14421569 ]
[ "test" ]
defmodule Plug.ParsersTest do use ExUnit.Case, async: true import Plug.Test import Plug.Conn defmodule BodyReader do def read_body(conn, opts) do {:ok, body, conn} = Plug.Conn.read_body(conn, opts) {:ok, body <> "BAR", conn} end def read_body(conn, opts, "test", "read body") do ...
063034609207be1ad5591029a4c1574d744c11ae
2,218
[ 896259126 ]
[]
defmodule AdventOfCode.Solution.Year2023.Day08 do use AdventOfCode.Solution.SharedParse defp navigate(current, target, step, count, instructions, nodes) do if current == target do count else {left, right} = Map.get(nodes, current) new_node = if instructions |> Enum.at(step) == ?L, do: le...
06308a1d8cc323fd847741dc8ce217af5d9fa083
3,474
[ 214440049 ]
[ "test" ]
defmodule Integration.LoggerTest do use Sparrow.IntegrationCase, async: false if Version.compare(System.version(), "1.11.0") != :lt do require Logger describe "Logger" do test "warn" do spawn_link(fn -> Logger.warn("message") end) refute_receive %Sparrow.Event{} ...
0630b28bdd0a6138ba8eeb129277857e8be18d6d
2,410
[ 251401867 ]
[ "documented" ]
defmodule OpenAPICompiler.MixProject do @moduledoc false use Mix.Project @version "1.0.0-beta.18" def project do [ app: :openapi_compiler, version: @version, elixir: "~> 1.9", start_permanent: Mix.env() == :prod, deps: deps(), dialyzer: [ plt_add_apps...
0630c86bb4a544382ba2c3937a0b30ee6e4ae510
1,915
[ 422112185 ]
[]
# 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 # Configures the endpoint config :ldnd, LdndWeb.Endpo...
0630c88ee14fc48ffc4bd7cc72e25f8859a9e1b5
2,304
[ 550548598, 520932864 ]
[ "typespec", "documented", "phoenix" ]
defmodule LivebookWeb.AuthPlug do @moduledoc false @behaviour Plug import Plug.Conn import Phoenix.Controller @impl true def init(opts), do: opts @impl true def call(conn, _opts) do mode = Livebook.Config.auth_mode() if authenticated?(conn, mode) do conn else authenticate(co...
0630efcab7cc82e381559eb9a05538d0ad4ef0c8
4,563
[ 167602904, 273096993, 244421451, 388270714 ]
[ "typespec", "macro", "documented", "ecto" ]
defmodule Pow.Ecto.Schema.Migration do @moduledoc """ Generates schema migration content. ## Configuration options * `:repo` - the ecto repo to use. This value defaults to the derrived context base repo from the `context_base` argument in `gen/2`. * `:table` - the ecto table name, defaults to "us...
06311151dbd92aaa26675133d77eaf7880d01376
1,596
[ 833663685 ]
[ "phoenix" ]
defmodule DynamicInputsWeb.Router do use DynamicInputsWeb, :router pipeline :browser do plug :accepts, ["html"] plug :fetch_session plug :fetch_live_flash plug :put_root_layout, html: {DynamicInputsWeb.Layouts, :root} plug :protect_from_forgery plug :put_secure_browser_headers end pipe...
06317281fab1bdae11906d8968d7af9bb6a4ff3b
11,787
[ 468102655 ]
[ "liveview" ]
defmodule B2Web.Live.Game.Figure do use B2Web, :live_component defp hide_if_left_gt(left, level) do if left > level, do: "hide-component", else: "" end def render(assigns) do ~H""" <div class="figure"> <svg id="drawing" xmlns="http://www.w3.org/2000/svg" x-height="155mm" ...
06318e7aee39b5da137a218ffe4e5a79d65b0e9f
1,944
[ 174167748 ]
[ "genserver" ]
defmodule ChromeRemote.Page.Authentication do use GenServer alias __MODULE__ alias ChromeRemote.Page alias ChromeRemote.Interface.Network defstruct page: nil, credentials: nil, attempted_auth: [] def start_link(args \\ [], opts \\ []), do: GenServer.start_link(__MODULE__, args, opt...
063197afd7bd3122b08930de9b14f2a5cc59ed2b
3,786
[ 619879440 ]
[]
defmodule TokenType do alias Token defp get_keywords_set do map_set = MapSet.new() map_set |> MapSet.put(:let) |> MapSet.put(:fn) |> MapSet.put(:true) |> MapSet.put(:false) |> MapSet.put(:return) |> MapSet.put(:if) |> MapSet.put(:else) end defp get_valid_2char_token_set do...
0631a7154dc76044788beaf159a9c0fc80d1b044
1,583
[ 259695632 ]
[ "phoenix" ]
defmodule DealiefWeb.Api.V1.UserController do use DealiefWeb, :controller import DealiefWeb.ControllerHelper alias Dealief.Account alias Dealief.Account.User action_fallback DealiefWeb.FallbackController plug :resource_ownership when action in [:show, :update, :delete] def index(conn, _params) do ...
0631bc4756e5ea8163f120477c5dcc82440ffae9
2,130
[ 77180941 ]
[ "genserver" ]
defmodule Config.Stash do use GenServer ##### # External API def start_link do IO.puts "Starting Config.Stash" GenServer.start_link(__MODULE__, nil, name: :config_stash) end # def start_link(current_number) do # IO.puts "starting stash server " # # {:ok,_pid} = ...
0631fffcd8f2c17503c1e031b68722753df03a4e
1,892
[ 525470137 ]
[ "typespec", "documented" ]
defmodule YatzeeGame.PlayerScore do @moduledoc """ YatzeeGame.PlayerScore is a struct to represent a player's score, plus a few functions to perform calculations related to a player's score. """ defstruct ones: nil, twos: nil, threes: nil, fours: nil, fives: ni...
0632018aa449e42666c709746f3597597e100742
3,712
[ 78242430, 184105686 ]
[ "supervisor", "documented" ]
defmodule RegistrySample.AccountSupervisor do @moduledoc """ Supervisor to handle the creation of dynamic `RegistrySample.Account` processes using a `simple_one_for_one` strategy. See the `init` callback at the bottom for details on that. These processes will spawn for each `account_id` provided to the `Re...
063204530a97308b10fae9565d169fcf35082639
2,522
[ 70379197 ]
[ "test" ]
defmodule Response.JsonTest do use ExUnit.Case, async: true use Plug.Test alias Response.Json, as: Json test "render returns default values" do conn = conn(:get, "/about/foo") result = Json.render(conn) assert(result.resp_body == "{}") assert(result.status == 200) end test "render Returns ...
06323c23951802cccab13e2a345718092621f776
1,757
[ 94888309 ]
[ "ecto" ]
defmodule WatchMe.LogEntries do import Ecto import Ecto.Query alias WatchMe.Repo def entries(:chrome, start_date, end_date), do: entries("Google Chrome", start_date, end_date) def entries(:iterm, start_date, end_date), do: entries("iTerm", start_date, end_date) def entries(name, nil, nil) do ...
063240c25cf10a4a1c8baa9cfd9225f94664e0db
8,293
[ 151506528 ]
[]
defmodule Gvp.Topo do def get_neighbours(list, topology) do neighbours = get_neighbours_helper(list, topology) numNodes = length(list) Enum.reduce(0..(numNodes - 1), %{}, fn x, acc -> Map.put(acc, Enum.at(list, x), Enum.at(neighbours, x)) end) end def get_neighbours_helper(list, topology)...
0632c816e99d071457e6af5c1e88a1df59774957
1,965
[ 288710084 ]
[ "macro", "documented", "phoenix" ]
defmodule ClientSocketsWeb 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 ClientSocketsWeb, :controller use ClientSocketsWeb, :view The definitions below will be executed for every vi...
0632e863f28942c954652a85f0780fe7be173182
3,379
[ 155064543 ]
[]
defmodule K2pokerIo.Queries.Friends.FriendsQuery do alias K2pokerIo.Repo alias K2pokerIo.Friendship alias K2pokerIo.User alias K2pokerIo.Decorators.FriendDecorator import K2pokerIo.Queries.Pagination import Ecto.Query def find(current_user_id, friend_id) do query = from f in Friendship, where...
06330ed7afedc13d21559c55ffc1014428db1a4f
2,366
[ 111030983 ]
[]
defmodule Shepherd do def count_sheeps([]), do: 0 def count_sheeps(sheeps) do [head | tail] = sheeps count_sheeps(tail) + (if head, do: 1, else: 0) end end defmodule Shepherd2 do def count_sheeps(sheeps, accumulator \\ 0) def count_sheeps([], accumulator) do accumulator end def count_sheep...
06334af24a0a273414a33851a454c39b930bf178
2,097
[ 423942783 ]
[ "documented" ]
defmodule Edgehog.Forwarder.Session.ManualActions.RequestSession do @moduledoc false use Ash.Resource.Actions.Implementation alias Ash.Error.Changes.InvalidArgument alias Edgehog.Devices.Device alias Edgehog.Forwarder @forwarder_session_module Application.compile_env( :edgeho...
063367172e4eadc765d4c36ace5e4e52a751393f
11,475
[ 485586448 ]
[ "typespec", "documented", "phoenix" ]
defmodule Kaffy.Utils do @moduledoc false @doc """ Returns the :admin_title config if present, otherwise returns "Kaffy" """ @spec title() :: String.t() def title() do env(:admin_title, "Kaffy") end @doc """ Returns the static path to the asset. """ @spec static_asset_path(Plug.Conn.t(), Str...
0633c37553a6e83ee1f76a8184f7c7b518d8a22b
2,362
[ 411863018 ]
[ "liveview", "documented" ]
defmodule AmbryWeb.Admin.AuditLive.Index do @moduledoc """ LiveView for audit admin interface. """ use AmbryWeb, :admin_live_view alias Ambry.Media alias Ambry.Utils @impl Phoenix.LiveView def mount(_params, _session, socket) do {:ok, socket |> assign(:header_title, "File Audit") |...
06341f61a7cb810ca4a8c951fc2093a849bba8c1
1,576
[ 367744569 ]
[ "documented" ]
defmodule AdventOfCode.Y2021.Day2 do @moduledoc """ Problem Link: https://adventofcode.com/2021/day/2 """ def run_1, do: load_file() |> solve_1() def run_2, do: load_file() |> solve_2() def solve_1(commands) do commands |> process_input() |> calc_pos() end def solve_2(commands) do com...
06346d757c5fcbb07381a2d87d4e2195f899772f
1,847
[ 804943814 ]
[ "genserver", "liveview", "ecto" ]
defmodule PokerWeb.GameLive.Index do use PokerWeb, :live_view alias Poker.Games alias Poker.Games.Game @impl true def mount(_params, _session, socket) do if connected?(socket), do: Poker.Games.subscribe() {:ok, stream(socket, :games, Games.list_games())} end @impl true def handle_params(para...
0634b0867da2a08a5dd38d05f8b8c58d6d514011
9,306
[ 675065258, 623651558, 669631778 ]
[ "macro", "liveview", "phoenix", "test" ]
defmodule Phoenix.LiveView.RouterTest do use ExUnit.Case, async: false import Phoenix.ConnTest import Phoenix.LiveViewTest alias Phoenix.LiveView.{Route, Session} alias Phoenix.LiveViewTest.{Endpoint, DashboardLive, DOM} alias Phoenix.LiveViewTest.Router.Helpers, as: Routes @endpoint Endpoint def ver...
06354cf004d99e1c81136920cf63a314cdc6d326
2,416
[ 32159602 ]
[]
defmodule Lab5 do defmodule Chat do defstruct [:members] end def new() do spawn_link(fn -> loop(%Chat{members: %{}}) end) end defp loop(chat) do receive do {:has_member?, pid, username} -> send(pid, Map.has_key?(chat.members, username)) loop(chat) {:join, p...
06356ce8e6b9d49406f9aa667aad623b58cccd7b
2,583
[ 106152216 ]
[]
defmodule Drop do require Planemo def drop do setup handle_drops end def handle_drops do receive do {from, planemo, distance} -> send(from, {planemo, distance, fall_velocity(planemo, distance)}) handle_drops end end def fall_velocity(planemo, distance) when distance >= 0 do {:atomic, [p |...
063653cfc8a9a7a91cc8f1d2e222a0f46a127355
2,834
[ 291790817 ]
[ "liveview" ]
defmodule LiveViewStudioWeb.LightLive do use LiveViewStudioWeb, :live_view def mount(_params, _session, socket) do socket = assign(socket, brightness: 10, temp: 3000) {:ok, socket} end def render(assigns) do ~L""" <h1>Front Porch Light</h1> <div id="light"> <div class="meter"> ...
0636af0c429639d88bce5df34056edbf7ac06961
1,650
[ 576446239 ]
[ "test" ]
defmodule HashTest do use ExUnit.Case doctest Dynamo import Emulation, only: [spawn: 2, send: 2] import Kernel, except: [spawn: 3, spawn: 1, spawn_link: 1, spawn_link: 3, send: 2] test "we can find coordinate node and return value" do Emulation.init() Emulation.append_fuzzers([Fuzzers.delay(2)])...
0636d94b445e6c20d309865198f6bb60ec8fff79
2,070
[ 914174378 ]
[ "phoenix" ]
defmodule StoreWeb.Router do use StoreWeb, :router import AshAdmin.Router pipeline :graphql do plug AshGraphql.Plug end pipeline :browser do plug :accepts, ["html"] plug :fetch_session plug :fetch_live_flash plug :put_root_layout, html: {StoreWeb.Layouts, :root} plug :protect_from_fo...
063722747fce7760e81ab54484d93d8a5505211d
2,882
[ 468101564 ]
[ "genserver" ]
defmodule DzenWeb.Counter do use GenServer require Ecto.Query alias Dzen.Repo ## API @total_sessions "total_sessions" @stopped_sessions "stopped_sessions" def start_link(_args \\ []) do # demo purposes only: race condition. Serialized: see global:trans case :global.whereis_name(__MODULE__) do ...
06372acf1849c5efd9ba784416eeadf1c194dd09
6,202
[ 269459264 ]
[ "test" ]
defmodule TournamentTest do use ExUnit.Case test "update_struct unseen win/loss" do empty_tourney = %Tournament{} thruple = {"Winner", "Loser", "win"} expected = %Tournament{:team_counter => %{"Winner" => {1,0,0}, "Loser" => {0,0,1}}} assert Tournament.update_struct(thruple, empty_tourney) == exp...
063746eb56e612ae3eb1e5f00499d240cae9d32f
1,952
[ 334296026, 334289371 ]
[ "macro", "documented", "phoenix" ]
defmodule AgileparkingWeb 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 AgileparkingWeb, :controller use AgileparkingWeb, :view The definitions below will be executed for every view,...
063776b5ff35fb1cbfc10e3d21a57522d1133e23
7,255
[ 429792432 ]
[]
%{ "certifi": {:hex, :certifi, "2.12.0", "2d1cca2ec95f59643862af91f001478c9863c2ac9cb6e2f89780bfd8de987329", [:rebar3], [], "hexpm", "ee68d85df22e554040cdb4be100f33873ac6051387baf6a8f6ce82272340ff1c"}, "decimal": {:hex, :decimal, "2.3.0", "3ad6255aa77b4a3c4f818171b12d237500e63525c2fd056699967a3e7ea20f62", [:mix], [...
063803869942c98968cfa8d2f9991162a4936b1b
7,350
[ 10272440 ]
[ "ecto" ]
# 7.2 Using Head and Tail to Process a List defmodule MyList do # simple recursive processing def len([]), do: 0 def len([_|tail]), do: 1 + len(tail) # usage of an accumulator def sum([], total), do: total def sum([ head | tail ], total), do: sum(tail, head+total) end IO.puts MyList.len([]) ...
0638a32469da6ff3ad9259acec08e2e54a0401fd
2,835
[ 132383143 ]
[ "documented" ]
defmodule SalesRegWeb.GraphQL.Schemas do @moduledoc false use Absinthe.Schema use Absinthe.Relay.Schema, :classic alias SalesRegWeb.GraphQL.MiddleWares.ChangesetErrors alias SalesRegWeb.GraphQL.MiddleWares.MutationResponse alias Absinthe.Middleware.Dataloader, as: AbsintheDataloader alias Absinthe.Plugi...
063921b971c80eb45fea18233b105efbf7d6a291
2,046
[ 213069237 ]
[]
defmodule Sbin.MixProject do use Mix.Project def project do [ app: :sbin, version: "0.1.0", elixir: "~> 1.5", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(), start_permanent: Mix.env() == :prod, aliases: aliases(), dep...
0639aed808611679793467e69fff7b8805d16062
2,529
[ 810570142 ]
[]
defmodule StatWeb.Resolvers.Posts do alias Stat.Posts def unsafe_check_if_user_can_check_in(_, _, %{context: %{current_user: user}}) do Posts.unsafe_check_if_user_can_check_in(user) end def unsafe_check_if_user_can_check_in(_, _, _) do {:error, "Please log in first"} end def list_text_posts(_, _,...
0639cf824fc2bd52c04ebd8bd3268995990ac48e
2,523
[ 905653659 ]
[ "test" ]
defmodule BrowserForge.Headers.UtilsTest do use ExUnit.Case, async: false doctest BrowserForge.Headers.Utils alias BrowserForge.Headers.Utils describe "get_user_agent/1" do test "gets User-Agent with pascal case" do headers = %{"User-Agent" => "Mozilla"} assert Utils.get_user_agent(headers) ==...
0639fc8998caf9a6c6cd0dfb7c938b7a70825853
1,662
[ 22797642 ]
[ "macro", "documented" ]
defmodule PhoenixDtl.Engine do @behaviour Phoenix.Template.Engine @doc """ Precompiles the String file_path into a function defintion, using erlydtl engine For example, given "templates/show.html.dtl", returns an AST def of the form: def render("show.html", assigns \\ []) """ def precompile(file_p...
063a0a26c310d6932ef28235d214a2f82fc312a5
1,774
[ 844673900 ]
[ "phoenix", "ecto" ]
defmodule PelableWeb.ThreadController do use PelableWeb, :controller alias Pelable.Learn alias Pelable.Learn.Thread def index(conn, _params) do threads = Learn.list_threads() render(conn, "index.html", threads: threads) end def new(conn, _params) do changeset = Learn.change_thread(%Thread{}) ...
063a4e8beaed4edc1bca4d2c26ddb440b5ae8059
3,543
[ 687730948 ]
[]
defmodule Solution do defmodule Hand do defstruct [:cards, :bid, combo: nil] end @combos %{ nil => 0, :high_card => 1, :one_pair => 2, :two_pair => 3, :three_kind => 4, :full_house => 5, :four_kind => 6, :five_kind => 7 } @card_order ~c"J23456789TQKA" @input_path "../inp...
063ae06b2501a2cd70dfe3973d890465a3454cb1
4,121
[ 564359760 ]
[ "genserver", "liveview", "documented", "ecto" ]
defmodule HydepwnsLiveviewWeb.UserShowLive do @moduledoc """ LiveView for displaying user details. """ use HydepwnsLiveviewWeb, :live_view alias HydepwnsLiveview.Accounts @impl Phoenix.LiveView def mount(_params, _session, socket) do default_theme = HydepwnsLiveview.ThemeSystem.ensure_default_theme...
063b60e9c56a4797436732e2cd74898ad99d2e19
3,845
[ 560255935 ]
[ "documented", "phoenix" ]
defmodule AoC.Day17 do @moduledoc false alias AoC.Intcode.{Interpreter, Memory, VacuumRobot} def run do IO.puts("day 17 part 1: #{AoC.Day17.part_1("../data/17.txt")}") IO.puts("day 17 part 2: #{AoC.Day17.part_2("../data/17.txt")}") end def part_1(filename) do filename |> Memory.load_from_fi...
063bdffec039370d4cc922ce16741b34c06d5efb
2,268
[ 155813625 ]
[ "ecto" ]
defmodule School.Account do use Ecto.Schema import Ecto.Changeset schema "account" do field :username, :string field :password, :string field :is_admin, :boolean field :is_saodo, :boolean field :is_loptruong, :boolean belongs_to :class, School.Class, foreign_key: :class_id end defp n...
063c16c534ec22e3fce14fd65919182cc0a84ae0
2,016
[ 193244709, 101434552, 198908023 ]
[ "documented" ]
defmodule GoogleApi.ResourceViews.V1beta2.Model.ResourceView do @moduledoc """ The resource view object. ## Attributes - creationTimestamp (String): The creation time of the resource view. Defaults to: `null`. - description (String): The detailed description of the resource view. Defaults to: `null`. - en...
063c4dfe306e3edd3e882635f5a2834fc1362e11
11,277
[ 665653661 ]
[ "macro", "documented" ]
defmodule LangChain.TextSplitter.LanguageSeparators do @moduledoc """ Separators lists for programming and markdown languages. Useful to use with `LangChain.TextSplitter.RecursiveCharacterTextSplitter`. """ @cpp [ # Split along class definitions "\nclass ", # Split along function definitions "...
063c5374ba20ef21016c37933ae7ab64a0ea540e
5,690
[ 111415024, 563322590 ]
[ "test", "documented" ]
defmodule GroupherServer.Test.CMS.AbuseReports.PostReport do @moduledoc false use GroupherServer.TestTools alias Helper.ORM alias GroupherServer.CMS alias CMS.Model.Post setup do {:ok, user} = db_insert(:user) {:ok, user2} = db_insert(:user) {:ok, community} = db_insert(:community) post_...
063c85ca548e101fc9bf3bd489296fb233016abb
6,149
[ 158683678 ]
[ "test", "ecto" ]
defmodule StoreHall.ItemsTest do use StoreHall.DataCase use ExUnitProperties alias StoreHall.Fixture alias StoreHall.Items alias StoreHall.Items.Item @items_count 100 describe "items" do @update_attrs %{ "details" => %{ "tags" => [], "images" => [], "rating" => %{"coun...
063d2292609a87955c4e895bd8dc40b24746a4e9
3,652
[ 417551153 ]
[ "test" ]
defmodule BettyPoker.Test.Core.RankingTest do use ExUnit.Case alias BettyPoker.Core.{Card, Ranking} doctest Ranking test "high card" do assert %Ranking{rank: :highest_card, tie_breaker: ["king", 9, 5, 3, 2]} == Ranking.rank_hand([ %Card{suit: "diamonds", value: "king"}, ...
063d65ab13336b6b8b77c7c1d7e60abbb5d29f9d
1,949
[ 528070007 ]
[ "test", "ecto" ]
defmodule Bleepground.PatchesTest do use Bleepground.DataCase alias Bleepground.Patches describe "patches" do alias Bleepground.Patches.Patch import Bleepground.PatchesFixtures @invalid_attrs %{description: nil, name: nil} test "list_patches/0 returns all patches" do patch = patch_fixtu...
063da25a86a1ca2ec0603fbec2aea867c51b43de
2,927
[ 650700339 ]
[ "documented", "ecto" ]
defmodule JetzySchema.MSSQL.User.Moment.Image.Table do use Ecto.Schema @nmid_index 58 require JetzySchema.NoizuTableBehaviour JetzySchema.NoizuTableBehaviour.mssql_table(:"UserMomentsImages") # ENTRY UserMomentsImages JetzySchema.MSSQL.User.Moment.Image.Table @moduledoc """ USE [travellerscon...
063e17504de35c72e38748774afe0b94811bb210
11,300
[ 216195237 ]
[ "test", "documented" ]
defmodule TaktaWeb.CommentControllerTest do @moduledoc """ This test suite tests commenting on whiteboards and how secure the api is. Create 2 user conns and then check permissions using different connections with attempts to destroy data for the other user """ use TaktaWeb.ConnCase, async: true ali...
063e65fc1a0d5719ccf91053d58a7feb6ac8ffa7
5,183
[ 1009790996 ]
[ "documented", "phoenix" ]
defmodule LocationSharingWeb.HealthController do @moduledoc """ Health check endpoints for monitoring and load balancer integration. """ use LocationSharingWeb, :controller alias LocationSharing.{Repo, Redis} require Logger @doc """ Basic health check endpoint. Returns 200 OK if the application i...
063ecf499908eede75fe2d42300ddac58b4a9d11
8,375
[ 984028116 ]
[ "test" ]
defmodule QueryCanary.CheckResultAnalyzerTest do use QueryCanary.DataCase alias QueryCanary.CheckResultAnalyzer alias QueryCanary.Checks.CheckResult describe "extract_numeric_values/1" do test "extracts numeric values from check results with map rows" do results = [ %CheckResult{success: tru...
063ef6bce7190e4e8a285669f2075908740f606e
5,695
[ 967739576 ]
[ "documented" ]
defmodule Day06.BoatRaces do @moduledoc """ You get a sheet of paper (your puzzle input) that lists the time allowed for each race and also the best distance ever recorded in that race. To guarantee you win the grand prize, you need to make sure you go farther in each race than the current record holder. The org...
063fae615792010a2845027412b0fc39d6b8247c
2,660
[ 782363121, 730573894 ]
[ "liveview", "ecto" ]
defmodule RealworldWeb.ArticleLive.FormComponent do use RealworldWeb, :live_component alias Realworld.Blogs @impl true def render(assigns) do ~H""" <div> <.header> <%= @title %> <:subtitle>Use this form to manage article records in your database.</:subtitle> </.header> ...
063fc24f47cfbf2e6feb36d207c5637a7cb5e8e4
1,509
[ 845745271 ]
[ "ecto" ]
defmodule NobleBackend.Repo.Migrations.AddTables do use Ecto.Migration def change do create table(:clients, primary_key: false) do add :id, :uuid, primary_key: true add :name, :string add :email, :string, unique: true add :password_hash, :string add :address, :string add :ph...
06403781ad5ec452a19ee046a762ff04a215cdeb
2,085
[ 237197924 ]
[ "supervisor", "documented", "ecto" ]
defmodule Astarte.Flow.Flows do @moduledoc """ The Flows context. """ alias Astarte.Flow.Flows.Flow alias Astarte.Flow.Flows.DETSStorage alias Astarte.Flow.Flows.Registry, as: FlowsRegistry alias Astarte.Flow.Flows.RealmRegistry alias Astarte.Flow.Flows.Supervisor, as: FlowsSupervisor require Logger ...
064047ab8f99ea55d105c4e8d3f5ecb29ce57a80
4,538
[ 248813741 ]
[ "genserver", "liveview", "ecto" ]
defmodule ElixirDemoWeb.StatsLive do use Phoenix.LiveView @num_points 100 def mount(_session, socket) do if connected?(socket), do: :timer.send_interval(100, self(), :update) # Assigning them to socket socket = assign(socket, operations: [], number: changeset(0)) {:ok, update_stats(socket)} e...
06406dd0edfd16dcb4797cf29391cdde081dfb45
9,750
[ 49143511, 65600148 ]
[ "test", "documented" ]
defmodule GuardianTest do @moduledoc false use ExUnit.Case, async: true setup do claims = %{ "aud" => "User:1", "typ" => "token", "exp" => Guardian.Utils.timestamp + 100_00, "iat" => Guardian.Utils.timestamp, "iss" => "MyApp", "sub" => "User:1", "something_else" => ...