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 |
|---|---|---|---|---|
04979503e99a39d38f7043cf9b9d2fc28ca70c4e | 7,035 | [
75424348,
18281293
] | [
"documented"
] | defmodule Stripe.InvoiceItems do
@moduledoc """
Invoice Items
Sometimes you want to add a charge or credit to a customer but only
actually charge the customer's card at the end of a regular billing
cycle. This is useful for combining several charges to minimize
per-transaction fees or having Stripe tabu... |
0497fa0aa4d3282e184a146adcaea8eab66dc663 | 7,674 | [
752213937
] | [
"documented"
] | defmodule DogAPI.CityProducer do
@moduledoc """
"""
use GenStage
require Logger
@name __MODULE__
def start_link(_args), do: GenStage.start_link(@name, [], name: @name)
def init(_args), do: {:producer, city_list()}
def handle_demand(demand, state) when demand > length(state) do
handle_demand(de... |
04980d5890215058e1eb0fc628b962e116873d34 | 5,422 | [
949664843
] | [
"test",
"documented"
] | defmodule Raxol.Core.Accessibility.FocusHandlingTest do
@moduledoc """
Tests for the focus handling system, including element focus tracking,
announcement generation, and screen reader compatibility.
"""
use ExUnit.Case, async: false
import Mox
alias Raxol.Core.Accessibility
alias Raxol.Core.UserPrefer... |
049815237b5af765975abd894a3dc0c88c23d92e | 5,479 | [
48894650
] | [
"genserver",
"typespec",
"documented"
] | defmodule Exon.Session do
@moduledoc false
use GenServer
require Logger
alias Exon.Structs.Client
def start_link(socket) do
GenServer.start_link(__MODULE__, socket, [])
end
def init(socket) do
client = peer_infos(socket)
Logger.debug "Handling session for peer #{inspect client} with pid #{i... |
04982bf65be8684d055e7fed9bc3f68bb7eb62ef | 1,885 | [
434068709
] | [] | defmodule Advent.Day10 do
def load_puzzle(), do: Advent.read("data/day10.txt")
def part1() do
load_puzzle()
|> syntax_error_score()
end
def part2() do
load_puzzle()
|> autocomplete_score()
end
def syntax_error_score(lines) do
lines
|> filter_scores(:corrupted)
|> Enum.sum()
... |
04985362eb928b8c4c2811c0d305fb23eb892e7f | 5,334 | [
1017722512
] | [
"ecto"
] | #!/usr/bin/env elixir
# Test the AuthView fix directly without Phoenix server
Mix.install([
{:ecto_sql, "~> 3.10"},
{:postgrex, ">= 0.0.0"},
{:bcrypt_elixir, "~> 3.0"},
{:jason, "~> 1.2"},
{:phoenix, "~> 1.7.10"}
])
defmodule AuthViewDirectTest do
# Define a simple repo for testing
defmodule SimpleRepo ... |
04994346345b33c06a188e209b2ac41b7b1e4b40 | 4,358 | [
520836540
] | [
"test"
] | defmodule OffBroadwayAmqp10.Producer.StateTest do
use ExUnit.Case, async: true
alias OffBroadwayAmqp10.Amqp10
alias OffBroadwayAmqp10.Producer.State, as: SUT
setup do
%{state: Fixture.build_producer_state()}
end
describe "new" do
test "builds initial state" do
assert %SUT{demand: 0, amqp: %... |
0499b1f7f1ac193f96d28a0e038138d690209572 | 7,880 | [
480152162
] | [
"test"
] | defmodule TextImage.Test do
use ExUnit.Case, async: true
import Image.TestSupport
alias Image.{Text, Shape}
@moduletag :text
@points [[0, 0], [0, 100], [70, 100], [90, 0]]
@polygon_color [116, 214, 245]
setup do
image = image_path("Singapore-2016-09-5887.jpg")
{:ok, image} = Image.open(image,... |
0499b5c0a6bfe3b268795a0aee9af04ae53f9bc7 | 1,647 | [
268841826
] | [
"typespec",
"documented"
] | defmodule AuctionHouse.Impl.UseCase.GetItemOrders do
@moduledoc """
Requests all the sell orders for the item with the given name.
"""
alias AuctionHouse.Impl.{HttpAsyncClient, UseCase}
alias AuctionHouse.Impl.UseCase.Data.{Request, Response}
alias AuctionHouse.Type
alias Jason
alias Shared.Data.OrderI... |
049a34f65bdac0786c773e6e456efa55c2c37ad9 | 1,991 | [
144562243
] | [
"documented"
] | defmodule Cards do
@moduledoc """
Provides methods for creating and handling a deck of cards.
"""
@doc """
Returns a list of strings representing a deck of playing cards.
"""
def create_deck do
values = ["Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen... |
049a6c18047ec6dc4424280c797039768d1509b7 | 1,755 | [
250355980,
418324559,
42472777,
213121474,
293948327,
347935406,
289236906,
316577321,
331790961,
232195183,
232450626,
366547649,
281806487,
355457922,
100891628,
138556589,
269459264
] | [
"test"
] | defmodule MatchingBracketsTest do
use ExUnit.Case
# @tag :pending
test "paired square brackets" do
assert MatchingBrackets.check_brackets("[]")
end
# @tag :pending
test "empty string" do
assert MatchingBrackets.check_brackets("")
end
# @tag :pending
test "unpaired brackets" do
refute Ma... |
049b982707f156459c38144d46160aa43f728e85 | 2,071 | [
898882208
] | [
"documented",
"ecto"
] | defmodule FinTech.Wallet do
use Ecto.Schema
import Ecto.Changeset
import Ecto.Query
alias FinTech.Repo
alias FinTech.Wallet
schema "wallets" do
field :balance, :decimal, default: 0.0
belongs_to :user, FinTech.Accounts.User
timestamps(type: :utc_datetime)
end
@doc false
def changeset(wal... |
049c14ffb5accf958bf5efc92fbddef6b7a2300f | 2,019 | [
259500149
] | [
"test"
] | defmodule WorkoutTest do
use ExUnit.Case
test "fold folds (empty list returns the accumulator)" do
res = Workout.fold("hi there", [], fn (a, b) -> a <> b end)
expected = "hi there"
assert res == expected
end
test "fold can fold number lists using *" do
res = Workout.fold(1, [2, 3, 4], fn (a, b... |
049c3272513ee721db30095bdbefcab87c8c86f3 | 3,662 | [
150022372
] | [
"ecto"
] | defmodule Tvmaze.Show do
use Ecto.Schema
import Ecto.Changeset
import Ecto.Query
require Logger
alias Tvmaze.{Show, Repo, User, Episode}
@fields ~w(tvmaze_id name summary status image type genres language runtime schedule externals premiered official_site tvmaze_weight)a
@primary_key {:id, :binary_id, ... |
049c891379c081691ddb0c7b5fc48b49e7077b86 | 7,193 | [
36162788
] | [] | defmodule Survey.HTML.Survey.Report do
alias Survey.Repo
alias Survey.User
import Ecto.Query
require Ecto.Query
alias Ecto.Adapters.SQL
alias Survey.HTML.Survey, as: S
@survey S.parse("data/survey.txt") |> S.index_mapping
def survey, do: @survey
@steamsort %{"+" => 5, "A" => 3, "E" => 2, "M" => 4, ... |
049ccdb6385487f085b2c76076c9cee07e0b6fc3 | 1,979 | [
172191048
] | [] | defmodule Instaghub.MixProject do
use Mix.Project
def project do
[
app: :instaghub,
version: "0.2.0",
elixir: "~> 1.5",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,
aliases: aliases(),... |
049d3dac70f4f917314fd184a0046ac8e4b13d35 | 1,880 | [
278435642
] | [
"macro",
"documented",
"phoenix"
] | defmodule MozartWeb 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 MozartWeb, :controller
use MozartWeb, :view
The definitions below will be executed for every view,
controller, etc... |
049e0fe788db78aa8a2c71628b0e3bc6e0977ca0 | 8,178 | [
898776424
] | [
"typespec",
"documented"
] | defmodule Aletopelta.Year2021.Day08 do
@moduledoc """
Day 8 of Year 2021
"""
defmodule Common do
@moduledoc """
Common part for Day 8
"""
@spec parse_input([binary()]) :: [[binary()]]
def parse_input(input) do
Enum.map(input, fn line ->
line
|> String.split("|")
... |
049e12e59aa883238f85c80668038f9a77e00ab6 | 3,828 | [
56229218
] | [
"test"
] | defmodule ExometerZabbixTest do
use ExUnit.Case, async: true
alias Exometer.Report.Zabbix
setup_all do
{:ok, state} = Zabbix.exometer_init([])
{:ok, state: state}
end
test "initialize zabbix reporter returns correct state" do
assert Zabbix.exometer_init([]) ==
{:ok,
%... |
049e16fbce7e7f14d83f09e1c89c883563054760 | 1,560 | [
168440845
] | [
"genserver"
] | defmodule Superviser do
use GenServer
def passive_node_list_adder(pid, message) do
GenServer.cast(pid, {:passive_node_list_adder, message})
end
def passive_node_list_getter(pid) do
GenServer.call(pid, :passive_node_list_getter, :infinity)
end
def active_node_list_getter(pid, i... |
049f3da07d43c67a1588bde3362b995307bb8758 | 2,608 | [
433694692
] | [
"documented"
] | defmodule Aoc do
@moduledoc """
Documentation for `Aoc`.
"""
@doc """
Hello world.
## Examples
iex> Aoc.hello()
:world
"""
def hello do
:world
end
def parse(text) do
# target area: x=20..30, y=-10..-5
{_, _, x, y} =
String.trim(text)
|> String.split([" ", ","... |
049f69f8a71ae4ec3cb093dd92da2672aee4c827 | 1,892 | [
178532637
] | [
"typespec",
"documented",
"ecto"
] | defmodule Banking.Accounts.Transactions.Deposit do
@moduledoc """
The way to create a Bank Operation Deposit
Each Deposit create an `t:Banking.Model.Balances.EventSchema.t/0` of `Type.Deposit` and Update the balance
according with the Last Balance Event
see `create/2`
"""
alias Banking.Model.Balances.E... |
049f9bf2cac44321ea333159c044bdb0e34108d1 | 2,408 | [
193244709,
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.ServiceNetworking.V1.Model.Field do
@moduledoc """
A single field of a message type.
## Attributes
* `cardinality` (*type:* `String.t`, *default:* `nil`) - The field cardinality.
* `defaultValue` (*type:* `String.t`, *default:* `nil`) - The string value of the default value of this f... |
049fa69775c9f49541b17235a834630378f3780a | 15,983 | [
318999575
] | [] | %{
"argon2_elixir": {:hex, :argon2_elixir, "2.3.0", "e251bdafd69308e8c1263e111600e6d68bd44f23d2cccbe43fcb1a417a76bc8e", [:make, :mix], [{:comeonin, "~> 5.3", [hex: :comeonin, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "28ccb63bff213aecec1... |
04a0def2b4a7712b0f586ee6221a7677112b93b9 | 1,564 | [
857118094
] | [
"documented"
] | ##
## echo_server.ex provides module EchoServer, an example of a simple TCP server
## Adapted from Elixir Guides: https://elixir-lang.org/getting-started/mix-otp/task-and-gen-tcp.html
##
defmodule EchoServer do
@moduledoc """
Documentation for `EchoServer`.
"""
require Logger
def accept(port) do
# The ... |
04a0ea165c9e1abc37b2e2e3c4ef5fb0a7d5b7a6 | 2,943 | [
472306255,
472343256
] | [
"liveview"
] | defmodule MyAppWeb.ThermostatLive do
use MyAppWeb, :live_view
# <div v-html='buttondec'/>
# <div v-html='buttoninc'/>
# <button phx-click="dec" class="minus">-</button>
# <button phx-click="inc" class="plus">+</button>
# <button v-on:click="increment">Count is: {{ count }}</button>
# <button v-on:click... |
04a1137d1c330e4d8082fd29aa593430b531957a | 3,261 | [
159072739
] | [
"test"
] | defmodule BureaucratDemoAppWeb."Admin".EmployeeControllerTest do
use BureaucratDemoAppWeb.ConnCase
alias BureaucratDemoApp.Admin
@create_attrs %{address: "some address", employee_number: 42, fiscal_number: "some fiscal_number", full_name: "some full_name"}
@update_attrs %{address: "some updated address", empl... |
04a1a19f638556839b6424abad75543e2426c90f | 1,647 | [
201058108
] | [
"documented",
"ecto"
] | defmodule BetManager.Bookmaker do
use Ecto.Schema
import Ecto.Changeset
import Ecto.Query, only: [from: 2]
alias BetManager.Repo
alias BetManager.Bookmaker
alias BetManager.User
schema "bookmakers" do
belongs_to :user, User
field :logo, :string
field :name, :string
timestamps()
end
... |
04a1a833e2e2c12ae442d1a8d6a35f089d9d5ae2 | 4,171 | [
806822991
] | [
"documented"
] | if Code.ensure_loaded?(Finch) do
defmodule Tesla.Adapter.Finch do
@moduledoc """
Adapter for [finch](https://github.com/sneako/finch).
Remember to add `{:finch, "~> 0.14.0"}` to dependencies. Also, you need to
recompile tesla after adding the `:finch` dependency:
```
mix deps.clean tesla
... |
04a237c5c29fb2772f2d532ae8593cfa1d0ab489 | 8,237 | [
495137583
] | [
"typespec",
"documented"
] | # credo:disable-for-this-file
defmodule Speechly.Slu.V1.SLUStart.Option do
@moduledoc false
defstruct key: "", value: [], __uf__: []
(
(
@spec encode(struct) :: {:ok, iodata} | {:error, any}
def encode(msg) do
try do
{:ok, encode!(msg)}
rescue
e in [Protox.Enco... |
04a271be3c289f5994a5b8551afb02ac3eb78e8e | 2,188 | [
55781078
] | [] | defmodule Rumbl.VideoChannel do
use Rumbl.Web, :channel
alias Rumbl.AnnotationView
def join("videos:" <> video_id, params, socket) do
last_seen_id = params["last_seen_id"] || 0
video_id = String.to_integer(video_id)
video = Rumbl.Repo.get(Rumbl.Video, video_id)
annotations = Repo.all(
fro... |
04a2d017dd7219cb2a67c708ea5d510085172e22 | 7,581 | [
144164839
] | [
"typespec",
"documented"
] | defmodule Tracker do
require Logger
alias __MODULE__.{Error, Response}
@type connection_id :: <<_::64>>
@type announce :: binary()
@udp_connect_timeout 15 * trunc(:math.pow(2, 8))
@udp_protocol_id <<0x41727101980::64>>
@connect <<0::32>>
@announce <<1::32>>
# @scrape <<2::32>>
@error <<3::32>>
... |
04a2fc571c600814a830b4de2bd13e66f67a59e3 | 1,539 | [
120600125
] | [
"test"
] | defmodule RumblWeb.Channels.VideoChannelTest do
use RumblWeb.ChannelCase
import Rumbl.TestHelpers
alias Rumbl.Repo
setup do
user = insert_user(name: "Rebecca")
video = insert_video(user, title: "Testing")
token = Phoenix.Token.sign(@endpoint, "user socket", user.id)
{:ok, socket} = connect(Rumb... |
04a30d7a541ae52a48a450a713f835907546c83c | 1,630 | [
346460690
] | [
"genserver",
"liveview",
"ecto"
] | defmodule TcpbinWeb.BinLive do
alias TcpBin.Bin
use TcpbinWeb, :live_view
@impl true
def mount(%{"bin" => id}, _session, socket) do
case Registry.lookup(Registry, id) do
[{pid, _value}] ->
Bin.subscribe(id)
{:ok,
assign(socket,
pid: pid,
id: id,
... |
04a34627f3babf9485ff5a91630ab4379e323351 | 1,943 | [
275762620
] | [
"macro",
"test"
] | defmodule Test.Acceptance.Ast.InlineIalTest do
use ExUnit.Case
describe "inline IAL enabled →" do
data = [
{"# A Header{:.classy}", [{"h1", [{"class", "classy"}], ["A Header"], %{}}]},
{"###### Another Header{:.classy}", [{"h6", [{"class", "classy"}], ["Another Header"], %{}}]},
{"> # Bq Head... |
04a35a70cf2861c61bfa51f91fcb0798ee79f54f | 1,577 | [
357358194
] | [
"test"
] | defmodule StravaGearData.Api.TokenTest do
use StravaGearData.DataCase, async: true
alias StravaGearData.Api
@token %OAuth2.AccessToken{
access_token: "fake-access-token",
expires_at: 1_618_987_211,
other_params: %{
"athlete" => %{
"badge_type_id" => 1,
"bio" => nil,
"ci... |
04a35f837535d11362de647c0ecc65cf517878cc | 3,687 | [
193244709,
101434552,
651976950,
198908023
] | [
"typespec",
"macro",
"documented"
] | defmodule GoogleApi.Gax.ModelBase do
require Poison.Decode
@moduledoc """
This module helps you quickly and concisely define API models.
Example:
defmodule Pet do
use GoogleApi.Gax.ModelBase
field(:id)
field(:category, as: Category)
field(:tags, as: Tag, type: :list)
... |
04a39f99a64ab18b3b91e1eda2446e00a1bee2f5 | 4,165 | [
580470778
] | [
"liveview"
] | defmodule Palette.Components.Card do
use Phoenix.Component
alias Palette.Utils.StringHelper
alias Palette.Utils.DateHelper
attr(:color, :atom, default: :default, values: [:default, :success, :warning, :error])
attr(:title, :string, default: nil)
attr(:description, :string, default: nil)
attr(:class, :st... |
04a41c86e33461901f03fc8b875116f78d56337c | 2,046 | [
147754959
] | [
"genserver",
"typespec",
"documented",
"ecto"
] | defmodule ROS.TCP do
use GenServer
require Logger
@moduledoc false
alias ROS.Message.ConnectionHeader, as: ConnHead
alias ROS.Helpers
import Helpers, only: [partial: 3]
import Elixir.Kernel, except: [send: 2]
# send a message on a socket
#
# really just calls `:gen_tcp.send/2`, but is re-ordered ... |
04a4c466b3a43df39a19aa04281dafb5c98341b0 | 2,239 | [
285137562
] | [
"test",
"ecto"
] | defmodule Maze.RecursiveBacktracking.MazeRBTest do
use ExUnit.Case
alias Maze.Common
alias Maze.RecursiveBacktracking.MazeRB, as: Maze
test "set_open" do
actual =
create_3x3_grid()
|> Common.set_open({1,1}, :n)
|> Common.set_open({1,1}, :e)
expected =
create_3x3_grid()
|... |
04a5622e5103435cb70644484eebd9a18ccfa7b0 | 2,086 | [
110279332
] | [] | defmodule Plenario.Mixfile do
use Mix.Project
def project do
[
app: :plenario,
version: "0.21.2",
elixir: "~> 1.7",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,
aliases: aliases(),
... |
04a5a1997a9dca43a1f23a70a7976df2e260155e | 1,709 | [
949664843
] | [
"typespec",
"documented"
] | defmodule Raxol.Terminal.Clipboard.Store do
@moduledoc """
Manages clipboard content storage and retrieval.
"""
defstruct [:content, :format, :timestamp]
@type t :: %__MODULE__{
content: String.t(),
format: String.t(),
timestamp: integer()
}
@doc """
Creates a new ... |
04a5b609cadd2368a549217e18d488f7bb4428e1 | 6,730 | [
936050620
] | [
"genserver",
"documented"
] | defmodule RustlerBtleplug.Genserver do
@moduledoc false
@name :ble_genserver
use GenServer
require Logger
def start_link(_opts) do
GenServer.start_link(__MODULE__, %{}, name: @name)
end
def child_spec(init_arg) do
Supervisor.child_spec(
%{
id: init_arg,
start: {__MODULE__,... |
04a621b24e3724cde6f9da6008213d9d3bfb18ed | 6,335 | [
159944984
] | [] | defmodule Day16.Part2 do
alias FileLoader
defmodule Opcode do
use Bitwise
def get_functions() do
:functions
|> __MODULE__.__info__()
|> Enum.map(fn {name, _arity} -> name end)
|> Enum.reject(fn name -> name == :get_functions end)
end
# (add register) stores into register C... |
04a6774b89d5832516928f639eec6a2a4dba86ae | 1,833 | [
162052920,
162206582
] | [
"macro",
"documented",
"phoenix"
] | defmodule BlockchainAnalyserWeb 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 BlockchainAnalyserWeb, :controller
use BlockchainAnalyserWeb, :view
The definitions below will be execut... |
04a7510c4410f544fdc1e4840e0c46553b1c9f1c | 4,143 | [
867641796
] | [
"test"
] | defmodule GrammarTest do
use ExUnit.Case
doctest Grammar
alias Grammar.SpecialTokens.Number
alias Grammar.Tokenizer
test "strict matching of token" do
grammar =
Grammar.new()
|> Grammar.add_clause(:start, [%Number{number: 42}, %Number{}], fn [a, b] -> {a, b} end)
|> Grammar.prepare!()... |
04a78f311f53d7fff264ef77a77665af0f0a3ff6 | 3,388 | [
351118317
] | [
"documented"
] | defmodule MeowNx.Mutation do
@moduledoc """
Numerical implementations of common mutation operations.
Mutation is a genetic operation that randomly alters genetic
information of some individuals within the population, usually
according to a fixed probability.
Mutation is used to maintain genetic diversity ... |
04a7c840a4ed63729b7bb38f02e2c68e3ad86b1f | 8,824 | [
183453235
] | [
"ecto"
] | defmodule Conduit.Blog do
import Ecto.Query, warn: false
alias Conduit.Repo
alias Conduit.Account.{User, UserFollower}
alias Conduit.Blog.{Article, Favorite, Comment, Tag}
# article CURD
def create_article(attrs, user) do
# need better way??
tag_list = attrs["tagList"] || attrs[:tagList] || []
... |
04a81e2cf5f364cef13ca98d47eed5b94ac6d56e | 2,792 | [
755184742
] | [
"genserver",
"typespec",
"documented"
] | defmodule Crawly.RequestsStorage.Worker do
@moduledoc """
Requests Storage, is a module responsible for storing requests for a given
spider.
Automatically filters out already seen requests (uses `fingerprints` approach
to detect already visited pages).
Pipes all requests through a list of middlewares, whi... |
04a82cc457488c2c86754f434e6f43793e85b630 | 1,746 | [
109163005
] | [
"macro",
"documented",
"phoenix"
] | defmodule CassandraPlaygroundWeb 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 CassandraPlaygroundWeb, :controller
use CassandraPlaygroundWeb, :view
The definitions below will be exe... |
04a84368e2edd2f44bee19e2bc8ef4676f7fa5f5 | 4,579 | [
264948683
] | [] | %{
"certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "805abd97539caf89ec6d4732c91e62ba9da0cda51ac462380bbd28ee697a8c42"},
"combine": {:hex, :combine, "0.10.0", "... |
04a85bbb8163f438fe3e1dabf9e8b335b52f78d7 | 2,396 | [
931846022
] | [
"phoenix"
] | defmodule CartaoWeb.Router do
use CartaoWeb, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, {CartaoWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :api do
plug :acce... |
04a895178adce4a0e862cb9bbd316b15bf5ddde8 | 2,184 | [
301902616
] | [] | defmodule App.MixProject do
use Mix.Project
def project do
[
app: :app,
version: "0.1.0",
elixir: "~> 1.7",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps:... |
04a8a93362663f7974a17597c8febc144a3d455d | 2,929 | [
994438838
] | [
"typespec",
"macro",
"documented"
] | defmodule Dspy.Module do
@moduledoc """
Behaviour for composable DSPy modules.
Modules are the building blocks of DSPy programs. They define
forward passes for inference and can contain optimizable parameters.
"""
@type t :: struct()
@type inputs :: map()
@type outputs :: Dspy.Prediction.t()
@doc "... |
04a90ddee89f59b340a8386ffc4b6ea914c35817 | 1,778 | [
106127142
] | [
"documented"
] | defmodule Mapi.Mapper do
require Logger
alias Plug.Conn
@doc false
def init(opts) do
opts
end
@doc false
def call(conn, opts) do
# Make sure function atoms defined before path conversion
opts[:mod].__info__(:functions)
path =
conn.path_info
|> List.first()
|> :erlang.... |
04a9bc339006a1494557d4cf604506ad5babf72f | 3,273 | [
968434148
] | [
"genserver",
"documented"
] | defmodule Powervisor.SecretChecker do
@moduledoc false
use GenServer
require Logger
alias Powervisor.Helpers
@interval :timer.seconds(15)
def start_link(args) do
name = {:via, Registry, {Powervisor.Registry.Tenants, {:secret_checker, args.id}}}
GenServer.start_link(__MODULE__, args, name: name)... |
04aa14028719e716277dbf920bbed2ce66a2f85b | 8,215 | [
965212098
] | [
"genserver",
"ecto"
] | defmodule Kaguyabot.CommentPoller do
use GenServer
require Logger
alias Kaguyabot.{Repo, CommentInvocation, GraphQLClient}
import Ecto.Query
@subreddit "kaguya"
# Matches either {{...}} or { ... } (non-greedy for the inner content)
@trigger_regex ~r/\{\{([^}]+)\}\}|\{([^}]+)\}/
@poll_interval 10_000
... |
04aa23cae5d5043a704ce3907e2edae98c3e3546 | 2,376 | [
509953083
] | [
"documented"
] | defmodule PhxJsonRpc.Router.Dispatcher do
@moduledoc """
Behaviour for the rpc requests dispatcher.
"""
alias PhxJsonRpc.{Request, Response}
alias PhxJsonRpc.Router.{Context, MetaData}
@doc """
Dispatches the given rpc request, using module and action definitions in metadata.
If no metadata specified,... |
04aa56b7fbd872f8d0c279a28da59266cc9fc658 | 3,171 | [
391463995
] | [] | %{
"amqp": {:hex, :amqp, "2.1.1", "ad8dec713ba885afffffcb81feb619fe7cfcbcabe9377ab65ab7a110bd4f43a0", [:mix], [{:amqp_client, "~> 3.8.0", [hex: :amqp_client, repo: "hexpm", optional: false]}], "hexpm", "b6d926770e4508e30e3e9e476c57b6c8aeda44f7715663bdc38935620ce5be6f"},
"amqp_client": {:hex, :amqp_client, "3.8.19",... |
04aaf5d2ff26266508ad77155c00dc6347a36d1d | 4,806 | [
374427984
] | [] | %{
"castore": {:hex, :castore, "0.1.10", "b01a007416a0ae4188e70b3b306236021b16c11474038ead7aff79dd75538c23", [:mix], [], "hexpm", "a48314e0cb45682db2ea27b8ebfa11bd6fa0a6e21a65e5772ad83ca136ff2665"},
"certifi": {:hex, :certifi, "2.6.1", "dbab8e5e155a0763eea978c913ca280a6b544bfa115633fa20249c3d396d9493", [:rebar3], [... |
04ab31a61c5713e98987a5488ba052143ace2dee | 2,688 | [
215134600
] | [
"test"
] | defmodule RrTest do
use ExUnit.Case
import Rr
setup do
[
sim_params_rr: %SimParameters{
algorithm: :round_robin,
processes: [
%CpuProcess{p_name: "p1", burst_size: 6, priority: 1},
%CpuProcess{p_name: "p2", burst_size: 3, priority: 2},
%CpuProcess{p_name: "... |
04ab5555862794ffc3441fb6e4e3fb1d7765d289 | 7,994 | [
651606171
] | [
"typespec",
"documented"
] | defmodule Ockam.Worker.Authorization do
@moduledoc """
Helper functions to configure worker message authorization.
Usage:
```
def is_authorized(message, _state)
Authorization.from_addresses(message, ["one", "two"])
end
```
Pipelining helpers:
```
def is_authorized(message, state)
Authoriza... |
04abb118d6f2886bd90857ef9d2e2c714523a223 | 2,171 | [
725698868
] | [] | alias Grid
alias Grid.Element
defmodule Day03 do
def part1(input) do
{part_nums, _} = collect_part_nums_gears(input)
Enum.sum(part_nums)
end
def part2(input) do
{_, gears} = collect_part_nums_gears(input)
Map.filter(gears, fn {_, v} -> length(v) == 2 end)
|> Map.values() |> Enum.map(fn [a, b... |
04abd6267597ca4d1c9f453fb3ca024288e12607 | 3,410 | [
54871321
] | [
"typespec",
"documented"
] | defmodule Tentacat.Organizations.Members do
import Tentacat
alias Tentacat.Client
@doc """
List members of a `organization`. The response will differ if the authenticated user is also owner of the organization
## Example
Tentacat.Organizations.Members.list "github"
Tentacat.Organizations.Member... |
04ad34d56d1f042648dec0ee61761144bc0231d2 | 1,918 | [
190667844
] | [
"test",
"phoenix"
] | defmodule Artemis.CreateUserRecognitionTest do
use Artemis.DataCase
import Artemis.Factories
alias Artemis.CreateUserRecognition
describe "call!" do
test "returns error when params are empty" do
assert_raise Postgrex.Error, fn ->
CreateUserRecognition.call!(%{}, Mock.system_user())
en... |
04ad750a43b2fea0fdd1f87b2e6a77b05e789464 | 2,064 | [
94678773,
95305505
] | [] | %{"certifi": {:hex, :certifi, "1.2.1", "c3904f192bd5284e5b13f20db3ceac9626e14eeacfbb492e19583cf0e37b22be", [:rebar3], [], "hexpm"},
"earmark": {:hex, :earmark, "1.2.2", "f718159d6b65068e8daeef709ccddae5f7fdc770707d82e7d126f584cd925b74", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.16.1", "b4b8a23602b4ce0e9a5a... |
04ad809a409d2771db7b34d8828d387e66fa7f4a | 3,667 | [
320817971
] | [
"typespec",
"phoenix"
] | defmodule SinceWeb.UserSocket do
use Phoenix.Socket
require Logger
alias Since.Accounts
alias __MODULE__.Monitor
# feed:<user-id>
channel "feed:*", SinceWeb.FeedChannel
# profile:<user-id>
channel "profile:*", SinceWeb.ProfileChannel
@impl true
@spec connect(any, any, any) :: :error | {:ok, Phoeni... |
04adcb997b68aeb7a00b7d71632af211e5aa3ac1 | 2,177 | [
812760654
] | [] | defmodule BasicScrapper.MixProject do
use Mix.Project
def project do
[
app: :basic_scrapper,
version: "0.1.0",
elixir: "~> 1.14",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps()
]
end
# Configurati... |
04addfc74a100915408a86037a12af448390f31c | 1,730 | [
458681875
] | [
"phoenix"
] | defmodule Repertoire2Web.Router do
use Repertoire2Web, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, {Repertoire2Web.LayoutView, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :api... |
04ae3ad48ac2786c461fb2aa29e827e04865594c | 2,095 | [
171365415
] | [] | # ur_msg_mod3.ex
# This script should create a Module I use to demonstrate how to
# send messages and use the after clause inside a receive block.
# Also, it should demo recursion inside the receive-block.
# Demo:
# elixirc ur_msg_mod3.ex
# ls -l *.beam
# elixir -e "Elixir.UrMsgMod3.ur_sndr"
# ASCII art and English ... |
04aebad73f455228b6de32437872deb9804409af | 2,456 | [
205466614
] | [] | defmodule VamNum do
def findFactors(n) do
half = div(length(to_charlist(n)), 2)
sorted = Enum.sort(String.codepoints("#{n}"))
Enum.filter(pairs(n), fn {a, b} -> length(to_charlist(a)) == half && length(to_charlist(b)) == half && Enum.count([a, b], fn x -> rem(x, 10) == 0 end) != 2
... |
04af06779b11cc3828c7a9609d033731ad2b7340 | 2,339 | [
181052285
] | [
"macro",
"documented"
] | defmodule LsProxy.Protocol.Header do
@moduledoc """
Represents a Language Server Protocol Header
"""
@behaviour LsProxy.Protocol.Parser
@enforce_keys [:content_length]
defstruct [:content_length, content_type: :utf8]
alias LsProxy.LsProxyUtils
@header_fields [
{"Content-Length", :content_length, ... |
04af33731dd5a765c9f74742c2fba57c8146926f | 1,619 | [
198002242
] | [
"macro",
"documented",
"phoenix"
] | defmodule PrToolWeb 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 PrToolWeb, :controller
use PrToolWeb, :view
The definitions below will be executed for every view,
controller, etc... |
04af429c887b419da1c1eb026c2755489ae6afb6 | 4,775 | [
295437634
] | [
"typespec",
"macro",
"documented"
] | defmodule PixelFont.DSL.OTFLayout.Lookups.Common do
@moduledoc false
import PixelFont.DSL.MacroHelper
alias PixelFont.Glyph
alias PixelFont.TableSource.OTFLayout.ChainedSequenceContext1
alias PixelFont.TableSource.OTFLayout.ChainedSequenceContext3
alias PixelFont.TableSource.OTFLayout.GlyphCoverage
alias... |
04b07e93e870b0b3fa75dec28f6b49335205a07e | 2,506 | [
380240566
] | [] | # This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config
# This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this
# file won't be loaded nor affect the paren... |
04b081498331750d944d45e416edc5acdaa3787c | 7,798 | [
191423461
] | [
"test"
] | defmodule MeadowWeb.AuthorityRecordsControllerTest do
use Meadow.DataCase
use MeadowWeb.ConnCase, async: true
alias Meadow.Repo
alias NUL.AuthorityRecords
alias NUL.Schemas.AuthorityRecord
alias NimbleCSV.RFC4180, as: CSV
describe "POST /api/authority_records/:filename (failure)" do
test "unauthori... |
04b0f9dae8799fcfbab324ecd36e94abe54f56fc | 2,498 | [
103569528
] | [] | %{"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [], [], "hexpm"},
"cowboy": {:hex, :cowboy, "1.1.2", "61ac29ea970389a88eca5a65601460162d370a70018afe6f949a29dca91f3bb0", [], [{:cowlib, "~> 1.0.2", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch,... |
04b185505585cbec2bd389773934fbfd4c4e1ddc | 13,640 | [
758833862
] | [
"test",
"phoenix"
] | defmodule ChannelSpec.TestingTest do
use ExUnit.Case, async: true
use ChannelSpec.Testing
def make_mod() do
String.to_atom("Elixir.Test#{System.unique_integer([:positive])}")
end
def build_socket(module, id, assigns, endpoint, opts \\ []) do
Phoenix.ChannelTest.__socket__(module, id, assigns, endpoi... |
04b22d9d3725a471fe2a0eb15cc4c4d7b34032c8 | 3,071 | [
75767893
] | [
"test"
] | Code.require_file("../test_helper.exs", __DIR__)
Code.require_file("holocene.exs", __DIR__)
Code.require_file("fakes.exs", __DIR__)
defmodule TimeTest do
use ExUnit.Case, async: true
doctest Time
test "sigil_T" do
assert ~T[12:34:56] ==
%Time{calendar: Calendar.ISO, hour: 12, minute: 34, second... |
04b35690384272a75620ce89645909ea415db23a | 2,692 | [
574542358
] | [] | defmodule AdventOfCode.Day05 do
def parse_input do
input = AdventOfCode.Input.get!(5)
[raw_crates, raw_procedure] = String.split(input, "\n\n")
crates_lines =
raw_crates
|> String.split("\n")
|> Enum.reverse()
stack_index_line =
crates_lines
|> hd
|> String.graph... |
04b35eea2898cb9252b5465357a779ff1589d391 | 6,692 | [
80004679
] | [
"macro"
] | defmodule Iexfly.Router do
defmacro __using__(_opts) do
quote do
def init(options) do
options
end
def call(conn, _opts) do
route(conn.method, conn.path_info, conn)
end
end
end
end
defmodule Iexfly.Routing do
import Plug.Conn
use Iexfly.Router
import Iexf... |
04b38ca5e4436717395380062a054788a5bf8e69 | 2,195 | [
162384511
] | [
"test"
] | defmodule Data.Contexts.AgentContextTest do
use Data.SchemaCase
alias Data.Contexts.AgentContext
alias Ecto.UUID
test "create_agent with valid params" do
provider = insert(:provider)
params = %{
first_name: "Janna",
last_name: "Dela Cruz",
department: "SDDD",
role: "TL",
... |
04b3d48900b97b6e4421cec448419794c3904f69 | 3,312 | [
725881958
] | [] | defmodule Day1 do
defp get_digit(line, digits) when byte_size(line) === 0 do
digits
end
defp get_digit(line, digits) when tuple_size(digits) > 1 do
head = String.first(line)
case Integer.parse(head) do
{_a, _} ->
digits = put_elem(digits, 1, head)
get_digit(String.slice(line, 1... |
04b42edade27e7c7135184e7ea9c1044830d559f | 2,080 | [
726095940
] | [] | defmodule AdventOfCode.Day09 do
@input AdventOfCode.Input.get!(9, 2023)
def part1(input \\ @input) do
input
|> String.split("\n", trim: true)
|> Enum.map(&String.split(&1, " "))
|> Enum.map(&Enum.map(&1, fn element -> String.to_integer(element) end))
|> Enum.map(&Sequence.extrapolate/1)
|> ... |
04b4a3e207b386d8fc243f33e7f8a677a8d146f8 | 4,292 | [
40844606
] | [
"macro",
"test"
] | defmodule LogicTestMacro do
defmacro test_setting(desc, setting, func, value) do
quote do
test unquote(desc) do
assert_send_settings {unquote(setting), unquote(value)}, apply( GameState, unquote(func), [GameState.initial, unquote(value)])
end
end
end
end
defmodule SimpleGameL... |
04b4d07f238e022397c44462b8923c8ed2e2ae98 | 1,907 | [
121685196
] | [
"genserver",
"documented"
] | defmodule ModernWeb.Web.StatsDService do
@moduledoc """
StatsD Service to Collect Counts and Measurements of Anything of Interest
"""
use GenServer
defp run(:dev, state) do
GenServer.start_link(__MODULE__, state,
debug: [:trace, :statistics]
)
end
defp run(:prod, state) do
GenServer.start... |
04b50ff2ad78ce1b54f7b7ccb8f68ea36e380b56 | 1,571 | [
716324921
] | [] | IO.puts("Hello world from elixir")
IO.puts(1) # integer
IO.puts(0x1F) # integer
IO.puts(1.0) # float
IO.puts(true) # boolean
IO.puts(:atom) # atom / symbol
IO.puts("elixir") # string
#IO.puts([1, 2, 3]) # list
#IO.puts({1, 2, 3}) # tuple
IO.puts(1 + 2)
IO.puts(3)
IO.puts(5 * 5)
IO.... |
04b54f35804b64444a2b29889ed798adbb4a0909 | 4,576 | [
369048033
] | [
"phoenix",
"documented"
] | defmodule HelixGymWeb.EmployeeAuth do
import Plug.Conn
import Phoenix.Controller
alias HelixGym.Accounts
alias HelixGymWeb.Router.Helpers, as: Routes
# Make the remember me cookie valid for 60 days.
# If you want bump or reduce this value, also change
# the token expiry itself in EmployeeToken.
@max_a... |
04b5c152aa2c320a616f2f2c61f23e69e6321df5 | 2,826 | [
649453980
] | [
"phoenix"
] | defmodule ChattyWeb.Router do
use ChattyWeb, :router
import ChattyWeb.UserAuth
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, html: {ChattyWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
p... |
04b5c6309a54d37e9de2f7f934ab28ad1ca3512f | 3,296 | [
52499497
] | [] | defmodule Alexa.Request do
alias Alexa.{Session, RequestElement, Request, Intent, User}
defstruct [session: %Session{}, version: "1.0", request: %RequestElement{}]
def intent_request(app_id, intent_name, user_id \\ nil, slot_values \\ nil, attributes \\ %{}, access_token \\ nil) do
%Request{
session: ... |
04b6164bc0490f593e02834380dd57670d095fd2 | 2,792 | [
835025183,
833568228
] | [
"genserver",
"liveview"
] | defmodule ChatAppWeb.RoomLive.Show do
use ChatAppWeb, :live_view
alias ChatApp.Rooms
alias ChatApp.Accounts
alias ChatApp.Rooms.Message
# "/counter" mountが最初に呼び出される
# mountのあとにhandle_paramsが呼び出される
# 1. mount
# 2. handle_params
# 3. render or テンプレートがレンダリングされてクライアントに渡す
@impl true
def mount(_para... |
04b6423c45f4ba57e9d16d75575c851d6d4b2b2a | 3,795 | [
245142720
] | [
"macro",
"ecto"
] | defmodule Chatourius.Coherence.Schemas do
use Coherence.Config
import Ecto.Query
@user_schema Config.user_schema()
@repo Config.repo()
def list_user do
@repo.all(@user_schema)
end
def list_by_user(opts) do
@repo.all(query_by(@user_schema, opts))
end
def get_by_user(opts) do
@repo.get_... |
04b66dd1d6fcab7918b7fe951873b79b9aa4bc84 | 2,116 | [
119268099
] | [
"test"
] | defmodule CatcastsWeb.VideoControllerTest do
use CatcastsWeb.ConnCase
import Catcasts.Factory
alias Catcasts.Videos.Video
@create_attrs %{video_id: "https://www.youtube.com/watch?v=wZZ7oFKsKzY"}
@invalid_attrs %{video_id: ""}
def fixture(:video) do
user = insert(:user)
video = Catcasts.Repo.insert... |
04b67267a7b602c8480b43ecd531c1664ee6ddfd | 1,824 | [
165687186,
22574046
] | [] | defmodule Fawkes.Mixfile do
use Mix.Project
def project do
[
app: :fawkes,
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,
... |
04b6893b5d5b8478e1665761a6acbd973743197e | 1,672 | [
106408964
] | [
"test"
] | defmodule InfoSysTest do
use ExUnit.Case
alias InfoSys.Result
defmodule TestBackend do
def start_link(query, ref, owner, limit) do
Task.start_link(__MODULE__, :fetch, [query, ref, owner, limit])
end
def fetch("result", ref, owner, _limit) do
send(owner, {:results, ref, [%Result{backend: "... |
04b6bdcc0543acd71ff0f33dfd5de6d4b2d46a77 | 3,193 | [
959817494
] | [
"liveview",
"ecto"
] | defmodule PourWeb.SubregionLive.Form do
use PourWeb, :live_view
alias Pour.WineRegions
alias Pour.WineRegions.Subregion
@impl true
def render(assigns) do
~H"""
<Layouts.app flash={@flash}>
<.header>
{@page_title}
<:subtitle>Use this form to manage subregion records in your data... |
04b70cd9822d308fabe5ee4f391dc1e45566496d | 2,581 | [
757463973,
768011158,
279895213,
336985718,
610994830,
792554244,
493445187,
644559297,
895439861,
756299391,
531030808,
449967422
] | [
"typespec",
"documented",
"ecto"
] | defmodule ChatApi.ApiKeys do
@moduledoc """
The ApiKeys context.
"""
import Ecto.Query, warn: false
alias ChatApi.Repo
alias ChatApi.ApiKeys.PersonalApiKey
@spec list_personal_api_keys(binary(), binary()) :: [PersonalApiKey.t()]
def list_personal_api_keys(user_id, account_id) do
PersonalApiKey
... |
04b70cdf51a45497d5916b8c1e0c331c3ca60908 | 4,870 | [
978891067
] | [
"typespec",
"documented"
] | defmodule ExFTP.DigestAuthUtil do
@moduledoc false
@nc "00000001"
def request(url, http_method, username, password) do
%{path: path} = URI.parse(url)
with {:ok, digest_info} <- init_digest(url, http_method) do
response = create_response(http_method, username, password, digest_info, path)
au... |
04b75e478356b991959768903ce02146ff59ea83 | 2,115 | [
808816833
] | [] | defmodule Acme.MixProject do
use Mix.Project
def project do
[
app: :acme,
version: "0.1.0",
elixir: "~> 1.14",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps()
]
end
# Configuration for the OTP appl... |
04b7ea0a1d72c45d48a632661343a9c7fb4b8598 | 3,350 | [
392041749
] | [
"typespec",
"documented"
] | defmodule Watchex.Gameplay.Utils.GridManager do
@moduledoc """
Contains core functions for handling the world grid
"""
@grid_width 10
@grid_height 10
@wall_cell 1
alias Watchex.Gameplay.Utils.Position
@doc """
Returns the world grid map
"""
@spec get_world_grid() :: map()
def get_world_grid ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.