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 |
|---|---|---|---|---|
07238d0940855a92f22cc3156d69a4af430ae2f7 | 2,492 | [
220865913
] | [
"genserver"
] | defmodule Sec.Protocol.OIS do
use GenServer
use Overridable
alias Sec.BLSNif, as: BLS
@g1 BLS.g1()
@g2 BLS.new_G1("1 2144250947445192081071618466765046647019257686245947349033844530891338159027816696711238671324221321317530545114427 2665798332422762660334686159210698639947668680862640755137811598895238932478... |
072432f1a048609cefd6eea9b863e74c86d542ea | 1,650 | [
529451757,
712696481
] | [
"phoenix"
] | defmodule BlockScoutWeb.AddressContractVerificationViaFlattenedCodeController do
use BlockScoutWeb, :controller
alias BlockScoutWeb.Controller
alias Explorer.Chain
alias Explorer.Chain.SmartContract
alias Explorer.SmartContract.{CompilerVersion, Solidity.CodeCompiler, Solidity.PublisherWorker}
def new(con... |
0724d96000b0ab7a57772f24c0e9b1657a654109 | 2,638 | [
407725509
] | [
"genserver",
"liveview"
] | defmodule BullsAndCowsV2Web.GameLive do
use BullsAndCowsV2Web, :live_view
alias BullsAndCowsV2.{Game, Player}
alias BullsAndCowsV2.Server
alias Phoenix.PubSub
require Logger
@impl true
def mount(%{"game" => game_code, "player" => player_id}, _session, socket) do
if connected?(socket) do
PubSub.... |
07253b20237edd5f32e2bcd967cb357a6541cd86 | 1,687 | [
190789950,
442465291
] | [
"test"
] | defmodule CritWeb.Reservations.ReservationControllerTest do
use CritWeb.ConnCase
alias CritWeb.Reservations.ReservationController, as: UnderTest
use CritWeb.ConnMacros, controller: UnderTest
alias Crit.Exemplars.ReservationFocused
alias Crit.Servers.Institution
alias CritBiz.ViewModels.Reservation.CalendarE... |
072547f12a24c9475b98fec253bbfe6c4ef9d20a | 14,272 | [
1010403460
] | [
"test"
] | defmodule ClaudeCodeSDK.StepPatternLibraryTest do
use ExUnit.Case, async: true
alias ClaudeCodeSDK.{StepPattern, StepDetector, Message}
describe "default_patterns/0" do
test "returns all required built-in patterns" do
patterns = StepPattern.default_patterns()
assert length(patterns) == 6
... |
07267b16751c2cc5f86b06fb2f8a4ee2dfb9de0e | 3,620 | [
317423666
] | [] | require Graph
defmodule Utils do
def to_ints(string), do: string |> to_strings |> Enum.map(&to_int/1)
def to_int([single_string]), do: to_int(single_string)
def to_int(string) do
string
|> Integer.parse()
|> elem(0)
end
def to_strings([single_string]), do: to_strings(single_string)
def to_st... |
0726bf290a40ed3752d2ec84ebac3a07467fd1ef | 1,564 | [
513103560
] | [] | defmodule OpenIDConnect.Mixfile do
use Mix.Project
@version "0.2.2"
def project do
[
app: :openid_connect,
version: @version,
elixir: "~> 1.3",
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
elixirc_paths: elixirc_paths(Mix.env()),
descript... |
0727a0254eeed8b5e77660537dc03a11b6f453f9 | 4,776 | [
662616260
] | [
"genserver",
"documented",
"ecto"
] | defmodule Cluster.Strategy.Database do
@moduledoc """
This clustering strategy relies on nodes stored in a database.
You can have `libcluster` automatically connect nodes on startup for you by configuring
the strategy like below:
config :libcluster,
topologies: [
db_config_example: [
... |
0727eb6e5c1b1030e2c90e79596310ec6567cf84 | 4,969 | [
60650632
] | [
"test"
] | defmodule Cyanometer.LocationEnvironmentalDataControllerTest do
use Cyanometer.ConnCase
require Logger
alias Cyanometer.Repo
alias Cyanometer.EnvironmentalData
@valid_attrs %{"air_pollution_index": "20",
"icon": "sun",
"taken_at": "2016-06-05T16:04:17"}
@invalid_attrs %{"i... |
0727edb160eab19450e05b70ca64e2e940a2d5bf | 4,428 | [
795963462
] | [
"typespec",
"documented"
] | defmodule Eluda.Transpiler do
@moduledoc """
Responsible for transpiling Elixir arithmetic expressions to C/CUDA.
"""
alias Eluda.Transpiler.Transpilation
@allowed_operators [:+, :-, :*, :/]
@indent " "
@doc """
Transpile
"""
@spec transpile(any()) :: String.t()
def transpile(expr_ast) do
... |
0727f8760ee75f47e1360acb770c80b06229085e | 4,038 | [
207814301
] | [
"genserver",
"test"
] | defmodule UserClientInfoTest do
use ExUnit.Case
@user_port Application.get_env(:server, :ports)[:user]
@ip {127, 0, 0, 1}
setup context do
u1_id = 65
u2_id = 11
# Connect 2 clients
{:ok, u1} = :gen_tcp.connect(@ip, @user_port, [:binary, packet: 0])
{:ok, u2} = :gen_tcp.connect(@ip, @user_... |
072834df37700a167378fccc8e93425b1608fe19 | 2,227 | [
78897274
] | [
"test"
] | defmodule Diffusion.Websocket.ProtocolTest do
use ExUnit.Case
doctest Diffusion.Websocket.Protocol
alias Diffusion.Websocket.Protocol.ConnectionResponse, as: ConnectionResponse
alias Diffusion.Websocket.Protocol.DataMessage, as: DataMessage
alias Diffusion.Websocket.Protocol, as: Protocol
test "can decode... |
0728c6ec5eb5bf20361708a2ba4a647693a50f32 | 3,333 | [
155727132
] | [
"test"
] | defmodule Saucexages.BinaryTest do
use ExUnit.Case, async: true
require Saucexages.Util.Binary
alias Saucexages.Util.Binary
test "pad_trailing_bytes/3 pads a binary with the correct amount of trailing bytes" do
assert Binary.pad_trailing_bytes(<<1, 2, 3>>, 6, <<6>>) == <<1, 2, 3, 6, 6, 6>>
assert Binar... |
0728e35da1cb004759eeb4762b89b3f9d03903fa | 1,822 | [
115942242
] | [
"documented",
"ecto"
] | defmodule Appointo.Countries do
@moduledoc """
The Countries context.
"""
import Ecto.Query, warn: false
alias Appointo.Repo
alias Appointo.Countries.Country
@doc """
Returns the list of countries.
## Examples
iex> list_countries()
[%Country{}, ...]
"""
def list_countries do
... |
07293d76b358dd338d409f1a76653a222fc94796 | 4,324 | [
79900140
] | [
"typespec",
"macro",
"documented"
] | defmodule Bundlex.Loader do
@moduledoc """
Some utilities to ease loading of Bundlex-based NIFs.
"""
alias Bundlex.Helper.{MixHelper, PathHelper}
@doc """
Binds the module to the specified NIF.
Accepts keyword list, that may contain two arguments:
- `:nif` - required, name of the NIF to be bound (the... |
07294248cc1552f0c49585293907a433d00446d4 | 1,863 | [
435577308
] | [] | defmodule Day3 do
def part1(data \\ nil) do
data
|> get_data()
|> Helpers.transpose()
|> Enum.map(&sort_bits_by_repetition(&1))
|> Helpers.transpose()
|> Enum.map(&Integer.undigits(&1, 2))
|> Helpers.multiply()
end
def sort_bits_by_repetition(numbers) do
numbers
|> Enum.group_... |
072968a866929443bc91f2fd278ef1796580d98f | 2,299 | [
46241701
] | [
"test"
] | if System.get_env("EXERCISM_TEST_EXAMPLES") do
Code.load_file("example.exs")
else
Code.load_file("triangle.exs")
end
ExUnit.start
ExUnit.configure exclude: :pending, trace: true
defmodule TriangleTest do
use ExUnit.Case, async: true
# @tag :pending
test "equilateral triangles have equal sides" do
asser... |
0729a56b6bf88bd93e388a70155c31f57e979145 | 4,010 | [
333239824
] | [
"typespec",
"documented"
] | defprotocol MscmpSystDb.DbTypes do
@moduledoc """
Defines the common functions which should be implemented for all custom
DbTypes implemented in MscmpSystDb.
"""
alias MscmpSystDb.Types
@doc """
Compares two values and returns the effective operating describing the
relationship.
# Parameters
*... |
0729b884683b86e984110c38803520130fcd2d38 | 2,608 | [
480510904
] | [
"test"
] | defmodule Devi.Core.Statements.IncomeTest do
use ExUnit.Case, async: true
import Devi.CoreFixtures
alias Devi.Core
alias Devi.Core.PeriodLedger
alias Devi.Core.Statements.Income
setup do
now = "2022-03-01T23:50:07Z" |> DateTime.from_iso8601() |> elem(1)
ledger = general_ledger_fixture(%{now: now, ... |
072a2d43c563e89e4c209f89a582296b225a7fcd | 21,720 | [
41432184
] | [
"typespec",
"macro",
"documented"
] | defmodule Money.Currency do
@moduledoc """
Provides currency support to `Money`.
Some useful helper methods include:
* `get/1`
* `get!/1`
* `exists?/1`
* `to_atom/1`
* `name/1`
* `name!/1`
* `symbol/1`
* `symbol!/1`
* `all/0`
A helper function exists for each currency usin... |
072a39aedcea96f5e2d7c6af72b2ddb48c0ff231 | 1,608 | [
493636191
] | [
"liveview",
"documented"
] | defmodule SelphiDaisy.Form.TextArea.Example05 do
@moduledoc """
TextArea 颜色示例。
"""
use Surface.Catalogue.Example,
subject: SelphiDaisy.Form.TextArea,
height: "500px",
title: "TextArea 组件 label 和 help "
alias SelphiDaisy.Form.SampleModel
alias Surface.Components.Form # 直接使用底层 Form!!
da... |
072ac87ae1c4322b34a628f74869eeec521d2dda | 4,025 | [
119807507
] | [] |
# AOC 2015 6-1
# toggle 461,550 through 564,900
defmodule Aoc2015.Six.One do
def parse_input(list, 0) do
line = Enum.reduce 0..999, %{}, fn x, acc -> Map.put(acc, x, :false) end
grid = Enum.reduce 0..999, %{}, fn x, acc -> Map.put(acc, x, line) end
parse_input(list, grid)
end
de... |
072b764beecc552698f17bcd4465788d88350660 | 2,794 | [
348614554
] | [] | defmodule StableMarriage2 do
def match(proposers, acceptors) do
{proposers, acceptors} = {prepare(proposers), prepare(acceptors)}
{proposers, _acceptors} = do_match(proposers, acceptors)
present(proposers)
end
defp present(proposers) do
for {p, %{partner: a}} <- proposers, do: {p, a}
end
def... |
072b8e059d22de99c057c145f2d161ca5a102233 | 11,426 | [
230532043
] | [] | %{
"bamboo": {:hex, :bamboo, "1.3.0", "9ab7c054f1c3435464efcba939396c29c5e1b28f73c34e1f169e0881297a3141", [:mix], [{:hackney, ">= 1.13.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false... |
072bda15925b592fe4bfcaf286a78f256fd2f5e9 | 2,530 | [
521738503
] | [
"genserver",
"liveview"
] | defmodule NarwinChatWeb.RosterLive do
use NarwinChatWeb, :live_view
use NarwinChatWeb.LiveViewNativeHelpers, template: "roster_live"
import Ecto.Query
alias NarwinChat.{Dispatcher, Repo}
alias NarwinChat.Accounts.UserBlock
alias NarwinChat.Chat.Room
on_mount {NarwinChat.LiveAuth, {false, {:redirect, Nar... |
072bf6664bdca83410cf7d0587461de4d676b5e5 | 2,007 | [
194607129,
418324559,
28871561,
134393059,
313369452,
61985538,
178610390,
146797403,
184417993,
194561084,
197690845,
141877522,
165673817,
141485641,
172127066,
172514736,
177739856,
326547006,
118996909,
123769675,
172359981,
132266462,
145987007,
157746283,
163211... | [
"test"
] | if !System.get_env("EXERCISM_TEST_EXAMPLES") do
Code.load_file("space_age.exs", __DIR__)
end
ExUnit.start()
ExUnit.configure(exclude: :pending, trace: true)
# You need to define a SpaceAge module containing a function age_on that given a
# planet (:earth, :saturn, etc) and a number of seconds returns the age in yea... |
072c0fdfdef1a2f0901421fff9863c4514ed48fa | 1,554 | [
34864644
] | [] | defmodule Revolver.Adapters.Hackney do
import Revolver.Conn
def conn(config, opts \\ []) do
%URI{scheme: scheme, host: host, port: port} = URI.parse(config[:host])
req_headers = config[:headers] || []
req_path = config[:req_path]
{:ok, state} = :hackney.connect(transport(scheme), host, port, opts)... |
072c40031d7644a5684a87edcb4ef61e28e696e7 | 2,053 | [
573307344
] | [] | defmodule Fifteen do
@y 2_000_000
@limit 4_000_000
def part_one(input) do
signals = parse(input)
n_beacons =
signals
|> Enum.map(&elem(&1, 1))
|> Enum.filter(fn {_, y} -> y == @y end)
|> MapSet.new()
|> MapSet.size()
signals
|> ranges_at(@y)
|> combine_ranges()
... |
072ccb6ca95138fcc1f0f578b89e142d19d40f25 | 5,460 | [
206297200
] | [
"typespec",
"documented"
] | defmodule Google.Ads.Googleads.V7.Services.GenerateKeywordIdeasRequest do
@moduledoc false
use Protobuf, syntax: :proto3
@type t :: %__MODULE__{
seed: {atom, any},
customer_id: String.t(),
language: String.t(),
geo_target_constants: [String.t()],
include_adult_ke... |
072d6259bb7cbbbca968100f81901eb0580d7006 | 5,104 | [
896762473
] | [] | defmodule Advent.Year2024.Day06 do
defmodule LabMap do
defstruct [:columns, :rows, obstacles: MapSet.new()]
end
defmodule Guard do
defstruct [:position, :direction]
end
def part1(args) do
{%LabMap{} = map, %Guard{} = guard} = parse_input(args)
positions_covered = MapSet.new()
move(guard... |
072db498194c4c82bf209864d4cd8a7371b533d7 | 2,594 | [
351943511
] | [
"test",
"phoenix"
] | defmodule Events9Web.EventControllerTest do
use Events9Web.ConnCase
alias Events9.Events
alias Events9.Events.Event
@create_attrs %{
date: ~D[2010-04-17],
name: "some name"
}
@update_attrs %{
date: ~D[2011-05-18],
name: "some updated name"
}
@invalid_attrs %{date: nil, name: nil}
de... |
072dd97c1b1f68421c953c480233276d497ad4a3 | 2,721 | [
387089661
] | [
"genserver",
"liveview"
] | defmodule HistoryWeb.CandleJob.IndexLive do
use HistoryWeb, :live_view
import HistoryWeb.JobView
alias History.{Candles, CandleHistoryJobs, Products}
@impl true
def mount(_params, _session, socket) do
CandleHistoryJobs.subscribe_by_id("*")
socket =
socket
|> assign_products()
|> as... |
072f99f65ad7150b21b2ee07d3bffa92f773fb40 | 2,342 | [
997268013
] | [
"test",
"phoenix"
] | defmodule RepartoWeb.RouteControllerTest do
use RepartoWeb.ConnCase
import Reparto.CoverageFixtures
@create_attrs %{day_of_week: 42}
@update_attrs %{day_of_week: 43}
@invalid_attrs %{day_of_week: nil}
describe "index" do
test "lists all routes", %{conn: conn} do
conn = get(conn, ~p"/routes")
... |
072ffca84ae7ff80cf86db9d8154c74041fa01e3 | 2,834 | [
144400863
] | [] | defmodule Idvote.Resolver.Precincts do
alias Idvote.Precinct
alias Idvote.Mapbox
require Logger
@date_format "%m/%d/%Y"
@time_format "%I:%M %p"
def find(%{id: id}) do
{:ok, Precinct.find_by_id(id)}
end
def find(%{}, %{address: address}, _) do
try do
case find_by_address(address) do
... |
073022af20415bace71dcbc7a2d736cd8511e02a | 4,180 | [
117138080
] | [
"documented",
"ecto"
] | defmodule TaskTracker.Job do
@moduledoc """
The Job context.
"""
import Ecto.Query, only: [from: 2]
alias TaskTracker.Repo
alias TaskTracker.Job.Task
@doc """
Returns the list of tasks.
## Examples
iex> list_tasks()
[%Task{}, ...]
"""
def list_tasks do
query = from t in Task,... |
0730255033faf2b37bdbadd8cca372c18edca8d2 | 1,511 | [
858982725
] | [] | defmodule Company do
defstruct title: "", emplyees: []
defimpl Enumerable do
def reduce(_, {:halt, acc}, _fun), do: {:halted, acc}
def reduce(company, {:suspend, acc}, fun) do
{:suspended, acc, &reduce(company, &1, fun)}
end
def reduce(%Company{emplyees: []}, {:cont, acc}, _fun) do
{:... |
07304fafb1ac3e4bdff033ac3e125e513d805ae5 | 2,946 | [
260950922
] | [
"documented",
"ecto"
] | defmodule Shodan.SSDPDiscoveryPipeline do
require Logger
require Host
require ProcessorFragment
import BroadwayHelper
use Broadway
alias Shodan.Repo
alias Broadway.Message
@moduledoc ~S"""
`SSDPDiscoveryPipeline` sends the typical SSDP discovery message to 1900/udp
Code logic:
Host
|> E... |
0730c558be10a469f67e27791e519192555a04ae | 1,863 | [
737255185
] | [
"documented"
] | defmodule ChainSync.TestHandler do
@moduledoc false
@behaviour :cowboy_websocket
@impl true
def init(request, state) do
{:cowboy_websocket, request, state}
end
@impl true
def websocket_init(state) do
{:ok, state}
end
@impl true
def websocket_handle({:text, payload}, state) do
current... |
0731071b3f3b0e43e3ba400b802ad46df67ada41 | 1,525 | [
298844485
] | [
"liveview"
] | defmodule SkulWeb.PageLive do
use SkulWeb, :live_view
@impl true
def mount(_params, session, socket) do
socket = assign_defaults(session, socket)
{:ok, assign(socket, query: "", results: %{})}
end
@impl true
def handle_event("test_email", _params, socket) do
if socket.assigns[:user] |> can?(:s... |
073130b651b72b20c13f4680c9b077ccb567cd11 | 1,717 | [
453805733
] | [] | # 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 :data_works,
ecto_repos: [DataWorks.Repo]
#... |
0731b5880e42dae973d9019daaee2d31a0eb88c5 | 1,981 | [
130483800
] | [
"typespec",
"documented"
] | defmodule DynamicModulesLoading do
@moduledoc """
Concept:
--------
Find the correct implementation by dynamically calling the module
based on the language name.
To implement a `GreetingsGenerator`, implement the `@behaviour` in a module
named after the language of the generated file.
> Ex: Python
>... |
073202eab73209ef4f962ea58fc2865fc5e881f3 | 2,848 | [
119747156
] | [
"phoenix",
"ecto"
] | defmodule NervesHubWeb.AccountController do
use NervesHubWeb, :controller
alias Ecto.Changeset
alias NervesHub.Accounts
alias NervesHub.Accounts.User
alias NervesHub.Accounts.UserNotifier
alias NervesHubWeb.Auth
plug(:registrations_allowed when action in [:new, :create])
def new(conn, _params) do
... |
0732582d4bd5fcad6176c8bbe3cbbd90bb916bb9 | 1,621 | [
405250537
] | [
"typespec",
"documented"
] | defmodule Google.Protobuf.NullValue do
@moduledoc false
use Protobuf, enum: true, syntax: :proto3
@type t :: integer | :NULL_VALUE
field :NULL_VALUE, 0
end
defmodule Google.Protobuf.Struct.FieldsEntry do
@moduledoc false
use Protobuf, map: true, syntax: :proto3
@type t :: %__MODULE__{
key: S... |
0732b987f78c0bd1d5ba20f4e43bb31015257002 | 7,570 | [
185663586
] | [
"test"
] | defmodule ParserTest do
use ExUnit.Case, async: true
test "parse job" do
{:ok, file} = File.read("test/ressources/job.html")
job_map = %{content: nil, tag_id: nil, title: nil, url: nil}
{_html, result} = WtjScrapper.Parser.parse_job(file, job_map)
assert result == %{
content:
... |
0732d63f91d464fa7c3fc8a83ea0b36937640c2e | 2,495 | [
193244709,
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.CloudIdentity.V1.Model.Operation do
@moduledoc """
This resource represents a long-running operation that is the result of a network API call.
## Attributes
* `done` (*type:* `boolean()`, *default:* `nil`) - If the value is `false`, it means the operation is still in progress. If `true`,... |
07337487c506ce4855e0cf4881c4b18688978c05 | 3,397 | [
104674184
] | [
"test"
] | defmodule ElixirBlog.PostControllerTest do
use ElixirBlog.ConnCase
alias ElixirBlog.Post
alias ElixirBlog.Repo
@valid_attrs %{author: "some content", body: "some content", category: "some content", image: "some content", likes: 42, sub_category: "some content", title: "some content"}
@invalid_attrs %{}
s... |
0733c28b55d6e87c5aa67fac96efb79ac02eb263 | 2,496 | [
579553056
] | [
"liveview",
"macro",
"documented",
"phoenix"
] | defmodule SampleStreamWeb 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 SampleStreamWeb, :controller
use SampleStreamWeb, :view
The definitions below will be executed for every view,... |
0733e86a8bcbe2e24759946a02fba3f75ce643f4 | 3,649 | [
179168080
] | [
"test",
"phoenix"
] | defmodule AccessiveWeb.UserControllerTest do
use AccessiveWeb.ConnCase
import AccessiveWeb.AuthCase
alias Accessive.Accounts
@create_attrs %{email: "<EMAIL>", password: "hard2guess"}
@update_attrs %{email: "<EMAIL>"}
@invalid_attrs %{email: nil}
setup %{conn: conn} = config do
conn = conn |> bypass... |
0734512f8e863f428ce02967a279177f2c75a295 | 2,572 | [
649155952,
898378345,
983671670,
669233706,
589184243,
928986497
] | [
"liveview",
"test"
] | defmodule RangerWeb.AlbumLive.IndexDoneTest do
use RangerWeb.ConnCase, async: false
import Phoenix.LiveViewTest
setup do
on_exit(fn ->
File.rm_rf!(Ranger.uploads_dir())
File.mkdir!(Ranger.uploads_dir())
end)
end
test "user can see preview of picture to be uploaded", %{conn: conn} do
... |
0734831bcc8a38e21f9426e55e5ede0a1711d632 | 2,238 | [
737972105,
773387614
] | [
"typespec"
] | defmodule Fedimintex.Ln.InvoiceRequest do
defstruct [:amount_msat, :description, :expiry_time]
@type ln_invoice_request :: %__MODULE__{
amount_msat: non_neg_integer(),
description: String.t(),
expiry_time: non_neg_integer() | nil
}
@spec new(non_neg_integer(), String.t(), n... |
07349630fd781d80411073c216a84f348b4968cc | 3,899 | [
343615720
] | [
"phoenix",
"ecto"
] | defmodule EventsAppWeb.EventController do
use EventsAppWeb, :controller
alias EventsApp.Events
alias EventsApp.Events.Event
alias EventsApp.Comments
alias EventsAppWeb.Plugs
plug Plugs.RequireUser when action in [:new, :edit, :create, :update]
plug :fetch_event when action in [:show, :edit, :update, :... |
0734e532260018387f0b8621c2c098ff9418a745 | 2,826 | [
608808456
] | [
"liveview",
"macro",
"documented",
"phoenix"
] | defmodule TempMonitorWeb 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 TempMonitorWeb, :controller
use TempMonitorWeb, :view
The definitions below will be executed for every view,
... |
073519e28d3995cf7c9a2330854439dfb96d3fbf | 2,365 | [
969999971
] | [
"documented"
] | defmodule DeeperHub.Core.Data.Migrations.BxAlbumsCmtsMedia do
@moduledoc """
Migration para criar e remover a tabela bx_albums_cmts_media.
"""
alias DeeperHub.Core.Data.Repo
alias DeeperHub.Core.Logger
require DeeperHub.Core.Logger
@doc """
Cria a tabela de bx_albums_cmts_media.
"""
def up do
... |
073556014783671730fbf7358bb000530f6982cc | 2,815 | [
803069683
] | [
"documented"
] | defmodule Apple.Rabbitmq.KinoUI do
alias Apple.Rabbitmq
alias VegaLite, as: Vl
defp inner_consume(channel, num, current) when current < num do
receive do
{:basic_deliver, payload, meta} ->
IO.puts(" [x] Received #{payload}")
AMQP.Basic.ack(channel, meta.delivery_tag)
inner_consu... |
07355d3c16d700795860cd9b36f3a4921c8cd2d0 | 3,119 | [
91039185
] | [] | defmodule MdnsSd.Helpers do
def open_inet_port do
udp_options = [
:binary,
active: true,
add_membership: {{224,0,0,251}, {0,0,0,0}},
multicast_loop: true,
multicast_ttl: 255,
reuseaddr: true
]
:gen_udp.open(5353, udp_options)
end
#utility for opening an i... |
0735a4b016efca54bdc268b378f067d443b3791f | 1,635 | [
960065661
] | [
"liveview",
"phoenix"
] | defmodule ReleaseDockerWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :release_docker
# 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... |
0735dfca358fd8241a08a8b8fefd29baaf193320 | 2,447 | [
85264006
] | [
"test"
] | defmodule MenuPlanner.Web.UserControllerTest do
use MenuPlanner.Web.ConnCase
alias MenuPlanner.Accounts
@create_attrs %{email: "some email", name: "some name", password: "some password"}
@update_attrs %{email: "some updated email", name: "some updated name", password: "some updated password_has"}
@invalid_a... |
0735e78c8aa1d7c33ab6f9398e40a578508f9ed6 | 1,883 | [
814869922
] | [
"typespec",
"documented",
"ecto"
] | defmodule Fhir.CoverageEligibilityResponseInsurance do
@moduledoc """
This resource provides eligibility and plan details from the processing of an CoverageEligibilityRequest resource.
"""
use Ecto.Schema
import Ecto.Changeset
@derive Jason.Encoder
@primary_key false
embedded_schema do
field(:id, :... |
0735f64d4b4ac419782de3b5c0abb992c6b7b895 | 3,825 | [
726175121
] | [] | defmodule Day23 do
use AOC, day: 23
@line_break_pattern ~r{\R}
@dirs [
{:v, 0, +1},
{:^, 0, -1},
{:>, +1, 0},
{:<, -1, 0}
]
def parse_field("."), do: :free
def parse_field(">"), do: :>
def parse_field("<"), do: :<
def parse_field("v"), do: :v
def parse_field("^"), do: :^
def parse_... |
073600455189f5ebe256ef64c727ca9478474da3 | 2,123 | [
638613557
] | [] | defmodule NewPassport do
def get_new_passport(now, birthday, form) do
with {:ok, timestamp} <- enter_building(now),
{:ok, manual} <- find_counter_information(now),
counter <- manual.(birthday),
{:ok, checksum} <- stamp_form(timestamp, counter, form),
passport_number <- get_new_... |
07365865e42bb04f0f7dcdb5e7fa91dc90eab208 | 2,288 | [
820405367
] | [
"test"
] | defmodule Pythonx.C.PyTuple.Test do
use ExUnit.Case, async: false
alias Pythonx.C.PyErr
alias Pythonx.C.PyList
alias Pythonx.C.PyObject
alias Pythonx.C.PyTuple
alias Pythonx.C.PyUnicode
setup do
Pythonx.initialize_once()
end
test "check/1" do
obj = PyTuple.new(0)
assert true == PyTuple.... |
07366bc0c7902a6e6f1b1736c2e5638913f05ae9 | 1,654 | [
315846026
] | [
"liveview"
] | defmodule TRSWeb.ModalComponent do
use TRSWeb, :live_component
@impl true
def render(assigns) do
~L"""
<div id="<%= @id %>" class="fixed z-10 inset-0 overflow-y-auto"
phx-capture-click="close"
phx-window-keydown="close"
phx-key="escape"
phx-target="#<%= @id %>"
phx-page-load... |
07366ec5fdfc981dc312f2abfdf216007cc84f07 | 2,323 | [
448717462
] | [
"test"
] | defmodule Twetch.ABITest do
use ExUnit.Case
alias BSV.{Address, Hash, Message}
alias Twetch.{Account, ABI}
import Support.TestConfig
@bProtocolPrefix "19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut"
@mapProtocolPrefix "1PuQa7K62MiKCtssSLKy1kh56WWU7MtUR5"
@aipProtocolPrefix "15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva"
d... |
0736982c8c59618b14f6a2aa3edfc21db4216ca1 | 7,779 | [
274447946
] | [
"test",
"ecto"
] | defmodule BandCatalog.BandsTest do
use BandCatalog.DataCase
alias BandCatalog.Bands
describe "bands" do
alias BandCatalog.Bands.Band
@valid_attrs %{genre: "some genre", name: "some name"}
@update_attrs %{genre: "some updated genre", name: "some updated name"}
@invalid_attrs %{genre: nil, name: ... |
0736b20228debddf7517b88c0ade484b13b994a0 | 1,501 | [
27213063,
806822137
] | [
"genserver",
"documented"
] | defmodule Bot.Markov do
@moduledoc """
This is an example event handler that greets users when they join a channel
"""
def start_link(client) do
GenServer.start_link(__MODULE__, [client], name: __MODULE__)
end
def init([client]) do
:random.seed(:os.timestamp)
ExIrc.Client.add_handler client, se... |
0736bddf09d0e09b202f4fd16677f690eb0c15b6 | 1,639 | [
193244709,
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.BigtableAdmin.V2.Model.ListInstancesResponse do
@moduledoc """
Response message for BigtableInstanceAdmin.ListInstances.
## Attributes
* `failedLocations` (*type:* `list(String.t)`, *default:* `nil`) - Locations from which Instance information could not be retrieved, due to an outage or ... |
07378b371416c8bdb905bd28a8e830ecc259ce08 | 2,698 | [
888975773
] | [
"test",
"ecto"
] | defmodule Vantage.ProjectionsTest do
use Vantage.DataCase
alias Vantage.Projections
describe "projections" do
alias Vantage.Projections.Projection
import Vantage.ProjectionsFixtures
@invalid_attrs %{name: nil, time: nil, file: nil, projection_type: nil}
test "list_projections/0 returns all pr... |
0737a5f401e439fcf7fde8ff3a9f34b03af7f1aa | 4,522 | [
242761425
] | [
"documented"
] | defmodule Membrane.Element.Msdk.H264.Encoder do
@moduledoc """
Membrane element that encodes raw video frames to H264 format using
hardware-accelerated API available for Intel® Gen graphics hardware platforms.
The element expects each frame to be received in a separate buffer, so the parser
(`Membrane.Elemen... |
0737eb34ecb0039e58a1e27c11ed7b5b27bf40d0 | 3,938 | [
248702688
] | [
"test",
"ecto"
] | defmodule Core.Talk.RoomTest do
use Core.DataCase
alias Core.Talk
describe "rooms" do
alias Core.Talk.Room
@valid_attrs %{
description: "some description",
name: "some name",
topic: "some topic"
}
@update_attrs %{
description: "updated description",
name: "updated ... |
07388e5274178bcaa6b1109323ac567cd4195eb1 | 1,534 | [
719863051
] | [] | IO.puts("Advent of Code Day5")
defmodule Day5 do
def load_file(f_name) do
file_lines = String.split(File.read!(f_name), "\n\n")
seeds = List.first(file_lines)
|> parse_seeds()
maps = Enum.map(tl(file_lines), &map_to_ranges/1)
part1 = map_seeds(seeds, maps)
|> Enum.min()
#part2 =
I... |
0738c7a38f071a5504b7551d471c91dce4f441d5 | 2,456 | [
583275740
] | [
"liveview",
"macro",
"documented",
"phoenix"
] | defmodule ShortenerWeb 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 ShortenerWeb, :controller
use ShortenerWeb, :view
The definitions below will be executed for every view,
contro... |
0738cfd34ad5be00f3467994158cdfe9a447937b | 2,077 | [
57212573
] | [
"test"
] | defmodule JuiceboxStream.Stream.ControlTests do
use ExUnit.Case, async: true
alias JuiceboxStream.Stream.Control, as: Control
setup do
[
state: %{
playing: nil,
history: [],
queue: [],
timer: nil
},
videos: {
%{ video: %{ video_id: 1 }, votes: 0 },
... |
0738e08104e595a7f69941b8bcf316512e5369be | 2,606 | [
608804587
] | [
"phoenix"
] | defmodule FoodTruckWeb.Router do
use FoodTruckWeb, :router
import FoodTruckWeb.UserAuth
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, {FoodTruckWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers... |
07390f1d9504b9102d26695312cdecc2187da268 | 1,934 | [
896933286
] | [
"documented"
] | defmodule DiskFragmenter do
@moduledoc """
Documentation for `DiskFragmenter`.
"""
@doc """
Hello world.
## DiskFragmenter
iex> DiskFragmenter.get_checksum("files/example.txt")
1928
iex> DiskFragmenter.get_checksum("files/sample.txt")
6310675819476
"""
def get_checksum(path)... |
073921ecb4eddd5a1a66d6a88e0ea8ebd2c04600 | 2,559 | [
737574059
] | [
"liveview",
"ecto"
] | defmodule StudioWeb.FieldLive.FormComponent do
use StudioWeb, :live_component
alias Studio.Portals
@impl true
def render(assigns) do
~H"""
<div>
<.header>
<%= @title %>
<:subtitle>Use this form to manage field records in your database.</:subtitle>
</.header>
<.simple... |
073a57f042cf6dffda53e88db649616fb24813db | 1,928 | [
433929203
] | [] | defmodule Day11P2 do
def solve(filename) do
File.read!(filename)
|> String.trim()
|> String.split("\n")
|> Enum.map(&String.graphemes/1)
|> Enum.with_index()
|> Enum.reduce(
%{},
fn {line, y}, map ->
line
|> Enum.with_index()
|> Enum.reduce(
... |
073a84aa4c3fb3f70429c02216e572b43120661c | 1,655 | [
610331649
] | [
"genserver",
"documented"
] | defmodule Slip.RoomServer do
use Slipstream
require Logger
def start_link(_config) do
config = [uri: "ws://localhost:4000/socket/websocket"]
Slipstream.start_link(__MODULE__, config,
name: __MODULE__,
hibernate_after: 10_000,
spawn_opt: [fullsweep_after: 200]
)
end
@impl Slip... |
073a86fbcac681fbca4fccdac0ad21b313b82eb2 | 11,158 | [
926727171
] | [
"documented"
] | defmodule SSE.ConnectionPlug do
@moduledoc """
A Plug for handling Server-Sent Events (SSE) connections with Model Context Protocol (MCP) support.
Query params:
* `sessionId` - The session ID for the connection
This plug provides two endpoints:
* `/sse` - Establishes the SSE connection
* `/message... |
073abc380688d02586d32bb79d2fbd5d697fb9fd | 2,462 | [
129441349
] | [
"typespec",
"documented"
] | defmodule Phone do
@doc """
Remove formatting from a phone number.
Returns "0000000000" if phone number is not valid
(10 digits or "1" followed by 10 digits)
## Examples
iex> Phone.number("212-555-0100")
"2125550100"
iex> Phone.number("+1 (212) 555-0100")
"2125550100"
iex> Phone.number("+1 (212... |
073b32ad08b136f75799f2e17939b83e456d9927 | 1,806 | [
95041299
] | [
"genserver",
"documented"
] | require IEx
defmodule MultiMongoex.Registry do
use GenServer
## Client API
@doc """
Starts the registry.
"""
def start_link do
GenServer.start_link(__MODULE__, :ok, name: MultiMongoex.Registry)
end
@doc """
Looks up the bucket pid for `name` stored in `server`.
Returns `{:ok, pid}` if the bu... |
073b67170b51b90cfa1b0c05362b6e5d7eec58ee | 2,454 | [
892089627
] | [] | defmodule LiveVueExamples.MixProject do
use Mix.Project
def project do
[
app: :live_vue_examples,
version: "0.1.0",
elixir: "~> 1.14",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps()
]
end
# Config... |
073c0527facae934e65ebbeef9d5ccafca9e4388 | 2,532 | [
757463973,
768011158,
279895213,
610994830,
792554244,
493445187,
644559297,
895439861,
756299391,
531030808
] | [
"typespec"
] | defmodule ChatApi.Google.Auth do
use OAuth2.Strategy
@spec client(keyword()) :: OAuth2.Client.t()
def client(params \\ []) do
OAuth2.Client.new(
strategy: __MODULE__,
client_id: System.get_env("PAPERCUPS_GOOGLE_CLIENT_ID"),
client_secret: System.get_env("PAPERCUPS_GOOGLE_CLIENT_SECRET"),
... |
073d05436024b8dcb16d2efe76d367a112d266ff | 1,737 | [
170485068
] | [] | %{
"benchfella": {:hex, :benchfella, "0.3.5", "b2122c234117b3f91ed7b43b6e915e19e1ab216971154acd0a80ce0e9b8c05f5", [:mix], []},
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], []},
"credo": {:hex, :credo, "1.0.2", "88bc918f215168bf6ce7070610a6173c45c82f32b... |
073d0f3fa9774bc119e906c82606530fb0bc0cae | 1,501 | [
123819994
] | [
"test"
] | defmodule LogLagerBackendTest do
use ExUnit.Case
import ExUnit.CaptureLog
require Logger
setup do
console_config = Application.get_env(:logger, :console)
:lager.set_loglevel(:lager_console_backend, :info)
on_exit(fn ->
Process.sleep(1000)
Logger.remove_backend(LogLagerBackend)
... |
073d201e563fb285633b0efaabd06e4ccd8ab906 | 2,813 | [
899506466
] | [] | {:ok, input} = File.read("input_2.txt")
defmodule Grid do
def at(grid, x, y) do
if Grid.in_bounds(grid, %{ x: x, y: y }) do
case Enum.at(grid, x) do
nil -> nil
row -> Enum.at(row, y)
end
end
end
def in_bounds(grid, point) do
dimensions = length(grid) - 1
(0 <= point.x... |
073d43ca6f15c5897b83b3dd5e8bf04ba085edd3 | 7,432 | [
316888241,
362839784
] | [
"documented"
] | defmodule App.Actions do
@moduledoc false
require Logger
use App.Commander
@form_url "https://docs.google.com/forms/d/e/1FAIpQLScpSOicLFqYdzJO3UeHtnFJy8RWdDM0YvHVev_tNZdXqIuhNQ/viewform"
@default_markup %Model.InlineKeyboardMarkup{
inline_keyboard: [
[
%{
callback_data: "/fill_... |
073d81a97c53ba0a5ad4c3207d0e5beb5a10d64a | 2,309 | [
785492675
] | [
"test",
"phoenix"
] | defmodule UserApiWeb.UrlControllerTest do
use UserApiWeb.ConnCase
import UserApi.UrlsFixtures
alias UserApi.Urls.Url
@create_attrs %{
link: "some link",
title: "some title"
}
@update_attrs %{
link: "some updated link",
title: "some updated title"
}
@invalid_attrs %{link: nil, title: n... |
073db3be675ea82d10893d504b94c2d8ce95d2d4 | 1,566 | [
412297856
] | [] | defmodule AoeReplayParser.Data.Command do
defstruct [:type, :command]
defmodule Stop do
defstruct [:object_ids]
end
defmodule Attack do
defstruct [:player_id, :target_id, :coords, :attacker_ids]
end
defmodule Move do
defstruct [:player_id, :coords, :units]
end
defmodule Order do
defs... |
073e94e8b0e826572d9e392d90b718750d9de06d | 1,840 | [
877242231
] | [] | defmodule Web.Api.NotificationsView do
def render_notification(%NotificationsRead.PatientNotification{} = notification) do
%Proto.Notifications.PatientNotification{
id: notification.id,
created_at: notification.inserted_at |> Timex.to_unix(),
read: notification.read,
type: parse_notificati... |
073e9b45e3773df3329a4e1d67a2cca58bd18fd7 | 4,329 | [
279151698
] | [] | %{
"certifi": {:hex, :certifi, "2.5.2", "b7cfeae9d2ed395695dd8201c57a2d019c0c43ecaf8b8bcb9320b40d6662f340", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "3b3b5f36493004ac3455966991eaf6e768ce9884693d9968055aeeeb1e575040"},
"earmark": {:hex, :earmark, "1.4.8", "a... |
073eb0ed0b4251d9b3d2a93779385e0d7145ab63 | 8,905 | [
772592209
] | [
"test",
"liveview"
] | defmodule Orange.Component.InputTest do
use ExUnit.Case
import Orange.Test.Assertions
alias Orange.{Terminal, Test}
test "receives keyboard events and renders input" do
[snapshot1, snapshot2, snapshot3, snapshot4, snapshot5] =
Test.render(__MODULE__.Input,
terminal_size: {25, 5},
ev... |
073ed005c2f1477f9258376a34abeea462feaae6 | 1,508 | [
970385734
] | [
"phoenix"
] | defmodule WishlistWeb.Router do
use WishlistWeb, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, html: {WishlistWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
plug WishlistWeb.Plugs.A... |
073eeb2b2fc4141e9a0b965ca590d4e5a605be81 | 2,749 | [
13962255
] | [] | # Based on http://golang.org/doc/play/solitaire.go
# pid = spawn(Pegboard, :solve, [Pegboard.board])
# pid <- self
defmodule Pegboard do
@row 12 # row length + \n
@board String.codepoints """
...........
...........
....●●●....
....●●●....
..●●●●●●●..
..●●●○●●●..
..●●●●●●●..
....●●●....
....●●●....
...........
...... |
073f4f8a65a0db8be95063cc24d6d722b64a30ed | 1,943 | [
987480345
] | [
"test"
] | defmodule DeribitEx.SubscriptionDebugTest do
use ExUnit.Case
alias DeribitEx.Client
require Logger
@tag :debug
test "debug subscription flow" do
test_pid = self()
# Track all messages we receive
callback = fn frame ->
Logger.info("Received frame: #{inspect(frame)}")
send(test_pid, ... |
073f6704b56f878ba4a40b66168064f66a1be670 | 1,663 | [
16886159
] | [
"genserver"
] | defmodule Confort.Server do
use GenServer
import Record
defrecordp :state, path: nil, conf: []
def start_link() do
:gen_server.start_link({ :local, __MODULE__ }, __MODULE__, [], [])
end
def init([]) do
case Keyword.get(Mix.Project.config(), :conf_path) do
nil ->
{ :ok, state() }
... |
073f9aa3d088f85e626ee60a85a3ad57a7359b28 | 2,268 | [
193244709,
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.Dialogflow.V3.Model.GoogleCloudDialogflowCxV3WebhookRequestIntentInfo do
@moduledoc """
Represents intent information communicated to the webhook.
## Attributes
* `confidence` (*type:* `number()`, *default:* `nil`) - The confidence of the matched intent. Values range from 0.0 (completely... |
07404b0fcd2688732a8756c99c55560902890627 | 2,603 | [
719422627
] | [
"typespec",
"supervisor",
"documented"
] | defmodule Sparrow.FCM.V1.Pool.Supervisor do
@moduledoc """
Supervises a single FCM workers pool.
"""
use Supervisor
@fcm_default_endpoint "fcm.googleapis.com"
@account_key "client_email"
@spec start_link(Keyword.t()) :: Supervisor.on_start()
def start_link(arg) do
Supervisor.start_link(__MODULE__,... |
0740eacdef88bea29f8e8179582e3d87a054c43b | 1,668 | [
418010354
] | [] | defmodule Solution do
def part1() do
input() |> aux()
end
def part2() do
input(5) |> aux()
end
def aux(stream) do
stream
|> Enum.reduce(0, fn {s, r}, acc ->
dfs(s, r, 0, %{})
|> elem(0)
|> then(&(&1 + acc))
end)
end
def input(times \\ 1) do
File.stream!("./inpu... |
07410cdede7f807ed2b2c95ebb93a7e51837bc3a | 1,568 | [
365580864
] | [
"documented"
] | defmodule Packlane.Accounts.UserNotifier do
# For simplicity, this module simply logs messages to the terminal.
# You should replace it by a proper email or notification tool, such as:
#
# * Swoosh - https://hexdocs.pm/swoosh
# * Bamboo - https://hexdocs.pm/bamboo
#
defp deliver(to, body) do
requi... |
07416f4d94ac53367d3dd76099cf3ea3032cf640 | 1,647 | [
683943631,
657861675
] | [
"liveview",
"phoenix"
] | defmodule ScaffoldAptosBasedOnAIWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :scaffold_aptos_based_on_ai
# 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 [
st... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.