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
0ba3792499b60e43cb2067ce4e7e6770deb04004
4,202
[ 990899539 ]
[ "phoenix" ]
# Script for populating the database with default roles and permissions alias Rephi.{Repo, Authorization} alias Rephi.Authorization.{Role, Permission} # Create default roles {:ok, admin_role} = Authorization.create_role(%{ name: "Administrator", slug: "admin", description: "Full system access" }) {:ok, manager_...
0ba3af0896b730655b1253fa765278312f819ad2
2,448
[ 744662263 ]
[ "genserver", "supervisor" ]
defmodule Mastery.Boundary.QuizSession do alias Mastery.Core.{Quiz, Response} use GenServer def child_spec({quiz, email}) do %{ id: {__MODULE__, {quiz.title, email}}, start: {__MODULE__, :start_link, [{quiz, email}]}, restart: :temporary } end def start_link({quiz, email}) do G...
0ba3e513f082930df6d07e2811f5cfa5f9e189e0
5,928
[ 399045494 ]
[ "phoenix", "ecto" ]
defmodule AzimuttWeb.OrganizationMemberController do use AzimuttWeb, :controller alias Azimutt.Accounts alias Azimutt.Organizations alias Azimutt.Organizations.Organization alias Azimutt.Organizations.OrganizationInvitation alias Azimutt.Organizations.OrganizationMember alias Azimutt.Organizations.Organiz...
0ba3fa176db79c6d976443dc3d7176c380ed5d29
1,850
[ 62398048, 62471089 ]
[]
%{"certifi": {:hex, :certifi, "0.4.0", "a7966efb868b179023618d29a407548f70c52466bf1849b9e8ebd0e34b7ea11f", [:rebar3], []}, "exjsx": {:hex, :exjsx, "3.2.0", "7136cc739ace295fc74c378f33699e5145bead4fdc1b4799822d0287489136fb", [:mix], [{:jsx, "~> 2.6.2", [hex: :jsx, optional: false]}]}, "hackney": {:hex, :hackney, "1....
0ba4159f2c6cfc6d3003d8e60c83a8d1c3858ea1
1,577
[ 128129827, 122071195 ]
[ "macro", "documented", "phoenix" ]
defmodule Task3Web 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 Task3Web, :controller use Task3Web, :view The definitions below will be executed for every view, controller, etc, s...
0ba48edeb271fb074b3aa966be29313f012d29fd
1,669
[ 193230474 ]
[ "documented" ]
defmodule HeimdallrWeb.Context do @behaviour Plug import Plug.Conn import Ecto.Query, only: [first: 1] alias Heimdallr.Repo alias Heimdallr.Schema.User def init(opts), do: opts def call(conn, _) do context = build_context(conn) put_private(conn, :absinthe, %{context: context}) end @doc ""...
0ba4f00ee5097130db64ebf8623f04da4e1015a4
1,628
[ 314728671 ]
[ "documented", "ecto" ]
defmodule ExNylas.Notetaker.Build do @moduledoc """ Helper module for validating a notetaker before creating/updating it. [Nylas docs](https://developer.nylas.com/docs/api/v3/ecc/#tag/notetaker) """ use TypedEctoSchema import Ecto.Changeset alias ExNylas.Schema.Util @derive {Jason.Encoder, only: [:me...
0ba50036aff5cba1eeee0d3f1125059a84c03ef5
1,974
[ 806822991 ]
[]
defmodule JokenJwks.MixProject do use Mix.Project @source_url "https://github.com/joken-elixir/joken_jwks" @version "1.6.0" def project do [ app: :joken_jwks, version: @version, name: "Joken JWKS", elixir: "~> 1.5", elixirc_paths: elixirc_paths(Mix.env()), start_permane...
0ba58d68b9b232649b0cb00a660afcd2be05dd54
2,037
[ 49529180 ]
[ "phoenix" ]
defmodule Back.Monster54Controller do use Back.Web, :controller alias Back.Monster54 plug :scrub_params, "monster54" when action in [:create, :update] def index(conn, _params) do monsters54 = Repo.all(Monster54) render(conn, "index.html", monsters54: monsters54) end def new(conn, _params) do ...
0ba5e659b7cb7fb5ff7413a938e094ea5d1a1c92
1,753
[ 378538397 ]
[ "typespec", "documented", "ecto" ]
defmodule FiveHundredWeb.GameStarter do use Ecto.Schema import Ecto.Changeset alias FiveHundred.{Game, GameServer} alias __MODULE__ embedded_schema do field :player_name, :string field :game_code, :string end @type t :: %GameStarter{ player_name: nil | String.t(), game_code: ...
0ba710d8262117d467c836ba98ea6226a0df38df
6,649
[ 642536641 ]
[]
defmodule FzHttp.Devices do alias FzHttp.{Repo, Config, Auth, Validator} alias FzHttp.{Users, Telemetry} alias FzHttp.Devices.{Device, Authorizer} def count do Device.Query.all() |> Repo.aggregate(:count) end def count_by_user_id(user_id) do Device.Query.by_user_id(user_id) |> Repo.aggrega...
0ba712bd40fd73debe2b2b83b7e3f7658dbeaae9
5,006
[ 609504907 ]
[ "documented", "ecto" ]
defmodule OneLitre.Games do @moduledoc """ The Games context. """ import Ecto.Query, warn: false alias OneLitre.Repo alias OneLitre.Games.Game @doc """ Returns the list of game. ## Examples iex> list_game() [%Game{}, ...] """ def list_game do Repo.all(Game) end @doc """ ...
0ba719ffecf1bd45b43604078559631e32bce604
3,013
[ 592451428 ]
[ "test" ]
defmodule Onvif.Media.Ver10.CreateOSDTest do alias Onvif.Media.Ver10.Schemas.OSD use ExUnit.Case, async: true @moduletag capture_log: true describe "CreateOSDs/2" do test "should create an OSD and return the token" do xml_response = File.read!("test/media/ver10/fixtures/create_osd_response_success.x...
0ba739a93feeb459ef68f623195f262745595840
3,710
[ 849226987 ]
[ "genserver", "typespec", "liveview" ]
defmodule CloudDbUiWeb.ProductLive.Show do use CloudDbUiWeb, :live_view use CloudDbUiWeb.FlashTimed, :live_view alias CloudDbUi.Accounts.User alias CloudDbUi.Products alias CloudDbUi.Products.Product alias CloudDbUi.Orders.SubOrder alias CloudDbUiWeb.ProductLive.FormComponent alias CloudDbUiWeb.FlashTi...
0ba7dbd4302615ebe68741be35c823c23d7cf610
1,504
[ 180445774 ]
[]
defmodule Weather.FetchData do require Logger def fetch_by_city(city) do Logger.info("Fetching weather data for #{city}") city_url(city) |> HTTPoison.get() |> handle_response end def fetch_by_latlong(lat, lon) do Logger.info("Fetching weather data for lat: #{lat} and lon: #{lon}") la...
0ba7e2fbb9319d2ed50161d5df51e514d766055f
2,369
[ 54318257 ]
[ "documented", "ecto" ]
defmodule EmotionsWheelBackend.Participant do use EmotionsWheelBackend.Web, :model alias EmotionsWheelBackend.{Participant, Country, City, Language, Rate, ExperimentsHasParticipants} schema "participants" do field :email, :string field :first_name, :string field :last_name, :string field :birthd...
0ba81752cf6754d39dedff7313d03b9315fc9d6b
1,913
[ 815481642 ]
[ "documented" ]
defmodule Envoy.Config.Filter.Network.DubboProxy.V2alpha1.ProtocolType do @moduledoc """ Dubbo Protocol types supported by Envoy. [#protodoc-title: Dubbo Proxy] Dubbo Proxy :ref:`configuration overview <config_network_filters_dubbo_proxy>`. [#extension: envoy.filters.network.dubbo_proxy] """ use Protobuf...
0ba89be7b39a731c593cb35bff7fade39cbc0d0c
2,511
[ 46393693 ]
[ "test" ]
defmodule CareCostManager.StockControllerTest do use CareCostManager.ConnCase alias CareCostManager.Stock @valid_attrs %{description: "some content", room_number: "some content", shift: "some content", size: "some content"} @invalid_attrs %{} setup do conn = conn() {:ok, conn: conn} end test "l...
0ba8f4ee4aabf8f90310c0d3b381687705cb5365
2,018
[ 287834883 ]
[ "supervisor" ]
defmodule Project4b.Application do use Application require Logger @port 5000 @server_ip "127.0.0.1" def start(_type, _args) do # List all child processes to be supervised children = [ # Start the endpoint when the application starts Project4bWeb.Endpoint # Starts a worker by calling...
0ba9557d1df777c7c2a28a801da4fb900cda7e20
3,388
[ 281870042 ]
[ "typespec", "macro", "documented" ]
defmodule HKDF do @moduledoc """ Provides a simple Hashed Message Authentication Code (HMAC)-based key derivation function (HKDF). ## Process Keys are derived in two steps: 1. Extract - a pseudorandom key is extracted from an input key material and optional salt. 2. Expand - an o...
0ba96bb9a7c1eab2d0dacc1e143c15b3aab6fc85
1,711
[ 193244709, 101434552, 198908023 ]
[ "typespec", "documented" ]
defmodule GoogleApi.Calendar.V3.Model.FreeBusyResponse do @moduledoc """ ## Attributes * `calendars` (*type:* `%{optional(String.t) => GoogleApi.Calendar.V3.Model.FreeBusyCalendar.t}`, *default:* `nil`) - List of free/busy information for calendars. * `groups` (*type:* `%{optional(String.t) => GoogleApi....
0ba9fb8ab07ad3e101ffe4a9b12acd0f1033d169
4,177
[ 402134949 ]
[ "typespec", "documented" ]
defmodule Exercism.Constants.Garden do @moduledoc """ Given a diagram, determine which plants each child in the kindergarten class is responsible for. The kindergarten class is learning about growing plants. The teacher thought it would be a good idea to give them actual seeds, plant them in actual dirt, and gro...
0baa270f8af94d5540f66020319c65eed2022313
8,360
[ 125843928 ]
[ "typespec", "macro", "documented" ]
defmodule IO.ANSI.Sequence do @moduledoc false defmacro defsequence(name, code, terminator \\ "m") do quote bind_quoted: [name: name, code: code, terminator: terminator] do def unquote(name)() do "\e[#{unquote(code)}#{unquote(terminator)}" end defp format_sequence(unquote(name)) do ...
0baa612bef99d2637883c51a8994d4e0ae407900
4,028
[ 253805558 ]
[ "ecto" ]
defmodule Cookbook.Recipe do use Ecto.Schema use EctoEnum, type: :category, enums: [:meat, :fish, :vegetarian, :vegan] alias Cookbook.{Chef, Ingredient, Repo, Recipe, RecipeIngredient} import Ecto.{Changeset, Query} require IEx schema "recipes" do field :name, :string, null: false field :steps, ...
0bab20431a019e8a8eb8243841fa6ffefc41c4e9
1,706
[ 605892711 ]
[ "documented", "ecto" ]
defmodule Todo.Task do @moduledoc """ The Task context. """ import Ecto.Query, warn: false alias Todo.Repo alias Todo.Task.Issue @doc """ Returns the list of issues. ## Examples iex> list_issues() [%Issue{}, ...] """ def list_issues do Repo.all(Issue) end @doc """ Gets...
0bab934c20e7d3c3ac4036de50b1ad2226ac44eb
4,663
[ 891712766 ]
[]
%{ "cldr_utils": {:hex, :cldr_utils, "2.28.2", "f500667164a9043369071e4f9dcef31f88b8589b2e2c07a1eb9f9fa53cb1dce9", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decima...
0baba79a7aadcf416beafae589be96aea9663619
2,322
[ 207497796 ]
[ "phoenix", "ecto" ]
defmodule WorkingTimeManagerWeb.ClockController do use WorkingTimeManagerWeb, :controller require Logger import Ecto.Query alias WorkingTimeManager.Repo alias WorkingTimeManager.Resource alias WorkingTimeManager.Resource.Clock alias WorkingTimeManager.Utils.DateTimeHelper alias WorkingTimeManagerWeb...
0bac6dffbf8fd416324d1b14596b229f87bbe45f
1,786
[ 426445032 ]
[]
# 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 :ex_brewery, ecto_repos: [ExBrewery.Repo] ...
0bac838e028a2ea1d157e64ff02b4a50e68b647c
1,642
[ 354842271 ]
[ "liveview" ]
defmodule SpotifyapiWeb.PageLive do use SpotifyapiWeb, :live_view @impl true def mount(_params, _session, socket) do {:ok, assign(socket, query: "", results: %{})} end @impl true def handle_event("suggest", %{"q" => query}, socket) do {:noreply, assign(socket, results: search(query), query: query)...
0bac8425d137098645461a2b8ce2bbe315508dd3
3,371
[ 559764804 ]
[ "test", "phoenix" ]
defmodule AttendanceWeb.StudentSessionControllerTest do use AttendanceWeb.ConnCase, async: true import Attendance.StudentsFixtures setup do %{student: student_fixture()} end describe "GET /students/log_in" do test "renders log in page", %{conn: conn} do conn = get(conn, Routes.student_session...
0bacf6c104b43dcd4e42a8df3bfbc47b0466f9c2
4,882
[ 510373016 ]
[ "typespec", "macro", "documented" ]
defmodule CharonOauth2 do @moduledoc """ use CharonOauth2, @charon_config """ alias __MODULE__.Internal alias CharonOauth2.Internal.GenMod.{ Authorization, Authorizations, Client, Clients, Grant, Grants, TestSeeds } alias CharonOauth2.Internal.GenMod.Plugs.{AuthorizationE...
0bacfdeb68b699376bd5a0a4cdcac726a2f88f6c
16,540
[ 125750092 ]
[ "test", "supervisor" ]
defmodule Rihanna.JobDispatcherTest do use ExUnit.Case, async: false import TestHelper alias Rihanna.JobDispatcher alias Rihanna.Mocks.{ LongJob, BehaviourMock, MFAMock, BadMFAMock, BadBehaviourWithBadAfterErrorMock, ErrorBehaviourMock, ErrorBehaviourWithBadAfterErrorMock, Error...
0bad06b0969d61346718a32aab00f15fa31aedd7
4,891
[ 549467606 ]
[ "documented" ]
defmodule Task1aSumOfSubsets do @moduledoc """ A module that implements functions for getting sum of subsets from a given 2d matrix and array of digits """ @doc """ #Function name: valid_sum #Inputs: matrix_of_sum : A 2d matrix containing two digit numbers for which subsebts are to be...
0bad1bb74d95c6a408d053a610cfb8baf484d6ec
7,576
[ 989918778 ]
[]
#!/usr/bin/env elixir # Test Safety Analyzer functionality # Run with: elixir test_safety_analyzer.exs defmodule TestSafetyAnalyzer do alias MCPChat.PlanMode.{Plan, Step, SafetyAnalyzer} alias MCPChat.PlanMode.SimpleRenderer, as: Renderer def run do IO.puts """ ==================================...
0bad2b335399eaa6314846192225fcc9c13d68ea
2,639
[ 212691133, 228719864 ]
[ "genserver", "documented" ]
defmodule VampireNumber do use GenServer def start_link do #IO.puts "worker start" GenServer.start_link(__MODULE__,[]) end def init([]) do {:ok,[]} end def dowork(process_id, {list, parent_pid}) do GenServer.cast(process_id, {list, parent_pid}) end def handle_cast({li...
0bad56ca6e7c140ed768b5fca07873463f3d3a1e
1,574
[ 911853824 ]
[ "phoenix" ]
defmodule PhoenixApiWeb.Router do use PhoenixApiWeb, :router pipeline :browser do plug :accepts, ["html"] plug :fetch_session plug :fetch_live_flash plug :put_root_layout, html: {PhoenixApiWeb.Layouts, :root} plug :protect_from_forgery plug :put_secure_browser_headers end pipeline :api...
0bad8edf600712b3e1072f5b4d8fdbb2a57255b3
1,638
[ 668676939 ]
[]
alias Acl.Accessibility.Always, as: AlwaysAccessible alias Acl.Accessibility.ByQuery, as: AccessByQuery alias Acl.GraphSpec.Constraint.Resource.AllPredicates, as: AllPredicates alias Acl.GraphSpec.Constraint.Resource.NoPredicates, as: NoPredicates alias Acl.GraphSpec.Constraint.ResourceFormat, as: ResourceFormatConstra...
0badd5945239b8b6c8a09b77e8b95976b7c4618e
3,549
[ 420990303 ]
[ "documented", "ecto" ]
defmodule ExPoll.Polls do @moduledoc """ The Polls context. """ import Ecto.Query, warn: false alias ExPoll.Repo alias ExPoll.Polls.Poll @doc """ Returns the list of polls. ## Examples iex> list_polls() [%Poll{}, ...] """ def list_polls do Repo.all(Poll) end @doc """ G...
0bae33274f3ea1d3a68e3043994e7f7e9f0bcede
1,718
[ 491472874, 969632369, 866561243 ]
[ "documented" ]
defmodule Plug.Goldcrest.HTTPServer do @moduledoc """ Documentation for `Plug.Goldcrest.HTTPServer`. """ @adapter Plug.Goldcrest.HTTPServer.Conn def child_spec(plug: plug, port: port, options: options) do Application.put_env( :goldcrest_http_server, :dispatcher, {__MODULE__, [plug: plug...
0bae7a07a9c34f5aee4b74bf2e15e05a529f87e2
3,602
[ 299723798 ]
[ "documented" ]
defmodule AwsIngressOperator.ExAws.FilterAliases do @moduledoc """ Aliases for filters used in list APIs """ @aliases %{ describe_target_groups: %{ load_balancer_arn: %{ name: :load_balancer_arn, list: false }, arn: %{ name: :target_group_arns, list: true ...
0baf0068ada06755849e52ac46b19cce383c943d
3,033
[ 994317602 ]
[ "genserver", "documented" ]
defmodule MqttSensors.Rotary do @moduledoc false use GenServer alias Phoenix.PubSub @topic "rotary_encoder" def start_link([]) do GenServer.start_link(__MODULE__, []) end def init([]) do # interval = Application.get_env(:mqtt_sensors, :interval) emqtt_opts = Application.get_env(:mqtt_senso...
0baf0dcb8ec1fc24b9257e1ff0ec39d25f2adf43
2,017
[ 43114034 ]
[ "phoenix" ]
defmodule HelloPhoenix.CardController do use HelloPhoenix.Web, :controller alias HelloPhoenix.Card plug :scrub_params, "card" when action in [:create, :update] def index(conn, _params) do IO.puts "==> index" cards = Repo.all(Card) render(conn, "index.html", cards: cards) end def new(conn, _p...
0baf316c502e200dc1edbcdfe565c54ce118f4aa
6,299
[ 720796861 ]
[ "test", "ecto" ]
defmodule StreetArt.ArtworkPhoto.ArtworkPhotosTest do use ExUnit.Case, async: true use StreetArt.DataCase alias StreetArt.{Factory, Repo, ArtworkPhoto, ArtworkPhoto.ArtworkPhotos} describe "create_artwork_photo/1" do setup do {:ok, artwork} = %{} |> Factory.artwork() |> Factory.insert() {:ok, ...
0bafa22c48aa4424ae2d54de1ab320bce6b59c68
13,657
[ 1013321258 ]
[ "genserver", "typespec", "documented" ]
defmodule RubberDuck.Instructions.CacheInvalidator do @moduledoc """ Intelligent cache invalidation system with file system integration. Provides automatic invalidation of instruction caches when files change, cascade invalidation for template inheritance, and smart invalidation patterns based on instruction...
0bafaca2f9f8ceee9514725d4755e9b7ed9c2a18
2,425
[ 162102894 ]
[ "test" ]
defmodule Mix.Tasks.TimeTest do use ExUnit.Case, async: true describe "run/1" do test "it outputs the current time" do Mix.Tasks.Time.run([]) assert_received {:mix_shell, :info, [time]} current_time = :calendar.local_time() |> NaiveDateTime.from_erl!() |> NaiveDateTi...
0bb05c39373fc13aedc55dac11ba22da6bccadbe
3,167
[ 297612902 ]
[ "test", "phoenix" ]
defmodule PnsWeb.EventControllerTest do use PnsWeb.ConnCase alias Pns.Account @create_attrs %{ end_time: ~N[2010-04-17 14:00:00], html_template: "some html_template", key: "7488a646-e31f-11e4-aace-600308960662", start_time: ~N[2010-04-17 14:00:00], website_url: "some website_url" } @upda...
0bb06016900f9ed0bba807bbb6c47643b8429eae
3,191
[ 190235095 ]
[ "documented" ]
defmodule ExEsi.API.Fleets do @moduledoc false alias ExEsi.API alias ExEsi.API.Character @version "v2" def current_fleet(%Character{id: character_id}) do "/#{@version}/characters/#{character_id}/fleet/" |> API.get() end @version "v1" def details(fleet_id) do "/#{@version}/fleets/#{fleet_i...
0bb0ac813a51dc107efb1e3bb534bf6ae8c80de6
4,324
[ 196200304, 211097139, 125843928, 19643959, 180274417 ]
[ "test" ]
Code.require_file("../../test_helper.exs", __DIR__) defmodule Mix.Tasks.App.TreeTest do use MixTest.Case defmodule AppDepsSample do def project do [app: :test, version: "0.1.0"] end def application do [applications: [:logger, :app_deps_sample]] end end @tag apps: [:test, :app_dep...
0bb100dac8cc79d02e5d46d6ce4cf385697aafac
1,511
[ 364949825 ]
[ "phoenix" ]
defmodule ElixirTaskWeb.PageController do use ElixirTaskWeb, :controller alias ElixirTask.OrderManager.{Order} alias ElixirTask.{Repo} import Ecto.{Query, Changeset} def index(conn, _params) do pickupAddress = "Street #2, 7th Avenue, New York City, USA" dropoffAddress = "Street #6, Block 3, Los Angel...
0bb114aa30439241ec74bc8c0f0d269c350e5877
2,083
[ 170898493 ]
[ "supervisor", "documented" ]
defmodule FirmwareDb.Application do # See https://hexdocs.pm/elixir/Application.html # for more information on OTP Applications @moduledoc false @target Mix.target() @otp_app Mix.Project.config[:app] use Application def start(_type, _args) do # See https://hexdocs.pm/elixir/Supervisor.html # fo...
0bb13caac08fb245f6ccd148916b95c410546621
2,503
[ 106458221 ]
[ "genserver", "documented" ]
defmodule Protein.AMQPAdapter.Connection do @moduledoc false use AMQP use GenServer require Logger alias AMQP.{Connection, Queue} alias Protein.Utils def start_link(opts) do name = Keyword.fetch!(opts, :connection_name) GenServer.start_link(__MODULE__, opts, name: name) end def init(opts) d...
0bb1483bad00380eb276932481d5ac0451bb31e7
1,782
[ 309049499 ]
[ "documented" ]
defmodule Euler.Problem92 do @moduledoc """ https://projecteuler.net/problem=92 Square digit chains A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before. For example, 44 → 32 → 13 → 10 → 1 → 1 85 → 89 → 145 →...
0bb16628e96bcfca5226dfaaee2fef759153b42e
1,628
[ 151191884 ]
[ "genserver", "documented" ]
defmodule KV.Registry do use GenServer ## Client API @doc """ Starts the registry """ def start_link(opts) do GenServer.start_link(__MODULE__, :ok, opts) end @doc """ Looks up the bucket pid for `name` stored in `server`. Returns `{:ok, pid}` if the bucket exists, `:e...
0bb1a786f2bf095526acd227398232e0626a175a
2,032
[ 57192889 ]
[ "phoenix" ]
defmodule VutuvWeb.Api.PostController do use VutuvWeb, :controller import VutuvWeb.Authorize alias Vutuv.{Publications, Publications.Post, UserProfiles, UserProfiles.User} action_fallback VutuvWeb.Api.FallbackController def action(conn, _), do: auth_action_slug(conn, __MODULE__, [:index, :show]) def in...
0bb1dd86b08a0dd0eec01eff81cf837fa7c68e9f
4,165
[ 125644881 ]
[]
defmodule Yatzee.Rules do alias Yatzee.Dices.Dice def check(dices, :full_house) do dices |> Enum.group_by(fn %Dice{face: face} -> face end) |> Enum.map(fn {_, dices} -> Enum.count(dices) end) |> verdict(:full_house) end def check(dices, :small_straight) do dices |> Enum.map(fn %Dice{fa...
0bb22b80a1adfaad45f23ace915dbcdd93f1cc00
8,922
[ 268299283 ]
[ "test", "ecto" ]
defmodule Qpoll.PollsTest do use Qpoll.DataCase alias Qpoll.Repo alias Qpoll.Polls describe "polls" do alias Qpoll.Polls.{Poll, PollOption} @valid_attrs %{question: "some question"} @update_attrs %{question: "some updated question"} @invalid_attrs %{question: nil} @without_options_attrs %...
0bb23a8adcabecc73dec6d7c29db102f19d7bdcf
2,178
[ 607729034, 803809623 ]
[ "phoenix" ]
defmodule OperatelyWeb.Router do use OperatelyWeb, :router import OperatelyWeb.AccountAuth pipeline :browser do plug :accepts, ["html"] plug :fetch_session plug :protect_from_forgery plug :put_secure_browser_headers plug :fetch_current_account plug :fetch_current_company plug :fetch_...
0bb29dd7ba2efd52d104e3c4d14f95e78c3e3f26
3,066
[ 493636191 ]
[ "liveview", "documented" ]
defmodule SelphiDaisy.Form.TelephoneInput.Example05 do @moduledoc """ TelephoneInput 示例。 """ use Surface.Catalogue.Example, subject: SelphiDaisy.Form.TelephoneInput, height: "700px", title: "TelephoneInput 组件 位于水平组件中 HGroup,忽略label ", direction: "vertical" alias SelphiDaisy.Form.S...
0bb30f5beb1a22bfed28d8a658fb673a977f1fd6
3,932
[ 193244709, 101434552, 198908023 ]
[ "typespec", "documented" ]
defmodule GoogleApi.AnalyticsData.V1beta.Model.PropertyQuota do @moduledoc """ Current state of all quotas for this Analytics Property. If any quota for a property is exhausted, all requests to that property will return Resource Exhausted errors. ## Attributes * `concurrentRequests` (*type:* `GoogleApi.Anal...
0bb3c8230f63e9d0404c30e2224c25e6bc684a4b
1,658
[ 83799024 ]
[ "macro", "documented", "ecto", "phoenix" ]
defmodule Instruktorg.Web do @moduledoc """ A module that keeps using definitions for controllers, views and so on. This can be used in your application as: use Instruktorg.Web, :controller use Instruktorg.Web, :view The definitions below will be executed for every view, controller, etc, so k...
0bb3ff40461c27f9a5fae5977f647ef15d6eda2b
1,870
[ 41606346 ]
[ "phoenix" ]
defmodule Codetalks.TalkController do use Codetalks.Web, :controller alias Codetalks.Talk plug :scrub_params, "talk" when action in [:create, :update] plug Codetalks.Plugs.CheckAuthentication def index(conn, _params) do talks = Repo.all(Talk) render(conn, "index.html", talks: talks) end def ne...
0bb4408a6223b48d4d9952492f578cece23d12f0
2,557
[ 823405818 ]
[ "documented" ]
defmodule PhxWeather.OpenWeatherService do @moduledoc false @openweather_base_api_path "https://api.openweathermap.org" @openweather_data_api_path "/data/2.5/weather" @openweather_geocode_api_path "/geo/1.0/direct" alias PhxWeather.WeatherData def geocode_location(location_name) do (%{status: status,...
0bb4612cd8504e03ccce661ac9a108aaa15386a0
2,712
[ 194607129 ]
[ "typespec", "documented" ]
defmodule Say do @words %{ 0 => "zero", 1 => "one", 2 => "two", 3 => "three", 4 => "four", 5 => "five", 6 => "six", 7 => "seven", 8 => "eight", 9 => "nine", 10 => "ten", 11 => "eleven", 12 => "twelve", 13 => "thirteen", 14 => "fourteen", 15 => "fifteen",...
0bb46381fec30f61257e4d0528bf3d809a6126de
1,528
[ 527392356 ]
[ "supervisor", "documented" ]
defmodule Traveler.Application do # See https://hexdocs.pm/elixir/Application.html # for more information on OTP Applications @moduledoc false use Application @impl true def start(_type, _args) do children = [ # Start the Ecto repository Traveler.Repo, # Server used for checking perm...
0bb480a12dde5ba7e39cd6ce8746ef98a49a0f3a
1,653
[ 997724315 ]
[ "liveview", "phoenix" ]
defmodule BudgetdWeb.Endpoint do use Phoenix.Endpoint, otp_app: :budgetd # The session will be stored in the cookie and signed, # this means its contents can be read but not tampered with. # Set :encryption_salt if you would also like to encrypt it. @session_options [ store: :cookie, key: "_budgetd_k...
0bb555216d6cc959d25dbba3eedb4720e7f5c8f1
1,818
[ 153749907 ]
[ "documented" ]
defmodule Train.Map.Map do @moduledoc false alias Train.Map.Vehicle alias Train.Map.Tile alias Train.Map.Signal defstruct initial_state: nil, sections: [], vehicles_by_location: nil, signals: nil def new(sections) do new(sections, [], []) end defp by_location(list) do Enum.reduce(list, %{}, ...
0bb55cd5fd675e54754340bc9c3f550ec454851d
14,505
[ 949664843 ]
[ "test", "liveview" ]
defmodule Raxol.UI.Components.TableTest do use ExUnit.Case import Raxol.Guards alias Raxol.UI.Components.Table @test_columns [ %{ id: :id, label: "ID", width: 4, align: :right, format: &String.Chars.to_string/1 }, %{ id: :name, label: "Name", width: 1...
0bb582cc28c76c8d410b98a0bf0360dfad2c12c2
11,967
[ 310810277 ]
[]
defmodule :m_erts_debug do use Bitwise def breakpoint(_, _) do :erlang.nif_error(:undef) end def disassemble(_) do :erlang.nif_error(:undef) end def display(_) do :erlang.nif_error(:undef) end def dist_ext_to_term(_, _) do :erlang.nif_error(:undef) end def flat_size(_) do :e...
0bb5b07af8ba0a804ad9161616756492fb43566e
5,010
[ 937967426 ]
[ "test", "ecto" ]
defmodule Smovie.MoviesTest do use Smovie.DataCase alias Smovie.Movies describe "watchedlist" do alias Smovie.Movies.WatchedList import Smovie.MoviesFixtures @invalid_attrs %{urating: nil, udescription: nil, uwatcheddate: nil} test "list_watchedlist/0 returns all watchedlist" do watched...
0bb65bb2400093ae6948464ed42e7552703ae619
1,990
[ 433890992 ]
[]
defmodule Day5 do import Helpers def parse_line(line) do [[x1, y1], [x2, y2]] = line |> String.split(" -> ") |> IO.inspect |> Enum.map(fn x -> x |> String.split(",") end) { { elem(Integer.parse(x1), 0), elem(Integer.parse(y1), 0) }, { elem(Integer.pars...
0bb72905e989dfb10bd85de15a36b3c28da3b3e8
3,805
[ 165115442, 969189171 ]
[ "documented" ]
defmodule Logflare.Logs.SyslogParser do @moduledoc false import NimbleParsec import Logflare.Logs.SyslogParser.Helpers alias Logflare.Logs.SyslogMessage defparsec( :do_parse, optional( byte_length() |> ignore(sp()) ) |> concat(priority()) |> concat(version()) |> ignore(sp(...
0bb734e50963f3f2db826443baf23e8b0e5f9d40
2,090
[ 41335202 ]
[ "macro", "documented", "phoenix" ]
defmodule Apiv3.Web do @moduledoc """ A module that keeps using definitions for controllers, views and so on. This can be used in your application as: use Apiv3.Web, :controller use Apiv3.Web, :view The definitions below will be executed for every view, controller, etc, so keep them short and...
0bb73b3b3fed5df8db6561f13f0226cb04c4fc4f
2,923
[ 32538317 ]
[ "genserver" ]
defmodule Bot.Skill.User do use Bot.Skill def begin(bot, []) do Bot.cast(bot, "regex.add", {"^register$", "user.register"}) Bot.cast(bot, "regex.add", {"^identify$", "user.identify"}) Bot.cast(bot, "regex.add", {"who am i", "user.who"}) Bot.cast(bot, "regex.add", {"my name is (?<name>.+)", "user.register.nam...
0bb765995529f2f3a21fb7adae5ae988c4d7ceb6
1,583
[ 53529124 ]
[ "genserver" ]
defmodule Snake.GameState do use GenServer def direction_changed(direction) do GenServer.cast(__MODULE__, {:direction, direction}) end def start_link do GenServer.start_link(__MODULE__, %{x: 30, y: 30, direction: :right}, name: __MODULE__) end def init(state) do send self, :start_tick {:o...
0bb7b1849443bc89e2a13f1ae12d59830d8450f4
5,074
[ 830050847 ]
[ "test", "ecto" ]
defmodule Rms.TariffLinesTest do use Rms.DataCase alias Rms.TariffLines describe "tbl_tariff_line" do alias Rms.TariffLines.TariffLine @valid_attrs %{ active_from: "some active_from", client: "some client", commodity: "some commodity", currency: "some currency", destinatio...
0bb7b3820e4ee6d798b20185d04faf7549971402
2,202
[ 726229795 ]
[]
defmodule Day11 do def check(val, label) do IO.inspect(val, charlists: :as_lists, label: label) end def getIndices(file) do getIndices(file, 0, 0) end def getIndices("", _, _) do [] end def getIndices(<<c>> <> file, row, col) do case c do ?...
0bb7ec970842648cfb1398c857ce38c7947503db
1,868
[ 363187228 ]
[]
defmodule Homework.MixProject do use Mix.Project def project do [ app: :homework, version: "0.1.0", elixir: "~> 1.10", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(), start_permanent: Mix.env() == :prod, aliases: aliases(), ...
0bb89089faca2b2325f846da795fc393e5ac29e1
6,769
[ 153922468 ]
[ "genserver", "test" ]
defmodule WorkerTest do use ExUnit.Case defmodule NoArgWorker do def perform do end end defmodule ThreeArgWorker do def perform(_, _, _) do end end defmodule CustomMethodWorker do def custom_perform do end end defmodule MetadataWorker do def perform() do %{class: "W...
0bb8b58280658103416aa41b31636511738107c0
1,772
[ 32239454 ]
[ "documented" ]
if Code.ensure_loaded?(ExAws) and Code.ensure_loaded?(SweetXml) do defmodule Exjprop.Properties.S3 do defstruct prop_fun: nil alias Exjprop.Properties.Function, as: PropFun alias Exjprop.String, as: ExjString @doc """ Create a new remote properties. Access and Secret key will be retrieved f...
0bb93d5b2bc94e223487757721cf987d5f43d250
3,171
[ 82792912 ]
[ "test", "ecto" ]
defmodule MssqlEcto.AlterTableTest do use MssqlEcto.Case, async: true import Ecto.Migration, only: [table: 1, table: 2] alias Ecto.Migration.Reference test "alter table" do alter = {:alter, table(:posts), [ {:add, :title, :string, [default: "Untitled", size: 100, null: false]}, ...
0bba57f384279dd2f1e5bd7a9be870617240024c
2,833
[ 838907457 ]
[ "typespec", "documented" ]
defmodule Electric.Postgres.Repo.Client do @moduledoc """ Postgres database client that relies on `Electric.Postgres.Repo`. Uses the repo to check out connections from the pool and execute queries on them. """ alias Electric.Postgres.Repo alias Electric.Replication.Connectors @type row :: [term] @typ...
0bbaa1f6126150df441c072e41f19a89cf5b73f1
4,835
[ 156912698 ]
[ "test" ]
defmodule DojinlistWeb.Mutations.AlbumTest do use DojinlistWeb.ConnCase alias Dojinlist.{ Albums, Fixtures } test "Can create an album" do query = """ mutation CreateAlbum($album: AlbumInput) { createAlbum(album: $album) { album { id } } } """ ...
0bbb85c829ebd02ab51d388cd5a6ede135e11305
2,754
[ 404493357 ]
[]
defmodule Rules do def hasOperator?(%Clauses{formula: x, sign: _}) do case x do {:and, _, _} -> true {:or, _, _} -> true {:not, _} -> true {:implies, _, _} -> true _ -> false end end def hasOperator?(_), do: nil def branching?(%Clauses...
0bbbc269c3369c50919185e8644b8a075a076abe
6,913
[ 949664843 ]
[ "documented" ]
defmodule Raxol.Plugins.Visualization.ChartRenderer do import Raxol.Guards @moduledoc """ Handles rendering logic for chart visualizations within the VisualizationPlugin. """ require Raxol.Core.Runtime.Log alias Raxol.Terminal.Cell alias Raxol.Plugins.Visualization.DrawingUtils alias Raxol.Style # ...
0bbbf52d80a687a85707adecfc359e815e16cd15
4,602
[ 81105471 ]
[ "test" ]
defmodule Wobserver.Web.Router.ApiTest do use ExUnit.Case, async: true use Plug.Test alias Wobserver.Util.Node.Remote alias Wobserver.Web.Router.Api @opts Api.init([]) test "/about returns about" do conn = conn(:get, "/about") conn = Api.call(conn, @opts) assert conn.state == :sent asse...
0bbc14bf011e45e8e23005f98a01fd1cc5b60b28
2,348
[ 73797323 ]
[ "test" ]
defmodule Perty.StoryControllerTest do use Perty.ConnCase alias Perty.Story @valid_attrs %{description: "some content"} @invalid_attrs %{} test "lists all entries on index", %{conn: conn} do conn = get conn, story_path(conn, :index) assert html_response(conn, 200) =~ "Listing stories" end test ...
0bbc34a9ecad408734a916d9392cb50dbfd47e3f
2,036
[ 120461958 ]
[ "typespec" ]
defmodule ExJsonSchema.Validator.Format do alias ExJsonSchema.Validator @date_time_regex ~r/^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9])?$/ @email_regex ~r<^[\w!#$%&'*+/=?`{|}~^-]+(?:\.[\w!#$%...
0bbd0cf3708b812a34e37c3cf6375bdd6309e214
5,108
[ 63960295 ]
[ "test" ]
defmodule Appsignal.TransmitterTest do use ExUnit.Case alias Appsignal.{Config, Transmitter} import AppsignalTest.Utils import ExUnit.CaptureLog setup do Application.put_env(:appsignal, :http_client, FakeFinch) on_exit(fn -> Application.delete_env(:appsignal, :http_client) end) end de...
0bbd0eef05438ac67ab231cd42cb19a2c02dbfb7
2,185
[ 64507444 ]
[]
defmodule Habitica.Parser do alias Habitica.Daily alias Habitica.Habit alias Habitica.Reward alias Habitica.Todo def parse_user_tasks(body) do json_body = Poison.Parser.parse!(body) json_body["data"] |> Enum.map(&task_from_json/1) |> Enum.filter(fn nil -> false t -> !St...
0bbd60edc090e82c8e32bbfefc16f26762b88f1d
1,687
[ 819144358 ]
[ "test", "phoenix" ]
defmodule SybanPnxWeb.UserRegistrationControllerTest do use SybanPnxWeb.ConnCase, async: true import SybanPnx.AccountsFixtures describe "GET /users/register" do test "renders registration page", %{conn: conn} do conn = get(conn, ~p"/users/register") response = html_response(conn, 200) asse...
0bbd8751899d96b804b4c8f92f49daee0ad3fc11
1,511
[ 9863072 ]
[]
defmodule Teller.Cowboy.WebsocketTester do @behaviour :websocket_client_handler # # Public API # # i.e.: # > alias Teller.Cowboy.WebsocketTester # > pid = WebsocketTester.start_link('ws://echo.websocket.org') # > WebsocketTester.send_text(pid, "il etait un petit navire...") # > WebsocketTester.close(...
0bbd8ef5f8a37e34cb244096b0d8b2796da2f362
1,726
[ 435651573 ]
[]
defmodule AOC.Puzzles.Y2021.DayNine do def parse(input) do input |> Enum.map(&AOC.Helpers.ints_from_string(&1, "")) |> Matrix.new() end def lower_than_neighbors?(matrix, coords) do value = Matrix.at!(matrix, coords) Matrix.adjacent_values(matrix, coords) |> Enum.all?(fn n -> value < n en...
0bbdf327a3113ac9bedfbcd3d38e97adf6e0f5f1
3,971
[ 812603976 ]
[ "phoenix" ]
defmodule IpdthWeb.Router do use IpdthWeb, :router import IpdthWeb.AuthN @content_security_policy "default-src 'self';img-src 'self' blob: data:;" pipeline :browser do plug :accepts, ["html"] plug :fetch_session plug :fetch_live_flash plug :put_root_layout, html: {IpdthWeb.Layouts, :root} ...
0bbe3dbca0909bac35cfcc55153fe9abbe6fb063
14,065
[ 234949112 ]
[ "test" ]
#! /usr/bin/env elixir # defmodule Day25 do require Bitwise defmodule Mapper do use Agent alias Day25.InvMgr defstruct input: [], output: [], auto: false @initial_instrs """ north west take mug west take easter egg east east south south take asterisk s...
0bbe989650b0326c49a70807096a84d472a691d3
1,840
[ 611751913 ]
[ "documented", "ecto" ]
defmodule StreamingApp.Movies do @moduledoc """ The Movies context. """ import Ecto.Query, warn: false alias StreamingApp.Repo alias StreamingApp.Movies.Movie @doc """ Returns the list of movies. ## Examples iex> list_movies() [%Movie{}, ...] """ def list_movies do Repo.all(M...
0bbe9b87d7fca2b3d4f7ef4dd728cdccc2770c55
3,170
[ 379678050 ]
[ "typespec", "documented" ]
defmodule Absinthe.Type.Union do @moduledoc """ A unions is an abstract type made up of multiple possible concrete types. No common fields are declared in a union. Compare to `Absinthe.Type.Interface`. Because it's necessary for the union to determine the concrete type of a resolved object, you must either:...
0bbedee0597e00107e2779e211c70da5a7e95ccf
2,931
[ 663561514 ]
[ "phoenix", "documented" ]
defmodule PhxSolidWeb.GController do use PhxSolidWeb, :controller # alias PhxSolidWeb.UserSessionController alias PhxSolid.SocialUser alias PhxSolid.Accounts.User require Logger @doc """ Plug to check the state """ def redirect_if_bad_state(conn, _opts) do g_state = fetch_session(conn) ...
0bbfc373e6a0e56d7f4992aea095daa36cac5c1e
1,515
[ 652435728 ]
[ "liveview", "ecto" ]
defmodule LiveviewEcommerceWeb.CartLive.FormComponent do use LiveviewEcommerceWeb, :live_component alias LiveviewEcommerce.Carts @impl true def update(%{cart: cart} = assigns, socket) do changeset = Carts.change_cart(cart) {:ok, socket |> assign(assigns) |> assign(:changeset, changeset...
0bbfd46148b3dda813aa3adeafa9c3eccd415b38
1,810
[ 614405134 ]
[ "test", "ecto" ]
defmodule LearnPhoenix.UrlsTest do use LearnPhoenix.DataCase alias LearnPhoenix.Urls describe "urls" do alias LearnPhoenix.Urls.Url import LearnPhoenix.UrlsFixtures @invalid_attrs %{link: nil, title: nil} test "list_urls/0 returns all urls" do url = url_fixture() assert Urls.list_...
0bc02054255f902b953bf82df6b7d75b5c712eea
2,587
[ 175288021 ]
[ "documented" ]
defmodule Stats.UploadParser.Football do @moduledoc """ Parser for football stats """ @keys_for_stat_type %{ "rushing" => ["entry_id", "player_id", "position", "yds", "att", "tds", "fum"], "kicking" => [ "entry_id", "extra_pt_att", "extra_pt_made", "fld_goals_att", "fld_go...