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 |
|---|---|---|---|---|
060d660349e6873bad1ff33747f38371b067f4fd | 8,101 | [
193244709,
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.ContainerAnalysis.V1.Model.ContaineranalysisGoogleDevtoolsCloudbuildV1BuildStep do
@moduledoc """
A step in the build pipeline.
## Attributes
* `allowExitCodes` (*type:* `list(integer())`, *default:* `nil`) - Allow this build step to fail without failing the entire build if and only if t... |
060d78f2b1d61afb2b5d2e9619b928c7a12bb349 | 4,960 | [
493824303
] | [
"typespec",
"supervisor",
"documented"
] | defmodule Deconzex.NetworkParameters do
@moduledoc false
defstruct nwk_panid: 0,
aps_extended_panid: 0,
current_channel: 0,
network_key: <<>>,
channel_mask: []
@type t :: %__MODULE__{}
end
defmodule Deconzex do
use Application
alias Deconzex.{Address, Device, ... |
060d828dddef313d4c560697f0b54b6aacc32660 | 8,182 | [
580790622
] | [
"macro",
"documented"
] | defmodule Cache.Redis do
@opts_definition [
uri: [
type: :string,
doc: "The connection uri to redis",
required: true
],
size: [
type: :pos_integer,
doc: "The amount of workers in the pool"
],
max_overflow: [
type: :pos_integer,
doc: "The amount of max ov... |
060dd59377b12b3ae363da7abc564e4a05118bd3 | 2,181 | [
258620636
] | [
"test",
"ecto"
] | defmodule PhoenixChatDemo.ChatsTest do
use PhoenixChatDemo.DataCase
alias PhoenixChatDemo.Chats
describe "messages" do
alias PhoenixChatDemo.Chats.Message
@valid_attrs %{body: "some body", name: "some name"}
@update_attrs %{body: "some updated body", name: "some updated name"}
@invalid_attrs %{... |
060df7691f33d20e6e195f6f9664e230f0ecaf0e | 2,025 | [
336985718
] | [
"phoenix"
] | defmodule ChatApiWeb.AccountView do
use ChatApiWeb, :view
alias ChatApi.{Utils, Accounts}
alias ChatApiWeb.{
AccountView,
UserView,
WidgetSettingsView,
WorkingHoursView
}
def render("index.json", %{accounts: accounts}) do
%{data: render_many(accounts, AccountView, "account.json")}
end... |
060e17eecf0e84b03bf2187e7ec7aa342f20d1dd | 15,101 | [
115170070
] | [
"documented"
] | defmodule Moola.GDAX do
use Moola, :context
alias Decimal, as: D
alias Moola.GDAXState
alias Moola.Fill
alias Moola.Order
alias Moola.FillQuery
alias Moola.OrderQuery
alias Moola.OrderLatency
def balance(currency) do
with {:ok, list} <- ExGdax.list_accounts,
cur <- currency |> upcase,
... |
060e2985f7600ee85d385b50fd7f2b0005679272 | 3,385 | [
102751238
] | [
"typespec",
"documented"
] | defmodule Aecore.Naming.Name do
@moduledoc """
Module defining the structure of a name
"""
alias Aecore.Chain.Identifier
alias Aecore.Governance.GovernanceConstants
alias Aecore.Keys
alias Aecore.Naming.Name
alias Aeutil.{Bits, Serialization}
@version 1
@typedoc "Reason of the error"
@type reas... |
060eaa090e7a7559455cba92b2ae0530757a33db | 2,473 | [
724550153,
808988160,
988078830,
720556173
] | [
"test",
"ecto"
] | defmodule Amazin.StoreTest do
use Amazin.DataCase
alias Amazin.Store
describe "products" do
alias Amazin.Store.Product
import Amazin.StoreFixtures
@invalid_attrs %{name: nil, description: nil, amount: nil, stock: nil, thumbnail: nil}
test "list_products/0 returns all products" do
produc... |
060eba670b9af801d631c819746183c200914459 | 2,102 | [
220987047
] | [
"documented",
"ecto"
] | defmodule TodoApp.Task do
@moduledoc """
The Task context.
"""
import Ecto.Query, warn: false
alias TodoApp.Repo
alias TodoApp.Task.Item
alias TodoApp.Task.Todolist
@doc """
Returns the list of items.
## Examples
iex> list_items()
[%Item{}, ...]
"""
def list_items do
Repo.a... |
060f084abc35c178d92b119b2461f48427412b02 | 1,606 | [
692204570
] | [
"liveview",
"phoenix"
] | defmodule PipeSpotWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :pipe_spot
plug CORSPlug
# 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,
... |
060f81155f8da59ec238f574c07dd704e6c54062 | 1,743 | [
164183996
] | [] | defmodule Hangman.Game do
defstruct turns_left: 7, game_state: :initializing, letters: [], used: MapSet.new()
alias Hangman.{Dictionary, Game}
def new_game(word) do
%Game{letters: word |> String.codepoints()}
end
def new_game do
Dictionary.random_word() |> new_game()
end
def make_move(game = %G... |
060fae182cacc727bc902d480b3c11cfd12a72e7 | 3,100 | [
34244562
] | [
"liveview"
] | defmodule Logger.Backends.Flowdock do
use GenEvent
def init(_) do
if user = Process.whereis(:user) do
Process.group_leader(self, user)
conf = configure()
{:ok, conf}
else
{:error, :ignore}
end
end
def handle_event({_level, gl, _event}, state) when node(gl) != node() do
... |
060fd6c8e5ef31552f1fa4934023369beff6bc7b | 8,553 | [
44943688
] | [
"typespec",
"documented"
] | defmodule JsonDiffEx do
@moduledoc """
This is the documentation of JsonDiffEx.
There are no runtime dependencies and it should be easy
to use.
You can use the javascript library
[jsondiffpatch](https://github.com/benjamine/jsondiffpatch)
with it since it get's it's diff format from it.
It contains b... |
0610274efa79b9611aea6cc39542e4141d8c6461 | 2,965 | [
418871405
] | [
"liveview",
"test"
] | defmodule FrontendWeb.Admin.UserLiveTest do
use FrontendWeb.ConnCase
import Phoenix.LiveViewTest
import Frontend.AccountsFixtures
@create_attrs %{}
@update_attrs %{}
@invalid_attrs %{}
defp create_user(_) do
user = user_fixture()
%{user: user}
end
describe "Index" do
setup [:create_use... |
061031cb6fe36791f29aefcfd50331f7fccdc381 | 2,427 | [
252759679
] | [
"test",
"ecto"
] | defmodule FinancialOperationsElixir.AuthTest do
use FinancialOperationsElixir.DataCase
alias FinancialOperationsElixir.Auth
describe "users" do
alias FinancialOperationsElixir.Auth.User
@valid_attrs %{is_active: true, email: "some email", password: "some password"}
@update_attrs %{
is_active:... |
06104a0b2ec3e9ae34ac9301247f3955a81e2c9f | 6,905 | [
799396731
] | [
"liveview",
"test"
] | defmodule ExpinWeb.AdminSettingsLiveTest do
use ExpinWeb.ConnCase, async: true
alias Expin.Admins
import Phoenix.LiveViewTest
import Expin.AdminsFixtures
describe "Settings page" do
test "renders settings page", %{conn: conn} do
{:ok, _lv, html} =
conn
|> log_in_admin(admin_fixture... |
061076f7a9e0cf2f77d8143c4480693ebfba8f43 | 3,398 | [
810163735
] | [
"liveview",
"test"
] | defmodule StreetglamWeb.OfferLiveTest do
use StreetglamWeb.ConnCase
import Phoenix.LiveViewTest
import Streetglam.ServicesFixtures
@create_attrs %{description: "some description", name: "some name"}
@update_attrs %{description: "some updated description", name: "some updated name"}
@invalid_attrs %{descri... |
0610ae2ad1dd6008e5faccf439d341a912cbd8dd | 1,700 | [
188736579
] | [
"test"
] | defmodule Kayrock.ClientTest do
use ExUnit.Case
@moduletag :integration
defp unexpected_processes(p_after, p_before) do
# returns a list of pids in p_after that were not in p_before _and also_ do
# not correspond to registered process names; registered processes sometimes
# spin up during normal ope... |
0610e6b9d23c8b1cbcff54ba6bf934e9f9964a75 | 2,170 | [
743670596
] | [
"test",
"ecto"
] | defmodule Board.RetroBoardsTest do
use Board.DataCase
alias Board.RetroBoards
describe "retro_boards" do
alias Board.RetroBoards.RetroBoard
import Board.RetroBoardsFixtures
@invalid_attrs %{title: nil}
test "list_retro_boards/0 returns all retro_boards" do
retro_board = retro_board_fixt... |
0610f39b2a64b5ca54a6f77393dfc553a2c83649 | 2,664 | [
833014332
] | [
"phoenix"
] | defmodule PhoenixServerWeb.Router do
use PhoenixServerWeb, :router
import PhoenixServerWeb.UserAuth
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, html: {PhoenixServerWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_... |
06111872922a2ff72aa23d71d7ad816612b97daf | 1,507 | [
791545662
] | [] | defmodule LinhaDigitavel do
def dvBloco(lista) do
Enum.reverse(lista)
|> Enum.map_every(2, fn x -> (x * 2) |> Integer.digits() |> Enum.sum() end)
|> Enum.sum()
|> (&(10 - rem(&1, 10))).()
end
def ordenar(codigodebarras) do
codigodebarras
|> Enum.slice(9..18)
|> then(fn append -> Enum.... |
06113771deeb1aa36f2c9c4a51688a943fb3e854 | 3,395 | [
310687206
] | [
"documented",
"ecto"
] | defmodule Auth.Accounts.User do
use Ecto.Schema
import Ecto.Changeset
@derive {Inspect, except: [:password]}
schema "users" do
field :email, :string
field :password, :string, virtual: true
field :hashed_password, :string
field :confirmed_at, :naive_datetime
timestamps()
end
@doc """
... |
061195c97d0d9c2b184e31c40730e7e2d1c3aadb | 3,085 | [
75657500
] | [] | defmodule Day18 do
def part1(input) do
input
|> parse()
|> count_faces(false)
end
def part2(input) do
cubes =
input
|> parse()
{{min_x, _, _}, {max_x, _, _}} = Enum.min_max_by(cubes, &elem(&1, 0))
{{_, min_y, _}, {_, max_y, _}} = Enum.min_max_by(cubes, &elem(&1, 1))
{{_, ... |
0611b1c659344a3966cc0bf921052c46b104847a | 2,381 | [
47661752
] | [] | defmodule ExHttpd.Response do
def reply(request) do
request
|> new_response
|> set_status_line
|> set_content_type
|> set_content
|> format_request
end
###############
# private
###############
defp new_response(data) do
%{
status_line: %{
version: nil... |
061214a366d1798c12a8931c6f207d026459a133 | 2,252 | [
137383377
] | [] | defmodule Excommerce.Query.Product do
use Excommerce.Query, schema: Excommerce.Catalog.Product
def has_variants_excluding_master?(repo, product) do
repo.one(count_variants_excluding_master(product)) > 0
end
def count_variants_excluding_master(product) do
from variant in all_variants_excluding_master(p... |
06127e211b5b469f3da24589bdaf215ceaf9ca88 | 10,714 | [
989918778
] | [
"test"
] | defmodule MCPChat.ConnectionPoolTest do
use ExUnit.Case, async: false
alias MCPChat.ConnectionPool
@moduletag :unit
describe "ConnectionPool" do
setup do
pool_name = :"test_pool_#{System.unique_integer([:positive])}"
{:ok, pid} =
ConnectionPool.start_link(
name: pool_name,
... |
0612d6d008380dae9689b8d43bceb0eec1ca00fc | 1,760 | [
333982952
] | [
"test",
"ecto"
] | defmodule Dogistics.DogsTest do
use Dogistics.DataCase
alias Dogistics.Dogs
describe "dogs" do
alias Dogistics.Dogs.Dog
@valid_attrs %{name: "some name"}
@update_attrs %{name: "some updated name"}
@invalid_attrs %{name: nil}
def dog_fixture(attrs \\ %{}) do
{:ok, dog} =
attrs... |
061306d3d70577ec80101e1a67382d2ac1f73c31 | 2,216 | [
42716040
] | [
"test"
] | defmodule SummerSinger.PlaylistControllerTest do
use SummerSinger.Web.ConnCase
alias SummerSinger.Playlist
@valid_attrs %{title: "some content"}
@invalid_attrs %{}
setup do
conn = conn() |> put_req_header("accept", "application/json")
{:ok, conn: conn}
end
test "lists all entries on index", %{c... |
06134d9f1bcf9324892f301b2c4c5f04ca11dbcc | 2,205 | [
193244709,
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.ServiceUsage.V1.Model.MethodSettings do
@moduledoc """
Describes the generator configuration for a method.
## Attributes
* `autoPopulatedFields` (*type:* `list(String.t)`, *default:* `nil`) - List of top-level fields of the request message, that should be automatically populated by the c... |
0613617251e417326bf0ef28b65bd7e5a19e3a76 | 9,726 | [
102094797
] | [
"test",
"phoenix"
] | defmodule CgratesWebJsonapi.TariffPlans.TpAccountActionControllerTest do
use CgratesWebJsonapi.ConnCase
alias CgratesWebJsonapi.TariffPlans.TpAccountAction
alias CgratesWebJsonapi.Repo
import CgratesWebJsonapi.Factory
import CgratesWebJsonapi.Guardian
setup do
user = insert(:user)
{:ok, token, _... |
06139b9865b4804952784982e7e52f080b6f14c7 | 2,088 | [
883177506
] | [
"test",
"ecto"
] | defmodule SampleApp.MicropostsTest do
use SampleApp.DataCase
alias SampleApp.Microposts
describe "microposts" do
alias SampleApp.Microposts.Micropost
import SampleApp.MicropostsFixtures
@invalid_attrs %{content: nil}
test "list_microposts/0 returns all microposts" do
micropost = micropo... |
0613aad7f64bce2a09bd55d56eea9037995c29ef | 3,392 | [
148493373
] | [
"documented",
"ecto"
] | defmodule Jumubase.Foundation.Contest do
use Jumubase.Schema
import Ecto.Changeset
import Jumubase.Gettext
alias Ecto.Changeset
alias Jumubase.JumuParams
alias Jumubase.Foundation.{Contest, ContestCategory, Host}
schema "contests" do
field :season, :integer
field :round, :integer
field :group... |
0613b42f820e2d86f1b114a72dc006afb332cb09 | 2,104 | [
159989230
] | [
"test"
] | defmodule AlchemistReduction do
def part_one(input) do
input
|> String.codepoints()
|> reduction()
end
def part_two(input) do
units =
Enum.map(MapSet.new(String.codepoints(String.downcase(input))), fn x ->
[x, String.upcase(x)]
end)
Enum.map(units, fn units ->
Strin... |
061498b2e94c37376de6360d6e76c5a83808f8b7 | 6,503 | [
498675807
] | [
"documented"
] | defmodule AppCount.Messaging.Utils.TextMessageReplies do
@moduledoc """
All the logic for handling replies from residents should go here.
As the functionality undoubtedly expands we may need to branch out into different modules.
Maybe one for payments, one for maintenance etc. But for now this will handle all.... |
0614a50c21a14d2dee1cf2426740b9e08531de1e | 3,181 | [
37492016
] | [
"test"
] | defmodule PubSubTest do
use ExUnit.Case
doctest PubSub
setup do
{:ok, server} = PubSub.start_link()
on_exit fn ->
assert_down(server)
PubSub.terminate(server, :shutdown)
end
end
test "child_spec returns the child spec for supervisors" do
assert PubSub.child_spec(arg: 1) == %{
... |
0614d27431be1429d4d689237d3fe4b52ad258db | 3,126 | [
382879753
] | [
"documented"
] | defmodule Mix.Tasks.OpenBanking.Import do
use Mix.Task
import OpenBanking.Transaction, only: [import!: 2, insert_all: 2]
import Mix.Tasks.OpenBanking.Helper, only: [print_transaction: 1, convert_confidence: 1]
require Logger
@shortdoc "Reads a CSV file and shows a list of matches against previous seen transa... |
06151db3eb818e92745f3b9ee3ca1bdc35d7b7b9 | 10,215 | [
438598317
] | [
"typespec",
"documented"
] | defmodule AntlPhonenumber do
@moduledoc "README.md"
|> File.read!()
|> String.split("<!-- MDOC !-->")
|> Enum.fetch!(1)
alias AntlPhonenumber.Nif
@default_ref_iso_country_code "IL"
# @supported_formats ~w(e164 international national rfc3966)
@google_supported_formats ~... |
06152a8e9dc47f8aecffd395f62108373624b762 | 3,948 | [
234903986
] | [
"documented",
"ecto"
] | defmodule BuckyPhoenix.Todo do
@moduledoc """
The Todo context.
"""
import Ecto.Query, warn: false
alias BuckyPhoenix.Repo
alias BuckyPhoenix.Todo.List
alias BuckyPhoenix.Accounts.User
@doc """
Returns the list of user lists.
## Examples
iex> list_user_lists(%User{})
[%List{}, ...]
... |
061549eee6963b198859050804bb8b3160f15d2a | 1,830 | [
181615723
] | [
"liveview",
"macro",
"documented",
"phoenix"
] | defmodule ErlportDemoWeb 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 ErlportDemoWeb, :controller
use ErlportDemoWeb, :view
The definitions below will be executed for every view,
... |
06168ba5b239325f14ea2ef73fe95ff056a6d03c | 3,708 | [
680432046
] | [
"test"
] | defmodule MoveDropTest do
use ExUnit.Case
test "Passing a 5*4 board, (0, 0), :right, returns a board that swapped successfully" do
fakeBoard =
Enum.map(0..3, fn y ->
Enum.map(0..4, fn x ->
case {x, y} do
{0, 0} -> :blue
_ -> :red
end
end)
... |
06168d43f9428209fbe9dccd6d698e7ecce28d94 | 1,725 | [
49330398
] | [
"macro",
"documented",
"ecto",
"phoenix"
] | defmodule SimpleChat.Web do
@moduledoc """
A module that keeps using definitions for controllers,
views and so on.
This can be used in your application as:
use SimpleChat.Web, :controller
use SimpleChat.Web, :view
The definitions below will be executed for every view,
controller, etc, so keep... |
0616b261784d700633a7365cc68b49a54311a726 | 4,541 | [
82234621
] | [
"documented"
] | Code.ensure_compiled(ExAdmin.Utils)
defmodule ExAdmin.Filter do
@moduledoc false
require Logger
require Ecto.Query
import ExAdmin.Theme.Helpers
import ExAdmin.Utils
import ExAdmin.Gettext
use Xain
@integer_options [eq: (gettext "Equal To"), gt: (gettext "Greater Than"), lt: (gettext "Less Than") ]
@s... |
0616f90d454fb66f4e12e676b2998b7a8efa0182 | 1,538 | [
423863622
] | [] | #https://www.beecrowd.com.br/judge/pt/problems/view/1072
defmodule BcParse do
def str_to_float(str) do
str
|> Float.parse()
|> elem(0)
end
def str_to_integer(str) do
str
|> Integer.parse()
|> elem(0)
end
def float_to_str(number, precision \\ 2) do
:erlang.float_to_binary(number,... |
06170930992332fa85cc403740e9554e42e863fb | 4,448 | [
21627144
] | [] | defmodule SFSObject do
def new() do
%{}
end
def new(%{} = data) do
data
end
def get(%{} = data, key) do
Map.get(data, key)
end
def put(%{} = data, key, {type, _} = tagged) when is_atom(type) do
Map.put(data, key, tagged)
end
def put_null(object, key) do
put_data(object, key, :n... |
06175544af11d9db88501d10819f68671ead0b75 | 8,745 | [
657799110,
679652486
] | [
"macro",
"typespec",
"test"
] | defmodule Credo.Check.Design.AliasUsageTest do
use Credo.Test.Case
@described_check Credo.Check.Design.AliasUsage
#
# single alias cases
#
#
# cases NOT raising issues
#
test "it should NOT report expected code" do
"""
defmodule CredoSampleModule do
alias ExUnit.Case
def fun1 ... |
06176df9656bb319606fab050023fe3c40e75d43 | 2,495 | [
73010257
] | [
"ecto"
] | defmodule Efl.Dadi do
use Efl.Web, :model
alias Efl.RefCategory
alias Efl.Dadi.Category
alias Efl.Dadi.Post
alias Efl.Repo
alias Efl.Dadi
alias Efl.TimeUtil
alias Efl.Mailer
alias Efl.Proxy
alias Efl.MyHttp
alias Efl.Dadi.Category
require IEx
require Logger
schema "dadi" do
field :titl... |
06187e6962e62c47709b69254dadae61547a8b60 | 2,999 | [
225233137
] | [] | defmodule HexTiler do
@directions_map %{
"e" => {2, 0},
"w" => {-2, 0},
"sw" => {-1, -1},
"nw" => {-1, 1},
"se" => {1, -1},
"ne" => {1, 1}
}
def load_initial_state(directions) do
directions
|> Enum.map(&directions_to_coordinates/1)
|> Enum.group_by(fn x -> x end)
|> Enum.m... |
0618e72665fc31a0d1df8648e89e2c0ee15fd9be | 5,290 | [
262421041
] | [] | %{
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"},
"cachex": {:hex, :cachex, "3.2.0", "a596476c781b0646e6cb5cd9751af2e2974c3e0d5498a8cab71807618b74fe2f", [:mix], [{:eternal, "... |
0618e8c8921f7660ed3f4e85d5959fd94dd22b49 | 6,016 | [
992476388
] | [] | defmodule ExEcc.OptimizedBLS12381.OptimizedCurve do
alias ExEcc.Fields.OptimizedBLS12381FQ, as: FQ
alias ExEcc.Fields.OptimizedBLS12381FQ2, as: FQ2
alias ExEcc.Fields.OptimizedBLS12381FQ12, as: FQ12
alias ExEcc.FieldMath
@field_modulus ExEcc.Fields.FieldProperties.field_properties()["bls12_381"].field_modulu... |
06193e70921b682c3db84d0718781bed746a5fe6 | 1,630 | [
149292201
] | [
"phoenix"
] | defmodule KoobaServerWeb.MpesaController do
use KoobaServerWeb, :controller
alias KoobaServer.Repo
alias KoobaServer.MpesaTransaction.SendMoneyRequest
alias KoobaServer.MpesaTransaction
alias KoobaServer.MicroFinance
alias KoobaServer.MicroFinance.LoanTaken
import Ecto.Query, warn: false
require Logge... |
061983d33bbef35876e361c80d4b63c4c8734c68 | 10,872 | [
507349355
] | [
"documented",
"ecto"
] | defmodule OmegaBravera.Offers.Offer do
use Ecto.Schema
import Ecto.Changeset
import OmegaBravera.Fundraisers.NgoOptions
alias OmegaBravera.Offers.{
OfferChallenge,
OfferReward,
OfferVendor,
OfferRedeem,
OfferLocation,
OfferGpsCoordinate
}
alias OmegaBravera.Groups.OfferPartner
@... |
061a046bb6aee401379129681225ee3fc7feedae | 4,312 | [
445972960
] | [
"test",
"ecto"
] | defmodule Discuss.BlogTest do
use Discuss.DataCase, async: true
import Discuss.Factories
alias Discuss.Blog
describe "topics" do
alias Discuss.Blog.Topic
@invalid_attrs %{title: nil}
@valid_attrs %{title: "Some title"}
test "list_topics/0 returns all topics ordered by title" do
%Topic... |
061a110214adf143b8086c30100a23927ea3ecb4 | 1,613 | [
125572405
] | [
"macro",
"documented",
"phoenix"
] | defmodule PolytextWeb 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 PolytextWeb, :controller
use PolytextWeb, :view
The definitions below will be executed for every view,
controlle... |
061a2907817518103bc58f7169f678807c220a12 | 2,780 | [
126642485
] | [
"genserver",
"phoenix"
] | defmodule CheckersWeb.GamesChannel do
use CheckersWeb, :channel
alias Checkers.Game
alias Phoenix.Socket
alias Checkers.Agent
def join("games:" <> name, payload, socket) do
if authorized?(payload) do
game = Checkers.Agent.get(name) || Game.new()
user = Map.get(payload, "user")
game = Ga... |
061abf87a272098a6eaeb12a21ab14b29e789533 | 2,436 | [
196256963
] | [
"test"
] | if !System.get_env("EXERCISM_TEST_EXAMPLES") do
Code.load_file("markdown.exs", __DIR__)
end
ExUnit.start()
#ExUnit.configure(exclude: :pending, trace: true)
defmodule MarkdownTest do
use ExUnit.Case
# @tag :pending
test "parses normal text as a paragraph" do
input = "This will be a paragraph"
expecte... |
061ad202563c2944700f3c901ebb2da28c29e887 | 2,856 | [
63981899
] | [
"ecto"
] | defmodule Artisan.Iterations do
use Artisan.Repo
alias Artisan.Iteration
def create_for(project_id) do
if active_iteration_exists?(project_id) do
{:error, :active_iteration_exists}
else
{:ok, iteration} = %Iteration{number: next_number(project_id), state: "planning"}
|> Iteration.chan... |
061b8e1641ab7efcdbbcc90b69e1fc81c9e47707 | 2,844 | [
193244709,
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.DocumentAI.V1beta2.Model.GoogleCloudDocumentaiV1beta1DocumentChunkedDocumentChunk do
@moduledoc """
Represents a chunk.
## Attributes
* `chunkId` (*type:* `String.t`, *default:* `nil`) - ID of the chunk.
* `content` (*type:* `String.t`, *default:* `nil`) - Text content of the chunk.
... |
061bda241ab3b5b712b83abb313f5ba7be1ccbaa | 2,328 | [
234328898
] | [] | %{
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"},
"credo": {:hex, :credo, "1.5.4", "9914180105b438e378e94a844ec3a5088ae5875626fc945b7c1462b41afc3198", [:mix], [{:bunt, "~> 0.... |
061d4515aa37aa3056d44a0a7729e928a6c9827e | 2,090 | [
576977600
] | [] | defmodule SuperPoker.IrcDataset.PlayerActions do
alias SuperPoker.IrcDataset.PlayerActions
defstruct [
:username,
:game_id,
:num_players,
:pos,
:preflop,
:flop,
:turn,
:river,
:bankroll,
:total_bet,
:winnings,
:hole_cards
]
# player #play prflop t... |
061e03f1c31700246db5aea699b7ebbba4c8b747 | 4,084 | [
203403185
] | [
"documented"
] | defmodule Rpitouch.Scene.Components do
@moduledoc """
Sample scene.
"""
use Scenic.Scene
alias Scenic.Graph
import Scenic.Primitives
import Scenic.Components
alias Rpitouch.Component.Nav
alias Rpitouch.Component.Notes
@body_offset 60
@notes """
\"Components\" shows the basic components ava... |
061e05f4c63e0f554fb7ceaff0aadf0ace3cb195 | 1,585 | [
62314655
] | [
"documented"
] | defmodule MAC.Parser do
@doc "Returns a list of tuples with {bitstring-mac (or part), company}"
def parse_wireshark_file(text) do
text
|> String.split("\n", trim: true)
|> Enum.map(fn line -> String.strip(line) end)
|> Enum.filter(fn line -> not String.starts_with?(line, "#") end)
|> Enum.map(&p... |
061e274abd53dbb3a6ac79ae4e056cb50b8b1050 | 3,592 | [
205204672
] | [
"macro",
"test"
] | defmodule AnalyzerTest do
use ExUnit.Case, async: true
doctest Analyzer
@subject Analyzer
describe "supported?/1" do
test "with pipe, anonymous function: fn, one argument" do
quoted = quote do: [1, 2, 3] |> Enum.map(fn x -> x + 1 end)
assert {:|>, [context: _, import: Kernel], [[1, 2, 3], rig... |
061e448f817c99ff2e96942a99a1200634b8bc28 | 2,410 | [
568578073
] | [
"test"
] | defmodule Sleeky.Domain.AuthorizationTest do
use Sleeky.DataCase
alias Blogs.Accounts
alias Blogs.Publishing
setup [:comments, :current_user]
describe "allow/3" do
test "denies if the scope does not match", context do
params =
context
|> other_user()
|> Map.fetch!(:params)... |
061e5ff6db8a72851ffca4e046005776c4a62a42 | 2,427 | [
850350239
] | [
"liveview"
] | # 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 :finance_control, FinanceControl.Repo,
adapt... |
061e949725cb1d68711b1079f4ff29783b106461 | 2,025 | [
134298117
] | [
"test"
] | defmodule FDBLeakTest do
use ExUnit.Case
import TestUtils
require Logger
alias FDB.Transaction
setup do
flushdb()
end
@tag timeout: 300_000, integration: true
test "memory leak" do
assert_memory()
db = new_database()
Task.async_stream(
1..100_000,
fn i ->
if Integ... |
061f1b259eb41ba2584392a3403b5663d96ef06b | 5,125 | [
26739267
] | [
"typespec",
"documented"
] | defmodule Loom.LWWRegister do
@moduledoc """
A Last-write-wins register
While alone, this kinda defeats the point of a CRDT, there are times, such as
in a map or other kind of composite CRDT, where an individual value should
be last-write-wins, but we'd like to preserve causality between all the
properties... |
061f2f9676164dae82d1f3bc489fb9e06c58bdc7 | 1,791 | [
795012823
] | [
"phoenix",
"ecto"
] | defmodule NestWeb.UserController do
use NestWeb, :controller
alias Nest.Repo
alias Nest.User
alias Nest.Reservation
alias NestWeb.CabinController
import Ecto.Query, only: [from: 2]
def create(conn, params) do
case create_user(params) do
{:ok, user} ->
json(conn, render_user(user))
... |
061f4a19ffb2856adf65f596f01511a0e185542a | 2,106 | [
98185781
] | [
"typespec",
"documented"
] | defmodule Codebattle.CodeCheck.Executor.RemoteDockerRun do
@moduledoc false
alias Codebattle.CodeCheck.Checker.Token
alias Runner.AtomizedMap
alias Runner.Languages
require Logger
@spec call(Token.t()) :: Token.t()
def call(token) do
%{
lang_slug: token.lang_meta.slug,
solution_text: to... |
061f85298208802acf0edfd898a6ae11c4e8c6a1 | 2,312 | [
91636531
] | [] | defmodule HelloNerves.Mixfile do
use Mix.Project
@target System.get_env("MIX_TARGET") || "host"
Mix.shell.info([:green, """
Env
MIX_TARGET: #{@target}
MIX_ENV: #{Mix.env}
""", :reset])
def project do
[app: :hello_nerves,
version: "0.1.0",
elixir: "~> 1.4.0",
target: @targe... |
06203cd7a049663385c73cd3e1842d9a42103b58 | 2,314 | [
736378358
] | [
"liveview",
"phoenix",
"documented"
] | defmodule HelloWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :hello
# 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: "_hello_key",
... |
06205556bff45b2881dc2ac0a586e1f39d9b62b0 | 1,702 | [
106020862
] | [
"documented"
] | defmodule Coherence.Redirects do
@moduledoc """
Define controller action redirection functions.
This module contains default redirect functions for each of the controller
actions that perform redirects. By using this Module you get the following
functions:
* session_create/2
* session_delete/2
* passw... |
06206e8b85262a2a667fd8e4b4242b3bcf83c3a9 | 1,526 | [
361128927,
335245648,
403883677
] | [
"test"
] | defmodule Ex35Test do
use ExUnit.Case
doctest Pymi
test "Gen list 10 elements 2" do
assert Ex351.solve() == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
assert Ex351.solve() == for(_ <- 1..10, do: 2)
end
test "Gen list N random integer" do
assert Ex352.solve(5) |> length == 5
assert Ex352.solve(3) |> Enum... |
062080d07dcae2cb5de8f18013c5c40becb35c4d | 1,560 | [
979602719
] | [
"macro",
"documented",
"phoenix"
] | defmodule QuranApiWeb do
@moduledoc """
The entrypoint for defining your web interface, such
as controllers, components, channels, and so on.
This can be used in your application as:
use QuranApiWeb, :controller
use QuranApiWeb, :html
The definitions below will be executed for every controller,... |
0620c1adeae26bd8f165316e680817ac042a138f | 5,559 | [
542291437
] | [
"typespec",
"documented"
] | defmodule AshAuthentication.Strategy.Password.SignInWithTokenPreparation do
@moduledoc """
Prepare a query for sign in via token.
This preparation first validates the token argument and extracts the subject
from it and constrains the query to a matching user.
"""
use Ash.Resource.Preparation
alias AshAut... |
0620c3f02acdac176c1dbe9147fc9f05ea659ea1 | 2,026 | [
677845133
] | [
"typespec",
"documented"
] | defmodule YouCongress.Votings.TitleRewordingAI do
@moduledoc """
Generate opinions via OpenAI's API.
"""
alias YouCongress.DigitalTwins.OpenAIModel
@prompt """
Generate two questions from the prompt so:
- It is short (more like a title) and grammatically correct in English. Translate to English if it's ... |
0620c621afe257fdcd28402879a23556a7662254 | 6,890 | [
582494031
] | [
"documented"
] | defmodule Fedi.Streams.BaseType do
@moduledoc false
require Logger
alias Fedi.Streams.Utils
def get_type_name(%{__struct__: module}, opts \\ []) do
type_name = apply(module, :type_name, [])
type_name =
cond do
Keyword.get(opts, :atom, false) ->
type_name |> Macro.underscore()... |
0621568c425fdc57ff87d59503ad0891b2acac25 | 6,860 | [
578394250,
434481099
] | [
"typespec",
"documented"
] | defmodule PassGenerator do
@moduledoc """
Generates random password depending on paramaters. Module main function is `generate(options)`.
That functon takes the options map.
Options example:
options = %{
"length" => "5",
"numbers" => "false",
"uppercase" => "false",
"symbol... |
06216992e042c4e61a9af687f9da6452951f3fa5 | 1,955 | [
250904436,
856324570,
872091867,
913995146,
915448704,
934044764,
962529983,
999002987,
1017248001,
828087786,
829435121,
981606048,
1002277727,
1017741371,
1019465249,
882758430,
884344453,
939645202,
1010134902,
877418520,
924963573,
947818330,
995397072,
980882450,
... | [
"typespec",
"macro",
"documented"
] | defmodule Jason.Sigil do
@doc ~S"""
Handles the sigil `~j` for JSON strings.
Calls `Jason.decode!/2` with modifiers mapped to options.
Given a string literal without interpolations, decodes the
string at compile-time.
## Modifiers
See `Jason.decode/2` for detailed descriptions.
* `a` - equivalent... |
0621c30512678c2526f6ca82fa2cfb6742121560 | 1,918 | [
423863622
] | [] | #https://www.beecrowd.com.br/judge/pt/problems/view/1144
defmodule BcParse do
def str_to_float(str) do
str
|> Float.parse()
|> elem(0)
end
def str_to_integer(str) do
str
|> Integer.parse()
|> elem(0)
end
def float_to_str(number, precision \\ 2) do
:erlang.float_to_binary(number,... |
062235ff29b621578d763d710eee5d898680f81d | 1,917 | [
117446337,
130597606
] | [
"documented",
"ecto"
] | defmodule Taskspa.Workers do
@moduledoc """
The Workers context.
"""
import Ecto.Query, warn: false
alias Taskspa.Repo
alias Taskspa.Workers.Worker
@doc """
Returns the list of workers.
## Examples
iex> list_workers()
[%Worker{}, ...]
"""
def list_workers do
Repo.all(Worker)
... |
06229c08cabe4033ad44ed07be79071746a9cf10 | 2,126 | [
729839046
] | [
"test"
] | defmodule Day5Test do
use ExUnit.Case
@example_input [
"seeds: 79 14 55 13",
"",
"seed-to-soil map:",
"50 98 2",
"52 50 48",
"",
"soil-to-fertilizer map:",
"0 15 37",
"37 52 2",
"39 0 15",
"",
"fertilizer-to-water map:",
"49 53 8",
"0 11 42",
"42 0 7",
... |
0622b86a39840a1e8df91deb8170b790136f2fab | 3,740 | [
563322590
] | [
"test"
] | defmodule GroupherServer.Test.Query.CMS.Search do
use GroupherServer.TestTools
# alias GroupherServer.Accounts.Model.User
alias GroupherServer.CMS
setup do
guest_conn = simu_conn(:guest)
{:ok, _community} = db_insert(:community, %{title: "react"})
{:ok, _community} = db_insert(:community, %{title:... |
0622fe561879d204fe4ab19354c77b8c5c6332f7 | 1,550 | [
534208201
] | [
"documented"
] | defmodule CloudEvents.CloudEvent.AttributesEntry do
@moduledoc false
use Protobuf, map: true, protoc_gen_elixir_version: "0.11.0", syntax: :proto3
field :key, 1, type: :string
field :value, 2, type: CloudEvents.CloudEventAttributeValue
end
defmodule CloudEvents.CloudEvent do
@moduledoc false
use Protobuf,... |
062302458b4e94ce6df9ad939b9c864d4d47e347 | 4,241 | [
589055635
] | [] | defmodule RabbitDriver.ScriptConsumer do
@behaviour RabbitDriver.Consumer
@lua_type "application/x-lua"
alias RabbitDriver.ImageConsumer
alias RabbitDriver.DataURL
def start_link(opts) do
defaults = [module: __MODULE__, topics: ["script.#"], queue: "script_consumer"]
opts = Keyword.merge(defaults, ... |
06230bf510e96b833e9478e4aab9729d0ae65aaa | 10,026 | [
376959663
] | [
"test",
"phoenix"
] | defmodule OliWeb.LegacySuperactivityControllerTest do
use OliWeb.ConnCase
alias Oli.Delivery.Sections
alias Oli.Seeder
alias Oli.Delivery.Attempts.Core, as: Attempts
alias Lti_1p3.Tool.ContextRoles
alias Oli.Activities
alias OliWeb.Router.Helpers, as: Routes
describe "legacy superactivity" do
se... |
062342f7f9b87ccb74da45896ae3140917d95c20 | 2,451 | [
308395466
] | [
"typespec",
"documented"
] | defmodule Dynamo do
@moduledoc """
Documentation for `Dynamo`.
"""
require Logger
@type ring() :: Ring
@doc """
Return the ring from the remote node
"""
@spec get_other_ring(atom()) :: ring()
def get_other_ring(node) do
{Dynamo.TaskSupervisor, node}
|> Task.Supervisor.async(Ring.Manager, :g... |
06234ffecdf005fb952df6f2d3580511f4bac5bb | 1,826 | [
839649565
] | [
"phoenix",
"ecto"
] | defmodule GoodreadsWeb.SaleController do
use GoodreadsWeb, :controller
alias Goodreads.Sales
alias Goodreads.Sales.Sale
alias Goodreads.Library.Book
def index(conn, _params) do
sales = Goodreads.Repo.all(Goodreads.Sales.Sale) |> Goodreads.Repo.preload(:book)
render(conn, :index, sales: sales)
end
... |
062365a0123cebd2601d4d1d256505d40d147029 | 1,891 | [
380122576
] | [
"ecto"
] | defmodule Rinari.Utils do
alias Ecto.Changeset
def typed_id_to_entity(type, id) when is_binary(type) do
typed_id_to_entity(String.to_atom(type), id)
end
def typed_id_to_entity(type, id) do
Rinari.Schemas.get(type)
|> Rinari.Repo.get!(id)
end
def entity_to_typed_id(entity) do
entity.__meta... |
062386a56455781c8ad27fcf89f8a52da30e7c04 | 2,367 | [
196374121
] | [
"genserver"
] | defmodule Calci.Calculator do
use GenServer
alias Calci.Calculator
defstruct value: 0
# API
def start_link(_arg \\ []) do
GenServer.start_link(__MODULE__, Calculator.new(), name: __MODULE__)
end
def new do
%Calculator{value: 0}
end
def add(number) do
GenServer.call(Calculator, {:add, ... |
06239f965df927bbf129422e33881d835e0bcf94 | 3,472 | [
437906643
] | [
"typespec",
"test",
"documented"
] | defmodule ExUnit.CaptureLog do
@moduledoc ~S"""
Functionality to capture logs for testing.
## Examples
defmodule AssertionTest do
use ExUnit.Case
import ExUnit.CaptureLog
require Logger
test "example" do
{result, log} =
with_log(fn ->
L... |
0623c5cae9c064044e230277e410675c0711a18f | 1,699 | [
213783551
] | [
"genserver",
"documented"
] | defmodule Master do
@moduledoc false
use GenServer
def start_link(opts) when is_tuple(opts) do
GenServer.start_link(__MODULE__, opts)
end
# def init({alive_count}) do
def init({numNodes, numRequests}) do
all_hops = []
{:ok, {numNodes, numRequests,all_hops}}
# {:ok, {numNodes, max_hop}}
... |
062439c7cdc447a42162f6b78aa70e81f0391da8 | 5,198 | [
164160757
] | [
"phoenix",
"ecto"
] | defmodule FivelWeb.RoomController do
use FivelWeb, :controller
alias Fivel.Repo
alias Fivel.Rooms
alias Fivel.Rooms.Room
alias Fivel.EssenceAlphas
alias Fivel.EssenceAlphas.EssenceAlpha
plug Guardian.Plug.EnsureAuthenticated, handler: FivelWeb.SessionController
action_fallback FivelWeb.FallbackContro... |
062446fee08ddc2254f85dc020a6e704c14de49a | 1,785 | [
680138507
] | [
"liveview"
] | defmodule SankolistaWeb.PostsLive.Index do
use SankolistaWeb, :live_view
#import Phoenix.HTML.Form
alias Sankolista.List.ListItem
@impl true
def render(assigns) do
~H"""
<h2>Sankolista</h2>
<div>
<%= for item <- @list_items do %>
<div>
<h3><%= item.title %></h3>
</... |
0624aefdd96cdd6bf1d01ab0f621ee441e094411 | 8,445 | [
904399333
] | [
"test",
"documented"
] | # credo:disable-for-this-file Credo.Check.Readability.LargeNumbers
# credo:disable-for-this-file Credo.Check.Readability.StringSigils
defmodule JSV.Generated.Draft7.BinaryKeys.AdditionalItemsTest do
alias JSV.Test.JsonSchemaSuite
use ExUnit.Case, async: true
@moduledoc """
Test generated from deps/json_schema... |
0624e693951ad3147e44e48d743573e92607d5bd | 1,706 | [
134590818
] | [
"phoenix"
] | defmodule Flux.Router do
use Flux.Web, :router
pipeline :api do
plug :accepts, ["json"]
end
pipeline :auth do
plug Guardian.Plug.Pipeline, module: Flux.Guardian, error_handler: Flux.GuardianErrorHandler
plug Guardian.Plug.VerifyHeader
plug Guardian.Plug.EnsureAuthenticated
plug Guardian.Pl... |
0624f837b356c728b2460d4eea1f7ba4df1460d5 | 7,628 | [
367278931
] | [
"documented"
] | defmodule Google.Cloud.Aiplatform.V1beta1.NasJobSpec.MultiTrialAlgorithmSpec.MultiTrialAlgorithm do
@moduledoc false
use Protobuf, enum: true, protoc_gen_elixir_version: "0.14.1", syntax: :proto3
field :MULTI_TRIAL_ALGORITHM_UNSPECIFIED, 0
field :REINFORCEMENT_LEARNING, 1
field :GRID_SEARCH, 2
end
defmodul... |
06251e1b812906f0c0ff0df54a13b5eac237e464 | 4,763 | [
716126299
] | [
"test",
"ecto"
] | defmodule Api.WorkfollowTest do
use Api.DataCase
alias Api.Workfollow
describe "working_times" do
alias Api.Workfollow.WorkingTime
import Api.WorkfollowFixtures
@invalid_attrs %{start: nil, end: nil}
test "list_working_times/0 returns all working_times" do
working_time = working_time_fi... |
0625470621534cc524ea7bcdca113e5bb448a156 | 6,087 | [
1013935747
] | [
"documented",
"ecto"
] | defmodule SongbasketPhoenix.Accounts.User do
@derive {Jason.Encoder,
only: [
:id,
:email,
:spotify_id,
:spotify_access_token,
:spotify_refresh_token,
:country,
:display_name,
:followers,
:hr... |
06260a47f96d47b7176459f8f315660fcc10d2d3 | 2,352 | [
286602964
] | [
"test"
] | defmodule WeatherWeb.PageViewTest do
use WeatherWeb.ConnCase, async: true
test "index.json" do
weather_data = Jason.decode!(File.read!("test/support/test.json"))
rendered_weather = WeatherWeb.WeatherView.render("index.json", %{data: weather_data})
assert rendered_weather == %{
date: "2020-08-10... |
06265da7fc26964f431177dee60b8ea2df6e537f | 2,499 | [
112712578
] | [
"documented"
] | defmodule Advent.Dec11 do
@moduledoc """
--- Day 11: Hex Ed ---
Crossing the bridge, you've barely reached the other side of the stream when a program comes up to you, clearly in distress. "It's my child process," she says, "he's gotten lost in an infinite grid!"
Fortunately for her, you have plenty of experi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.