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 |
|---|---|---|---|---|
006c8f960ee1aa956da4b12a20649b67250d02b7 | 1,679 | [
795051456
] | [
"liveview"
] | defmodule CodingTrainingElixirWeb.Chapter7Live do
use CodingTrainingElixirWeb, :live_view
@convert_value 0.09290304
@feet "feet"
@meter "meter"
def mount(_params, _session, socket) do
socket = assign(socket, result: "결과가 여기에 나타납니다", unit_options: [피트: @feet, 미터: @meter])
{:ok, socket}
end
def ha... |
006c969897939b4ed3958652946deadacf68a629 | 8,118 | [
196256963
] | [
"test"
] | if !System.get_env("EXERCISM_TEST_EXAMPLES") do
Code.load_file("bowling.exs", __DIR__)
end
ExUnit.start()
#ExUnit.configure(exclude: :pending, trace: true)
defmodule BowlingTest do
use ExUnit.Case
defp roll_reduce(game, rolls) do
Enum.reduce(rolls, game, fn roll, game -> Bowling.roll(game, roll) end)
end... |
006cd54ad6d99c4dff6d4d031c5b6524d82fc662 | 8,637 | [
101364852
] | [] | defmodule Ttl.Parse.Export do
defp db_date_to_string(date, bracket, time_interval, date_range, repeat_interval ) do
date = Timex.from_unix(date) |> Timex.to_erl
# TODO - the second date
# The hours will remain the same since we don't have enough information for that
# org-mode scheduling is also a ... |
006dfc9151ec46dbebe03c4b7e57b09eb53116a1 | 1,765 | [
726304467
] | [
"test",
"ecto"
] | defmodule Store.AlbumsTest do
use Store.DataCase
alias Store.Albums
describe "albums" do
alias Store.Albums.Album
import Store.AlbumsFixtures
@invalid_attrs %{name: nil}
test "list_albums/0 returns all albums" do
album = album_fixture()
assert Albums.list_albums() == [album]
e... |
006ea6d5f1e8af3d7c3daf0918302d737c4aa0d0 | 22,478 | [
940715177
] | [] | %{
"absinthe": {:hex, :absinthe, "1.7.8", "43443d12ad2b4fcce60e257ac71caf3081f3d5c4ddd5eac63a02628bcaf5b556", [:mix], [{:dataloader, "~> 1.0.0 or ~> 2.0", [hex: :dataloader, repo: "hexpm", optional: true]}, {:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 1.2.2 or ~... |
006ec316add4b34e45beabeacb96712789a43ea0 | 3,264 | [
869569647
] | [] | defmodule CameraApi.DatabaseSeeder do
alias CameraApi.Repo
alias CameraApi.Account.User
alias CameraApi.Devices.Camera
import Logger
Application.ensure_loaded(:faker)
@brands ["Intelbras", "Hikvision", "Giga", "Vivotek", "Dahua", "Axis"]
@batch_size 100
def run(opts \\ []) do
total_users = Keywor... |
006ec672a669c0a8e5d0e5b52678b3bc784bbda2 | 14,436 | [
101862771
] | [
"test"
] | defmodule Apientry.EbayJsonTransformerTest do
use Apientry.ConnCase, async: true
alias Apientry.EbayJsonTransformer
@redirect_base "https://sandbox.apientry.com/redirect/"
@category_url "http://www.xyz.com/camera-lenses/nikon/products?oq=nikon&linkin_id=8094918"
@ebay_category_url "http://www.shopping.com/c... |
006f3ee0233d640ba4f743797dd87fe4b1bec84b | 24,142 | [
416902200
] | [
"typespec",
"liveview",
"documented",
"phoenix"
] | defmodule PetalComponents.Field do
use Phoenix.Component
import PetalComponents.Icon
@doc """
Renders an input with label and error messages. If you just want an input, check out input.ex
A `%Phoenix.HTML.FormField{}` and type may be passed to the field
to build input names and error messages, or all the ... |
006f681ddf72f0fd6d448b83c5fc844d0be2450c | 1,777 | [
726459148
] | [] | #!/bin/elixir
defmodule HASH do
def calc(chunk) do
for <<c::utf8>> <- chunk |> String.graphemes, reduce: 0 do hash -> rem((hash + c) * 17, 256) end
end
def add({order, kv}, id, v) do
{
case Map.has_key?(kv, id) do
true -> order
false -> order ++ [id]
end,
Map.put(kv, id... |
006feb2c431d4c856f5de59a5149fda4fa282e5d | 2,378 | [
193244709,
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.Dialogflow.V3.Model.GoogleCloudDialogflowCxV3SessionEntityType do
@moduledoc """
Session entity types are referred to as **User** entity types and are entities that are built for an individual user such as favorites, preferences, playlists, and so on. You can redefine a session entity type at th... |
007066145c767a04972501bc33e21a04cd30d198 | 1,757 | [
244740863,
244031665,
244430603
] | [
"liveview",
"macro",
"documented",
"phoenix"
] | defmodule KioskPhxWeb 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 KioskPhxWeb, :controller
use KioskPhxWeb, :view
The definitions below will be executed for every view,
controlle... |
0070bc28a3c8cea468f18fff9cd4df3145719900 | 6,923 | [
193244709,
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.Retail.V2.Model.GoogleCloudRetailV2Model do
@moduledoc """
Metadata that describes the training and serving parameters of a Model. A Model can be associated with a ServingConfig and then queried through the Predict API.
## Attributes
* `createTime` (*type:* `DateTime.t`, *default:* `nil`... |
0070bc97b027510f125497309d8e9f571d446eb0 | 1,601 | [
156054729
] | [
"macro",
"documented",
"phoenix"
] | defmodule AvidadeWeb 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 AvidadeWeb, :controller
use AvidadeWeb, :view
The definitions below will be executed for every view,
controller, ... |
0070efc60b38a06c664474372ed42dac74edfdda | 2,351 | [
147546085
] | [
"ecto"
] | defmodule MusicDB.Exercises.ChangesetExercises do
import Ecto.Changeset
alias MusicDB.{Repo, Artist, Album}
def create_changeset_for_artist(artist) do
# create a changeset for the given Artist struct - your changeset should set
# the name to "Sarah Vaughan"
change(artist, %{name: "Sarah Vaughan"})
... |
0070f7dc6a92d0131814324443fc9d14ec753fa1 | 4,475 | [
59744094
] | [] | %{"certifi": {:hex, :certifi, "0.4.0", "a7966efb868b179023618d29a407548f70c52466bf1849b9e8ebd0e34b7ea11f", [:rebar3], []},
"cowboy": {:hex, :cowboy, "1.0.4", "a324a8df9f2316c833a470d918aaf73ae894278b8aa6226ce7a9bf699388f878", [:rebar, :make], [{:cowlib, "~> 1.0.0", [hex: :cowlib, optional: false]}, {:ranch, "~> 1.0",... |
00713f4c80a7ade4489b0f82647c9c515d9e6b5c | 2,640 | [
708108915
] | [
"genserver"
] | defmodule NbaLotteryWeb.LotteryServer do
use GenServer
@name :lottery_server
@pubsub NbaLottery.PubSub
@topic "lottery"
def start_link(_opts) do
GenServer.start_link(__MODULE__, %{}, name: @name)
end
@teams [
%{name: "San Antonio Gramsci", logo: "/images/gramsci.jpg", num_balls: 140, odds: {0, ... |
00718b3cabdd0560f00142c650491d66a5cbaf22 | 6,596 | [
193244709,
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.DFAReporting.V34.Api.OperatingSystemVersions do
@moduledoc """
API calls for all endpoints tagged `OperatingSystemVersions`.
"""
alias GoogleApi.DFAReporting.V34.Connection
alias GoogleApi.Gax.{Request, Response}
@library_version Mix.Project.config() |> Keyword.get(:version, "")
@do... |
0072725609f2a6ac8b727534b61bfeef5a8bc34c | 2,037 | [
803809623
] | [
"ecto"
] | defmodule Operately.Projects.CheckIn do
use Operately.Schema
use Operately.Repo.Getter
alias Operately.Notifications
schema "project_check_ins" do
belongs_to :author, Operately.People.Person, foreign_key: :author_id
belongs_to :project, Operately.Projects.Project, foreign_key: :project_id, where: [del... |
0072a0f36e3dcbf062df076328b44c1a2419ce65 | 7,790 | [
62584632
] | [
"typespec",
"documented",
"ecto"
] | defmodule TestCoherenceWeb.ViewHelpers do
@moduledoc """
Helper functions for Coherence Views.
"""
use Phoenix.HTML
alias Coherence.Config
alias Coherence.Messages
@type conn :: Plug.Conn.t()
@type schema :: Ecto.Schema.t()
@separator {:safe, " | "}
@helpers Module.concat(Application.c... |
0072bc75ebf99ada665eb0fadc4564961db38f26 | 2,026 | [
480335982
] | [
"test"
] | defmodule DeliveryApp.Orders.CreateOrUpdateTest do
use ExUnit.Case
import DeliveryApp.Factory
alias DeliveryApp.Orders.CreateOrUpdate
alias DeliveryApp.Users.Agent, as: UserAgent
describe "call/1" do
setup do
DeliveryApp.start_agents()
cpf = "93857382856"
user = build(:u... |
007307114763d5aae1608173650b3da813911692 | 2,512 | [
304054970
] | [
"phoenix",
"ecto"
] | defmodule InfinWeb.TagController do
use InfinWeb, :controller
alias Infin.Invoices
alias Infin.Invoices.Tag
def index(conn, _params, company_id) do
tags = Invoices.list_company_tags(company_id)
render(conn, "index.html", tags: tags)
end
def new(conn, _params, _c) do
changeset = Invoices.chang... |
007308bd3a461903ccd8534337b89c39269e0bd1 | 3,313 | [
60390243
] | [
"liveview",
"documented"
] | defmodule JSONStream do
@moduledoc """
Small but useful wrapper above the erlang's JSON parsing toolkit `jsx` to stream json
elements from an Elixir binary stream.
"""
def init(stream_path), do:
%{stream_path: Enum.reverse(stream_path), stack: [], path: []}
def handle_event(:end_json, %{stack: stack})... |
00731073aa4104ca5bb94c11092622fb5810a160 | 6,806 | [
149609679
] | [
"test",
"ecto"
] | defmodule EctoCrdtTypes.ChangesetTest do
use ExUnit.Case, async: true
import EctoCrdtTypes.Changeset
import Ecto.Changeset
alias EctoCrdtTypes.Types.State.{
AWSet,
LWWRegister
}
defmodule Schema do
use Ecto.Schema
use EctoCrdtTypes.Fields
schema "entities" do
crdt_field :test, A... |
007366b5ce1f0b4fb7c1320fce2396f8b65c5806 | 1,557 | [
942811655,
920024200
] | [
"documented"
] | defmodule Gofer.ReleaseTasks do
@moduledoc """
Operations that are easy to do with Mix but without Mix (in release)
they have to be programmed.
"""
@start_apps [
:crypto,
:ssl,
:postgrex,
:ecto
]
@repos Application.compile_env(:gofer, :ecto_repos, [])
def migrate() do
start_depend... |
007381d4f28f283dda5477a9a075079a287e4bc6 | 3,249 | [
829367455
] | [
"liveview",
"test"
] | defmodule ChatWeb.PostLiveTest do
use ChatWeb.ConnCase
import Phoenix.LiveViewTest
import Chat.ContentFixtures
@create_attrs %{title: "some title", body: "some body"}
@update_attrs %{title: "some updated title", body: "some updated body"}
@invalid_attrs %{title: nil, body: nil}
defp create_post(_) do
... |
0074e6de16dbbd6f3fefdd475b7bf4f8be35a79c | 2,289 | [
338131945
] | [
"documented",
"phoenix"
] | defmodule NoozoWeb.AuthController do
@moduledoc """
Auth controller responsible for handling Ueberauth responses
"""
use NoozoWeb, :controller
plug Ueberauth
alias Ueberauth.Strategy.Helpers
alias Noozo.Core
def request(conn, %{"redirect_url" => redirect_url} = _params) do
conn
|> put_req_he... |
00753cac6dcc77399f9e2c44fdf1f03057d18659 | 4,849 | [
995651883
] | [
"documented"
] | defmodule Torngen.Client.Path.User do
@moduledoc """
Get any User selection.
Key access level depends on the required selections. <br>Choose one or more selections (comma separated).
## Parmeters
- selections: Selection names
- id: selection id
- limit: N/A
- from: Timestamp that sets the lower limit ... |
0075a4f59d18c0380bf566e941165fd9a2d0d907 | 9,038 | [
768092405
] | [
"documented",
"ecto"
] | defmodule Board.Accounts do
@moduledoc """
The Accounts context.
"""
import Ecto.Query, warn: false
alias Board.Repo
alias Board.Accounts.{User, UserToken, UserNotifier}
## Database getters
@doc """
Gets a user by email.
## Examples
iex> get_user_by_email("<EMAIL>")
%User{}
... |
0075e3445f70e18f013dbbf9b07b40eeda1e656e | 9,173 | [
779245900
] | [
"liveview"
] | defmodule TheArkWeb.AddResultLive do
use TheArkWeb, :live_view
alias TheArk.{
Classes,
Subjects,
Results,
Classresults
}
@impl true
def mount(
%{"id" => id},
_session,
socket
) do
class = Classes.get_class!(id)
subject_id =
Enum.map(class.subjects... |
007613288c0f1eba69ad4a1ce86b7e4daf57bf06 | 1,508 | [
893971373
] | [
"supervisor",
"documented"
] | defmodule SoleilDemo.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
@impl true
def start(_type, _args) do
children =
[
SoleilDemo.Repo,
{Ecto.Migrator,
repos: Application.fetch_e... |
0076a812cf466cf11fb906150ec9cc311a5d3d81 | 1,701 | [
318249466
] | [] | defmodule Bitmasks do
use Bitwise
def parse("mask = " <> mask) do
{:mask, String.trim(mask) |> decode_mask()}
end
def parse("mem" <> line) do
[addr_s, value_s] = Regex.run(~r/\[(\d+)\] = (\d+)/, line, capture: :all_but_first)
{:set, String.to_integer(addr_s), String.to_integer(value_s)}
end
d... |
0076de9831eaecc970e3089e9fbd38787daa64c1 | 7,289 | [
903999320
] | [
"test"
] | defmodule JidoTest.ExecDoRunTest do
use JidoTest.Case, async: false
use Mimic
import ExUnit.CaptureLog
alias Jido.Exec
alias JidoTest.TestActions.BasicAction
alias JidoTest.TestActions.ErrorAction
alias JidoTest.TestActions.RetryAction
@attempts_table :action_do_run_test_attempts
@attempts_table :... |
0077ba82210a5a31ef68637984c9b9d8e4b12774 | 6,496 | [
77712444
] | [
"test",
"documented"
] | defmodule Car do
@moduledoc """
Used in the tests/examples below
"""
defstruct(
make: :unknown,
model: :unknown,
style: :unknown,
price: :unknown,
description: :unknown)
end
defmodule Shopper do
@moduledoc """
Used in the tests/examples below
"""
defstruct(
name: :unknown,
age: :unknown... |
0077cbb1ca0b4de7f237aaa1d76aa53ad82ce9ba | 1,931 | [
189953391
] | [] | defmodule Hangman.Game do
defstruct(
turns_left: 7,
game_state: :initializing,
letters: [],
used: MapSet.new
)
def new_game(word) do
%Hangman.Game{
letters: word |> String.codepoints
}
end
def new_game() do
new_game(Dictionary.random_word)
end
def make_move(g... |
0077f1d1484ecee039ef73a8ab54b3e79991e5ba | 1,582 | [
239822890,
459291087
] | [
"documented",
"phoenix"
] | defmodule OliWeb.Api.TagController do
@moduledoc """
Endpoints to provide access to and mutation of tags.
"""
alias Oli.Authoring.Editing.ResourceEditor
import OliWeb.Api.Helpers
use OliWeb, :controller
def index(conn, %{"project" => project_slug}) do
author = conn.assigns[:current_author]
cas... |
00783329e84aa42de3770ee3ad2942100071cdab | 1,706 | [
11330455
] | [
"macro"
] | defmodule Scarecrow.Models.Document do
defmacro __using__(opts) do
self = opts[:self] || :self
quote do
import unquote(__MODULE__)
@fields []
@default_funcs []
@record_seted false
@record_self unquote(self)
@before_compile unquote(__MODULE__)
use Scarecrow.Models.... |
0078a305585af47db2800a2e2d359a1493db6eb0 | 6,341 | [
898079158
] | [
"test"
] | defmodule Aoc2024.Solutions.Y24.Day17Test do
alias AoC.Input, warn: false
alias Aoc2024.Solutions.Y24.Day17, as: Solution, warn: false
use ExUnit.Case, async: true
# defp solve(input, part) do
# problem =
# input
# |> Input.as_file()
# |> Solution.parse(part)
# apply(Solution, part, ... |
0079061d051ef75d1a1d3acfc5760decb1053a76 | 1,993 | [
29372051
] | [] | defmodule WsServer do
# Websocket handler
defmodule SocketHandler do
@behaviour :cowboy_websocket_handler
require Logger
alias :jsx, as: JSON
def init({tcp, http}, req, _opts) do
{:upgrade, :protocol, :cowboy_websocket}
end
def websocket_init(_TransportName, req, _opts) do
... |
00790f4694d87634a0038802604d2c5ddc8079be | 2,417 | [
855153094
] | [] | defmodule Pluggy.CheckoutController do
require IEx
alias Pluggy.Helper
alias Pluggy.Checkout
alias Pluggy.User
alias Pluggy.Order
import Pluggy.Template, only: [render: 4, render: 3]
import Plug.Conn, only: [send_resp: 3]
def index(conn) do
session_user = conn.private.plug_session["user_id"]
... |
00794c448f7d4ddff5dca13711004e6d56a9e7e4 | 2,906 | [
157935889
] | [
"typespec",
"documented"
] | defmodule PNG do
@moduledoc """
Documentation for PNG.
"""
alias PNG.{LowLevel, ZLib}
@type size :: {pos_integer(), pos_integer()}
@type mode :: {atom(), pos_integer()}
@type bit_depth :: 8 | 16
@type rgb_tuple :: {
red :: non_neg_integer(),
green :: non_neg_integer(),
bl... |
00796acfd355ff5c2d989f4f9fc3ace6c2c5ebd3 | 1,604 | [
723912989
] | [
"documented"
] | defmodule AOC.Y2024.Day7 do
@moduledoc false
use AOC.Solution
@impl true
def load_data() do
Data.load_day(2024, 7)
|> Enum.map(fn line -> String.split(line, ": ") end)
|> Enum.map(fn [test_value, numbers] ->
{String.to_integer(test_value),
numbers |> String.split(" ") |> Enum.map(&Str... |
0079c15800fb6e0f3f7fa12d57287b4c1384cce3 | 1,999 | [
166092965
] | [
"documented",
"phoenix"
] | defmodule ApiWeb.Admin.SessionController do
@moduledoc false
use ApiWeb.Web, :controller
plug(:redirect_already_authorized when action in [:new, :create])
plug(ApiWeb.Plugs.RequireAdmin when action in [:delete])
def new(conn, _) do
changeset = ApiAccounts.change_user(%ApiAccounts.User{})
render(conn... |
0079cedb747a31977e9eb30acfce79e6739a1af7 | 1,935 | [
318945858,
276023881
] | [] | defmodule Pleroma.Web.ApiSpec.PollOperation do
alias OpenApiSpex.Operation
alias OpenApiSpex.Schema
alias Pleroma.Web.ApiSpec.Schemas.ApiError
alias Pleroma.Web.ApiSpec.Schemas.FlakeID
alias Pleroma.Web.ApiSpec.Schemas.Poll
import Pleroma.Web.ApiSpec.Helpers
def open_api_operation(action) do
operati... |
007a80f7499f257369bba0aacd1078c8028eb3d4 | 2,325 | [
824383954
] | [
"typespec",
"ecto"
] | defmodule Galerie.Repo do
use Ecto.Repo,
otp_app: :galerie,
adapter: Ecto.Adapters.Postgres
alias Galerie.Repo.Page
require Ecto.Query
@type record_id :: integer()
def first(queryable) do
queryable
|> Ecto.Query.limit(1)
|> all()
|> List.first()
end
def fetch_first(queryable) d... |
007b3f28fe02db6d7514982d0d6231e00ad865e6 | 5,113 | [
805616069,
1008214681,
1010774883
] | [
"typespec",
"documented"
] | defmodule CommonCore.Resources.VirtualServiceBuilder do
@moduledoc false
alias CommonCore.OpenAPI.IstioVirtualService.HTTPRoute
alias CommonCore.OpenAPI.IstioVirtualService.L4MatchAttributes
alias CommonCore.OpenAPI.IstioVirtualService.TCPRoute
alias CommonCore.OpenAPI.IstioVirtualService.VirtualService
@s... |
007b8204d50cc84cb2f159884c4c3323761d0162 | 8,175 | [
122170032
] | [
"documented"
] | defmodule MatchEngine.Score do
@moduledoc false
alias MatchEngine.Geo
alias MatchEngine.Query
@leaf_operators Query.leaf_operators()
def filter([], _doc) do
score_map(0)
end
def filter(parts, doc) when is_list(parts) do
score_part({:_and, parts}, doc)
end
def score(parts, doc) when is_lis... |
007b966a0c4a08985d71281e7dad0941455eba6d | 1,624 | [
193244709,
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.Compute.V1.Model.ForwardingRuleServiceDirectoryRegistration do
@moduledoc """
Describes the auto-registration of the forwarding rule to Service Directory. The region and project of the Service Directory resource generated from this registration will be the same as this forwarding rule.
## Att... |
007c2d6fdb7d61957076cce9fbd66d969b5c89ed | 2,178 | [
189251630
] | [
"documented"
] | defmodule Alerts.Match do
@moduledoc """
Returns the alerts which match the provided InformedEntity or entities.
Passing multiple entities will allow the matching to be more efficient.
"""
use Timex
alias Alerts.InformedEntitySet, as: IESet
def match(alerts, entity, datetime \\ nil)
def match(aler... |
007c2de889f5e65dacc8030c7993efdfe5382a0b | 1,500 | [
193244709,
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.Recommender.V1beta1.Model.GoogleCloudRecommenderV1beta1ListInsightTypesResponse do
@moduledoc """
Response for the `ListInsightTypes` method. Next ID: 3
## Attributes
* `insightTypes` (*type:* `list(GoogleApi.Recommender.V1beta1.Model.GoogleCloudRecommenderV1beta1InsightType.t)`, *defaul... |
007c3a05fdff646f9f9176cb69e60ef2278ebfeb | 7,101 | [
239259699
] | [
"documented"
] | defmodule Historian.TUi.Search do
@moduledoc """
This module is awful, thar be dragons and terrible nightmares lurking in here.
TODO/FIXME: Slay dragons, allow hopes and dreams again.
"""
alias Historian.Config
alias Historian.TerminalUI.Cursor
import Historian.Gettext
import Historian.TUi.Elements
... |
007c4bd0d2e2bc624df0a1786a60f6663ffa35c4 | 1,608 | [
515647081
] | [] | defmodule ListAdd.DoubleReverse do
def add_lists(list) do
Enum.reduce(list, [0], fn value, acc ->
[value | Enum.reverse(acc)]
|> Enum.reverse()
end)
end
end
defmodule ListAdd.Concat do
def add_lists(list) do
Enum.reduce(list, [0], fn value, acc ->
acc ++ [value]
end)
end
end
... |
007c5c9b3cf789e9d945247f3905ed661a995f06 | 3,237 | [
995918756
] | [
"liveview",
"test"
] | defmodule BoltForumWeb.ThreadListLive do
use BoltForumWeb.ConnCase
import Phoenix.LiveViewTest
alias BoltForum.Forum
setup do
%{user: insert(:user)}
end
describe "index view" do
test "shows thread when exists", %{conn: conn, user: user} do
thread = insert(:thread, created_by: user)
... |
007c904092fe82f4d7af50c1b2344b78178247cf | 3,262 | [
59310243
] | [
"test"
] | defmodule Exdns.Zone.CacheTest do
use ExUnit.Case, async: false
require Exdns.Records
setup do
name = "example.com"
soa_record = Exdns.Records.dns_rr(name: name, type: :dns_terms_const.dns_type_soa, data: Exdns.Records.dns_rrdata_soa())
ns_record = Exdns.Records.dns_rr(name: name, type: :dns_terms_c... |
007cd202b6e27762846ec9d7ba3f41d52460c33a | 1,509 | [
38796387
] | [
"test",
"documented"
] | #!/usr/bin/env elixir
# http://elixir-lang.org/docs/stable/elixir/IO.html
# http://elixir-lang.org/docs/stable/elixir/File.html
defmodule CowInterrogator do
# docstring are quite useful you can generate docs out of them
# check: http://elixir-lang.org/getting-started/module-attributes.html
# for more info
@d... |
007d1f028e8df451b8298cdd2bfd8b80993dd9fa | 2,136 | [
894414782
] | [
"documented",
"ecto"
] | defmodule NdbRestApi.Conditions do
@moduledoc """
The Conditions context.
"""
import Ecto.Query, warn: false
alias NdbRestApi.Repo
alias NdbRestApi.Conditions.Condition
@doc """
Returns the list of conditions.
## Examples
iex> list_conditions()
[%Condition{}, ...]
"""
def list_co... |
007d5c768997de706be3c065b3bb322e5b942b3f | 2,067 | [
317723873
] | [] | defmodule Day07 do
def part1 do
"priv/input.txt"
|> stream()
|> parse_lines()
|> children_to_parent_map
|> count_bags_that_eventually_contain_shiny_gold()
end
def part2 do
"priv/input.txt"
|> stream()
|> parse_lines()
|> parent_to_children_map()
|> count_bags_inside_shiny_... |
007d78ee276f3add3171cacde357a9872dd2b821 | 2,014 | [
319055143
] | [
"phoenix"
] | defmodule DigestApiWeb.ArticleController do
use DigestApiWeb, :controller
import Ecto.Query
alias DigestApi.Repo
alias DigestApi.Repository
alias DigestApi.Repository.Article
action_fallback DigestApiWeb.FallbackController
def indexTopic(conn, %{"topic" => topic}) do
IO.inspect conn.assigns.curren... |
007dabf8b4f246f70d59a405609abdeb5ef67943 | 2,687 | [
595815766,
736880718,
721395351,
666173803,
786109588
] | [
"liveview"
] | defmodule ShipWeb.PlayerResetPasswordLive do
use ShipWeb, :live_view
alias Ship.Players
def render(assigns) do
~H"""
<div class="mx-auto max-w-sm">
<.header class="text-center">Reset Password</.header>
<.simple_form
for={@form}
id="reset_password_form"
phx-submit="re... |
007e371c296ec735562b5b1e07db5e9a58332d16 | 4,384 | [
215202932
] | [
"test",
"phoenix"
] | defmodule BackendWeb.TopicControllerTest do
use BackendWeb.ConnCase
alias Dbstore.{Repo, User, SubCategory, Topic}
# TODO: This has now become redundant... Should be moved
# to the macro helper file. (like the one setup in the Notebooks project)
def setup_user(context) do
{:ok, user} =
%User{... |
007f11d3d9f1815ba7719d8f6ad8bc7114ad671d | 2,698 | [
261114258
] | [
"genserver"
] | defmodule Fetch do
use GenServer
# PORTS:
# 8679 - Message Broker
# 8680 - Publisher
# 8681 - Join Subscriber
# 8682 - Notify subscribers
# 8683 - Forecast Subscriber
# 8684 - Aggregator Subscriber
def init(init_arg) do
{:ok, init_arg}
end
def start_link(url_leg... |
008034808eaefba5cfe3f349f6d5684516146d8c | 21,762 | [
63960295
] | [
"typespec",
"test",
"documented"
] | defmodule Appsignal.ObanTest do
use ExUnit.Case
alias Appsignal.{FakeAppsignal, Span, Test, Tracer}
import AppsignalTest.Utils, only: [with_config: 2]
setup do
start_supervised!(Test.Nif)
start_supervised!(Test.Tracer)
start_supervised!(Test.Span)
start_supervised!(Test.Monitor)
:ok
end
... |
00803826b1e90304b6684c5dc3a7a2cebe73c3c9 | 9,860 | [
759241459
] | [
"genserver",
"documented"
] | defmodule AzureAPI.VirtualMachineController do
@moduledoc """
Interface for making API calls.
Stores required information as a state in the genserver
Client functions:
1. Starts Genserver (upon loading VM page)
2. List Machines and Statuses
3. Get VM Availability
4. Start Machine
5. Stop M... |
00806213ccece44cf4a7c89e9933d5030d810fb8 | 8,400 | [
965286383
] | [
"typespec",
"documented"
] | defmodule Graph.Pathfinding do
@moduledoc false
# This module contains implementation code for path finding algorithms used by `libgraph`.
import Graph.Utils, only: [edge_weight: 3]
@type heuristic_fun :: (Graph.vertex() -> integer)
@spec bellman_ford(Graph.t(), Graph.vertex()) ::
%{Graph.vertex... |
0080696632461f3bc24f053daa3c82c00a5f2f2e | 2,331 | [
128416446
] | [
"typespec",
"documented"
] | defmodule ActiveJorb.QueueAdapter.Test do
@moduledoc """
Use this module to facilitate testing. This will not execute the jobs (we can't,
they're on a remote system), but we can verify that you enqueued a job with
the correct parameters.
"""
@behaviour ActiveJorb.QueueAdapter
alias ActiveJorb.Job
@do... |
00809d8e3f352f6049ce95984c63b8d7652165b3 | 3,522 | [
949664843
] | [
"documented"
] | defmodule Raxol.Core.Runtime.Plugins.StateManager do
@moduledoc """
Handles plugin state management operations including getting, setting, and updating plugin states.
"""
require Raxol.Core.Runtime.Log
@doc """
Sets a plugin's state directly.
"""
def set_plugin_state(plugin_id, new_state, state) do
... |
0080bfc9fc98e1beeb7a772f4e6daae925727f9c | 1,658 | [
956221799
] | [
"typespec",
"documented"
] | defmodule MyApp.Scenarios.SupermarketScenario do
@moduledoc """
Scenario for a Chinese restaurant waiter named Verba.
"""
@type state :: :start | :continue
@doc """
Returns the system prompt for the given state.
"""
@spec get_system_prompt(state) :: String.t()
def get_system_prompt(:start) do
"Y... |
0080c21edd53579ca0d241722a52e1e1f3e8c8dd | 4,617 | [
191103364
] | [
"genserver",
"typespec",
"documented"
] | defmodule Storage do
@moduledoc """
Storage
Module contains CRUD API
"""
use GenServer
alias :mnesia, as: Mnesia
@mytable :kv
@attributes [
:key, # Uniq Key
:value, # String
:ttl # Integer
]
# Старт генсервера
def start_link(_state \\ []) do
... |
0080d3e79033fa817e2eea4356e33cd527f8d782 | 6,820 | [
613459518
] | [
"liveview",
"test"
] | defmodule LivebookWeb.HomeLiveTest do
use LivebookWeb.ConnCase, async: true
import Phoenix.LiveViewTest
alias Livebook.{Sessions, Session}
test "disconnected and connected render", %{conn: conn} do
{:ok, view, disconnected_html} = live(conn, ~p"/")
assert disconnected_html =~ "Running sessions"
a... |
0081e616716818e6518fc70b5e4038391a89fd1d | 3,629 | [
188573227
] | [] | defmodule BuffServer.MixProject do
use Mix.Project
def project do
[
app: :buff_server,
version: "0.1.0",
elixir: "~> 1.8",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,
elixirc_options:... |
0081e7042d10f282e6ed3af0276ff7afd117d75e | 1,764 | [
669079833
] | [
"typespec"
] | defmodule CustomSet do
@opaque t :: %__MODULE__{elements: list}
defstruct elements: []
@spec new(Enum.t()) :: t
def new(enumerable) do
struct(__MODULE__, elements: Enum.uniq(enumerable))
end
@spec empty?(t) :: boolean
def empty?(custom_set) do
Enum.empty?(custom_set.elements)
end
@spec con... |
00821c3cc4e6640c40f04b2db5d899cbb49412bc | 2,987 | [
883763780
] | [
"test",
"ecto"
] | defmodule ComponentTest.ParlorTest do
use ComponentTest.DataCase
alias ComponentTest.Parlor
describe "pizzas" do
alias ComponentTest.Parlor.Pizza
import ComponentTest.ParlorFixtures
@invalid_attrs %{
name: nil,
size: nil,
sauce_amount: nil,
cheese_amount: nil,
topping... |
00823d6038a837dd878d4826749bf952b729ff93 | 4,292 | [
190667844
] | [] | defmodule Artemis.ListEventReports do
use Artemis.Context
use Artemis.ContextReport
import Artemis.Helpers.Filter
import Artemis.Helpers.Search
import Ecto.Query
alias Artemis.EventAnswer
alias Artemis.Repo
def call(reports \\ [], params \\ %{}, user) do
get_reports(reports, params, user)
end
... |
008240a1e54b20b53e66f6ac22fe54d1ce5d7633 | 3,645 | [
743247489,
754086270
] | [] | defmodule BrcStream do
use Agent
@pool_size 32
@job_size 10_000
# each process has its own partial map of the cities
# for each line, parse out the city name and temperature * 10, keeping the numbers as integers
# if a city is already in the map, to the min, max and counting on it
def process_lines(s... |
00824b265d68a540271cf8f998c5c1db6f350345 | 2,012 | [
969999971
] | [
"documented"
] | defmodule DeeperHub.Core.Data.Migrations.BxPollsScoresTrack do
@moduledoc """
Migration para criar e remover a tabela bx_polls_scores_track.
"""
alias DeeperHub.Core.Data.Repo
alias DeeperHub.Core.Logger
require DeeperHub.Core.Logger
@doc """
Cria a tabela de bx_polls_scores_track.
"""
def up do
... |
008257ec858253ab67ba35eee707c88076285f77 | 2,289 | [
707855517
] | [
"test"
] | defmodule BananaBankWeb.UsersControllerTest do
use BananaBankWeb.ConnCase
alias BananaBank.Users
alias Users.User
import Mox
setup :verify_on_exit!
describe "create/2" do
test "successfully creates an user", %{conn: conn} do
params = %{
name: "João",
cep: "96402130",
em... |
008271d4100889e4c088ed96ed355b49721e28ef | 2,024 | [
854313489
] | [
"documented"
] | defmodule MagusLive.Agents.Storm.WriteSection do
alias LangChain.Message
alias LangChain.PromptTemplate
alias Magus.AgentChain
alias MagusLive.Agents.StormState
alias MagusLive.Agents.Storm.Util
alias MagusLive.SemanticSearch
@json_schema_path "agent_schema/storm/write_section.json"
@base_prompt_templ... |
00827db3a4c3fd37f41015bf527cfa9001c1a786 | 2,568 | [
265666152
] | [
"documented",
"ecto"
] | defmodule Puzzlespace.User do
use Puzzlespace.Schema
import Ecto.Changeset
import Ecto.Query, only: [from: 2]
alias Puzzlespace.User
alias Puzzlespace.Entity
alias Puzzlespace.AuthToken
alias Puzzlespace.Relationship
schema "users" do
field :username, :string, unique: true
field :hashed_pass, :... |
0082b4f63577f4f08fbf676088ff80506c5ea65e | 1,647 | [
868249985,
372499099
] | [
"genserver",
"documented"
] | defmodule Kino.Test.GroupLeader do
@moduledoc false
# A process mocking the Livebook group leader,
# for testing parts relying on Kino.Bridge.
use GenServer
@doc """
Starts a new group leader.
All messages that would be sent to Livebook are sent to
`target` instead.
"""
def start_link(target) do... |
0082ec8ebf917a95b61464ba3da1c227b6fbaefb | 2,826 | [
567860115
] | [
"liveview",
"ecto"
] | defmodule DocketWeb.TaskLive.FormComponent do
use DocketWeb, :live_component
alias Docket.Tasks
@impl true
def render(assigns) do
~H"""
<div>
<.header>
<%= @title %>
<:subtitle>Use this form to manage task records in your database.</:subtitle>
</.header>
<.simple_for... |
0083428939a14a9a95e05e55f3e0069a1c6c1030 | 4,168 | [
78787036
] | [
"typespec",
"documented"
] | defmodule Blogit.RepositoryProvider do
@moduledoc """
A behaviour module for implementing access to remote or local repository
containing files which can be used as a source for a blog and its posts.
A provider to a repository should be able to check if files exist in it,
if files were updated or deleted, to... |
0083ce968fc02881e33672f07ffa33bc89b0b28f | 1,706 | [
737197522
] | [
"documented",
"ecto"
] | defmodule AlternativeServer.Accounts.UserNotifier do
import Swoosh.Email
alias AlternativeServer.Mailer
# Delivers the email using the application mailer.
defp deliver(recipient, subject, body) do
email =
new()
|> to(recipient)
|> from({"AlternativeServer", "<EMAIL>"})
|> subject(s... |
0084dd726521575905fdeb8715b9817b91810e52 | 7,545 | [
736944816
] | [] | defmodule Galaxies.Planets.Actions.EnqueueBuilding do
@behaviour Galaxies.Planets.Action
import Ecto.Query
require Logger
alias Galaxies.Planet
alias Galaxies.Accounts.Player
alias Galaxies.Prerequisites
alias Galaxies.Planets.PlanetEvent
alias Galaxies.Planets.PlanetAction
alias Galaxies.Repo
@b... |
0084eaaef14112f4fded02245cb10fb67f588427 | 1,600 | [
968434148
] | [
"documented"
] | defmodule Mix.Tasks.Powervisor.Gen.Appup do
@moduledoc """
Generates an appup file for a given release.
## Examples
# Generate an appup from 0.0.1 to 0.0.2 versions
mix powervisor.gen.appup --from=0.0.1 --to=0.0.2
"""
use Mix.Task
alias Distillery.Releases.Appup
@impl true
def run(args)... |
008506291c4fa1b8dfc540d5d07e7efcf6d8ee8a | 5,712 | [
786846015
] | [
"phoenix",
"documented"
] | defmodule ViolacorpWeb.Admin.LoginController do
use Phoenix.Controller
require Logger
alias Violacorp.Repo
import Ecto.Query
alias Violacorp.Schemas.Administratorusers
alias Violacorp.Libraries.Loginhistory
@doc "admin login"
def login(conn, params) do
unless map_size(params) == 0 do
admin... |
008511d4e0e957f779bad97a64afbc7862d3edc8 | 1,806 | [
101434552,
198908023
] | [
"typespec",
"documented"
] | defmodule GoogleApi.WalletObjects.V1.Model.SetPassUpdateNoticeRequest do
@moduledoc """
Request to send a private pass update notice information to Google, so that devices can then fetch the notice prompting the user to update a pass.
## Attributes
* `externalPassId` (*type:* `String.t`, *default:* `nil`) -... |
00853223f1e9973ec26f504718893566884e78b9 | 1,754 | [
334284638
] | [
"phoenix"
] | defmodule HeimdallWeb.UserResetPasswordController do
use HeimdallWeb, :controller
alias Heimdall.Accounts
plug :get_user_by_reset_password_token when action in [:edit, :update]
def new(conn, _params) do
render(conn, "new.html")
end
def create(conn, %{"user" => %{"email" => email}}) do
if user = ... |
008540d264dfc55665158dd41a018eb1631d8dd8 | 2,283 | [
379540653
] | [
"documented",
"ecto"
] | defmodule IdeaSnippets.Codes do
@moduledoc """
The Codes context.
"""
import Ecto.Query, warn: false
alias IdeaSnippets.Repo
alias IdeaSnippets.Codes.Post
alias IdeaSnippets.Comments
@doc """
Returns the list of posts.
## Examples
iex> list_posts()
[%Post{}, ...]
"""
def list_p... |
00859e647c2ed7e9a3448dcc5616887638f76f34 | 2,670 | [
107586277
] | [
"test"
] | defmodule BlogWeb.BlogControllerTest do
use BlogWeb.ConnCase
alias Blog.Data
@create_attrs %{author: "some author", content: "some content", title: "some title"}
@update_attrs %{author: "some updated author", content: "some updated content", title: "some updated title"}
@invalid_attrs %{author: nil, content... |
0085ae226af4a2e51fa43c9cbbd18ea318bb035d | 4,365 | [
555509288,
552857516
] | [
"documented",
"ecto"
] | defmodule TodoApp.Todos do
@moduledoc """
The Todos context.
"""
import Ecto.Query, warn: false
alias TodoApp.Repo
alias TodoApp.Todos.Todo
@topic inspect(__MODULE__)
@doc """
Subscribe to real time updates.
"""
def subscribe do
Phoenix.PubSub.subscribe(TodoApp.PubSub, @topic)
end
@do... |
0085ee16384d87a27d9f7217ce97ef3da26d4afa | 1,758 | [
59990483
] | [] | defmodule Cloudini.URL do
def fetch(%{base_fetch: base_fetch, name: name}, url) do
"#{base_fetch}/#{name}/image/fetch/#{url}"
end
def transform(_, image_url, trans_opts)
when is_list(trans_opts) or is_map(trans_opts) do
uri = URI.parse(image_url)
path_elements = uri.path |> String.split("/", parts:... |
008601cf1b1d4ef39720330181ca039995521c22 | 2,411 | [
766267941
] | [
"liveview",
"test"
] | defmodule AirbnbExWeb.UserConfirmationLiveTest do
use AirbnbExWeb.ConnCase, async: true
import Phoenix.LiveViewTest
import AirbnbEx.AccountsFixtures
alias AirbnbEx.Accounts
alias AirbnbEx.Repo
setup do
%{user: user_fixture()}
end
describe "Confirm user" do
test "renders confirmation page", %... |
00861286acffea3b239bf51c6da4643f0b8b0b38 | 3,377 | [
31404445
] | [
"phoenix"
] | defmodule HelloWeb.Router do
use HelloWeb, :router
import HelloWeb.UserAuth
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, html: {HelloWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
plu... |
00863cc3025cbbe4a1e171f2454db8b29354fbc0 | 2,164 | [
159077460
] | [
"documented"
] | defmodule AnkikoreanWeb.KrDict do
use Tesla
alias AnkikoreanWeb.KoreanDictionary
@behaviour KoreanDictionary
@moduledoc """
KrDict dictionary
https://krdict.korean.go.kr
"""
plug Tesla.Middleware.BaseUrl,
"https://krdict.korean.go.kr/eng/dicSearch/search?nation=eng&nationCode=6&mainSearchWord="
... |
008656407e260d94f0659e4b56d3f10458b62b68 | 3,308 | [
810146441
] | [
"documented"
] | defmodule ChinaAdminDivisions.Gen.Lv4xg.M4303 do
@moduledoc false
def name("430382203000"), do: "杨林乡"
def name("430382200000"), do: "韶山乡"
def name("430382101000"), do: "银田镇"
def name("430382100000"), do: "清溪镇"
def name("430381203000"), do: "育塅乡"
def name("430381202000"), do: "金薮乡"
def name("43038120000... |
008667e6df773625564ec12a1dd8214d7870c52c | 5,470 | [
345000299
] | [
"typespec",
"test",
"documented"
] | defmodule IslandsEngine.GameTest do
@moduledoc false
use ExUnit.Case, async: false
import IslandsEngine.Game, only: [is_game_reference: 1]
alias IslandsEngine.Coordinate
alias IslandsEngine.Game
alias IslandsEngine.Island
alias IslandsEngine.Rules
setup do
# Reset the game state ETS table before... |
00867c43fca97aa84ccfdb3b664c9f5509622144 | 2,107 | [
89370907
] | [] | use Mix.Config
config :stripe_callbacks, StripeCallbacks.Repo, [
adapter: Ecto.Adapters.Postgres,
database: "stripe_ui_callbacks_#{Mix.env}",
username: "postgres",
password: "",
hostname: "localhost",
]
# For development, we disable any cache and enable
# debugging and code reloading.
#
# The watchers confi... |
00867fe0fec5d27ce36a71f7a16cf19a80a91eb1 | 9,421 | [
938349679
] | [
"test"
] | defmodule Commanded.Event.HandleEventTest do
use Commanded.MockEventStoreCase
import Commanded.Enumerable, only: [pluck: 2]
import Commanded.Assertions.EventAssertions
alias Commanded.{DefaultApp, MockedApp}
alias Commanded.Event.AppendingEventHandler
alias Commanded.Event.EchoHandler
alias Commanded.Ev... |
0086d6e67b138fdec0922f196f4b4f2cdb5640fe | 3,277 | [
331143113
] | [
"documented"
] | defmodule Vickrey.Analysis do
@moduledoc """
With returned data from the DB, create aggregations and calcs.
"""
alias Vickrey.{Repo, Query}
def get_3_letter_open_auctions(), do: Query.get_auctions_by_name_and_type("OPEN", 3)
def get_3_letter_bid_auctions(), do: Query.get_auctions_by_name_and_... |
0086ed23dfd57979ddb32713dbe0d1192187f42a | 3,127 | [
929310139
] | [
"test"
] | defmodule DesignexTest do
use ExUnit.Case
@version Designex.latest_version()
@commit Designex.latest_commit()
test "start function with configured version and commit" do
assert {:ok, pid} = Designex.start(nil, nil)
assert is_pid(pid)
end
test "warn on start function without configured version and... |
008741b5aed4d41ee2dcb85f7337892b12afcd7c | 1,955 | [
164160757
] | [
"phoenix"
] | defmodule FivelWeb.SessionController do
use FivelWeb, :controller
alias Fivel.Repo
alias Fivel.Users
alias Fivel.Users.User
alias Fivel.Guardian
def create(conn, params) do
case authenticate(params) do
{:ok, user} ->
new_conn = Guardian.Plug.sign_in(conn, user)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.