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 |
|---|---|---|---|---|
0b635df972d9c63fdfc7288f43e1af5857095a1c | 11,902 | [
996802329
] | [
"genserver",
"test",
"phoenix"
] | defmodule SnmpSimPhase4IntegrationTest do
use ExUnit.Case, async: false
doctest SnmpSim
alias SnmpSim.Device
alias SnmpSim.TestHelpers.PortHelper
@moduletag :integration
setup_all do
# Start the application if not already started
Application.ensure_all_started(:snmp_sim)
:ok
end
setup do... |
0b641f755ba418a39450ae96aa5acd87b04ba2b6 | 5,234 | [
189251630
] | [
"typespec",
"macro",
"documented"
] | defmodule Stops.Repo do
@moduledoc """
Matches the Ecto API, but fetches Stops from the Stop Info API instead.
"""
use Nebulex.Caching.Decorators
alias Dotcom.Cache.KeyGenerator
alias Routes.Route
alias Stops.{Api, Repo.Behaviour, Stop}
@cache Application.compile_env!(:dotcom, :cache)
@ttl :timer.h... |
0b647b5e168634865b537fc35c1b5c05015445b3 | 3,083 | [
360705510
] | [
"test",
"phoenix"
] | defmodule DirectoryAnalyzerWeb.DirectoryControllerTest do
use DirectoryAnalyzerWeb.ConnCase
alias DirectoryAnalyzer.Directories
@create_attrs %{file_count: 42, name: "some name", word_count: 42}
@update_attrs %{file_count: 43, name: "some updated name", word_count: 43}
@invalid_attrs %{file_count: nil, name... |
0b648bba6021a0140c4ff3e287aa6bda016bc84a | 2,066 | [
43247111
] | [
"test",
"documented"
] | defmodule Credo.Check.Warning.BoolOperationOnSameValuesTest do
use Credo.Test.Case
@described_check Credo.Check.Warning.BoolOperationOnSameValues
#
# cases NOT raising issues
#
test "it should NOT report expected code" do
"""
defmodule CredoSampleModule do
use ExUnit.Case
def some_fu... |
0b6505a1ea954acbe8cc87a9bdd9d6a90c821798 | 1,784 | [
615745091
] | [
"liveview",
"ecto"
] | defmodule LiveViewStudioWeb.ServerFormComponent do
alias LiveViewStudio.Servers
alias LiveViewStudio.Servers.Server
use LiveViewStudioWeb, :live_component
def mount(socket) do
# Create empty `Server` struct
changeset = Servers.change_server(%Server{})
{:ok, assign(socket, :form, to_form(changeset)... |
0b653adb438e520e76cd43afda1e5bf98692d4f3 | 2,876 | [
795134594
] | [] | defmodule Storybook.Components.Join do
use PhoenixStorybook.Story, :component
alias DaisyUIComponents.Button
alias DaisyUIComponents.Input
alias DaisyUIComponents.Join
alias DaisyUIComponents.Select
alias DaisyUIComponents.Utils
def function, do: &Join.join/1
def imports, do: [{Button, button: 1}, {I... |
0b6569b7310bcdc5ba6935827aede5afa3fef620 | 5,481 | [
569243827
] | [
"documented",
"ecto"
] | defmodule Core.HealthIssues do
@moduledoc """
The HealthIssues context.
"""
import Ecto.Query, warn: false
alias Core.Repo
alias Core.HealthIssues.Aliment
@doc """
Returns the list of aliments.
## Examples
iex> list_aliments()
[%Aliment{}, ...]
"""
def list_aliments do
from(
... |
0b65fb4456018b6c25c3f01c1f9dee4405e66399 | 3,753 | [
662356100
] | [
"liveview",
"test"
] | defmodule BytebinderWeb.NailWatchLiveTest do
use BytebinderWeb.ConnCase
import Phoenix.LiveViewTest
import Bytebinder.NotebookFixtures
@create_attrs %{date: "2023-09-23", flag: "some flag", nails: 42, skin: 42, blood: 42}
@update_attrs %{date: "2023-09-24", flag: "some updated flag", nails: 43, skin: 43, bl... |
0b66ceec0814c1b3b2f094bbb71ecd12eb922ac2 | 1,622 | [
119209152
] | [] | defmodule Exfootball.External.FootballData do
use Tesla
plug Tesla.Middleware.BaseUrl, Application.get_env(:exfootball, :football_data_api_url)
plug Tesla.Middleware.Timeout, timeout: Application.get_env(:exfootball, :football_data_api_timeout)
plug Tesla.Middleware.JSON
adapter Tesla.Adapter.Hackney
@ca... |
0b67110959fba16be068699bba2a196eedb09ffd | 2,127 | [
972810178,
168643505,
390166925
] | [
"documented",
"ecto"
] | defmodule Data.Quest do
@moduledoc """
Quest schema
"""
use Data.Schema
alias Data.Script
alias Data.NPC
alias Data.QuestRelation
alias Data.QuestStep
schema "quests" do
field(:name, :string)
field(:description, :string)
field(:completed_message, :string)
field(:level, :integer)
... |
0b679dd9ad80dc6624f517190c9098f4dcd722dc | 1,798 | [
242592509
] | [
"phoenix",
"ecto"
] | defmodule ContactWeb.FolderController do
use ContactWeb, :controller
alias Contact.Content
alias Contact.Content.Folder
def index(conn, _params) do
folders = Content.list_folders()
render(conn, "index.html", folders: folders)
end
def new(conn, _params) do
changeset = Content.change_folder(%Fo... |
0b67d62f980db67526b6ee62ddb9e30795a7334d | 1,838 | [
343209812,
448948658,
459182862,
341577165,
343815695,
275466745,
341934035,
341590671,
343276976,
183581270,
378250684,
425655561,
341506243,
343844359,
473697525,
361519846,
397255799,
386716688,
521332927,
389101999
] | [
"documented"
] | defmodule Credo.Check.Readability.TrailingWhiteSpace do
use Credo.Check,
base_priority: :low,
tags: [:formatter],
param_defaults: [
ignore_strings: true
],
explanations: [
check: """
There should be no white-space (i.e. tabs, spaces) at the end of a line.
Most text editors... |
0b684074e6b1b03fe9cd46827ff624ace2f737a5 | 4,204 | [
242378112
] | [
"typespec",
"supervisor",
"documented",
"phoenix"
] | defmodule Athena.Telemetry do
@moduledoc """
API Telemetry
"""
use Supervisor
import Telemetry.Metrics
@spec start_link(args :: Keyword.t()) :: Supervisor.on_start()
def start_link(arg) do
Supervisor.start_link(__MODULE__, arg, name: __MODULE__)
end
@impl Supervisor
def init(_arg) do
Sup... |
0b6867dbcbbc9f57c63d98f1329a95b2f6590e90 | 2,477 | [
205228081
] | [
"phoenix"
] | defmodule CiMetricsWeb.RepositoryController do
require Logger
use CiMetricsWeb, :controller
alias CiMetrics.GithubProject
alias CiMetrics.Metrics.TimeUnitMetric
alias CiMetrics.Project.Repository
@project Application.get_env(:ci_metrics, :project, GithubProject)
def new(conn, _params) do
render(conn... |
0b688a69b1648a6a02402a3cbd5655499f4f2dc9 | 9,672 | [
707872156
] | [
"ecto"
] | import Ecto.Query
alias Postion.Repo
alias Postion.Accounts.User
alias Postion.Content.Topic
alias Postion.Content.Post
alias Postion.Content.Contributor
require Logger
Logger.configure(level: :error)
defmodule Inserter do
def insert_all(params, schema, inserted_at, inc \\ fn _ -> :ok end) do
params
|> St... |
0b68f7c00ddf660583ec3749f11a03d423a242b0 | 4,026 | [
196673549
] | [
"typespec",
"macro",
"documented"
] | defmodule Shapt do
@moduledoc """
Use this to create your own feature toggle worker as in the example:
```elixir
defmodule TestModule do
use Shapt,
adapter: {Shapt.Adapters.Env, []},
toggles: [
feature_x?: %{
key: "MYAPP_FEATURE_X",
deadline: ~D[2019-12-31]
... |
0b696f979ab6a6fdc57cd7bafce4cb441ca567ca | 2,028 | [
783689692
] | [
"test",
"ecto"
] | defmodule MyApp.AuthTest do
use MyApp.DataCase
alias MyApp.Auth
describe "users" do
alias MyApp.Auth.User
import MyApp.AuthFixtures
@invalid_attrs %{email: nil, is_active: nil, password: nil}
test "list_users/0 returns all users" do
user = user_fixture()
assert Auth.list_users() =... |
0b6977b35c1a76ec896a5b1e9c4becc112d19386 | 3,962 | [
78014292
] | [
"typespec",
"documented"
] | defmodule ScaleGenerator do
@sharp_notes ~w(A A# B C C# D D# E F F# G G#)
@flat_notes ~w(A Bb B C Db D Eb E F Gb G Ab)
@flat_chromatic_scales ~w(F Bb Eb Ab Db Gb d g c f bb eb)
@doc """
Find the note for a given interval (`step`) in a `scale` after the `tonic`.
"m": one semitone
"M": two semitones (full... |
0b69da9809aa7eb562f74a0ef276ba1127e2899c | 1,592 | [
340326825
] | [] | # 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.
# General application configuration
use Mix.Config
# Configures the endpoint
config :nsg_lora, NsgL... |
0b69f5037febba1ec5a0b54f3ff2c32e513ea9bb | 3,669 | [
637430436
] | [
"test"
] | defmodule ValidatorTest do
use ExUnit.Case
defmodule UserTest do
use Validator.Struct
defstruct ~w[id name email]a
@forbidden_names ["admin", "moderator", "root"]
# type validations
validation(:id, type: :integer)
validation(:email, type: :binary)
validation(:name, type: :binary)
... |
0b6a69c9d25a75750b5940bceb90d9b6ed8fa48a | 2,327 | [
1010011901
] | [] | defmodule Sui.Rpc.V2alpha.GetDatatypeRequest do
use Protobuf, protoc_gen_elixir_version: "0.14.1", syntax: :proto3
def descriptor do
# credo:disable-for-next-line
%Google.Protobuf.DescriptorProto{
name: "GetDatatypeRequest",
field: [
%Google.Protobuf.FieldDescriptorProto{
name... |
0b6b0ea4a77a4bb696e742561e72f58ec35ba325 | 4,091 | [
560599498,
501366957
] | [] | defmodule Eflatbuffers.Generator do
@defaults %{
max_string_len: 100,
max_vector_len: 15,
skip_key_probability: 0.1,
default_probability: 0.1
}
def map_from_schema(schema_str, opts \\ %{}) when is_binary(schema_str) do
{:ok, {schema, %{root_type: root_type}}} =
schema_str
|> Eflat... |
0b6bb2f86605b31e50981242e563682c950b286d | 3,261 | [
300698298
] | [
"typespec",
"documented"
] | defmodule ChannelSenderEx.Core.PubSub.ReConnectProcess do
@moduledoc false
alias ChannelSenderEx.Core.Channel
alias ChannelSenderEx.Core.ChannelSupervisor
import ChannelSenderEx.Core.Retry.ExponentialBackoff, only: [execute: 6]
require Logger
@type kind() :: :websocket | :sse | :longpoll
@max_retries ... |
0b6c29340dbf96542c41201aba27dc011400f174 | 5,330 | [
231021959
] | [] | %{
"certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "805abd97539caf89ec6d4732c91e62ba9da0cda51ac462380bbd28ee697a8c42"},
"connection": {:hex, :connection, "1.0.... |
0b6ccd1c40f82094ecced6391f20bae123953529 | 1,891 | [
406155080
] | [
"typespec"
] | defmodule Nurse.Healthcheck do
defstruct [
:name,
:health_status,
:endpoint,
:request,
:check_delay,
:retry_delay,
:connection_timeout,
:evaluation_interval,
:response_condition,
:response_timeout,
:health_condition,
:retry_condition
]
@type t :: %Nurse.Healthcheck... |
0b6d0566ec1d8505e848548a10a83e02cd24fa10 | 2,465 | [
770141885
] | [
"test",
"phoenix"
] | defmodule DietWeb.ImcControllerTest do
use DietWeb.ConnCase
import Diet.ProfileFixtures
alias Diet.Profile.Imc
@create_attrs %{
user: "some user",
age: 42,
height: 120.5,
weight: 120.5
}
@update_attrs %{
user: "some updated user",
age: 43,
height: 456.7,
weight: 456.7
}
... |
0b6d0a6d2e8195ab2702ba1cbfa78cbcfe595bda | 1,802 | [
144102545
] | [] | defmodule Schemer.NumbersGames do
use Schemer.Primitive
def add(a, 0), do: a
def add(a, b), do: add(1 + a, b - 1)
def sub(a, 0), do: a
def sub(a, b), do: sub(a - 1, b - 1)
def addtup([]), do: 0
def addtup([h | t]), do: add(h, addtup(t))
def times(_, 0), do: 0
def times(a, b), do: add(a, times(a, b... |
0b6d7dbea21f1a527d5ccff5e476144bd6afec70 | 2,399 | [
84955864
] | [
"test"
] | defmodule NewRelic.TransactionTest do
use ExUnit.Case, async: false
import TestHelpers.Assertions
alias NewRelic.Transaction
setup do
[name: "Test Transaction"]
end
# finish
test "finish records elapsed time with correct key", context do
transaction = Transaction.start(context[:name])
Tran... |
0b6d839618ac78ab44376d962c838d6dc8bb3253 | 14,217 | [
423942783
] | [
"test"
] | defmodule EdgehogWeb.Schema.Mutation.CreateUpdateCampaignTest do
use EdgehogWeb.GraphqlCase, async: true
import Edgehog.BaseImagesFixtures
import Edgehog.DevicesFixtures
import Edgehog.GroupsFixtures
import Edgehog.UpdateCampaignsFixtures
alias Edgehog.UpdateCampaigns.ExecutorRegistry
alias Edgehog.Upda... |
0b6d8f8b60c7cc1fa6666442b2f9a8d8fb9aa319 | 1,670 | [
58740982
] | [
"macro",
"documented",
"ecto",
"phoenix"
] | defmodule Posts.Web do
@moduledoc """
A module that keeps using definitions for controllers,
views and so on.
This can be used in your application as:
use Posts.Web, :controller
use Posts.Web, :view
The definitions below will be executed for every view,
controller, etc, so keep them short and... |
0b6dca1b505f0a2f63560d667a840d1a92b8d6bc | 1,815 | [
43266941
] | [
"phoenix"
] | defmodule Books.BookController do
use Books.Web, :controller
alias Books.Book
plug :scrub_params, "book" when action in [:create, :update]
def index(conn, _params) do
books = Repo.all(Book)
render(conn, "index.html", books: books)
end
def new(conn, _params) do
changeset = Book.changeset(%Boo... |
0b6e616f4056ff1bdcd74c8ea2644b283768d595 | 2,463 | [
582845182
] | [
"test",
"phoenix"
] | defmodule PayfyWeb.RaffleControllerTest do
use PayfyWeb.ConnCase
use Oban.Testing, repo: Payfy.Repo
describe "create raffle /api/raffle" do
test "create raffle with rigth params, should return 200 ok", %{conn: conn} do
conn =
post(conn, Routes.raffle_path(conn, :create), %{
"name" =>... |
0b6eedae9f6a618b6c6d58c871c37bc65af662e4 | 2,047 | [
962370900
] | [] | # 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 :halo_labs_demo,
ecto_repos: [HaloLabsDemo.R... |
0b6efc14ea5032f50726d25382865a5f71523323 | 1,802 | [
991942273
] | [
"typespec",
"documented"
] | defmodule Polarex.CustomerBenefitGrantDiscord do
@moduledoc """
Provides struct and type for a CustomerBenefitGrantDiscord
"""
@type t :: %__MODULE__{
benefit: Polarex.BenefitDiscordSubscriber.t(),
benefit_id: String.t(),
created_at: DateTime.t(),
customer: Polarex.Custo... |
0b6f6e604f63fde35d85b313f994119ce473ccc7 | 3,800 | [
161563088
] | [
"documented"
] | defmodule AlchemyVM.Decoder do
alias AlchemyVM.LEB128
alias AlchemyVM.Module
alias AlchemyVM.Decoder.TypeSectionParser
alias AlchemyVM.Decoder.FunctionSectionParser
alias AlchemyVM.Decoder.GlobalSectionParser
alias AlchemyVM.Decoder.TableSectionParser
alias AlchemyVM.Decoder.MemorySectionParser
alias Al... |
0b6f8ab5d0111b31748ba9d29ec16229fec0f2d8 | 4,780 | [
184792488
] | [
"documented"
] | defmodule SegmentChallenge.Notifications.AthleteNotifications do
@moduledoc """
Notifications for an athlete
"""
defstruct [:athlete_notification_uuid, :athlete_uuid, :email, notifications: %{}]
alias SegmentChallenge.Commands.{
SubscribeAthleteToAllNotifications,
ToggleEmailNotification,
Update... |
0b700ea7fe2ed086e60d63e04ac21c6ee653a814 | 1,963 | [
822483007
] | [
"documented",
"ecto"
] | defmodule Kemiskinan.Survei do
@moduledoc """
The Survei context.
"""
import Ecto.Query, warn: false
alias Kemiskinan.Repo
alias Kemiskinan.Survei.Respons
@doc """
Returns the list of respons.
## Examples
iex> list_respons()
[%Respons{}, ...]
"""
def list_respons do
Repo.all(... |
0b708d7247cc342f11a14fc1c0f8b420d6fa83b6 | 9,214 | [
231223176
] | [
"typespec",
"documented",
"phoenix"
] | defmodule WaxAPIREST.Plug do
@moduledoc """
A plug that exposes the FIDO2 REST API
[7. Transport Binding Profil](https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-server-v2.0-rd-20180702.html#transport-binding-profile).
## Usage
In a Phoenix router, forward a route to the `WaxAPIREST.Plug`:
d... |
0b712ac9dc16a557300ccf9894d4b57085cd0c52 | 12,703 | [
48874454
] | [
"typespec",
"documented"
] | defmodule Process do
@moduledoc """
Conveniences for working with processes and the process dictionary.
Besides the functions available in this module, the `Kernel` module
exposes and auto-imports some basic functionality related to processes
available through the functions:
* `Kernel.spawn/1` and `Kern... |
0b71fc885c1d3386a44c162d83a8b31a8b7edee8 | 3,607 | [
519690576
] | [
"typespec"
] | defmodule Cordial.Parsers.GRPC.Tokenizer do
@blocks %{
?( => :tuple,
?{ => :block,
?[ => :array,
?< => :template
}
@block_open Map.keys(@blocks)
@block_types Map.values(@blocks)
@spec tokenize(binary) :: Enumerable.t()
def tokenize(data) do
{result, _} = tokenize(data, [])
post(resu... |
0b726abb5b06ebdb4a2be1ec46ae645ef8c20ee1 | 2,991 | [
327146852
] | [
"documented",
"ecto"
] | defmodule Nyra.Accounts.User do
@moduledoc """
User contains both the authentication information and their profile information and flags.
Current flags:
- Premium
- Banned
- Activated
- Filter Access
"""
use Ecto.Schema
import Ecto.Changeset
import Ecto.Query
alias Nyra.Repo
alias... |
0b7376eaeb9ca4220d207577ea1309d8194fd8a4 | 3,489 | [
564863485,
741187755
] | [
"typespec",
"documented"
] | defmodule Evision.BOWKMeansTrainer do
import Kernel, except: [apply: 2, apply: 3]
@typedoc """
Type that represents an `Evision.BOWKMeansTrainer` struct.
- **ref**. `reference()`
The underlying erlang resource variable.
"""
@type t :: %__MODULE__{
ref: reference()
}
@enforce_keys [:ref]
de... |
0b737e42bad6c25c27929bf442cd74f864b71e04 | 2,612 | [
904259553
] | [] | defmodule December04 do
import Data
##### Day 4 - Part 1 solution #####
def part1 do
results =
read("04")
|> get_grid()
|> word_search("XMAS")
IO.puts("The number of times XMAS appears in the grid is: #{length(results)}")
end
##### Day 4 - Part 2 solution #####
def part2 do
... |
0b7395a1462825f9b29d15e8d76cbc856412e467 | 2,534 | [
104818572
] | [
"genserver",
"documented"
] | defmodule WeePub.Broadcaster do
@moduledoc """
A `GenServer` that manages distribution of messages to interested clients
"""
use GenServer
@broadcaster __MODULE__
@registry WeePub.Registry
@topic @broadcaster
@doc false
def child_spec(options) do
%{
id: @broadcaster,
start: {__MODUL... |
0b73b732c9f4d9f08d97bac89cbf1ee2a3d831cc | 9,074 | [
238851279
] | [
"phoenix"
] | defmodule WmDevForumWeb.PageController do
use WmDevForumWeb, :controller
alias WmDevForum.UserManagement
alias WmDevForum.Schema.{User, Answer}
alias WmDevForum.UserManagementQueries
def index(conn, _params) do
render(conn, "index.html")
end
def back_from_error_page(conn, _params) do
render(conn... |
0b73d0a0c37cc67fa5bfa2b097e209ae9b5c64f8 | 2,312 | [
728474475
] | [
"macro",
"documented"
] | defmodule DOTCOM.Api do
@moduledoc false
@modules :application.get_key(:mbta_sdk, :modules)
|> Kernel.elem(1)
|> Enum.filter(fn module ->
Kernel.to_string(module) |> String.match?(~r/Api/)
end)
|> Enum.map(fn module ->
parent_module_str = Kernel... |
0b754c708788519dc6a846738d37c73668c04bfc | 2,040 | [
613043822
] | [
"supervisor"
] | defmodule Week4.GenericSupervisor do
use Supervisor
require Logger
def start_link(state) do
Supervisor.start_link(__MODULE__, state)
end
def init({nr, module, init_state}) do
Process.flag(:trap_exit, true)
{:ok, lb} = Week4.LoadBalancer.start_link({nr, self(), module})
{:ok, pool_manager} ... |
0b754eb08a978a82c17993d97e67e4720e86584b | 8,783 | [
511591295
] | [] | %{
"bamboo": {:hex, :bamboo, "2.2.0", "f10a406d2b7f5123eb1f02edfa043c259db04b47ab956041f279eaac776ef5ce", [:mix], [{:hackney, ">= 1.15.2", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.4", [hex: :mime, repo: "hexpm", optional: false]}... |
0b755273abf626f59192153170e0bee8e07b63b6 | 2,842 | [
96471998
] | [] | defmodule Pmdb.Path do
defp get_path_matching_environment() do
path_separator = Application.get_env(:pmdb, :path_separator)
path_index_opening_delimiter = Application.get_env(:pmdb, :path_index_opening_delimiter)
path_index_closing_delimiter = Application.get_env(:pmdb, :path_index_closing_delimiter)
... |
0b75800f1c46c7b6451f92a07a23ffe6749a8416 | 2,264 | [
77685453
] | [] | %{"certifi": {:hex, :certifi, "1.0.0", "1c787a85b1855ba354f0b8920392c19aa1d06b0ee1362f9141279620a5be2039", [:rebar3], []},
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], []},
"erlzk": {:git, "https://github.com/huaban/erlzk.git", "a005aab956e88... |
0b759520272986d146bb37dcee674533eb423aad | 2,245 | [
472516020
] | [
"test"
] | defmodule Spotify_API_Test do
use ExUnit.Case
doctest Spotify_API
# ascending
test "should create ascending pagination for result = page_size" do
expected = [
%{offset: 0, limit: 5}
]
result = Spotify_API.Paging.create_paging_parameters(5, 5)
assert(expected == result)
end
test "shou... |
0b7597eb9289732b9a0809e4e36102ad85e37c65 | 13,100 | [
540018478
] | [
"typespec",
"documented"
] | defmodule Instance.SystemAI.Parser do
@moduledoc """
Parses JSON files created from the [Behavior Tree visual
editor](https://github.com/adobe/behavior_tree_editor) into a `BehaviorTree.Node`,
ready to be supplied to a bot.
Note, you can automatically import your defined Actions into the visual editor with
... |
0b75a870bc1591133a391f8f4620f7d7284bcb15 | 2,127 | [
317589041
] | [
"documented"
] | defmodule Day18 do
@moduledoc """
Solution for day 18 of AoC 2020 in Elixir.
"""
def tokenize(line) do
Regex.scan(~r/\d+|[\+\*\(\)]/, line)
|> Enum.map(fn [c|_] -> c end)
end
def parse_params(toks, acc \\ [], i \\ 1) do
if i == 0 do
[_ | inner] = acc
{Enum.reverse(inner), t... |
0b761b713789d22ff2fcfe582d012033ad560bd3 | 2,771 | [
389146705
] | [
"test",
"ecto"
] | defmodule FcGuilds.GuildEventsTest do
use FcGuilds.DataCase
alias FcGuilds.GuildEvents
describe "guild_events" do
alias FcGuilds.GuildEvents.GuildEvent
@valid_attrs %{duration: 42, event_date: "2010-04-17T14:00:00Z", title: "some title"}
@update_attrs %{duration: 43, event_date: "2011-05-18T15:01:0... |
0b76ddf356a8080564a364197a53fbf87482eefe | 2,303 | [
32404260
] | [] | Code.require_file("spec_formatters/custom_formatter.ex")
Code.require_file("spec_formatters/spec_helper.exs")
defmodule DiffShowcaseSpec do
use ESpec, async: true
it "shows eq" do
expect([1 + 1]) |> to(eq 2)
end
it "shows eql" do
expect(" one") |> to(eq "none ")
end
it "shows be" do
expect(2... |
0b775bc78e4694510b8b752a78f677e607aa6b55 | 2,736 | [
198798318
] | [
"genserver",
"liveview"
] | defmodule GrasstubeWeb.PollsLive do
use GrasstubeWeb, :live_view
alias Grasstube.{ChatAgent, PollsAgent, Presence, ProcessRegistry}
def render(assigns) do
GrasstubeWeb.PageView.render("polls_live.html", assigns)
end
def mount(_params, %{"room" => room, "current_user" => current_user, "chat" => chat}, s... |
0b7769e341c1fcb935df3e4f298e94ca6d781426 | 3,789 | [
10550954
] | [
"typespec",
"documented"
] | defmodule Edeliver.Relup.Instructions.StartSection do
@moduledoc """
This upgrade instruction starts a new section
and logs that info on the node which runs the upgrade and
in the upgrade script started by the
`$APP/bin/$APP upgrade $RELEASE` command. Usage:
```
Edeliver.Relup.Instructions.S... |
0b7816a6a172b55ad8bdcb492d5a6b2c96b60d93 | 1,799 | [
90559172
] | [
"phoenix"
] | defmodule WebApi.AccountController do
use WebApi.Web, :controller
alias WebApi.{Account, WidgetSender}
def index(conn, _params) do
accounts = Repo.all(Account)
render(conn, "index.json", accounts: accounts)
end
def create(conn, %{"account" => account_params}) do
changeset = Account.changeset(%A... |
0b785f9a9966e6f320d54a108a96be6b021f1a9e | 1,624 | [
108323713
] | [
"documented",
"ecto"
] | defmodule Autocar.Accounts.Provider do
use Ecto.Schema
import Ecto.Changeset
alias Autocar.Accounts.{Provider, User}
alias Autocar.CMS.Request
schema "providers" do
field :address, :string
field :aditional_phone, :string
field :brands, :string
field :company_name, :string
field :company... |
0b78a068fa7fac1ac47f441d7620b858e0e39455 | 1,577 | [
102243516
] | [
"macro",
"documented",
"phoenix"
] | defmodule TlauiWeb 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 TlauiWeb, :controller
use TlauiWeb, :view
The definitions below will be executed for every view,
controller, etc, s... |
0b7968ea99eb7bd8dcb0734ccc99b8dde21ed335 | 1,579 | [
50200655
] | [
"phoenix"
] | defmodule Clase2.RegistrationController do
use Clase2.Web, :controller
alias Clase2.Bank
alias Clase2.User
alias Clase2.Repo
alias Clase2.Card
def register(conn, {who, changeset}) do
if changeset.valid? do
write_registry(conn, {who, changeset})
else
send_registry_error(conn, {who, changese... |
0b7a084cb2bf6765f85088694ffd02971464bcd6 | 3,389 | [
708213978
] | [
"documented",
"ecto"
] | defmodule MangaService.VolumesDB do
@moduledoc """
The Volumes context.
"""
import Ecto.Query, only: [from: 2], warn: false
alias MangaService.Repo
alias MangaService.VolumesDB.Volume
def parse_integer!(string) do
case Integer.parse(string || "0") do
{number, _} -> number
:error -> 0
... |
0b7a27addf332ba4992ba14af62378b1d11f9db5 | 1,518 | [
557934311
] | [] | defmodule KVServer do
require Logger
def accept(port) do
# The options below mean:
#
# 1. `:binary` - receives data as binaries (instead of lists)
# 2. `packet: :line` - receives data line by line
# 3. `active: false` - blocks on `:gen_tcp.recv/2` until data is available
# 4. `reuseaddr: tr... |
0b7adfa8b266fbeffaa7373ac74cb9f1efc6f1ca | 2,867 | [
251141161
] | [
"test"
] | defmodule Chess.BoardTest do
use ExUnit.Case
import Chess.Factory
alias Chess.Board
alias Chess.Piece
describe "create/0" do
test "succesfully creation board" do
assert %Board{} = Board.create()
end
end
describe "add_piece/2" do
test "succesfully add piece on board" do
board = ... |
0b7b2bfdb01b7d27d48a348f942a1af1b4f35ca9 | 3,245 | [
571044780
] | [
"documented"
] | defmodule ParkingLot.CustomersFixtures do
@moduledoc """
This module defines test helpers for creating
entities via the `ParkingLot.Customers` context.
"""
import ParkingLot.Digits, only: [sigil_d: 2]
alias ParkingLot.Customers
alias ParkingLot.Digits
alias ParkingLot.Document
alias ParkingLot.Phone
... |
0b7b51ecea73e36b7e49edcfa96e59b64504bd65 | 3,499 | [
193244709
] | [
"typespec",
"documented"
] | defmodule GoogleApi.Dataform.V1beta1.Model.ReleaseConfig do
@moduledoc """
Represents a Dataform release configuration.
## Attributes
* `codeCompilationConfig` (*type:* `GoogleApi.Dataform.V1beta1.Model.CodeCompilationConfig.t`, *default:* `nil`) - Optional. If set, fields of `code_compilation_config` overr... |
0b7b8871f7f38e00d81dcf3e4716f97a6e6f8baf | 3,618 | [
967831208
] | [
"test",
"documented"
] | defmodule WebsockexNova.Behaviors.MessageHandlerTest do
use ExUnit.Case, async: true
# Define a mock module that implements the MessageHandler behavior
defmodule MockMessageHandler do
@moduledoc false
@behaviour WebsockexNova.Behaviors.MessageHandler
def message_init(opts) do
send(opts[:test_p... |
0b7ba4b97e0c2575713ebb0a50b33d86501a4e16 | 2,659 | [
240457237,
59786258,
250209979,
261426583,
236611337,
246627270,
252248528,
242563663,
246632238,
263685306
] | [] | %{
"certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "805abd97539caf89ec6d4732c91e62ba9da0cda51ac462380bbd28ee697a8c42"},
"hackney": {:hex, :hackney, "1.15.2", "... |
0b7bacc0e5ff7103b438eb79c5fbad483db3af49 | 2,555 | [
295290852
] | [
"genserver"
] | defmodule Console.Watchers.Upgrade do
use Console.Watchers.Base, state: [:upgrades, :queue_id, :target, :last]
alias Console.Deployments.Statistics
alias Console.Plural.{Upgrades, Socket}
alias Console.Watchers.Plural
@poll_interval 60 * 1000
@resource_interval :timer.minutes(60)
def handle_call(:state,... |
0b7bc6132f8b546aaca84f22e880037e817dd660 | 1,674 | [
154017495
] | [
"macro",
"documented",
"phoenix"
] | defmodule FileSurrenderWeb 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 FileSurrenderWeb, :controller
use FileSurrenderWeb, :view
The definitions below will be executed for every vi... |
0b7bdcac669708f8fe21592b442356db6383e8aa | 1,991 | [
708706694
] | [] | defmodule TCPClient do
def start(player_id) do
start('localhost', 4000, player_id)
end
def start(hostname, port, player_id) do
socket = Client.connect(hostname, port)
IO.puts("#{player_id} connected to #{hostname}:#{port}")
:welcome = Client.identify(player_id, socket)
IO.puts("server welcome... |
0b7c3d8afd41aae6ec48268423198574bf86a2c4 | 1,897 | [
120684714
] | [] | defmodule GrovePositioningSystem do
def read_input(filename) do
{:ok, data} = File.read(filename)
data
|> String.split("\n")
|> Enum.map(fn s -> String.to_integer(s) end)
|> Enum.with_index()
end
def find_current_position(original_position, encrypted) do
Enum.find_index(encrypted, fn {_n... |
0b7c46ccc579f12b0e00e358fb50c37609b96820 | 2,798 | [
317715024
] | [] | defmodule DAY23 do
def parse_input() do
File.read!("inputs/day_23.input")
|> String.split("\n")
|> Enum.with_index(0)
|> Enum.flat_map(fn {row, y} ->
String.graphemes(row)
|> Enum.with_index
|> Enum.map(fn {el, x} -> {el, {y,x}} end)
end)
|> Enum.into(%{}, fn {el, pos} -> {po... |
0b7ccb545cf49be06836cf838abbb2791d35ddc2 | 3,213 | [
664020166
] | [
"phoenix"
] | defmodule RecordidWeb.Router do
use RecordidWeb, :router
import RecordidWeb.UserAuth
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, html: {RecordidWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_secure_browser_heade... |
0b7ceaebf342a62ee4327468ba66cb7e1b98a5f1 | 2,278 | [
179918085,
157010549
] | [
"documented",
"ecto"
] | defmodule Studor.Students do
@moduledoc """
The Students context.
"""
import Ecto.Query, warn: false
alias Studor.Repo
alias Studor.Students.Student
@doc """
Returns the list of students.
## Examples
iex> list_students()
[%Student{}, ...]
"""
def list_students do
Repo.all(Stu... |
0b7d32085ca8eb30952ad16549cca3a91733ebe3 | 3,831 | [
195741418,
388511880,
603610250,
762131773,
970389734,
579412520,
746798402,
385691311,
820624395,
682357176,
719664534,
609216219,
574323694,
394023530,
511371868,
675225385,
580235090,
823014073,
399631385,
417119332,
424214145,
424400274,
739033590,
558629623,
5652... | [
"typespec",
"documented",
"ecto"
] | defmodule Pleroma.MFA do
@moduledoc """
The MFA context.
"""
alias Pleroma.User
alias Pleroma.MFA.BackupCodes
alias Pleroma.MFA.Changeset
alias Pleroma.MFA.Settings
alias Pleroma.MFA.TOTP
@doc """
Returns MFA methods the user has enabled.
## Examples
iex> Pleroma.MFA.supported_method(User... |
0b7d4c42cb1b1c627d76687d4eef924432ada0bd | 1,586 | [
377882024
] | [] | defmodule ReturnStatementNDFA do
def checkToken(stream, xml_carry, index \\ 0, tokenState \\ 0) do
tokenObj = Lexer.lexer(stream, index)
token = tokenObj["token"]
tokenType = tokenObj["type"]
nextIndex = tokenObj["index"]
case tokenState do
0 ->
IO.inspect("Checking token Retur... |
0b7da7ce077bbfe8baa6218c4f2c107e3f25f841 | 3,151 | [
726584041
] | [
"typespec",
"documented"
] | defmodule AdventOfCode2023.Day17 do
import Record
@moduledoc """
Day 17 of Advent of Code 2023.
"""
@spec part1([String.t()]) :: integer
def part1(lines), do: solve(lines, 1..3)
@spec part2([String.t()]) :: integer
def part2(lines), do: solve(lines, 4..10)
# ===== Helper functions =====
@type coo... |
0b7df51dc3be7d564846699a86598c35169e933e | 15,427 | [
345517080,
279914339
] | [
"typespec",
"macro",
"documented"
] | defmodule Tesla.Error do
defexception env: nil, stack: [], reason: nil
def message(%Tesla.Error{env: %{url: url, method: method}, reason: reason}) do
"#{inspect(reason)} (#{method |> to_string |> String.upcase()} #{url})"
end
end
defmodule Tesla.Env do
@moduledoc """
This module defines a `t:Tesla.Env.t... |
0b7e04fd2d71e8135c920e718e31f269292916fb | 7,992 | [
226820764
] | [
"genserver",
"liveview"
] | defmodule MishkaHtmlWeb.ResetChangePasswordLive do
use MishkaHtmlWeb, :live_view
alias MishkaUser.Validation.RandomCode
# TODO: change this with config
@hard_secret_random_link "Test refresh"
@impl true
def render(assigns) do
Phoenix.View.render(MishkaHtmlWeb.ClientAuthView, "reset_change_password_liv... |
0b7e220d27170d94cb6f47cbef19bedecaf5e522 | 10,371 | [
250923883
] | [] | %{
"boundary": {:hex, :boundary, "0.4.4", "46dbe9bd7b1565a69ef7c83e4964c480e1079686c7ffaed1d5942fb4691f8ebe", [:mix], [], "hexpm", "d6adb866b283812bf3fb7177ac88e36fab4d011ae58a8aa7edfa61ba6736cb3e"},
"castore": {:hex, :castore, "0.1.5", "591c763a637af2cc468a72f006878584bc6c306f8d111ef8ba1d4c10e0684010", [:mix], [],... |
0b7e4fc01fc8be4fe008ed046e6123c03e3d8989 | 6,906 | [
59428665,
800630804,
933455501
] | [
"typespec",
"documented"
] | defmodule Benchee.Conversion.Scale do
@moduledoc """
Functions for scaling values to other units. Different domains handle
this task differently, for example durations and counts.
See `Benchee.Conversion.Count` and `Benchee.Conversion.Duration` for examples
"""
alias Benchee.Conversion.Unit
@type unit ... |
0b7e930d1e1dd25aa9a2d6361f12f398dc40824f | 1,864 | [
520916947
] | [] | defmodule Tower.Helpers.AccessToken do
import Tower.Config, only: [repo: 0, generator: 0]
alias Tower.Models.AccessToken
def insert_access_token(nil, _), do: {:error, "Token could not be created"}
def insert_access_token(token, resource_owner_id: resource_owner_id, application_id: application_id, scopes: ... |
0b7ed412454f1a6c2c2f8e7a3dcc88d23651a974 | 2,492 | [
193244709,
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.Script.V1.Model.File do
@moduledoc """
An individual file within a script project. A file is a third-party source code created by one or more developers. It can be a server-side JS code, HTML, or a configuration file. Each script project can contain multiple files.
## Attributes
* `creat... |
0b8027b2bc2cd075a73f92ff61f8b88daa4dd0ed | 2,083 | [
523834443
] | [
"genserver"
] | defmodule Airbag.Consumer do
@behaviour :gen_cycle
alias __MODULE__
alias Airbag.Buffer
require Logger
defstruct [:buffer_name, :partition_index, :dequeue_limit, :processor, :interval]
@default_interval 1
def start_link(opts) do
:gen_cycle.start_link(__MODULE__, opts)
end
@impl true
def init... |
0b807b1217da33ed7dbc4ffb3b46997486b85b32 | 2,027 | [
111740698
] | [] | use Mix.Config
# For production, we often load configuration from external
# sources, such as your system environment. For this reason,
# you won't find the :http configuration below, but set inside
# LivevoxWeb.Endpoint.init/2 when load_from_system_env is
# true. Any dynamic configuration should be done there.
#
# Do... |
0b80a341b5ba059d63f9cd283f256a079618312f | 2,321 | [
237045775
] | [
"genserver",
"documented"
] | defmodule Arduiner.Servers.SerialPortServer do
use GenServer
alias Circuits.UART, as: Port
@moduledoc """
A GenServer which represents the connection to the Arduino. The GenServer itself is always active
as it starts a child GenServer for the Port communication.
"""
# Client side API
@doc false
de... |
0b80a8772a6724ad25cc17e1cdc3a328c1e874ae | 2,219 | [
824775390
] | [
"phoenix",
"ecto"
] | defmodule ScoregoblinWeb.GameController do
use ScoregoblinWeb, :controller
alias Scoregoblin.Games
alias Scoregoblin.Games.Game
def index(conn, _params) do
games = Games.list_games()
render(conn, :index, games: games)
end
def new(conn, _params) do
changeset = Games.change_game(%Game{})
a... |
0b80f95603f14e49281fedf3e6ea0b499c97d15f | 4,538 | [
442713912
] | [
"documented"
] | defmodule NotionUrlId do
@moduledoc """
Should parse a notion url and raise an error if it's not correct
"""
def call(notion_url) do
notion_url |> String.trim() |> String.split("-") |> List.last()
end
end
defmodule NotionHttpClient do
@notion_api_key System.get_env("NOTION_API_KEY")
@moduledoc """
... |
0b8140541da7f89698dbeec60a63d32fa2a0af28 | 1,890 | [
138639402
] | [] | # Import all plugins from `rel/plugins`
# They can then be used by adding `plugin MyPlugin` to
# either an environment, or release definition, where
# `MyPlugin` is the name of the plugin module.
Path.join(["rel", "plugins", "*.exs"])
|> Path.wildcard()
|> Enum.map(&Code.eval_file(&1))
use Mix.Releases.Config,
# T... |
0b82296c0474fd65b25bbabab76e991bb2464255 | 5,323 | [
75769666
] | [] | defmodule TR do
# [ { path e.g.: "t:/Pubs/P2"
# , recsByGroup List of lists, each sublist is a newspaper/magazine
# , nonTRMs Files where the base conforms to \d{4} but the
# } extension is not TRM or trm. All other files are ignored.
# , {...}
# , {...}
... |
0b8274f588111c283579b53ef919bc8194cb27fd | 1,756 | [
160069062
] | [
"documented"
] | defmodule Keypad.Directional do
@moduledoc """
Functions for a directional keypad.
```
+---+---+
| ^ | A |
+---+---+---+
| < | v | > |
+---+---+---+
```
"""
def move_permutations({from, to}) do
{fy, fx} = location(from)
{ty, tx} = location(to)
{dy, dx} = {ty - fy, tx - fx}
... |
0b8297ad8fd63532d92d0075c7d476ec1c74eb11 | 2,263 | [
42089133
] | [
"genserver"
] | defmodule APNS.FeedbackWorker do
use Connection
def start_link(pool_conf) do
Connection.start_link(__MODULE__, pool_conf, [])
end
def init(pool_conf) do
state = APNS.State.get(pool_conf)
{:connect, :init, state}
end
# -- server
def connect(_, _state, sender \\ APNS.Sender)
def connect(:... |
0b829a73f7bb14973935791da49d4de4abcb97f0 | 1,541 | [
126006317
] | [
"documented"
] | defmodule Mix.Tasks.Virtuoso.Gen.Routine do
@moduledoc """
Generates a basic routine for a given Bot.
mix virtuoso.gen.bot BotName RoutineName
The first argument is the bot's module name (BotName).
The second argument is the desired routine module name (RoutineName)
Generates `project/lib/bot/routine/... |
0b83060648b09e608473648194c126f8765f1a62 | 2,252 | [
726882148
] | [] | defmodule Advent2023.Day07 do
use Advent2023.Day, input: :lines
def part_one(input) do
input
|> Enum.map(&parse_line/1)
|> Enum.map(fn {hand, bid} -> {Enum.map(hand, &rank_card(&1, jacks: :high)), bid} end)
|> Enum.sort_by(&classify_hand(&1, jacks: :normal))
|> Enum.with_index(1)
|> Enum.ma... |
0b8401ef9a797cab0a7e8a1b4dd070364c9a0698 | 6,137 | [
353779559
] | [
"documented"
] | defmodule OnFlow.Execution.PingRequest do
@moduledoc false
use Protobuf, protoc_gen_elixir_version: "0.11.0", syntax: :proto3
end
defmodule OnFlow.Execution.PingResponse do
@moduledoc false
use Protobuf, protoc_gen_elixir_version: "0.11.0", syntax: :proto3
end
defmodule OnFlow.Execution.GetAccountAtBlockIDReq... |
0b8406ddefa7f6ec9d7813fc961d848604f3ea6c | 6,442 | [
821119358
] | [
"test"
] | defmodule DeckTest do
use ExUnit.Case
doctest Deck
require(Deck)
@valid_ranks ~w(9 J Q K 10 A)
@valid_suits ~w(C D H S)
test "[new] new deck generation" do
deck = Deck.new()
assert length(deck.cards) == length(@valid_ranks) * length(@valid_suits)
# generate list of all possible cards to chec... |
0b8480cb6eccc6c2fa36a7cbccb3350ca89dc192 | 5,830 | [
1010011901
] | [
"documented"
] | defmodule Sui.Rpc.V2beta.EndOfEpochTransactionKind do
@moduledoc """
Operation run at the end of an epoch.
"""
use Protobuf, protoc_gen_elixir_version: "0.14.1", syntax: :proto3
def descriptor do
# credo:disable-for-next-line
%Google.Protobuf.DescriptorProto{
name: "EndOfEpochTransactionKind",... |
0b84eb540db0090910e6e0afb3f1caed5ab14f50 | 3,321 | [
471617373
] | [
"documented"
] | defmodule Mix.Tasks.Trogon.TypeProvider.List do
@moduledoc """
Lists all registered type mappings for a given TypeProvider module.
## Usage
mix trogon.type_provider.list TypeProvider
## Examples
# List all types in a specific provider
mix trogon.type_provider.list MyApp.EventTypeProvider
... |
0b8557bef8a15218926d6485f174d7c8becefa0e | 9,474 | [
886069713
] | [
"liveview"
] | # lib/songapp_web/live/home_phoenix_live.ex
defmodule SongappWeb.HomeLive do
use SongappWeb, :live_view
def mount(_params, _session, socket) do
{:ok, socket}
end
def render(assigns) do
~H"""
<%!-- <h1>Home Page</h1> --%>
<%!-- <nav> --%>
<%!-- <a href="#" phx-click="nav... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.