code stringlengths 114 1.05M | path stringlengths 3 312 | quality_prob float64 0.5 0.99 | learning_prob float64 0.2 1 | filename stringlengths 3 168 | kind stringclasses 1
value |
|---|---|---|---|---|---|
defmodule Ecto.Query.JoinBuilder do
@moduledoc false
alias Ecto.Query.BuilderUtil
alias Ecto.Query.Query
alias Ecto.Query.QueryExpr
alias Ecto.Query.JoinExpr
@doc """
Escapes a join expression (not including the `on` expression).
It returns a tuple containing the binds, the on expression (if availabl... | lib/ecto/query/join_builder.ex | 0.815637 | 0.435121 | join_builder.ex | starcoder |
defmodule Shippex.ISO do
@moduledoc """
This module contains data and functions for obtaining geographic data in
compliance with the ISO-3166-2 standard.
"""
import Shippex.Util, only: [unaccent: 1]
@iso Shippex.Config.json_library().decode!(
File.read!(:code.priv_dir(:shippex) ++ '/iso-3166-2.js... | lib/shippex/iso.ex | 0.804751 | 0.456955 | iso.ex | starcoder |
defmodule Pathex.Builder.Viewer do
@moduledoc """
Module with common functions for viewers
"""
import Pathex.Common, only: [list_match: 2, pin: 1]
# Helpers
def match_from_path(path, initial \\ {:x, [], Elixir}) do
path
|> Enum.reverse()
|> Enum.reduce_while({:ok, initial}, fn
{:map, {_... | lib/pathex/builder/viewer.ex | 0.647575 | 0.53959 | viewer.ex | starcoder |
defmodule Assent.JWTAdapter.AssentJWT do
@moduledoc """
JWT adapter module for parsing JSON Web Tokens natively.
See `Assent.JWTAdapter` for more.
"""
alias Assent.{Config, JWTAdapter}
@behaviour Assent.JWTAdapter
@impl JWTAdapter
def sign(claims, alg, secret_or_private_key, opts) do
header = jws... | lib/assent/jwt_adapter/assent_jwt.ex | 0.783616 | 0.443661 | assent_jwt.ex | starcoder |
defprotocol Cat.Applicative do
@moduledoc """
Applicative defines
* `pure(t(any), a) :: t(a)`
* `ap(t((a -> b)), t(a)) :: t(b)`
* `product(t(a), t(b)) :: t({a, b})`
* `product_l(t(a), t(any)) :: t(a)`
* `product_r(t(any), t(a)) :: t(a)`
* `map2(t(a), t(b), (a, b -> c)) :: t(c)`
**It must ... | lib/cat/protocols/applicative.ex | 0.890276 | 0.611121 | applicative.ex | starcoder |
defmodule CodeCorps.StripeService.Adapters.StripeConnectAccountAdapter do
alias CodeCorps.MapUtils
alias CodeCorps.Adapter.MapTransformer
# Mapping of stripe record attributes to locally stored attributes
# Format is {:local_key, [:nesting, :of, :stripe, :keys]}
@stripe_mapping [
{:id_from_stripe, [:id]}... | lib/code_corps/stripe_service/adapters/stripe_connect_account.ex | 0.724286 | 0.445107 | stripe_connect_account.ex | starcoder |
defmodule Duration do
@type t :: %__MODULE__{
years: non_neg_integer,
months: pos_integer,
days: pos_integer,
hours: non_neg_integer,
minutes: non_neg_integer,
seconds: non_neg_integer
}
defstruct years: 0,
months: 0,
days: ... | lib/duration.ex | 0.886131 | 0.557665 | duration.ex | starcoder |
defmodule MangoPay.PayIn do
@moduledoc """
Functions for MangoPay [pay in](https://docs.mangopay.com/endpoints/v2.01/payins#e264_the-payin-object).
"""
use MangoPay.Query.Base
set_path "payins"
@doc """
Get a pay in.
## Examples
{:ok, pay_in} = MangoPay.PayIn.get(id)
"""
def get id do
_... | lib/mango_pay/pay_in.ex | 0.749271 | 0.455078 | pay_in.ex | starcoder |
defmodule TaskBunny.JobError do
@moduledoc """
A struct that holds an error information occured during the job processing.
## Attributes
- job: the job module failed
- payload: the payload(arguments) for the job execution
- error_type: the type of the error. :exception, :return_value, :timeout or :exit
... | lib/task_bunny/job_error.ex | 0.743727 | 0.529263 | job_error.ex | starcoder |
defmodule Mix.SCM do
@doc """
This module provides helper functions and defines the
behavior required by any SCM used by mix.
"""
@doc """
Register required callbacks.
"""
def behaviour_info(:callbacks) do
[key: 0, consumes?: 1, available?: 2, get: 2, check?: 2, update: 2, clean: 2]
end
@doc "... | lib/mix/lib/mix/scm.ex | 0.832985 | 0.512083 | scm.ex | starcoder |
defmodule Bliss.Interpreter do
@moduledoc """
The actual Bliss (Joy) interpreter. Takes parsed input.
Note about the modes:
- normal is :RUN mode, i.e. evaluating whatever gets handed in.
- 'compile' is :LIBRA or :DEFINE mode, they are terminated with a period.
"""
def new_opts, do: %{mode: :RUN, flags: ... | bliss_01/lib/bliss/interpreter.ex | 0.624752 | 0.415314 | interpreter.ex | starcoder |
defmodule Plug.Crypto.MessageEncryptor do
@moduledoc ~S"""
`MessageEncryptor` is a simple way to encrypt values which get stored
somewhere you don't trust.
The cipher text and initialization vector are base64 encoded and
returned to you.
This can be used in situations similar to the `MessageVerifier`, but... | lib/plug/crypto/message_encryptor.ex | 0.870989 | 0.441372 | message_encryptor.ex | starcoder |
defmodule Grizzly do
@moduledoc """
Grizzly functions for controlling Z-Wave devices and the
Z-Wave network.
## Sending commands to Z-Wave
The most fundamental function in `Grizzly` is `Grizzly.send_command/3`.
There are two ways of using this function.
First, by passing in a node id for a node on the... | lib/grizzly.ex | 0.902142 | 0.823612 | grizzly.ex | starcoder |
defmodule ExMachina do
@moduledoc """
Defines functions for generating data
In depth examples are in the [README](readme.html)
"""
defmodule UndefinedFactoryError do
@moduledoc """
Error raised when trying to build or create a factory that is undefined.
"""
defexception [:message]
def ... | lib/ex_machina.ex | 0.875375 | 0.452717 | ex_machina.ex | starcoder |
defmodule AOC.Y2021.Day18 do
@behaviour AOC.Solution
def input_path() do
"./lib/2021/input/day18.txt"
end
# sfn = snailfish number
def parse_input(input) do
input
|> String.split("\n", trim: true)
|> Enum.map(&parse_pair/1)
end
defp parse_pair(pair) do
{sfn, _} = Code.eval_string(pa... | lib/2021/day18.ex | 0.658198 | 0.522689 | day18.ex | starcoder |
defmodule CanvasAPI.CanvasService do
@moduledoc """
A service for viewing and manipulating canvases.
"""
use CanvasAPI.Web, :service
import CanvasAPI.UUIDMatch
alias CanvasAPI.{Account, Canvas, SlackNotifier, Team, User}
@preload [:team, :template, creator: [:team]]
@doc """
Create a new canvas f... | lib/canvas_api/services/canvas_service.ex | 0.909877 | 0.896659 | canvas_service.ex | starcoder |
defmodule Mirage do
@moduledoc """
This top level module is for transforming images.
For reading and writing images, see the `Mirage.Image` module.
"""
alias Mirage.Image
@type filter_type ::
:nearest
| :triangle
| :catmull_rom
| :gaussian
| :lanczos3
... | lib/mirage.ex | 0.957566 | 0.953405 | mirage.ex | starcoder |
defmodule Exnoops.Wordbot do
@moduledoc """
Module to interact with Github's Noop: Wordbot
See the [official `noop` documentation](https://noopschallenge.com/challenges/wordbot) for API information including the accepted parameters
"""
require Logger
import Exnoops.API
@noop "wordbot"
@doc """
Que... | lib/exnoops/wordbot.ex | 0.648021 | 0.440289 | wordbot.ex | starcoder |
defmodule Appsignal.Instrumentation do
@tracer Application.get_env(:appsignal, :appsignal_tracer, Appsignal.Tracer)
@span Application.get_env(:appsignal, :appsignal_span, Appsignal.Span)
@spec instrument(function()) :: any()
@doc false
def instrument(fun) do
span = @tracer.create_span("background_job", @... | lib/appsignal/instrumentation.ex | 0.803752 | 0.507385 | instrumentation.ex | starcoder |
defmodule AWS.CognitoIdentity do
@moduledoc """
Amazon Cognito Federated Identities
Amazon Cognito Federated Identities is a web service that delivers scoped
temporary credentials to mobile devices and other untrusted environments.
It uniquely identifies a device and supplies the user with a consistent
id... | lib/aws/cognito_identity.ex | 0.896169 | 0.574574 | cognito_identity.ex | starcoder |
defmodule ESpec.AssertionHelpers do
@moduledoc """
Defines helper functions for modules which use ESpec.
These functions wrap arguments for ESpec.ExpectTo module.
See `ESpec.Assertion` module for corresponding 'assertion modules'
"""
alias ESpec.Assertions
@elixir_types ~w(atom binary bitstring boolean ... | lib/espec/assertion_helpers.ex | 0.782538 | 0.929184 | assertion_helpers.ex | starcoder |
defmodule Cog.Support.ModelUtilities do
@moduledoc """
Utilities for making it easier to interact with models.
Intended for use in interactive situations and testing fixture
setup. From your interactive shell prompt, just type:
iex> import #{inspect __MODULE__}
and you'll be good to go.
These func... | lib/cog/support/model_utilities.ex | 0.638723 | 0.48054 | model_utilities.ex | starcoder |
defmodule Cldr.Calendar.Backend do
@moduledoc false
def define_calendar_module(config) do
backend = config.backend
quote location: :keep, bind_quoted: [config: config, backend: backend] do
defmodule Calendar do
@moduledoc """
Calendar support functions for formatting dates, times and... | lib/cldr/backend/calendar.ex | 0.836721 | 0.517815 | calendar.ex | starcoder |
defmodule Plaid.Investments.Holdings do
@moduledoc """
Functions for Plaid `investments/holdings` endpoints.
"""
import Plaid, only: [make_request_with_cred: 4, validate_cred: 1]
alias Plaid.Utils
@derive Jason.Encoder
defstruct accounts: [], item: nil, securities: [], holdings: [], request_id: nil
... | lib/plaid/investments/holdings.ex | 0.78968 | 0.607547 | holdings.ex | starcoder |
if Code.ensure_loaded?(Plug) do
defmodule Guardian.Plug.LoadResource do
@moduledoc """
This plug loads the resource associated with a previously
validated token. Tokens are found and validated using the `Verify*` plugs.
By default, load resource will return an error if no resource can be found.
Y... | lib/guardian/plug/load_resource.ex | 0.826852 | 0.793586 | load_resource.ex | starcoder |
defmodule Mix.Tasks.Compile.ElixirMake do
use Mix.Task
@recursive true
@moduledoc """
Runs `make` in the current project.
This task runs `make` in the current project; any output coming from `make` is
printed in real-time on stdout.
## Configuration
This compiler can be configured thro... | deps/elixir_make/lib/mix/tasks/compile.make.ex | 0.788746 | 0.489564 | compile.make.ex | starcoder |
defmodule ExLibSRTP do
@moduledoc """
[libsrtp](https://github.com/cisco/libsrtp) bindings for Elixir.
The workflow goes as follows:
- create ExLibSRTP instance with `new/0`
- add streams with `add_stream/2`
- protect or unprotect packets with `protect/3`, `unprotect/3`, `protect_rtcp/3`, `unprotect_rtcp/3... | lib/ex_libsrtp.ex | 0.787359 | 0.416915 | ex_libsrtp.ex | starcoder |
defmodule Txpost do
@moduledoc """


Send and receive Bitcoin transactions from your Phoenix or Plug-based Elixir
... | lib/txpost.ex | 0.936205 | 0.72331 | txpost.ex | starcoder |
defmodule ABA do
@moduledoc """
ABA is an Elixir library for performing validation and lookups on ABA routing
numbers. It stores all routing numbers and bank information in an ETS table.
Therefore, you should initialize the application in a supervision tree.
## Installation
Add `aba` to your list of depen... | lib/aba.ex | 0.829665 | 0.857887 | aba.ex | starcoder |
defmodule Gobstopper.Service.Auth.Identity do
@moduledoc """
Provides interfaces to identities.
Requires operations that have restricted access, meet those requirements.
"""
require Logger
alias Gobstopper.Service.Auth.Identity
defp unique_identity({ :error, %{ errors: [identity: _] }... | apps/gobstopper_service/lib/gobstopper.service/auth/identity.ex | 0.863852 | 0.494263 | identity.ex | starcoder |
defmodule Monad.Behaviour do
@moduledoc """
A behaviour that provides the common code for monads.
Creating a monad consists of three steps:
1. Call `use Monad.Behaviour`
2. Implement `return/1`
3. Implement `bind/2`
By completing the above steps, the monad will automatically conform to the
`Functor` a... | lib/monad/behaviour.ex | 0.887467 | 0.574037 | behaviour.ex | starcoder |
defmodule ExotelEx.InMemoryMessenger do
@behaviour ExotelEx.Messenger
# Public API
@doc """
The send_sms/4 function sends an sms to a
given phone number from a given phone number.
## Example:
```
iex(1)> ExotelEx.Messenger.InMemoryAdapter.send_sms("15005550006", "15005550001", "test message")
... | lib/exotel_ex/messengers/in_memory_messenger.ex | 0.672439 | 0.658935 | in_memory_messenger.ex | starcoder |
defmodule TimeZoneInfo.DataStore do
@moduledoc """
A behaviour to store data and serve them later on.
"""
@default_time_zone "Etc/UTC"
@doc "Puts the given `data` into the store."
@callback put(data :: TimeZoneInfo.data()) :: :ok | :error
@doc """
Returns the `transitions` for a given `time_zone`.
... | lib/time_zone_info/data_store.ex | 0.894092 | 0.547283 | data_store.ex | starcoder |
defmodule Lemma do
@moduledoc ~S"""
A morphological parser (analyzer) / lemmatizer implemented with
textbook standard method, using an abstraction called Finite State Transducer (FST).
FST is implemented in [gen_fst](https://github.com/xiamx/gen_fst) package
A parser can be initilized with desired language ... | lib/lemma.ex | 0.879283 | 0.914711 | lemma.ex | starcoder |
defmodule Exnoops.Fizzbot do
@moduledoc """
Module to interact with Github's Noop: Fizzbot
See the [official `noop` documentation](https://noopschallenge.com/challenges/fizzbot) for API information
"""
require Logger
import Exnoops.API
@noop "fizzbot"
@doc ~S"""
Query Fizzbot for a question
If ... | lib/exnoops/fizzbot.ex | 0.57523 | 0.566049 | fizzbot.ex | starcoder |
defmodule YamlFrontMatter do
@moduledoc """
Parse a file or string containing front matter and a document body.
Front matter is a block of yaml wrapped between two lines containing `---`.
In this example, the front matter contains `title: Hello`, and the body is
`Hello, world`:
```md
---
title: Hello
... | lib/yaml_front_matter.ex | 0.872687 | 0.860838 | yaml_front_matter.ex | starcoder |
defmodule CCSP.Chapter3.Start do
alias CCSP.Chapter3.CSP
alias CCSP.Chapter3.QueensConstraint
alias CCSP.Chapter3.MapColoringConstraint
alias CCSP.Chapter3.WordSearch
alias CCSP.Chapter3.WordSearchConstraint
alias CCSP.Chapter3.SendMoreMoneyConstraint
@moduledoc """
Convenience module for setting up an... | lib/ccsp/chapter3/start.ex | 0.585694 | 0.423249 | start.ex | starcoder |
defmodule Day13.Route do
@moduledoc """
Computes the shortest route to the destination.
"""
alias Day13.Cubicle
alias Day13.Route
defstruct [:input, :confirmed, :unconfirmed]
def new(input) do
%Route{input: input, confirmed: %{}, unconfirmed: %{{1, 1} => 0}}
end
def find(route, destination) do
... | 2016/day13/lib/day13/route.ex | 0.785103 | 0.50116 | route.ex | starcoder |
defmodule Netcode.ReadEncryptedPacket do
@moduledoc """
The following steps are taken when reading an encrypted packet, in this exact order:
If the packet size is less than 18 bytes then it is too small to possibly be valid, ignore the packet.
If the low 4 bits of the prefix byte are greater than or equal to 7, the... | lib/netcode/ReadEncryptedPackets.ex | 0.780579 | 0.782205 | ReadEncryptedPackets.ex | starcoder |
defmodule Strava.Athlete do
@moduledoc """
Athletes are Strava users, Strava users are athletes.
More info: https://strava.github.io/api/v3/athlete/
"""
import Strava.Util, only: [parse_date: 1, struct_from_map: 2]
@type t :: %__MODULE__{
id: integer,
resource_state: integer,
firstname: Strin... | lib/strava/athlete.ex | 0.845767 | 0.442757 | athlete.ex | starcoder |
defmodule Mole.Content do
use Private
@moduledoc """
The Content context. Stores interesting information about the game, like the
images and the statistics.
"""
import Ecto.Query, warn: false
alias Mole.Repo
alias Mole.Accounts.User
alias Mole.Content.{Answer, Condition, Image, Set, Survey, SurveyS... | lib/mole/content/content.ex | 0.860677 | 0.422207 | content.ex | starcoder |
defmodule Ecto.Adapters.Riak.DateTime do
@type year :: non_neg_integer
@type month :: non_neg_integer
@type day :: non_neg_integer
@type hour :: non_neg_integer
@type min :: non_neg_integer
@type sec :: non_neg_integer
@type msec :: non_neg_integer
@type date ::... | lib/ecto/adapters/riak/datetime.ex | 0.516352 | 0.552419 | datetime.ex | starcoder |
defmodule BPXE.Engine.SensorGateway do
@moduledoc """
*Note: This gateway is not described in BPMN 2.0. However, it's available through
BPXE's extension schema.*
This gateway senses which of first N-1 incoming sequence flows fired (i.e.
their conditions were truthful) [where N is the total number of incoming... | lib/bpxe/engine/sensor_gateway.ex | 0.717507 | 0.431225 | sensor_gateway.ex | starcoder |
defmodule Livebook.Intellisense.Docs do
@moduledoc false
# This module is responsible for extracting and normalizing
# information like documentation, signatures and specs.
@type member_info :: %{
kind: member_kind(),
name: atom(),
arity: non_neg_integer(),
documentatio... | lib/livebook/intellisense/docs.ex | 0.81812 | 0.459743 | docs.ex | starcoder |
defmodule ExAlgo.Number.Catalan do
@moduledoc """
Catalan numbers are a sequence of natural numbers that occurs in many interesting
counting problems like counting the number of expressions containing n pairs
of parentheses that are correctly matched, the number of possible Binary Search
Trees with n keys, th... | lib/ex_algo/number/catalan.ex | 0.841435 | 0.745885 | catalan.ex | starcoder |
defmodule Pond.Acc do
import Pond
@idle {__MODULE__, :idle}
@halt {__MODULE__, :halt}
@moduledoc ~S"""
Functions for accumulating state.
State accumulators are useful when combined with
`Pond.Next` for piping while preserving previous
invocations state.
For example, piping our hello world example ... | lib/pond/acc.ex | 0.68616 | 0.577227 | acc.ex | starcoder |
defmodule Stripe.Orders do
@moduledoc """
Main API for working with Customers at Stripe. Through this API you can:
-create orders
-delete single order
-delete all order
-count orders
Supports Connect workflow by allowing to pass in any API key explicitely (vs using the one from env/config).
(API ref:... | lib/stripe/orders.ex | 0.842378 | 0.778186 | orders.ex | starcoder |
defmodule Cizen.Automaton do
@moduledoc """
A saga framework to create an automaton.
Handle requests from `Saga.call/2` and `Saga.cast/2`:
case perform(%Receive{}) do
%Automaton.Cast{request: {:push, item}} ->
[item | state]
%Automaton.Call{request: :pop, from: from} ->
... | lib/cizen/automaton.ex | 0.88225 | 0.718224 | automaton.ex | starcoder |
defmodule SanbaseWeb.Graphql.DocumentProvider do
@moduledoc ~s"""
Custom Absinthe DocumentProvider for more effective caching.
Absinthe phases have one main difference compared to plugs - all phases must run
and cannot be halted. But phases can be jumped over by returning
`{:jump, result, destination_phase}`... | lib/sanbase_web/graphql/document/document_provider.ex | 0.866613 | 0.461381 | document_provider.ex | starcoder |
defmodule DataTracer.SupervisorUtils do
@doc """
Get the restart settings for a supervisor
Example return value: `%{max_restarts: 3, max_seconds: 5}`
"""
def restart_settings(supervisor_pid) do
supervisor_state = :sys.get_state(supervisor_pid)
max_restarts = supervisor_state |> elem(5)
max_second... | lib/data_tracer/supervisor_utils.ex | 0.695545 | 0.498901 | supervisor_utils.ex | starcoder |
defmodule Ash.Query.Aggregate do
@moduledoc "Represents an aggregated association value"
defstruct [
:name,
:relationship_path,
:default_value,
:resource,
:query,
:field,
:kind,
:type,
:authorization_filter,
:load,
filterable?: true
]
@type t :: %__MODULE__{}
@kin... | lib/ash/query/aggregate.ex | 0.761893 | 0.45641 | aggregate.ex | starcoder |
defmodule Chunky.Sequence.OEIS.Sigma do
@moduledoc """
OEIS Sequences for Sigma values.
Some sigma sequences are in the `Sequence.OEIS.Core` module.
## Available Sequences
### Sigma_M of integers
Sequences of `sigma_M(n)` of integers:
- `create_sequence_a001158/1` - A001158 - Sum of cubes of diviso... | lib/sequence/oeis/sigma.ex | 0.893979 | 0.801042 | sigma.ex | starcoder |
defmodule DBConnection.SojournError do
defexception [:message]
def exception(message), do: %DBConnection.SojournError{message: message}
end
defmodule DBConnection.Sojourn do
@moduledoc """
A `DBConnection.Pool` using sbroker.
### Options
* `:pool_size` - The number of connections (default: `10`)
*... | deps/db_connection/lib/db_connection/sojourn.ex | 0.803868 | 0.436322 | sojourn.ex | starcoder |
defmodule Norm.Schema do
@moduledoc false
# Provides the definition for schemas
alias __MODULE__
defstruct specs: %{}, struct: nil
def build(%{__struct__: name} = struct) do
# If we're building a schema from a struct then we need to reject any keys with
# values that don't implement the conformable... | lib/norm/schema.ex | 0.78316 | 0.489259 | schema.ex | starcoder |
defmodule JUnitFormatter do
@moduledoc """
An `ExUnit.Formatter` implementation that generates a XML in the format understood by JUnit.
To accomplish this, there are some mappings that are not straight one to one.
Therefore, here goes the mapping:
- JUnit - `ExUnit`
- Testsuites - :testsuite
- Testsuite... | lib/formatter.ex | 0.863449 | 0.592195 | formatter.ex | starcoder |
defmodule Xgit.FilePath do
@moduledoc ~S"""
Describes a file path as stored in a git repo.
Paths are always stored as a list of bytes. The git specification
does not explicitly specify an encoding, but most commonly the
path is interpreted as UTF-8.
We use byte lists here to avoid confusion and possible ... | lib/xgit/file_path.ex | 0.909581 | 0.581184 | file_path.ex | starcoder |
defmodule Mix.Tasks.Phx.Gen.Live.Slime do
@shortdoc "Generates LiveView, templates, and context for a resource"
@moduledoc """
Generates LiveView, templates, and context for a resource.
mix phx.gen.live Accounts User users name:string age:integer
The first argument is the context module followed by the... | lib/mix/tasks/phx.gen.live.slime.ex | 0.866019 | 0.520435 | phx.gen.live.slime.ex | starcoder |
defmodule Kaffe.GroupMember do
@moduledoc """
Note: The `brod_group_member` behavior is used.
Consume messages from a Kafka topic for a consumer group. There is one brod
group member per topic! So as new topics are added to configuration so are
the number of brod group members. Likewise, if you're using some... | lib/kaffe/consumer_group/subscriber/group_member.ex | 0.847983 | 0.436202 | group_member.ex | starcoder |
defmodule MdnsLite do
@moduledoc """
A simple implementation of an mDNS (multicast DNS (Domain Name Server))
server. mDNS uses multicast UDP rather than TCP. Its primary use is to
provide DNS support for the `local` domain. `MdnsLite` listens on a
well-known ip address/port. If a request arrives that it reco... | lib/mdns_lite.ex | 0.857112 | 0.812421 | mdns_lite.ex | starcoder |
defmodule Broadway.Message do
@moduledoc """
This struct holds all information about a message.
A message is first created by the producers. It is then
sent downstream and gets updated multiple times, either
by a module implementing the `Broadway` behaviour
through the `c:Broadway.handle_message/3` callbac... | lib/broadway/message.ex | 0.860325 | 0.597872 | message.ex | starcoder |
defmodule Mayo.Number do
@doc """
Checks the minimum value of a number.
iex> Mayo.Number.min(4, 3)
4
iex> Mayo.Number.min(1, 3)
{:error, %Mayo.Error{type: "number.min"}}
"""
def min(value, limit) when is_number(value) and value >= limit, do: value
def min(value, _) when is_number(va... | lib/mayo/number.ex | 0.794744 | 0.49347 | number.ex | starcoder |
defmodule WandCore.WandFile do
alias WandCore.WandFile
alias WandCore.Interfaces.File
@requirement "~> 1.0"
@vsn "1.0.0"
@moduledoc """
Module describing the internal state of a wand file, along with helper functions to manipulate the dependencies and serialize the module to disk.
## Wand.json
The for... | lib/wand_file.ex | 0.676834 | 0.45302 | wand_file.ex | starcoder |
defmodule Phoenix.Token do
@moduledoc """
Tokens provide a way to generate, verify bearer
tokens for use in Channels or API authentication.
## Basic Usage
When generating a unique token for usage in an API or Channel
it is advised to use a unique identifier for the user typically
the id from a database... | lib/phoenix/token.ex | 0.838647 | 0.520862 | token.ex | starcoder |
defmodule Jackalope do
use Supervisor
require Logger
@moduledoc "README.md"
|> File.read!()
|> String.split("<!-- MDOC !-->")
|> Enum.fetch!(1)
@default_mqtt_server {
Tortoise311.Transport.Tcp,
host: "localhost", port: 1883
}
@default_max_work_list_size 100... | lib/jackalope.ex | 0.820469 | 0.535402 | jackalope.ex | starcoder |
defmodule Semigroup do
@typedoc """
Semigroup dictionary
intuitive type: fmap : f (a -> b) -> f a -> f b
* `fmap`: (f a, a -> b) -> f b # params are swapped to facilitate piping, mandatory
* `lift_left`: a -> f b -> f a # default implementation provided, optional
"""
@type t :: %__MODULE__{
<>: (any... | typeclassopedia/lib/semigroup.ex | 0.854536 | 0.555194 | semigroup.ex | starcoder |
defmodule TableRex.Table do
@moduledoc """
A set of functions for working with tables.
The `Table` is represented internally as a struct though the
fields are private and must not be accessed directly. Instead,
use the functions in this module.
"""
alias TableRex.Cell
alias TableRex.Column
alias Tabl... | lib/table_rex/table.ex | 0.904405 | 0.563798 | table.ex | starcoder |
defmodule TILEX.Behaviours do
defmodule Greet do
@moduledoc """
Defines a behaviour to greet people hello and goodbye in different languages.
Behaviours provide a way to:
- define a set of functions that have to be implemented by a module;
- ensure that a module implements all the functions in th... | lib/behaviours.ex | 0.683314 | 0.676092 | behaviours.ex | starcoder |
defmodule Exop.Chain do
@moduledoc """
Provides macros to organize a number of Exop.Operation modules into an invocation chain.
## Example
defmodule CreateUser do
use Exop.Chain
alias Operations.{User, Backoffice, Notifications}
operation User.Create
operation Backoffice.... | lib/exop/chain.ex | 0.885983 | 0.598371 | chain.ex | starcoder |
defmodule Livebook.ANSI.Modifier do
@moduledoc false
defmacro defmodifier(modifier, code, terminator \\ "m") do
quote bind_quoted: [modifier: modifier, code: code, terminator: terminator] do
defp ansi_prefix_to_modifier(unquote("#{code}#{terminator}") <> rest) do
{:ok, unquote(modifier), rest}
... | lib/livebook_web/ansi.ex | 0.828245 | 0.479626 | ansi.ex | starcoder |
defmodule AWS.CodePipeline do
@moduledoc """
AWS CodePipeline
## Overview
This is the AWS CodePipeline API Reference.
This guide provides descriptions of the actions and data types for AWS
CodePipeline. Some functionality for your pipeline can only be configured
through the API. For more information, ... | lib/aws/generated/code_pipeline.ex | 0.933454 | 0.871693 | code_pipeline.ex | starcoder |
defmodule Day22 do
alias Day22.RangeParser
def part_one(input) do
22
|> input.contents_of(:stream)
|> Stream.map(&String.trim/1)
|> Stream.map(&parse_line(&1, -50, 50))
|> Enum.reduce(MapSet.new(), fn
{:on, cubes}, acc -> MapSet.union(acc, cubes)
{:off, cubes}, acc -> MapSet.differe... | year_2021/lib/day_22.ex | 0.512693 | 0.446796 | day_22.ex | starcoder |
defmodule MealTracker.Command do
@moduledoc """
Defines the interface and utilities for the command-line sub-commands.
## Attributes
There are attributes that integrate a command module with the rest of the system:
* `@shortdoc` - makes the command public with a short description that shows up in `track he... | lib/meal_tracker/command.ex | 0.78403 | 0.510008 | command.ex | starcoder |
defmodule AWS.KMS do
@moduledoc """
AWS Key Management Service
AWS Key Management Service (AWS KMS) is an encryption and key management web
service.
This guide describes the AWS KMS operations that you can call programmatically.
For general information about AWS KMS, see the [ *AWS Key Management Service... | lib/aws/generated/kms.ex | 0.896761 | 0.572006 | kms.ex | starcoder |
defmodule Membrane.Core.Element.PadModel do
@moduledoc false
# Utility functions for veryfying and manipulating pads and their data.
alias Membrane.Element.Pad
alias Membrane.Core.Element.State
use Bunch
@type pads_data_t :: %{Pad.ref_t() => Pad.Data.t()}
@type pad_info_t :: %{
required(:acce... | lib/membrane/core/element/pad_model.ex | 0.856167 | 0.492798 | pad_model.ex | starcoder |
defmodule Elasticlunr.Dsl.BoolQuery do
use Elasticlunr.Dsl.Query
alias Elasticlunr.Index
alias Elasticlunr.Dsl.{NotQuery, Query, QueryRepository}
defstruct ~w[rewritten should must must_not filter minimum_should_match]a
@type clause :: struct() | list(struct())
@type t :: %__MODULE__{
filter: ... | lib/elasticlunr/dsl/query/bool_query.ex | 0.766905 | 0.473779 | bool_query.ex | starcoder |
defmodule Durango.Dsl.Function.Names do
@functions [
#{name, arity}
# https://docs.arangodb.com/3.3/AQL/Functions/TypeCast.html
document: 1,
document: 2,
collections: 0,
has: 2,
to_bool: 1,
to_number: 1,
to_... | lib/dsl/function/names.ex | 0.60964 | 0.438905 | names.ex | starcoder |
defmodule MIDISynth.Command do
@moduledoc """
Convert MIDI commands to raw bytes
"""
defguardp is_int7(num) when num >= 0 and num <= 127
@typedoc "A 7-bit integer"
@type int7 :: 0..127
@typedoc """
A MIDI note
For non-percussion instruments, the frequency of a note
is `440 * 2^((n − 69) / 12)` w... | lib/midi_synth/command.ex | 0.859177 | 0.459015 | command.ex | starcoder |
defmodule AWS.AutoScalingPlans do
@moduledoc """
AWS Auto Scaling
Use AWS Auto Scaling to create scaling plans for your applications to
automatically scale your scalable AWS resources.
## API Summary
You can use the AWS Auto Scaling service API to accomplish the following tasks:
* Create and manage... | lib/aws/generated/auto_scaling_plans.ex | 0.888623 | 0.587884 | auto_scaling_plans.ex | starcoder |
defmodule MetricsReporter.LatencyStatsCalculator do
def calculate_latency_percentage_bins_data(latency_bins_list, expected_latency_bins) do
time_sorted_latency_bins_list = time_sort_latency_bins_list(latency_bins_list)
aggregated_latency_bins_data = aggregate_latency_bins_data(time_sorted_latency_bins_list)
... | monitoring_hub/apps/metrics_reporter/lib/metrics_reporter/latency_stats_calculator.ex | 0.563258 | 0.712545 | latency_stats_calculator.ex | starcoder |
defmodule Video.TrimmedSource do
@known_params [
:source,
:coord_from,
:coord_to,
:duration_ms_uncut,
:coords_uncut
]
@type t :: %__MODULE__{
source: binary(),
coord_from: Video.TimedPoint.t(),
coord_to: Video.TimedPoint.t(),
duration_ms_uncut: Video.Ti... | lib/video/trimmed_source.ex | 0.88836 | 0.528047 | trimmed_source.ex | starcoder |
defmodule LibPE.ResourceTable do
@moduledoc """
Parses windows resource tables
By convention these are always three levels:
Type > Name > Language
"""
alias LibPE.ResourceTable
use Bitwise
defstruct characteristics: 0,
timestamp: 0,
major_version: 0,
minor_... | lib/libpe/resource_table.ex | 0.845624 | 0.654674 | resource_table.ex | starcoder |
defmodule DES do
@moduledoc """
Encrypt and Decrypt files using DES symmetric algorithm.
## Examples
``` bash
$ ./bin enc my_file my_file.enc
$ ./bin dec my_file.enc my_file
```
iex> DES.encrypt(['12345678', '12345678'])
iex> DES.decrypt(['12345678', '12345678'])
"""
@block_size_bytes 8
@... | des/lib/des.ex | 0.656548 | 0.866302 | des.ex | starcoder |
defmodule MarathonEventExporter.SSEParser do
@moduledoc """
A GenServer to turn a stream of bytes (usually from an HTTP response) into a
stream of server-sent events.
See https://html.spec.whatwg.org/multipage/server-sent-events.html
(particularly sections 9.2.4 and 9.2.5) for the protocol specification.
"... | lib/sse_parser.ex | 0.652352 | 0.467453 | sse_parser.ex | starcoder |
defmodule BitcoinRpc do
@moduledoc """
Module to connect to a bitcoin node and make requests to the node through JSON RPC calls.
## Configuration
config :bitcoin_rpc,
host: "localhost",
port: "18333",
user: "myuser",
pass: "<PASSWORD>",
callback: nil # required only... | lib/bitcoin_rpc.ex | 0.806358 | 0.439447 | bitcoin_rpc.ex | starcoder |
defmodule Timex.Format.Time.Formatter do
@moduledoc """
This module defines the behaviour for custom Time formatters
"""
use Behaviour
use Timex
import Timex.Macros
alias Timex.Translator
alias Timex.Format.Time.Formatters.Default
alias Timex.Format.Time.Formatters.Humanized
defmacro __using__(_) d... | lib/format/time/formatter.ex | 0.892199 | 0.466116 | formatter.ex | starcoder |
defmodule Blogit.Components.Metas do
@moduledoc """
A `Blogit.Component` process which can be queried from outside.
The `Blogit.Components.Metas` process holds the meta data for all the posts
in the blog as its state.
For some queries only the meta data of the posts is needed and quering this
component for... | lib/blogit/components/metas.ex | 0.702938 | 0.550728 | metas.ex | starcoder |
defmodule Floki do
alias Floki.{Finder, HTMLParser, FilterOut, HTMLTree}
@moduledoc """
Floki is a simple HTML parser that enables search for nodes using CSS selectors.
## Example
Assuming that you have the following HTML:
```html
<!doctype html>
<html>
<body>
<section id="content">
<p c... | lib/floki.ex | 0.784897 | 0.64646 | floki.ex | starcoder |
defmodule StarkInfra.Utils.Parse do
alias EllipticCurve.Signature
alias EllipticCurve.PublicKey
alias EllipticCurve.Ecdsa
alias StarkInfra.Utils.Check
alias StarkInfra.Utils.JSON
alias StarkInfra.Utils.API
alias StarkInfra.User.Project
alias StarkInfra.User.Organization
alias StarkInfra.Error
alias ... | lib/utils/parse.ex | 0.839931 | 0.51129 | parse.ex | starcoder |
defmodule Csvto.Builder do
@moduledoc """
Conveniences for building a Csvto
This module can be `use`-d into a Module to build a Csvto
## Example
```
defmodule MyCsvto do
use Csvto.Builder
csv :product do
field :name, :string, name: "Name"
field :number, :string, name: "Number"
f... | lib/csvto/builder.ex | 0.903431 | 0.770206 | builder.ex | starcoder |
defmodule Ferryman.Client do
@moduledoc """
This module provides the Client API to communicate with a Ferryman Server.
## Overview
To start communicating with the Ferryman server, let's first start our redis process:
iex> {:ok, redis} = Redix.start_link()
Now we can simply call the functions, the se... | lib/client.ex | 0.770292 | 0.508422 | client.ex | starcoder |
defmodule Rajska do
@moduledoc """
Rajska is an elixir authorization library for [Absinthe](https://github.com/absinthe-graphql/absinthe).
It provides the following middlewares:
- `Rajska.QueryAuthorization`
- `Rajska.QueryScopeAuthorization`
- `Rajska.ObjectAuthorization`
- `Rajska.ObjectScopeAuthorizat... | lib/rajska.ex | 0.829457 | 0.808483 | rajska.ex | starcoder |
defmodule Indicatorex.MACD do
@type t :: %Indicatorex.MACD{
fast: number(),
slow: number(),
dif: number(),
v: [Indicatorex.MACD.Sericalize.t()]
}
defstruct fast: 0, slow: 0, dif: 0, v: [%Indicatorex.MACD.Sericalize{}]
@doc """
MACD calc function
"""
@spec cal... | lib/macd.ex | 0.70202 | 0.523481 | macd.ex | starcoder |
defmodule Applicative do
@typedoc """
Functor dictionary
intuitive type: fmap : f (a -> b) -> f a -> f b
* `fmap`: (f a, a -> b) -> f b # params are swapped to facilitate piping, mandatory
* `lift_left`: a -> f b -> f a # default implementation provided, optional
"""
@type t :: %__MODULE__{
functor:... | typeclassopedia/lib/applicative.ex | 0.837487 | 0.634685 | applicative.ex | starcoder |
defmodule WiseHomex do
@moduledoc """
Api Client for Wise Home
## Usage:
### Getting a configuration
First, get a configuration struct by invoking `new_config/2` or `new_config/3` with either `:api_key`, `:plain` or `:auth_header` as first argument.
```
config = WiseHomex.new_config(:api_key, "your_ap... | lib/wise_homex.ex | 0.849191 | 0.776453 | wise_homex.ex | starcoder |
defmodule Exop.TypeValidation do
@known_types ~w(boolean integer float string tuple struct map list atom function keyword module uuid)a
Enum.each(@known_types, fn type ->
def type_supported?(unquote(type), _opts), do: :ok
end)
def type_supported?(nil, nil), do: :ok
def type_supported?(nil, []), do: :ok... | lib/exop/validations/type_validation.ex | 0.596198 | 0.530723 | type_validation.ex | starcoder |
defmodule Vivaldi.Simulation.Runner do
@moduledoc """
Implements all the boilerplate stuff required for both the centralized and distributed algorithm.
"""
alias Vivaldi.Simulation.Vector
def run(n, radius, compute_next_x_i_func) do
points = create_coordinate_cluster(n, type: :circular, radius: radius)... | vivaldi/lib/simulation/runner.ex | 0.785061 | 0.550668 | runner.ex | starcoder |
defmodule Mix.Tasks.Changix.Gen.Changelog do
@moduledoc """
Generates a new changelog entry.
## Command line options:
- `--folder` or `-f`. Optional, defaults to `/changelog`.
- `--kind` or `-k`. Optional, defaults to nil.
- `--quiet` or `-q'. Optional.
- `title`. Mandatory.
## Examples:
`... | lib/mix/tasks/changix.gen.changelog.ex | 0.88513 | 0.585546 | changix.gen.changelog.ex | starcoder |
defmodule DataTracer.Server do
use GenServer
require Logger
@moduledoc """
Reads and writes the traced data to ETS
Data format `{key, timestamp, value}`
"""
@table_name :data_tracer
defmodule State do
defstruct [:table_name, :table]
end
@doc """
Options:
* `:table` - The ETS table to us... | lib/data_tracer/server.ex | 0.765418 | 0.494263 | server.ex | starcoder |
defmodule ExComponentSchema.Validator.Error do
# credo:disable-for-this-file Credo.Check.Readability.ModuleDoc
defstruct [:error, :path]
defmodule AdditionalItems do
defstruct([:additional_indices])
end
defmodule AdditionalProperties do
defstruct([])
end
defmodule AllOf do
defstruct([:inva... | lib/ex_component_schema/validator/error.ex | 0.536799 | 0.59887 | error.ex | starcoder |
defmodule Robot.Links.Server do
@moduledoc """
Robot model as a GenServer
"""
use GenServer
import Robot.Links
import Collision.Detector
# Client
@doc """
## Example
{:ok, pid} =Robot.Links.Server.start_link([])
"""
def start_link(ops) do
GenServer.start_link... | dpp/lib/robot/robot_links_server.ex | 0.787564 | 0.498901 | robot_links_server.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.