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 |
|---|---|---|---|---|
080f1925d5e0f6f866d22c59b4ed6b962531ecb7 | 1,915 | [
101512326
] | [
"ecto"
] | defmodule ArchitectWeb.Mutations.KnownHostsMutations do
use Absinthe.Schema.Notation
alias Absinthe.Subscription
alias Architect.KnownHosts
require Logger
alias Architect.Repo
object :known_hosts_mutations do
@desc "Create unverified known host"
field :create_known_host, non_null(:known_host_payloa... |
080f3050e8c5d54d1b35cb707faf6f0ca9fa8796 | 2,485 | [
573164331
] | [
"documented"
] | defmodule AdventOfCode2022.RockPaperScissors do
@moduledoc false
@win_points 6
@draw_points 3
@lose_points 0
def calc_score(games_file_path) do
games_file_path
|> File.read!()
|> String.split("\n")
|> Enum.reduce(0, fn game, total_score ->
score =
game
|> String.split("... |
080f7f26b1652cd98548999e1f905a6bfdea02d6 | 2,804 | [
953756529
] | [] | # 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 :ash,
allow_forbidden_field_for_relationship... |
0810c337f8c0995b65685dca2ac9caea308ff376 | 2,036 | [
102414376
] | [
"test"
] | defmodule Sengoku.AuthenticationTest do
use ExUnit.Case, async: true
alias Sengoku.{Authentication, Player}
describe "authenticate_player/3" do
test "with no player_id, replaces the first AI player" do
old_state = %{
turn: 0,
players: %{
1 => %Player{ai: false},
2 =... |
08111c4e79c62a647585751a68ffc02a84a60b02 | 1,858 | [
465178265
] | [
"test"
] | defmodule FzCommon.FzNetTest do
use ExUnit.Case, async: true
alias FzCommon.FzNet
describe "ip_type/1" do
test "it detects IPv4 addresses" do
assert FzNet.ip_type("127.0.0.1") == "IPv4"
end
test "it detects IPv6 addresses" do
assert FzNet.ip_type("::1") == "IPv6"
end
test "it r... |
0811895bac87ab90b8e0796cf758272b7cd2d7fd | 1,807 | [
167046908
] | [
"typespec"
] | defmodule Eager do
@type atm :: {:atm, atom()}
@type var :: {:var, atom()}
@type cons(expresion) :: {:cons, expresion, expresion}
def eval_expr({:atm, value}, []) do {:ok, value} end
def eval_expr({:var, value}, env) do
case Env.lookup(value, env) do
nil ->
:error
{_, structure} ->
... |
0811c6df50c7e0aecaef8ab8ec7397721b52ffad | 6,017 | [
120253392
] | [] | defmodule Calc do
def main() do
input = IO.gets("Enter expression without parenthesis and hit enter \n")
IO.puts(eval(input))
main()
end
def eval(line) do
line = clean_whitespace(line)
line = solve_parenthesis(line)
line = solve_multi_divi(line)
line = solve_add_sub(line)
parse_ex... |
0811dc93d4e97e0340704f727270b4ee51cb998d | 5,223 | [
507349355
] | [
"phoenix",
"ecto"
] | defmodule OmegaBraveraWeb.AdminPanelOfferController do
use OmegaBraveraWeb, :controller
import Ecto.Query
alias OmegaBravera.{
Repo,
Offers,
Offers.Offer,
Fundraisers.NgoOptions,
Offers.OfferChallenge
}
use Timex
plug :assign_available_options when action in [:edit, :new]
def inde... |
0812edfd1c6cd44ff851e71f0becb2f59e4a9ed1 | 4,262 | [
371549682
] | [] | %{
"assignment_messages": {:git, "https://github.com/distributed-applications-2021/assignment-messages", "4b66e589e0c5d39a570058a5a2a306141fa62ccd", [branch: "main"]},
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm", "4a0850c9be22a43... |
081497bb725d29e0c5b83fe25a9231eb18e2a848 | 1,697 | [
369019496
] | [
"genserver"
] | defmodule Server.Protocol do
require Logger
use GenServer
alias Server.Client
@behaviour :ranch_protocol
def start_link(ref, transport, _opts) do
pid = :proc_lib.spawn_link(__MODULE__, :init, [ref, transport])
{:ok, pid}
end
def init(ref, transport) do
{:ok, socket} = :ranch.handshake(ref... |
08151864c015adffac693f493e1ac6256a73d976 | 1,539 | [
103553409
] | [
"documented"
] | defmodule Servy.TwilioTasks do
@moduledoc """
handles asynchronous dispatch to Twilio
"""
def twilio_url() do
#this needs to be a configuration set item
#for now it is hardcoded to a fake address here
"https://damp-journey-48506.herokuapp.com"
end
def std_headers() do
# nope: headers = %{ 'content-type' ... |
081570dfe33c5d6a9b49a770802cd96b0403f8e2 | 2,720 | [
157366169
] | [
"genserver"
] | defmodule Pizzeria.Table do
use GenServer
# We use some alias to avoid too much typing
# Log module puts some color on the terminal
alias Pizzeria.Log
# This stuct will contain the state of our gen server
# Similar to a map, with some default and validation
defstruct phase: :deciding
# Some constant. ... |
0815e2a47247ace3dcbd73912031edb09d891c63 | 1,856 | [
897655349
] | [
"typespec",
"documented"
] | defmodule AstralDiscord.Interactions do
@moduledoc """
Register slash commands and handles interactions
"""
require Logger
alias Nostrum.Api
alias AstralDiscord.Interactions.{Register}
@spec register_commands() :: any()
def register_commands do
{public_commands, _private_commands} =
[
... |
08160c2f89e0f70e9a60601b914c42b9e37509ef | 2,279 | [
88336584
] | [] | defmodule Datjournaal.Mixfile do
use Mix.Project
def project do
[app: :datjournaal,
version: "0.0.1",
elixir: "~> 1.2",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
... |
0816242a22c131c31f86443054667ab2e2e1d069 | 1,752 | [
152831879
] | [
"genserver",
"documented"
] | defmodule Chord.LocationServer do
@moduledoc """
Location Server to get a node n' to join a network.l
TODO: A scalable solution to location service. http://cs.brown.edu/~jj/papers/grid-mobicom00.pdf
"""
use GenServer
require Logger
###
###
### Client API
###
###
@doc """
Chord.Location... |
0816f4e0b65eec838d54d8096c2d7d418ae06818 | 7,751 | [
189251630
] | [
"test"
] | defmodule Dotcom.RoutePdfsTest do
use ExUnit.Case, async: true
import Dotcom.RoutePdfs
alias CMS.Partial.RoutePdf
@date ~D[2018-01-01]
describe "fetch_and_choose_pdfs/2" do
test "returns at least one result" do
assert [_at_least_one_result | _] = fetch_and_choose_pdfs("87", ~D[2019-01-01])
e... |
08173b6b47397219c9970ac0d34fb220f1b34900 | 4,758 | [
317893940
] | [
"test"
] | defmodule DayTen.DayTenTest do
use ExUnit.Case
@short_input "16
10
15
5
1
11
7
19
6
12
4"
@long_input "28
33
18
42
31
14
46
20
48
47
24
23
49
45
19
38
39
11
1
32
25
35
8
17
7
9
4
2
34
10
3"
test "handle small test input" do
i... |
0817ca1a33c64c665a81830e7bc356c960d9b690 | 2,432 | [
405565073
] | [] | defmodule NatureRemoCli.App do
@behaviour Ratatouille.App
import Ratatouille.View
alias NatureRemoCli.Api
alias NatureRemoCli.Interface.{ApplicanceComponent, SensorComponent, AirconComponent}
alias Ratatouille.Constants
@enter Constants.key(:enter)
@esc Constants.key(:esc)
def init(_context \\ %{}) ... |
0817ea09b4b41bd5f6265593e015486333c1b947 | 1,750 | [
86494113
] | [
"test"
] | defmodule BusCarDslShouldTest do
use ExUnit.Case
doctest BusCarDsl.Should
alias BusCarDsl.Should
test "parse :should :match list accumulates correctly" do
result = Should.parse([:should, :match, "name", 344], [])
assert result == {[], [%{match: %{"name" => %{query: 344}}}]}
end
test "parse :should... |
081806a316c5f178e668e1781fa5c4f22ed882d8 | 1,589 | [
122717336
] | [
"macro",
"documented",
"phoenix"
] | defmodule DarfeyWeb 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 DarfeyWeb, :controller
use DarfeyWeb, :view
The definitions below will be executed for every view,
controller, etc... |
08184b20d322fe4c5ddcb9136d0c709b6e39ee1f | 5,127 | [
930600936
] | [
"documented"
] | defmodule TriviaAdvisor.VenueStatistics do
@moduledoc """
Context module for handling venue statistics and geographical data for visualizations.
"""
import Ecto.Query, warn: false
alias TriviaAdvisor.Repo
alias TriviaAdvisor.Locations.Venue
alias TriviaAdvisor.Cache
# Cache key for active venues count... |
0818fcc5f1635e9eb3842c44ace9e0dfeba005c3 | 2,018 | [
756340681
] | [
"liveview",
"test"
] | defmodule DAUWeb.CoreComponentsTest do
alias Phoenix.LiveViewTest
alias DAUWeb.CoreComponents
use ExUnit.Case
import Phoenix.LiveViewTest
import Phoenix.Component
test "text media preview with single url" do
assigns = %{}
urls = ["https://example.com"]
component =
rendered_to_string(~H"... |
08190a649ad75fb5de805c33ab9385b0e4361698 | 8,109 | [
831995252
] | [
"typespec",
"documented"
] | defmodule ColouredFlow.Expression do
@moduledoc """
An Elixir expression.
"""
alias ColouredFlow.Expression.Env
alias ColouredFlow.Expression.EvalDiagnostic
alias ColouredFlow.Expression.Scope
@doc """
Converts a string to a quoted expression and returns its ast and the unbound
variables.
## Exam... |
081927b2c92283bb0c25c20394848ab0ad31d9ca | 6,413 | [
433484844
] | [
"test"
] | defmodule ExCubicIngestion.Workers.FetchDmapTest do
use ExCubicIngestion.DataCase, async: true
use Oban.Testing, repo: ExCubicIngestion.Repo
alias ExCubicIngestion.Schema.CubicDmapDataset
alias ExCubicIngestion.Schema.CubicDmapFeed
alias ExCubicIngestion.Workers.FetchDmap
describe "perform/1" do
test ... |
081949860c7e527eeb82713c7045e2e12cfa9605 | 1,916 | [
274654852
] | [
"macro",
"documented",
"phoenix"
] | defmodule PhxTestHogeWeb 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 PhxTestHogeWeb, :controller
use PhxTestHogeWeb, :view
The definitions below will be executed for every view,
... |
08194e5ed5c8861d4020afc821ab7ed00a0b7602 | 1,642 | [
40621234
] | [
"phoenix"
] | defmodule News.Plug.Authenticate do
import Plug.Conn
import News.Router.Helpers
import Phoenix.Controller
import News.I18n.Helper
def init(options \\ []), do: options
def call(conn, options) do
anon = Dict.get(options, :anon, false)
required_flags = Dict.get(options, :flags, [])
authenticate_r... |
08198d07ac451a44ebde6a1458347942003003fc | 1,528 | [
529381362
] | [
"liveview",
"phoenix"
] | defmodule ArvoreApiWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :arvore_api
# 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: "_arvo... |
08198eb79fabb28f5f59d37cc879e6dc8f39b39d | 1,647 | [
62610235
] | [
"typespec",
"documented"
] | defmodule Omise.Account do
@moduledoc ~S"""
Provides Account API interfaces.
<https://www.omise.co/account-api>
"""
use Omise.HTTPClient, endpoint: "account"
defstruct object: "account",
id: nil,
livemode: nil,
location: nil,
email: nil,
currenc... |
081a8c0cf8e03552b1ddb17bffcac0e54d99e3f5 | 8,711 | [
961658705
] | [
"typespec",
"documented"
] | defmodule Heaters.Clips.Operations.Shared.TempManager do
@moduledoc """
Centralized temporary directory management for transformation operations.
This module provides consistent temporary directory creation, cleanup, and
management patterns across all transformation operations, eliminating
duplicate implemen... |
081a8c820dca9123dcf3002e02a2053bc799b830 | 5,346 | [
59659564
] | [] | defmodule Tammes do
# helper function
def call(args, fun) do
apply(fun, args)
end
def call(args, fun, module) do
apply(module, fun, args)
end
def vector_fun(e1, e2, fun) do
Enum.zip(e1, e2)
|> Enum.map(&Tuple.to_list(&1))
|> Enum.map(&call(&1, fun))
end
def dot_product(c1, c2) d... |
081b1419f617954c6fb916e17ea95d99b2bd8e9e | 2,441 | [
367278931
] | [
"documented"
] | defmodule Google.Ads.Googleads.V18.Services.MutateKeywordPlanCampaignKeywordsRequest do
@moduledoc false
use Protobuf, protoc_gen_elixir_version: "0.14.1", syntax: :proto3
field :customer_id, 1, type: :string, json_name: "customerId", deprecated: false
field :operations, 2,
repeated: true,
type: Goog... |
081b8e170aabbb354d68ef104e53cbf2fff632ac | 3,256 | [
429142740,
888628980,
336673860,
314109232,
299711271,
429363580,
575166467,
851844573,
336679900,
297389399,
264829031,
766605102
] | [
"macro",
"documented"
] | defmodule Credo.Priority do
@moduledoc false
# In Credo each Issue is given a priority to differentiate issues by a second
# dimension next to their Category.
alias Credo.Code.Module
alias Credo.Code.Parameters
alias Credo.Code.Scope
alias Credo.SourceFile
@def_ops [:def, :defp, :defmacro]
@many_fu... |
081bb2bcce8e8f1d69000dbef3b83d7ab5cf8c0c | 1,897 | [
107278104
] | [] | defmodule ExAws.Dynamo.Mixfile do
use Mix.Project
@version "4.2.2"
@service "dynamo"
@url "https://github.com/ex-aws/ex_aws_#{@service}"
@name __MODULE__ |> Module.split() |> Enum.take(2) |> Enum.join(".")
def project do
[
app: :ex_aws_dynamo,
version: @version,
elixir: "~> 1.13",
... |
081d4ec2957d6e8884004db28818c0885fe96174 | 8,346 | [
135832997
] | [
"liveview"
] | defmodule Data.Article.Blog.BinnenhafenHarburg do
use Article.Default
def name(), do: "#{created_at()}-10-binnenhafen-harburg"
def created_at(), do: ~D[2019-01-08]
def title(), do: "Nartenstraße (Radroute 10)"
# def start(), do: ~d[2021-02-15]
# def stop(), do: ~d[2022-10-30]
def type(), do: :planned
... |
081d8cc95e0d9dbfca4d527a956701db1449ddac | 1,997 | [
196528207
] | [] | defmodule ApiGatewayWeb.Gql.Resolvers.SubListItemComment do
alias ApiGatewayWeb.Gql.Utils.Errors
alias ApiGateway.Models
def get_sub_list_item_comment(_, %{where: %{id: sub_list_item_comment_id}}, _) do
{:ok, Models.SubListItemComment.get_sub_list_item_comment(sub_list_item_comment_id)}
end
def get_sub_... |
081d9618fdeda69d8d0cf6659c7a5669a83e6033 | 2,505 | [
207940796
] | [
"phoenix",
"ecto"
] | defmodule CriusChatWeb.UserController do
use CriusChatWeb, :controller
alias CriusChat.Auth
alias CriusChat.Auth.User
def index(conn, _params) do
users = Auth.list_users()
render(conn, "index.html", users: users)
end
def new(conn, _params) do
changeset = Auth.change_user(%User{})
render(c... |
081e23d7cc4e81b419de9f7ccca4af0318ef3b60 | 3,813 | [
326738007
] | [
"typespec",
"documented",
"ecto"
] | defmodule Kalda.Payments do
@moduledoc """
The Payments context.
"""
require Logger
alias Kalda.Accounts.User
alias Kalda.Payments.Stripe
alias Kalda.Payments.BillingNotifier
import Ecto.Query, warn: false
alias Kalda.Repo
alias Kalda.Payments.SubscriptionEvent
@doc """
Get the stripe customer... |
081e7fd14b92f54ca5098a3200d173a8cfc3a54e | 2,970 | [
682235251
] | [
"typespec",
"liveview",
"ecto"
] | defmodule HelpWeb.WrongLive do
use HelpWeb, :live_view
@impl true
def mount(_params, _session, socket) do
{:ok,
assign(socket,
score: 0,
message: "Let's play",
guess: (:rand.uniform() * 10) |> round,
time: time_now(),
won?: false
)}
# |> IO.inspect()
# {... |
081ec28e18eb9600b3156c48bff6178916828cf3 | 3,137 | [
317109309
] | [
"genserver"
] | defmodule Servy.FourOhFourCounter do
use GenServer
@process_name :four_oh_four_counter
def start_link(_arg) do
GenServer.start_link(__MODULE__, %{}, name: @process_name)
end
def bump_count(route) do
GenServer.call(@process_name, {:bump_count, route})
end
def get_count(route) do
GenServer.c... |
081ed6f778d70f9438877e0143b9a5d136b0f690 | 3,674 | [
167747228
] | [
"documented",
"ecto"
] | defmodule StratRouletteApi.Strats do
@moduledoc """
The Strats context.
"""
import Ecto.Query, warn: false
alias StratRouletteApi.Repo
alias StratRouletteApi.Strats.GameType
@doc """
Returns the list of game_types.
## Examples
iex> list_game_types()
[%GameType{}, ...]
"""
def lis... |
081f244c58e23f1a4ff230e399529defe63936bf | 2,365 | [
197339344
] | [
"typespec",
"documented"
] | defmodule Calypte.Engine do
@moduledoc """
Algorithm behaviour for a pluggable algorithm.
As the execution part has many parts in common and there are different operations happening in
common and that algorithm doesn't bother with this things, the selection and execution parts are
separated from `Engine` imp... |
081f652bbf22036e2c658c0b135813e9ef469da8 | 5,339 | [
129697834
] | [
"typespec",
"macro",
"documented"
] | use Croma
defmodule Antikythera.Websocket do
@moduledoc """
Behaviour module for websocket handlers.
Note the naming convention of the websocket-related modules; we use `Websocket`, `WebSocket` is not allowed.
Websocket module of gears must `use` this module as in the example below.
`use Antikythera.Websoc... |
0820030671dde0ad6932d25577aecfbaa3ef0fbf | 1,884 | [
80109961
] | [
"test"
] | defmodule Membrane.Opus.Encoder.EncoderTest do
use ExUnit.Case, async: true
import Membrane.Testing.Assertions
import Membrane.ChildrenSpec
alias Membrane.Opus.Encoder
alias Membrane.RawAudio
alias Membrane.Testing.{Pipeline, Sink}
@input_path "test/fixtures/raw_packets"
@reference_path "test/fixture... |
0820f4924f50291acd7570067b13328f5e583592 | 2,496 | [
191456474
] | [
"test"
] | defmodule Kolt.MonitorTest do
use ExUnit.Case, async: true
import Kolt.Monitor
alias Mimic
import Mimic
@client :dummy_client
@endpoints [{'localhost', 9095}]
setup :verify_on_exit!
setup do
Mimic.stub(:brod)
Mimic.stub(:telemetry)
:ok
end
defp topic_offset_responses(topic) do
{:... |
08219783fee5173e7817a5a1472818e1c74a5e7a | 1,525 | [
527254920
] | [
"documented",
"ecto"
] | defmodule Reel.Saves do
@moduledoc """
Functions around saving movies.
"""
import Ecto.Changeset
import Reel.Repo
import Ecto.Query
alias Reel.Schemas.Save, as: Save
alias Reel.Schemas.Account, as: Account
defp get_save(account, movie) do
account_id = account.id
movie_id = movie.id
Sav... |
0821cc2be0ac340cea9437f9d2f6cb4b4fa44047 | 2,161 | [
907567329
] | [
"typespec",
"documented"
] | defmodule ExBanking.Users.UserAdapter do
@moduledoc """
Adapter for `ExBanking.Users.UsersTable`
"""
alias ExBanking.Users.UsersTable
defstruct [:id, :currencies]
@doc """
Create a new user without any currency stored
"""
@spec create_user(binary()) :: :ok | {:error, :user_already_exists | :wrong_ar... |
0821da154c79d5f31e3437062f09876f6bf6ff6f | 1,950 | [
105523229
] | [
"genserver",
"phoenix"
] | defmodule ChatterWeb.RoomChannel do
use Phoenix.Channel
alias ChatterWeb.Presence
def join("room:lobby", _payload, %{assigns: %{user_id: verified_user_id}} = socket) do
send(self(), :after_join)
messages = get_messages("lobby")
{:ok, %{user_id: verified_user_id, messages: messages}, socket}
end
... |
0822187e1168441342a3d39cef767520260acac0 | 1,523 | [
121324508
] | [
"macro",
"documented",
"phoenix"
] | defmodule EquilanWeb 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 EquilanWeb, :controller
use EquilanWeb, :view
The definitions below will be executed for every view,
controller, ... |
0822f3226335b062d25c5952e2253c193ee5c202 | 3,800 | [
840860523
] | [
"test",
"ecto"
] | defmodule MagicCommander.CardsTest do
use MagicCommander.DataCase
alias MagicCommander.Cards
describe "cards" do
alias MagicCommander.Cards.Card
import MagicCommander.CardsFixtures
@invalid_attrs %{name: nil, magic_card_id: nil, mana_cost: nil, cmc: nil, type_line: nil, oracle_text: nil, power: ni... |
0823325a1ab4158bf0a5b0d25ec66247f5ba050b | 8,892 | [
39921724
] | [
"typespec",
"documented"
] | defmodule Timex.Timezone.Local do
@moduledoc """
Contains the logic and parser for extracting local timezone configuration.
"""
alias Timex.DateTime, as: DateTime
alias Timex.Date, as: Date
alias Timex.Timezone.Database, as: ZoneDatabase
alias Timex.Parsers.ZoneInfo, ... |
082335fd4d7aca275882a02272c18dcea8a733f0 | 1,637 | [
165115442,
969189171
] | [
"documented"
] | defmodule Logflare.Lql.Validator do
@moduledoc false
import Logflare.Logs.SearchOperations.Helpers
alias Logflare.Utils.List, as: ListH
@timestamp_filter_with_tailing "Timestamp filters can't be used if live tail search is active"
@default_max_n_chart_ticks 250
def validate(lql_rules, opts) do
%{
... |
0823f831f3c3e6d56ee8d97786f7ef76f702eca6 | 1,957 | [
113168366
] | [] | defmodule Advent do
defmodule State do
defstruct [:row, :col, :dir, :letters, :steps]
end
def solve(input) do
{maze, start_col} = parse(input)
walk(maze, %State{row: 1, col: start_col, dir: :south, letters: [], steps: 1})
end
def parse(input) do
maze = String.split(input, "\n", trim: true)
... |
08241b397d8ba7cf0ffce11e2ccaf830ef69f019 | 2,244 | [
803502084,
750475301
] | [
"typespec",
"documented"
] | defmodule OneDHCPD.Utility do
@moduledoc false
@spec decode_integer(<<_::32>>) :: non_neg_integer()
def decode_integer(<<a::integer-size(32)>>), do: a
def encode_integer(type, a), do: <<type, 4, a::integer-size(32)>>
@spec decode_short(<<_::16>>) :: 0..65535
def decode_short(<<a::integer-size(16)>>), do: ... |
08241d479de165fe5897b075e70cb5cc6516b0c6 | 2,949 | [
168637688,
190667844,
171961091
] | [
"test",
"phoenix"
] | defmodule ArtemisWeb.UserControllerTest do
use ArtemisWeb.ConnCase
import Artemis.Factories
@create_attrs %{email: "some@email", name: "some name"}
@update_attrs %{email: "some_updated@email", name: "some updated name"}
@invalid_attrs %{email: nil, name: nil}
setup %{conn: conn} do
{:ok, conn: sign_i... |
082455b8182e510ad0f0ebc0cbc63ae61d7b9f44 | 6,937 | [
93765520,
99250164
] | [
"typespec",
"macro",
"documented"
] | defmodule HashDict do
@moduledoc """
WARNING: this module is deprecated.
Use the `Map` module instead.
"""
# TODO: Remove by 2.0
# (hard-deprecated in elixir_dispatch)
use Dict
@node_bitmap 0b111
@node_shift 3
@node_size 8
@node_template :erlang.make_tuple(@node_size, [])
@opaque t :: %__MO... |
0824a0ca8768d98129e2672d14af2605fcf06f2a | 8,008 | [
162377738
] | [
"documented"
] | defmodule Innerpeace.Db.Datatables.ProductDentalRiskShareDatatable do
@moduledoc ""
import Ecto.Query
alias Plug.CSRFProtection
alias Innerpeace.Db.{
Repo,
Schemas.Facility,
Schemas.Product,
Schemas.ProductCoverage,
Schemas.ProductCoverageFacility,
Schemas.ProductCoverageDentalRiskShare... |
082599e463a3b0ca832049ba1b174aec968bd50d | 1,523 | [
498675807
] | [
"test"
] | defmodule AppCount.Finance.FinanceBoundaryTest do
use AppCount.Case
alias AppCount.Finance.FinanceBoundary
defmodule AccountRepoParrot do
use TestParrot
parrot(:repo, :all, [])
parrot(:repo, :insert, {
:ok,
%AppCount.Finance.Account{
name: "Some Account",
number: "123456... |
0826152ff91758ad1219f4ba34f0401352865d15 | 1,748 | [
753729948,
753281487
] | [
"typespec",
"documented"
] | defmodule Circuits.RGB do
@moduledoc """
This module enables Elixir programs to interact with hardware that's connected
via a SPI bus.
"""
alias Circuits.RGB.Bus
@typedoc """
Backends specify an implementation of a Circuits.SPI.Backend behaviour
The second parameter of the Backend 2-tuple is a list o... |
08268ffa50a12404b438ea008adec5ec1893e675 | 1,683 | [
169586276
] | [
"genserver"
] | defmodule FreddieClient.PerfCollector do
use GenServer
require Logger
defstruct total_received_byte: 0, completed_num: 0, tasks: [], profiling_time: 0, max_num: 0
def start_link(args) do
GenServer.start_link(__MODULE__, args, name: __MODULE__)
end
@impl true
def init(args) do
session_num = Key... |
0826ecc5028bd550c097456093e5ef9a27833b89 | 3,623 | [
193244709,
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.Integrations.V1.Model.GoogleCloudIntegrationsV1alphaTestIntegrationsRequest do
@moduledoc """
The request for testing an integration.
## Attributes
* `clientId` (*type:* `String.t`, *default:* `nil`) - Required. This is used to identify the client on whose behalf the event will be execut... |
0827959c594dbf69eb5f88da78280a2c024642b8 | 10,219 | [
650700339
] | [
"phoenix",
"documented"
] | if Application.get_env(:api, :tanbits_shim)[:include_vnext] do
defmodule JetzyApi.V2_0.Referral.Controller do
use JetzyApi, :controller
use PhoenixSwagger
#---------------------------------------
# def index/2
#---------------------------------------
swagger_path :index do
PhoenixSwagger.Path.get "/v2... |
0827f29d35e0bdae1f68a72534c6abe0f745be62 | 1,859 | [
589658219
] | [
"typespec",
"documented"
] | defmodule RationalNumbers do
@type rational :: {integer, integer}
@doc """
Add two rational numbers
"""
@spec add(r1 :: rational, r2 :: rational) :: rational
def add({a1, b1}, {a2, b2}) do
reduce({(a1 * b2) + (a2 * b1), b1 * b2})
end
@doc """
Subtract two rational numbers
"""
@spec subtract(... |
082915e0b5ecfccdde8acde35829ac04574ecf6e | 1,516 | [
119561582
] | [] | # Matthew Brookes (mb5715) and Abhinav Mishra (am8315)
defmodule System2 do
def main do
init :local, []
end # main
def main_docker do
init :docker, []
end # main_docker
def main_net do
domains =
File.stream!("/etc/ips.txt")
|> Stream.map(&String.trim_trailing/1)
|> Enum.to_li... |
08291b61b0955bda7e6322b10927bfbc3b7dc102 | 4,863 | [
227866011
] | [
"macro",
"documented",
"ecto"
] | defmodule EctoAQL.Repo do
@doc false
defmacro __using__(opts) do
quote bind_quoted: [opts: opts] do
@otp_app opts[:otp_app]
def child_spec(opts \\ []) do
opts
|> config()
|> Arangox.child_spec()
end
def config(opts \\ []) do
Application.get_env(@otp_app... |
082966b7f6332f5bac1b8f99a7dc571a096ffca6 | 1,866 | [
974674586
] | [
"typespec",
"documented"
] | defmodule Apify.Webhook do
@moduledoc """
Provides struct and type for a Webhook
"""
use Apify.Encoder
@type t :: %__MODULE__{
__info__: map,
condition: Apify.WebhookCondition.t(),
createdAt: String.t(),
description: String.t() | nil,
doNotRetry: boolean | ni... |
082a4f9a5da0b7c9aaab87cd1b3b350d16cf4f2c | 1,508 | [
398072886
] | [
"genserver"
] | defmodule Remote.Users.GenServer do
use GenServer
alias Remote.Repo
alias Remote.Users.User
import Ecto.Query
@one_minut_in_ms 60 * 1000
# Client API
def start_link(opts) do
max_number = Keyword.get(opts, :max_number) || integer_from_zero_to_n_inclusive(100)
last_query_time = Keyword.get(opts, :... |
082a6cf6b6d67a94feb73233ad642b3ef6e8952f | 2,233 | [
878328262
] | [
"documented",
"ecto"
] | defmodule Zomato.Gallery do
@moduledoc """
The Gallery context.
"""
import Ecto.Query, warn: false
alias Zomato.Repo
alias Zomato.Gallery.Photo
@doc """
Returns the list of photos.
## Examples
iex> list_photos()
[%Photo{}, ...]
"""
def list_photos do
Repo.all(Photo)
end
... |
082ab1dced423429efb556e212ab1cb0cbc3bcc7 | 11,571 | [
416259673,
415908578
] | [
"typespec",
"documented"
] | defmodule Earmark do
if Version.compare(System.version, "1.12.0") == :lt do
IO.puts(:stderr, "DEPRECATION WARNING: versions < 1.12.0 of Elixir are not tested anymore and will not be supported in Earmark v1.5")
end
@type ast_meta :: map()
@type ast_tag :: binary()
@type ast_attribute_name :: binary()
@... |
082ae42b70e0d29d5f9ad1f17069effc12fc2403 | 2,245 | [
158100912
] | [
"typespec"
] | defmodule Solution2 do
# 47ms
@spec minimum_sum_subarray(nums :: [integer], l :: integer, r :: integer) :: integer
def minimum_sum_subarray(nums, l, r) do
min_sum = minimum_sum_subarray(nums, l, r, Enum.count(nums), 1_000_000_000)
if min_sum == 1_000_000_000 do; -1 else min_sum end
end
@spec minimum_... |
082b22ed7b08e05ced5e82714aa9a225d84ce288 | 1,772 | [
727056204
] | [] | defmodule Day11 do
def parse_input(f) do
file =
File.read!(f)
|> String.split("\n", trim: true)
all =
file
|> Enum.with_index(0)
|> Enum.flat_map(fn {row, r} ->
String.split(row, "", trim: true)
|> Enum.with_index(0)
|> Enum.map(fn {text, c} -> {text, r, ... |
082b876333d939b376d5c302d5ae81aa84d8ce75 | 3,945 | [
291482163
] | [
"typespec",
"documented"
] | defmodule ResourceManager.Factory do
@moduledoc false
alias ResourceManager.Credentials.Schemas.{Password, PublicKey, TOTP}
alias ResourceManager.Identities.Schemas.{ClientApplication, User}
alias ResourceManager.Permissions.Schemas.{ClientApplicationScope, Scope, UserScope}
alias ResourceManager.Repo
@de... |
082b9cd8c227c06139d5b7c6c4d086ce4ba3751b | 4,817 | [
373384929
] | [] | defmodule Compiler do
@symbol_t "s"
require Compiler.Macros
import Compiler.Macros
def compile({:start, _, children}) do
children
|> Enum.map(&Task.async(fn -> compile(&1) end))
|> Enum.map(&Task.await/1)
|> Enum.join("\n")
end
def compile({:block, _, children}) do
children
|> Enu... |
082bb1c64510d8fd67160c5f73e15d0cfface95b | 2,749 | [
378018261
] | [] | %{
"connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"},
"db_connection": {:hex, :db_connection, "2.4.0", "d04b1b73795dae60cead94189f1b8a51cc9e1f911c234cc23074017c43c031... |
082c810a8f8943e9bc64754da091973aadaa3749 | 1,835 | [
584745223
] | [
"typespec"
] | # Definition for a binary tree node.
defmodule TreeNode do
@type t :: %__MODULE__{
val: integer,
left: TreeNode.t() | nil,
right: TreeNode.t() | nil
}
defstruct val: 0, left: nil, right: nil
end
defmodule Helper do
def gentree(lst), do: do_gentree({List.to_tuple(lst), length... |
082d030dbb3538beaeeb8cb2b3391bba00fb02c5 | 2,157 | [
196731991
] | [
"genserver"
] | defmodule RumblWeb.VideoChannel do
use RumblWeb, :channel
alias Rumbl.{Accounts, Multimedia}
alias RumblWeb.AnnotationView
def join("videos:" <> video_id, params, socket) do
send(self(), :after_join)
last_seen_id = params["last_seen_id"] || 0
video_id = String.to_integer(video_id)
video = Mult... |
082d30a7a2040113c50f473d9c93350266763440 | 2,021 | [
153937532
] | [
"documented"
] | defmodule Aoc.Day13 do
@doc """
iex> inp = Aoc.Day13.input("priv/day13/example.txt")
...> Aoc.Day13.part1(inp)
295
"""
def part1([ear, minutes]) do
{id, earliest} =
minutes
|> String.split(",", trim: true)
|> Enum.reject(fn x ->
x == "x"
end)
|> Enum.map... |
082d8f39d475691bcb2e6e43f0dcf7293a369f7c | 2,578 | [
686868352
] | [
"liveview"
] | defmodule HuntWeb.Shirt do
use HuntWeb, :live_component
def render(assigns) do
~H"""
<div class={"transition-all z-50 fixed max-w-2xl mx-auto bottom-0 top-32 left-0 right-0 #{if @open, do: "translate-y-0", else: "translate-y-full"}"}>
<div class="relative h-full bg-white mx-4 rounded-t-xl p-4 overflo... |
082dbb4541a0a12abd8e21c3670c50503d1697f8 | 1,895 | [
193244709,
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.CloudSupport.V2beta.Model.DiffChecksumsResponse do
@moduledoc """
# gdata.* are outside protos with mising documentation
## Attributes
* `checksumsLocation` (*type:* `GoogleApi.CloudSupport.V2beta.Model.CompositeMedia.t`, *default:* `nil`) - # gdata.* are outside protos with mising docum... |
082e1b44a5ec247d104cbc787714c1168ffebfc6 | 1,698 | [
960533781
] | [
"documented"
] | defmodule PIIDetector.Platform.Slack.APIBehaviour do
@moduledoc """
Behaviour module for Slack API interactions.
This allows us to mock the Slack API calls in tests.
"""
@doc """
Posts a request to the Slack API.
"""
@callback post(endpoint :: String.t(), token :: String.t(), params :: map()) ::
... |
082e2c0c165840e3dd11240386fc5a9ea9c874c4 | 2,274 | [
83796366,
80350625,
80913823
] | [] | defmodule Earmark.CLI do
def main(argv) do
argv
|> parse_args
|> process
end
@args """
usage:
earmark --help
earmark --version
earmark [ options... <file> ]
convert file from Markdown to HTML.
where options can be any of:
-- code_class_prefix -- gfm -- smartypants -... |
082e80a2fd53e13126eef4c048109569bea15d19 | 2,759 | [
124496138
] | [
"documented"
] | defmodule Dawdle.Backend.SQS do
@moduledoc """
Implementation of the `Dawdle.Backend` behaviour for Amazon SQS.
"""
use ModuleConfig, otp_app: :dawdle
alias ExAws.SQS
require Logger
@behaviour Dawdle.Backend
@impl true
def init, do: :ok
@impl true
def queue, do: get_config(:queue_url)
@im... |
082faf144ab08c659a46bddfa91b46ba16490e5b | 3,737 | [
605754163
] | [
"phoenix"
] | defmodule RldLiveViewStudioWeb.Router do
use RldLiveViewStudioWeb, :router
import RldLiveViewStudioWeb.UserAuth
pipeline :browser do
plug(:accepts, ["html"])
plug(:fetch_session)
plug(:fetch_live_flash)
plug(:put_root_layout, {RldLiveViewStudioWeb.Layouts, :root})
plug(:protect_from_forgery)... |
082fc82f09bf59198dee5f4a29b6b1779d7e1f5a | 2,023 | [
225709103
] | [] | defmodule OrbitCounter do
def count_orbits(input) do
orbits =
Enum.map(input, &input_to_relationship(&1))
|> map_orbits_for_relationships
satellites = Map.keys(orbits)
reducer = fn satellite, acc -> count_orbits_for_satellite(satellite, orbits) + acc end
Enum.reduce(satellites, 0, reducer... |
082fcf832b9c4929801994f9ed627fa548517dd7 | 3,329 | [
575214595
] | [
"test",
"ecto"
] | defmodule Api.Location.CountryTest do
use Api.DataCase, async: true
import Api.Factory
alias Api.Location.Country
alias Ecto.Changeset
setup do
attrs = params_for(:country)
{:ok, attrs: attrs}
end
describe "changeset/1 returns a valid changeset" do
test "when name is valid", %{attrs: attr... |
082fd63f76703d290a7816b4e24dcd270c7e06a7 | 1,889 | [
81671333
] | [
"ecto"
] | defmodule Skiptip.User do
use Skiptip.Web, :model
import Ecto.Query
alias Skiptip.Utils
alias Skiptip.Repo
alias Skiptip.FacebookLogin
alias Skiptip.BuyerProfile
alias Skiptip.User
alias Skiptip.Message
alias Skiptip.Location
alias Skiptip.RidesProviderProfile
schema "users" do
field :api_key... |
082fd8a352b57f05aa173397cd5543628e4fcc54 | 1,988 | [
55319188
] | [
"documented"
] | defmodule RPNCalc.Calculator do
@moduledoc """
An RPN calculator.
Provides methods for calculating operations in RPN notation.
An instance provides a single method, `process`, which takes
either a numeric input, or an operator.
Supports:
- addition `+`
- subtraction `-`
- multiplication `*`
- div... |
08306f1972b2d2dc012b43f5ddff02e50623e717 | 3,022 | [
453796695
] | [
"documented"
] | defmodule Mix.Tasks.Ecto.Gen.Repo do
use Mix.Task
import Mix.Ecto
import Mix.Generator
@shortdoc "Generates a new repository"
@switches [
repo: [:string, :keep],
]
@aliases [
r: :repo,
]
@moduledoc """
Generates a new repository.
The repository will be placed in the `lib` directory.
... |
0830768089a415db2c933052efd032a9fd53bbc0 | 14,260 | [
536312544
] | [
"documented"
] | defmodule TalibEx.Nif do
@moduledoc false
# Generated File
@on_load :load_nifs
def load_nifs do
:talib_ex_nif
|> :code.priv_dir()
|> Path.join("talib")
|> :erlang.load_nif(0)
end
def nif_acos(_) do
raise "nif_acos/1 not implemented end"
end
def nif_ad(_, _, _, _) do
raise "ni... |
08307c1709bdf61f8af681418db96323550f9e94 | 2,531 | [
921753499
] | [
"test",
"ecto"
] | defmodule Demo.StatisticTest do
use Demo.DataCase
alias Demo.Statistic
describe "transaction" do
alias Demo.Statistic.Transaction
import Demo.StatisticFixtures
@invalid_attrs %{quantity: nil, total_price: nil, transaction_date: nil}
test "list_transaction/0 returns all transaction" do
t... |
08308b79d05b3a3fa331ec5ff6d0e789f8e503cd | 1,886 | [
143164828,
91143120
] | [] | use Mix.Config
config :unbrella, :plugins, one_chat: [
module: OneChat,
application: OneChat.Application,
schemas: [OneChat.Accounts.Account, OneChat.Accounts.User],
router: OneChatWeb.Router,
page_size: 76,
defer: true,
emoji_one: [
# single_class: "big",
ascii: true,
wrapper: :span,
id_... |
08309f2761d1c62322eaf6f94b1091ad73ce456f | 1,538 | [
123950412
] | [
"documented"
] | defmodule PlugServerTiming.Plug do
@moduledoc """
Documentation for PlugServerTiming.
"""
@behaviour Plug
import Plug.Conn
def init(opts), do: opts
def call(conn, _opts) do
register_before_send_headers(conn)
end
def register_before_send_headers(conn) do
register_before_send(conn, fn conn -... |
0830c6d71659c7c20e3ca5e82ecae7e18c0ec36d | 2,442 | [
142629370
] | [
"macro",
"typespec",
"test",
"documented"
] | defmodule PowAssent.Test.OAuth2TestCase do
@moduledoc false
use ExUnit.CaseTemplate
setup do
TestServer.start(scheme: :https)
params = %{"code" => "test", "state" => "test"}
config = [client_secret: "secret", base_url: TestServer.url(), session_params: %{state: "test"}]
{:ok, callback_params: p... |
0830e23411a4a9456f54f1db6582eba416a2d3ef | 1,778 | [
250396789
] | [
"phoenix"
] | defmodule DiplomacyWeb.Router do
use DiplomacyWeb, :router
import DiplomacyWeb.UserAuth
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
plug :fetch_current_user
end
pipeline :api do
pl... |
08315f950351464426ca1829a070c7f7e810b800 | 1,651 | [
179849036,
237435523
] | [] | defmodule RumblWeb.MixProject do
use Mix.Project
def project do
[
app: :rumbl_web,
version: "0.1.0",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
elixir: "~> 1.5",
elixirc_paths: elixirc_... |
0832da72b6ed052cde0f6e90638374e8f7c8d0e7 | 2,953 | [
926851044
] | [] | defmodule Vitoria do
def jogo_terminou?(tabuleiro) do
verificar_vencedor(tabuleiro) or verificar_empate(tabuleiro)
end
def verificar_vencedor(tabuleiro) do
verificar_linhas(tabuleiro) or
verificar_colunas(tabuleiro) or
verificar_diagonais(tabuleiro)
end
def verificar_linhas(tabuleiro) do... |
08330f226ef6328c607d4b0ac2349338b31dd8ab | 6,128 | [
600990834
] | [
"documented"
] | defmodule Habitsheet.Agendas do
@moduledoc """
The Agendas context.
"""
import Ecto.Query, warn: false
alias Habitsheet.Repo
alias Habitsheet.Tasks
alias Habitsheet.Users.User
alias Habitsheet.Agendas.Agenda
@behaviour Bodyguard.Policy
# Agendas
def authorize(:list_agendas_for_user, %User{id: ... |
08339f2af17755b34f0b2a38b0b7095a0c264b98 | 16,216 | [
996920193
] | [
"typespec",
"supervisor",
"documented"
] | defmodule Foundation.BEAM.Processes do
@moduledoc """
BEAM-native process ecosystem management.
This module provides process-first design patterns that embrace the BEAM's
unique process model. Instead of thinking in terms of single GenServers,
this module helps you create ecosystems of collaborating processe... |
083411f4a2c52a59977e2223fe6c38e72e4984b4 | 1,546 | [
294529641
] | [
"liveview",
"phoenix"
] | defmodule WorkwizorWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :workwizor
# 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: "_workw... |
0834534ae3b0c92ba5513ab6d37cf5b1ca562c54 | 3,964 | [
972810178,
390166925
] | [
"typespec",
"documented"
] | defmodule Game.Command.Socials do
@moduledoc """
The "mail" command
"""
use Game.Command
import Game.Room.Helpers, only: [find_character: 2]
alias Game.Character
alias Game.Events.RoomHeard
alias Game.Format.Socials, as: FormatSocials
alias Game.Socials
commands(["socials"], parse: false)
@im... |
0834a84b4b88335372f5545e746843b506acb774 | 9,176 | [
987064679
] | [] | # Script for populating the database. You can run it as:
#
# mix run priv/repo/seeds.exs
#
# Inside the script, you can read and write to any of your
# repositories directly:
#
# BookATable.Repo.insert!(%BookATable.SomeSchema{})
#
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as the... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.