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 LevelWeb.Schema.Mutations do
@moduledoc false
use Absinthe.Schema.Notation
@desc "A validation error."
object :error do
@desc "The name of the invalid attribute."
field :attribute, non_null(:string)
@desc "A human-friendly error message."
field :message, non_null(:string)
end
@... | lib/level_web/schema/mutations.ex | 0.820433 | 0.4112 | mutations.ex | starcoder |
defmodule ExEnum do
##== Preamble ===========================================================
@moduledoc """
A simple enumeration library for Elixir.
Just add **use ExEnum, from: [ ... ]** to your module and it will
automagically acquire the following functionality:
- Ability to list all the values in th... | lib/exenum.ex | 0.713032 | 0.881411 | exenum.ex | starcoder |
defmodule AWS.Organizations do
@moduledoc """
Organizations is a web service that enables you to consolidate your multiple
Amazon Web Services accounts into an *organization* and centrally manage your
accounts and their resources.
This guide provides descriptions of the Organizations operations. For more
... | lib/aws/generated/organizations.ex | 0.831143 | 0.580679 | organizations.ex | starcoder |
defmodule LogstashJson.Event do
@moduledoc """
This module contains functions for generating and serializing logs events.
"""
@doc "Generate a log event from log data"
def event(level, msg, ts, md, %{fields: fields, utc_log: utc_log, formatter: formatter}) do
fields
|> format_fields(md, %{
"@ti... | lib/logstash_json/event.ex | 0.630571 | 0.462594 | event.ex | starcoder |
defmodule Dotx do
@typedoc """
An `id` type is a value in DOT : either a simple string or an HTML string.
The `%Dotx.HTML{}` allows you to match the latter.
"""
@type id :: binary | %Dotx.HTML{html: binary}
@typedoc """
A `nodeid` type is a either a simple node id `["myid"]` or a node id with a p... | lib/dotx.ex | 0.953046 | 0.754847 | dotx.ex | starcoder |
defmodule Export.Ruby do
@moduledoc """
Wrapper for ruby.
## Example
```elixir
defmodule SomeRubyCall do
use Export.Ruby
def call_ruby_method
# path to ruby files
{:ok, ruby} = Ruby.start(ruby_lib: Path.expand("lib/ruby"))
# call "upcase" method from "test" file with "hello" argum... | lib/export/ruby.ex | 0.850903 | 0.778313 | ruby.ex | starcoder |
defmodule Mux.Video.Spaces do
@moduledoc """
This module provides functions for managing Spaces in Mux Video. [API Documentation](https://docs.mux.com/api-reference/video#tag/spaces)
"""
alias Mux.{Base, Fixtures}
@path "/video/v1/spaces"
@doc """
Create a new space.
Returns `{:ok, space, %Tesla.Clie... | lib/mux/video/spaces.ex | 0.825062 | 0.412441 | spaces.ex | starcoder |
defmodule Benchmarks.GoogleMessage3.Message22853 do
@moduledoc false
use Protobuf, syntax: :proto2
field :field22869, 1, optional: true, type: Benchmarks.GoogleMessage3.Enum22854, enum: true
field :field22870, 2, repeated: true, type: :uint32, packed: true, deprecated: false
field :field22871, 3, repeated: t... | bench/lib/datasets/google_message3/benchmark_message3_2.pb.ex | 0.635901 | 0.487551 | benchmark_message3_2.pb.ex | starcoder |
defmodule ExUnit.CaptureIO do
@moduledoc ~S"""
Functionality to capture IO for testing.
## Examples
defmodule AssertionTest do
use ExUnit.Case
import ExUnit.CaptureIO
test "example" do
assert capture_io(fn -> IO.puts("a") end) == "a\n"
end
test "checkin... | lib/ex_unit/lib/ex_unit/capture_io.ex | 0.854582 | 0.751899 | capture_io.ex | starcoder |
defmodule Hammox.TypeMatchError do
@moduledoc false
defexception [:message]
alias Hammox.Utils
@impl true
def exception({:error, reasons}) do
%__MODULE__{
message: "\n" <> message_string(reasons)
}
end
defp human_reason({:arg_type_mismatch, index, value, type}) do
"#{Ordinal.ordinaliz... | lib/hammox/type_match_error.ex | 0.795698 | 0.430117 | type_match_error.ex | starcoder |
defmodule Serum.Project.ElixirValidator do
@moduledoc false
_moduledocp = "A module for validation of Serum project definition data."
@type result() :: :ok | {:invalid, binary()} | {:invalid, [binary()]}
@all_keys [
:site_name,
:site_description,
:author,
:author_email,
:server_root,
... | lib/serum/project/elixir_validator.ex | 0.771413 | 0.445107 | elixir_validator.ex | starcoder |
defmodule ATECC508A.Certificate do
@moduledoc """
Convert between X.509 certificates and ATECC508A compressed certificates
This is an implementation of the compressed certificate definition described in
Atmel-8974A-CryptoAuth-ATECC-Compressed-Certificate-Definition-ApplicationNote_112015.
"""
import X509.... | lib/atecc508a/certificate.ex | 0.874935 | 0.491578 | certificate.ex | starcoder |
defmodule ReWeb.Types.Interest do
@moduledoc """
GraphQL types for interests
"""
use Absinthe.Schema.Notation
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
alias ReWeb.Resolvers.Interests, as: InterestsResolver
object :interest do
field :id, :id
field :uuid, :uuid
field :name, :... | apps/re_web/lib/graphql/types/interest.ex | 0.608594 | 0.488893 | interest.ex | starcoder |
defmodule MaxwellTimber.Middleware do
@moduledoc """
Maxwell middleware for logging outgoing requests to Timber.io.
Using this middleware will log all requests and responses using Timber.io formatting and metadata.
### Example usage
```
defmodule MyClient do
use Maxwell.Builder, ~w(get)a
middlewar... | lib/maxwell_timber/middleware.ex | 0.828939 | 0.548855 | middleware.ex | starcoder |
defmodule Cafex.Consumer.Manager do
@moduledoc """
This module is the main manager for a high-level kafka consumer
## structure
The manager works together with a offset manager and a group manager to
manage the consumer workers.
The group manager handles the client assignment via kafka(0.9) or zookeeper.... | lib/cafex/consumer/manager.ex | 0.793346 | 0.783988 | manager.ex | starcoder |
defmodule JSON.LD do
use RDF.Serialization.Format
import RDF.Sigils
alias JSON.LD.{Compaction, Context, Expansion, Flattening, Options}
@id ~I<http://www.w3.org/ns/formats/JSON-LD>
@name :jsonld
@extension "jsonld"
@media_type "application/ld+json"
@keywords ~w[
@base
@container
@context... | lib/json_ld.ex | 0.8308 | 0.44734 | json_ld.ex | starcoder |
defmodule Oban.Crontab.Parser do
@moduledoc false
@doc """
Parses the given `binary` as cron.
Returns `{:ok, [token], rest, context, position, byte_offset}` or
`{:error, reason, rest, context, line, byte_offset}` where `position`
describes the location of the cron (start position) as `{line, column_on_li... | lib/oban/crontab/parser.ex | 0.844377 | 0.472136 | parser.ex | starcoder |
defmodule Yodlee.Cobrand do
@moduledoc """
Functions for `cobrand` endpoint.
"""
import Yodlee
alias Yodlee.Utils
defstruct cobrand_id: nil, application_id: nil, locale: nil, session: nil
@type t :: %__MODULE__{cobrand_id: integer,
application_id: String.t,
... | lib/yodlee/cobrand.ex | 0.776623 | 0.404919 | cobrand.ex | starcoder |
defmodule SiteEncrypt.Phoenix do
@moduledoc """
`SiteEncrypt` adapter for Phoenix endpoints.
## Usage
1. Add `use SiteEncrypt.Phoenix` to your endpoint immediately after `use Phoenix.Endpoint`
2. Configure https via `configure_https/2`.
3. Add the implementation of `c:SiteEncrypt.certification/0` to the e... | lib/site_encrypt/phoenix.ex | 0.854171 | 0.510863 | phoenix.ex | starcoder |
defmodule Gotham.TokenStore do
@moduledoc """
The `Gotham.TokenStore` is a simple `GenServer` that manages storage and retrieval
of tokens `Gotham.Token`. When adding to the token store, it also queues tokens
for a refresh before they expire: ten seconds before the token is set to expire,
the `TokenStore` wil... | lib/gotham/token_store.ex | 0.753557 | 0.461199 | token_store.ex | starcoder |
defmodule Similarity.Simhash do
@moduledoc """
Simhash string similarity algorithm.
[Description of Simhash](https://matpalm.com/resemblance/simhash/)
iex> Similarity.simhash("Barna", "Kovacs")
0.59375
iex> Similarity.simhash("Austria", "Australia")
0.65625
"""
@moduledoc since: "0.... | lib/similarity/simhash.ex | 0.925668 | 0.704275 | simhash.ex | starcoder |
defmodule Backpack.Moment.Presenter do
@minutes_in_year 525600
@minutes_in_quarter_year 131400
@minutes_in_three_quarters_year 394200
def time_ago_in_words(from, opts) do
unit = Keyword.get(opts, :unit, :seconds)
distance_of_time_in_words(from, Backpack.Moment.timestamp(unit), opts)
end
def distan... | lib/backpack/moment/presenter.ex | 0.547706 | 0.51312 | presenter.ex | starcoder |
defmodule NimbleTOTP do
@moduledoc ~S"""
NimbleTOTP is a tiny library for Two-factor authentication (2FA) that
allows developers to implement Time-Based One-Time Passwords (TOTP)
for their applications.
## Two-factor authentication (2FA)
The concept of 2FA is quite simple. It's an extra layer of security
... | lib/nimble_totp.ex | 0.889984 | 0.75101 | nimble_totp.ex | starcoder |
defmodule Kino.Output do
@moduledoc """
A number of output formats supported by Livebook.
"""
import Kernel, except: [inspect: 2]
@typedoc """
Livebook cell output may be one of these values and gets rendered accordingly.
"""
@type t ::
ignored()
| stdout()
| text()
... | lib/kino/output.ex | 0.922596 | 0.610163 | output.ex | starcoder |
defprotocol Casex.Serializable do
@moduledoc """
Protocol controlling how a value is serialized. It is useful to handle custom
structs of your app, without that the `Casex` will be skipped and passed directly to Jason.
## Deriving
The protocol allows leveraging the Elixir's `@derive` feature
to simplify p... | lib/casex/serializable.ex | 0.912932 | 0.639215 | serializable.ex | starcoder |
defimpl Inspect, for: Graph do
# For graphs with less than 100 vertices, we'll try to pretty print it,
# however we should avoid doing so with larger graphs, as it will likely cause outrageous
# memory consumption, not to mention be expensive to calculate, and the pretty form is not
# very useful at that size a... | lib/graph/inspect.ex | 0.547464 | 0.633169 | inspect.ex | starcoder |
defmodule Automaton.Types.BT do
@moduledoc """
Implements the Behavior Tree (BT) state space representation.
Each tree is goal-oriented, i.e. associated with a distinct, high-level goal
which it attempts to achieve.
Behavior trees are a unique combination of state space representation
(graphical, or tree) ... | lib/automata/automaton_types/graphical/behavior_tree/control/bt.ex | 0.599016 | 0.522568 | bt.ex | starcoder |
defmodule Akin.SubstringSet do
@moduledoc """
Functions for string comparsion where common words between the strings are compared in sets.
Two sets
#MapSet<["alice", "in", "wonderland"]>
#MapSet<["adventures", "alice", "glass", "looking", "s", "the", "through"]>
Commonality
* `common_words = "alice"`
... | lib/akin/algorithms/substring_set.ex | 0.855006 | 0.408749 | substring_set.ex | starcoder |
defmodule MapQueue do
@moduledoc """
MapQueue is an implemenation of a queue with a single map as the underlying
data structure.
The benefit of using a MapQueue over a list is that appending to the tail of
a list `++` can become quite an expensive operation when the list is large.
With MapQueue adding ... | lib/map_queue.ex | 0.89683 | 0.71015 | map_queue.ex | starcoder |
defmodule Statistex do
@moduledoc """
Calculate all the statistics for given samples.
Works all at once with `statistics/1` or has a lot of functions that can be triggered individually.
To avoid wasting computation, function can be given values they depend on as optional keyword arguments so that these values... | lib/statistex.ex | 0.950537 | 0.745329 | statistex.ex | starcoder |
defmodule Recipe do
@moduledoc """
### Intro
The `Recipe` module allows implementing multi-step, reversible workflows.
For example, you may wanna parse some incoming data, write to two different
data stores and then push some notifications. If anything fails, you wanna
rollback specific changes in differe... | lib/recipe.ex | 0.865324 | 0.467514 | recipe.ex | starcoder |
defmodule Xandra do
@moduledoc """
This module provides the main API to interface with Cassandra.
This module handles the connection to Cassandra, queries, connection pooling,
connection backoff, logging, and more. Many of these features are provided by
the [`DBConnection`](https://hex.pm/packages/db_connect... | lib/xandra.ex | 0.931408 | 0.741399 | xandra.ex | starcoder |
defmodule StaffNotes.Ecto.Slug do
@moduledoc """
An `Ecto.Type` that represents an identifier that can be used in a URL.
This type also makes it so that `binary_id` is distinguishable from a name because it keeps them
both strongly typed.
## Use
Use this as the type of the database field in the schema:
... | lib/staff_notes/ecto/slug.ex | 0.872048 | 0.825695 | slug.ex | starcoder |
defmodule Type.Union do
@moduledoc """
Represents the Union of two or more types.
The associated struct has one field:
- `:of` which is a list of all types that are being unioned.
For performance purposes, Union keeps its subtypes in
reverse-type-order.
Type.Union implements both the enumerable protoco... | lib/type/union.ex | 0.86757 | 0.873485 | union.ex | starcoder |
defmodule Joystick do
@moduledoc """
Simple wrapper to get Linux Joystick events.
# Usage
```
iex()> {:ok, js} = Joystick.start_link(0, self())
iex()> flush()
{:joystick, %Joystick.Event{number: 1, timestamp: 1441087318, type: :axis, value: -60}}
{:joystick, %Joystick.Event{number: 4, timestamp: 144108... | lib/joystick.ex | 0.775477 | 0.582729 | joystick.ex | starcoder |
defmodule Cldr.Unit.Test.ConversionData do
@moduledoc false
@conversion_test_data "test/support/data/conversion_test_data.txt"
@external_resource @conversion_test_data
@offset 1
def conversion_test_data do
@conversion_test_data
|> File.read!()
|> String.split("\n")
|> Enum.map(&String.trim/1... | test/support/parse_conversion_data.ex | 0.70304 | 0.548432 | parse_conversion_data.ex | starcoder |
defmodule FaultTree.Analyzer do
@moduledoc """
Handles building a fault tree out of an array of nodes.
"""
alias FaultTree.Analyzer.Probability
alias FaultTree.Gate
alias FaultTree.Node
require Logger
@doc """
Converts a `FaultTree` struct into a hierarchical map.
"""
def process(tree) do
{:... | lib/fault_tree/analyzer.ex | 0.860501 | 0.636099 | analyzer.ex | starcoder |
defmodule ReIntegrations.Credipronto.Mapper do
@moduledoc """
Module for mapping Credipronto's query and response payloads
"""
def query_out(params), do: Enum.reduce(params, %{}, &map_attributes/2)
def payload_in(params), do: Enum.reduce(params, %{}, &map_payload/2)
defp map_attributes({:mutuary, value},... | apps/re_integrations/lib/simulators/credipronto/mapper.ex | 0.605449 | 0.582877 | mapper.ex | starcoder |
defmodule ETFs.Stream do
defstruct path: nil, format: :v3
@fourcc "ETFs"
@doc false
def open(path, opts \\ []) do
format = Keyword.get(opts, :format, :v3)
%__MODULE__{path: path, format: format}
end
def record_count(%__MODULE__{path: path, format: :v3}) do
with {:ok, f} <- File.open(path, [:r... | lib/etfs/stream.ex | 0.518059 | 0.456228 | stream.ex | starcoder |
defmodule Discordian.Calendar do
@behaviour Calendar
@type year :: Integer.t()
@type month :: 1..6
@type day :: 1..73
@type day_of_week :: 1..5
@type hour :: 0..23
@type minute :: 0..59
@type second :: 0..60
@type microsecond :: Integer.t()
@seconds_per_minute 60
@seconds_per_hour 60*60
@secon... | lib/discordian/calendar.ex | 0.89874 | 0.586612 | calendar.ex | starcoder |
defmodule AWS.Appflow do
@moduledoc """
Welcome to the Amazon AppFlow API reference. This guide is for developers
who need detailed information about the Amazon AppFlow API operations, data
types, and errors.
Amazon AppFlow is a fully managed integration service that enables you to
securely transfer data ... | lib/aws/generated/appflow.ex | 0.882168 | 0.543651 | appflow.ex | starcoder |
defmodule Evolvr.Bio do
@moduledoc """
A collection of bioinformatics algorithms.
"""
@doc"""
Returns a list of kmers.
"""
def get_kmers(seq, k) do
ks = get_all_kmers(seq, k)
Enum.filter(ks, fn(x) -> String.length(x) == k end)
end
defp get_all_kmers("", _k) do
[]
end
defp get_all_km... | lib/evolvr/bio.ex | 0.619817 | 0.462412 | bio.ex | starcoder |
defmodule Books.PassiveAbilities do
@moduledoc """
The PassiveAbilities context.
"""
import Ecto.Query, warn: false
alias Books.Repo
alias Books.PassiveAbilities.PassiveAbility
@doc """
Returns the list of passive_abilities.
## Examples
iex> list_passive_abilities()
[%PassiveAbility{}... | lib/books/passive_abilities.ex | 0.83772 | 0.430985 | passive_abilities.ex | starcoder |
defmodule CipherSuites do
@moduledoc """
Support OpenSSL-style cipher suite selection in Erlang/Elixir applications.
"""
@doc """
Applies the specified OpenSSL cipher selection string to the list of known
cipher suites and returns the resulting list.
The result can be used in the `:ciphers` option for `... | lib/cipher_suites.ex | 0.828904 | 0.471284 | cipher_suites.ex | starcoder |
defmodule Mint.HTTP1 do
@moduledoc """
Processless HTTP client with support for HTTP/1 and HTTP/1.1.
This module provides a data structure that represents an HTTP/1 or HTTP/1.1 connection to
a given server. The connection is represented as an opaque struct `%Mint.HTTP1{}`.
The connection is a data structure ... | lib/mint/http1.ex | 0.797044 | 0.562357 | http1.ex | starcoder |
defmodule Mix.Tasks.Phx.New do
@moduledoc """
Creates a new Phoenix project.
It expects the path of the project as an argument.
mix phx.new PATH [--module MODULE] [--app APP]
A project at the given PATH will be created. The
application name and module name will be retrieved
from the path, unless `-... | installer/lib/mix/tasks/phx.new.ex | 0.761494 | 0.469946 | phx.new.ex | starcoder |
defmodule Ash.Type do
@array_constraints [
min_length: [
type: :non_neg_integer,
doc: "A minimum length for the items"
],
max_length: [
type: :non_neg_integer,
doc: "A maximum length for the items"
],
nil_items?: [
type: :boolean,
doc: "Whether or not the list c... | lib/ash/type/type.ex | 0.904329 | 0.753897 | type.ex | starcoder |
defmodule Alerts.Sort do
@moduledoc """
Sorts alerts in order of relevance. Currently, the logic is:
* effect name
* lifecycle
* severity
* updated at (newest first)
* future affected period (closest first)
* id
"""
@lifecycle_order [
:new,
:upcoming,
:ongoing_upcoming,
:ongoing... | apps/alerts/lib/sort.ex | 0.627381 | 0.412501 | sort.ex | starcoder |
defmodule Phoenix.Template do
@moduledoc """
Templates are used by Phoenix when rendering responses.
Since many views render significant content, for example
a whole HTML file, it is common to put these files into a particular
directory, typically "web/templates".
This module provides conveniences for rea... | lib/phoenix/template.ex | 0.903049 | 0.455199 | template.ex | starcoder |
defmodule TimeZoneInfo.DataStore.PersistentTerm do
if function_exported?(:persistent_term, :get, 0) do
@moduledoc false
# This module implements the `TimeZoneInfo.DataStore` and stores the data with
# [:persistent_term](https://erlang.org/doc/man/persistent_term.html).
@behaviour TimeZoneInfo.DataSt... | lib/time_zone_info/data_store/persistent_term.ex | 0.83602 | 0.511778 | persistent_term.ex | starcoder |
defmodule BitPal.ExchangeRate do
alias BitPal.Currencies
alias BitPalSchemas.Currency
@type pair :: {Currency.id(), Currency.id()}
@type t :: %__MODULE__{
rate: Decimal.t(),
pair: pair
}
defstruct [:rate, :pair]
# Creation
@spec new!(Money.t(), Money.t()) :: t
@spec new!(... | lib/bitpal/exchange_rate/exchange_rate.ex | 0.882365 | 0.614307 | exchange_rate.ex | starcoder |
defmodule Axon.Optimizers do
@moduledoc """
Implementations of common gradient-based optimization algorithms.
All of the methods in this module are written in terms of
the update methods defined in `Axon.Updates`. Axon treats
optimizers as the tuple:
{init_fn, update_fn}
where `init_fn` returns an ... | lib/axon/optimizers.ex | 0.957378 | 0.786336 | optimizers.ex | starcoder |
defmodule TypeCheck.Builtin.NamedType do
defstruct [:name, :type, :local]
use TypeCheck
@type! t :: %TypeCheck.Builtin.NamedType{name: atom(), type: TypeCheck.Type.t(), local: boolean()}
@type! problem_tuple ::
{t(), :named_type, %{problem: lazy(TypeCheck.TypeError.Formatter.problem_tuple())},
... | lib/type_check/builtin/named_type.ex | 0.533884 | 0.466724 | named_type.ex | starcoder |
defmodule Result do
@moduledoc """
Documentation for Result.
"""
@type t(error, value) :: Result.Error.t(error) | Result.Ok.t(value)
@doc """
See `Result.Ok.of/1`
"""
defdelegate ok(value), to: Result.Ok, as: :of
@doc """
See `Result.Error.of/1`
"""
defdelegate error(value), to: Result.Error,... | lib/result.ex | 0.814864 | 0.556641 | result.ex | starcoder |
defmodule ChromicPDF.Template do
@moduledoc """
Helper functions for page styling.
For a start, see `source_and_options/1`.
## Motivation
This module contains helper functions that make it easier to to build HTML templates (body,
header, and footer) that fully cover a given page. Like an adapter, it trie... | lib/chromic_pdf/template.ex | 0.853165 | 0.469216 | template.ex | starcoder |
defmodule Membrane.HTTPAdaptiveStream.Sink do
@moduledoc """
Sink for generating HTTP streaming manifests.
Uses `Membrane.HTTPAdaptiveStream.Manifest` for manifest serialization
and `Membrane.HTTPAdaptiveStream.Storage` for saving files.
## Notifications
- `{:track_playable, input_pad_id}` - sent when th... | lib/membrane_http_adaptive_stream/sink.ex | 0.893411 | 0.428473 | sink.ex | starcoder |
defmodule EQRCode.Matrix do
@moduledoc false
import Bitwise
defstruct [:version, :modules, :mask, :matrix]
@type matrix :: term
@type t :: %__MODULE__{version: integer, modules: integer, matrix: matrix}
@type coordinate :: {integer, integer}
@ecc_l 0b01
@alignments %{
1 => [],
2 => [6, 18],
... | lib/eqrcode/matrix.ex | 0.854975 | 0.640439 | matrix.ex | starcoder |
defmodule StarkInfra.IssuingBalance do
alias __MODULE__, as: IssuingBalance
alias StarkInfra.Error
alias StarkInfra.Utils.Rest
alias StarkInfra.Utils.Check
alias StarkInfra.User.Project
alias StarkInfra.User.Organization
@moduledoc """
Groups IssuingBalance related functions
"""
@doc """
The Iss... | lib/issuing_balance/issuing_balance.ex | 0.850949 | 0.502563 | issuing_balance.ex | starcoder |
defmodule BitPalPhx.ExchangeRate do
@moduledoc false
@type t :: %__MODULE__{
rate: Decimal.t(),
pair: {atom, atom}
}
defstruct [:rate, :pair]
@spec new(Money.t(), Money.t()) :: t
def new(amount, fiat_amount) do
%__MODULE__{
rate: Decimal.div(Money.to_decimal(fiat_amoun... | lib/bitpal_phx/exchange_rate.ex | 0.803174 | 0.545225 | exchange_rate.ex | starcoder |
defmodule OAuthXYZ.Model.ResourceRequest do
@moduledoc """
Resource Request Handling Module.
```
# Resources
[
{
"actions": [
"read",
"write",
"dolphin"
],
"locations": [
"https://server.example.net/",
"https://resource.local/other"
],
... | lib/oauth_xyz/model/resource_request.ex | 0.749546 | 0.734548 | resource_request.ex | starcoder |
defmodule Ra do
require Logger
@doc """
Defines the banner to use when showing the help.
"""
defmacro banner(banner) do
quote do
@banner unquote(banner)
end
end
@doc """
Defines and describes a subcommand.
You have do provide at least the `name` of the command as a string and the
fu... | lib/ra.ex | 0.771542 | 0.629276 | ra.ex | starcoder |
defmodule Ankh.HTTP2.Frame do
@moduledoc """
HTTP/2 frame struct
The __using__ macro injects the frame struct needed by `Ankh.HTTP2.Frame`.
"""
require Logger
alias Ankh.HTTP2.Frame.Encodable
@typedoc "Struct injected by the `Ankh.HTTP2.Frame` __using__ macro."
@type t :: struct()
@typedoc "Frame... | lib/ankh/http2/frame.ex | 0.917261 | 0.463201 | frame.ex | starcoder |
defmodule Credo.Code do
@moduledoc """
Credo.Code contains a lot of utility or helper functions that deal with the
analysis if - you guessed it - Code.
Whenever a function serves a general purpose in this area, e.g. getting the
value of a module attribute inside a given module, we want to extract that
func... | lib/credo/code.ex | 0.744285 | 0.55097 | code.ex | starcoder |
defmodule Coxir.Struct.Guild do
@moduledoc """
Defines methods used to interact with Discord guilds.
Refer to [this](https://discordapp.com/developers/docs/resources/guild#guild-object)
for a list of fields and a broader documentation.
In addition, the following fields are also embedded.
- `owner` - an us... | lib/coxir/struct/guild.ex | 0.876086 | 0.420005 | guild.ex | starcoder |
defmodule Protox.MergeMessage do
@moduledoc """
This module provides a helper function to merge messages.
"""
alias Protox.Field
@doc """
Singular fields of `msg` will be overwritten, if specified in `from`, except for
embedded messages which will be merged. Repeated fields will be concatenated.
Note... | lib/protox/merge_message.ex | 0.870212 | 0.617729 | merge_message.ex | starcoder |
defmodule AVLTree.Node do
@moduledoc false
@compile {:inline,
value: 1,
height: 1,
fix_height: 1,
rotate_left: 1,
rotate_right: 1,
big_rotate_left: 1,
big_rotate_right: 1,
balance: 1}
def put(nil, value, _less), do: ... | lib/avl_tree/node.ex | 0.721253 | 0.511229 | node.ex | starcoder |
defmodule Sslcerts do
@moduledoc """
# Sslcerts
An elixir wrapper to [Let's Encrypt](https://letsencrypt.org/) and [Certbot](https://certbot.eff.org/) for SSL certification management.
This library is sufficiently opinionated, so to learn more about how to integrate Let's Encrypt
SSL certs into your projec... | lib/sslcerts.ex | 0.737536 | 0.901488 | sslcerts.ex | starcoder |
defmodule Objex do
defmacro __using__(_opts) do
quote do
import Objex, only: [class: 2, defm: 2]
end
end
defmacro class(name, do: body) do
quote do
defmodule unquote(name) do
use GenServer
def start_link(ref) do
GenServer.start_link(__MODULE__, %{},
... | lib/objex.ex | 0.598782 | 0.4291 | objex.ex | starcoder |
defmodule StringFormatterUtils do
@moduledoc """
Contains various helper methods to avoid duplicating the stuff all over
"""
@doc """
Transforms a map or a keyword list into a new map
where all keys are strings
"""
def normalize_params(params) do
params
|> Enum.map(fn {key, val} -> {to_string(k... | pattern_matching_and_state_machines/lib/string_formatter_utils.ex | 0.601477 | 0.478163 | string_formatter_utils.ex | starcoder |
defmodule Serum.Result do
@moduledoc """
This module defines types for positive results or errors returned by
functions in this project.
"""
import Serum.IOProxy, only: [put_err: 2]
@type t :: :ok | error()
@type t(type) :: {:ok, type} | error()
@type error :: {:error, err_details()}
@type err_deta... | lib/serum/result.ex | 0.858704 | 0.470615 | result.ex | starcoder |
defmodule Paidy.Payment do
@moduledoc """
Functions for working with payments at Paidy. Through this API you can:
* create a payment,
* capture a payment,
* update a payment,
* get a payment,
* refund a payment,
* partially refund a payment.
* close a payment.
Paidy API reference: ht... | lib/paidy/payment.ex | 0.886525 | 0.604778 | payment.ex | starcoder |
defmodule Geometry.Feature do
@moduledoc """
A combination of a `geometry` and `properties`.
"""
alias Geometry.{Feature, GeoJson}
defstruct [:geometry, properties: %{}]
@type t :: %Feature{
geometry: Geometry.t() | nil,
properties: map()
}
@doc """
Creates a new empty `F... | lib/geometry/feature.ex | 0.949658 | 0.741884 | feature.ex | starcoder |
defmodule NervesTime.RTC.DS3231.Date do
@moduledoc false
alias NervesTime.RealTimeClock.BCD
@doc """
Return a list of commands for reading and writing the time-date registers
"""
def reads() do
# Register 0x00 to 0x06
[{:write_read, <<0x0>>, 7}]
end
@doc """
Decode register values into a da... | lib/nerves_time/rtc/ds3231/date.ex | 0.788135 | 0.477371 | date.ex | starcoder |
defmodule Parent.Supervisor do
@moduledoc """
Supervisor of child processes.
This module works similarly to callbackless supervisors started with `Supervisor.start_link/2`.
To start a supervisor and some children you can do the following:
Parent.Supervisor.start_link([
child_spec1,
child... | lib/parent/supervisor.ex | 0.78609 | 0.488405 | supervisor.ex | starcoder |
defmodule PassiveSupport.Enum do
@moduledoc """
Functions extending the functionality of enumerables.
"""
@doc """
Converts an enumerable to a `Map`, using the index of
each item as the item's key.
## Examples
iex> to_map(["hello", "world", "how", "are", "you"])
%{0 => "hello", 1 => "world"... | lib/passive_support/base/enum.ex | 0.843686 | 0.546496 | enum.ex | starcoder |
defmodule AWS.TimestreamWrite do
@moduledoc """
Amazon Timestream is a fast, scalable, fully managed time series database
service that makes it easy to store and analyze trillions of time series data
points per day.
With Timestream, you can easily store and analyze IoT sensor data to derive
insights from ... | lib/aws/generated/timestream_write.ex | 0.895916 | 0.684877 | timestream_write.ex | starcoder |
defmodule DynamicInputsFor do
@moduledoc """
Helpers to create HTML forms with nested fields that can be created and deleted dynamically from
the client.
The functions in this module extend the functionality of `Phoenix.HTML.Form.inputs_for/4` to
return the html of a form with nested fields grouped in HTML t... | lib/dynamic_inputs_for.ex | 0.86031 | 0.497803 | dynamic_inputs_for.ex | starcoder |
defmodule Screens.Headways do
@moduledoc false
alias Screens.Schedules.Schedule
@dayparts [
{:late_night, ~T[00:00:00], :close},
{:early_morning, :open, ~T[06:30:00]},
{:am_peak, ~T[06:30:00], ~T[09:00:00]},
{:midday, ~T[09:00:00], ~T[15:30:00]},
{:pm_peak, ~T[15:30:00], ~T[18:30:00]},
{... | lib/screens/headways.ex | 0.68437 | 0.590897 | headways.ex | starcoder |
defmodule ExNcurses do
alias ExNcurses.{Getstr, Server}
@moduledoc """
ExNcurses lets Elixir programs create text-based user interfaces using ncurses.
Aside from keyboard input, ExNcurses looks almost like a straight translation of the C-based
ncurses API. ExNcurses sends key events via messages. See `liste... | lib/ex_ncurses.ex | 0.812979 | 0.491578 | ex_ncurses.ex | starcoder |
defmodule Ecto.Adapters.SQL.Sandbox do
@moduledoc ~S"""
A pool for concurrent transactional tests.
The sandbox pool is implemented on top of an ownership mechanism.
When started, the pool is in automatic mode, which means the
repository will automatically check connections out as with any
other pool.
Th... | lib/ecto/adapters/sql/sandbox.ex | 0.885798 | 0.66556 | sandbox.ex | starcoder |
defmodule Tesla.Middleware.Normalize do
@moduledoc false
def call(env, next, _opts) do
env
|> normalize
|> Tesla.run(next)
|> normalize
end
def normalize({:error, reason}) do
raise %Tesla.Error{message: "adapter error: #{inspect(reason)}", reason: reason}
end
def normalize(env) do
... | lib/tesla/middleware/core.ex | 0.816333 | 0.59131 | core.ex | starcoder |
defmodule Galaxy.DNS do
@moduledoc """
This topologying strategy works by loading all your Erlang nodes (within Pods) in the current [DNS
namespace](https://kubernetes.io/docs/concepts/service-networking/dns-pod-service/).
It will fetch the targets of all pods under a shared headless service and attempt to conn... | lib/galaxy/dns.ex | 0.79858 | 0.544256 | dns.ex | starcoder |
defmodule AWS.SecretsManager do
@moduledoc """
AWS Secrets Manager API Reference
AWS Secrets Manager provides a service to enable you to store, manage, and
retrieve, secrets.
This guide provides descriptions of the Secrets Manager API. For more
information about using this service, see the [AWS Secrets M... | lib/aws/generated/secrets_manager.ex | 0.891369 | 0.623119 | secrets_manager.ex | starcoder |
defmodule Grizzly.Report do
@moduledoc """
Reports from Z-Wave commands
When you send a command in Z-Wave you will receive a report back.
## When Things Go Well
There are two primary reports that are returned when sending a command.
The first is `:command` report and the second is an `:ack_response` rep... | lib/grizzly/report.ex | 0.871023 | 0.82566 | report.ex | starcoder |
defmodule Day22.RecursiveGame do
defstruct p1_cards: [],
p1_next: [],
p1_total: 0,
p2_cards: [],
p2_next: [],
p2_total: 0,
building: 1,
seen: MapSet.new()
def build(%__MODULE__{building: 1} = game, "Player 1:"), do: game
def buil... | year_2020/lib/day_22/recursive_game.ex | 0.534855 | 0.470068 | recursive_game.ex | starcoder |
defmodule BSV.Block do
@moduledoc """
A block is a data structure consisting of a `t:BSV.BlockHeader.t/0` and a list
of [`transactions`](`t:BSV.Tx.t/0`).
Transaction data is permanently recorded into blocks. Because each block
contains a reference to the previous block, over time blocks form a chain.
"""
... | lib/bsv/block.ex | 0.889936 | 0.817356 | block.ex | starcoder |
defmodule Beeline.HealthChecker do
@moduledoc """
A GenServer which periodically polls a producer's stream positions and
process
This GenServer emits `:telemetry` measurements which serve as an interface
for exporting this health-check information to an external monitoring
service.
`Beeline.HealthChecke... | lib/beeline/health_checker.ex | 0.845241 | 0.568865 | health_checker.ex | starcoder |
defmodule Bfs do
defp neighbors(graph, v) do
{Map.get(graph, v, MapSet.new), v}
end
defp find_path(_, from, to, path) when from == to, do: path
defp find_path(prev, from, to, path) when from != to, do: find_path(prev, from, Map.get(prev, to), [Map.get(prev, to) | path])
@doc """
Gi... | bfs_elixir/lib/bfs.ex | 0.827863 | 0.537466 | bfs.ex | starcoder |
defmodule GGity.Labels do
@moduledoc """
Common functions for transforming axis tick labels.
Break (i.e. axis tick or legend item) labels are formatted based on a
scale's `:labels` option. This option can be provided in several forms:
- `nil` - No labels are drawn
- `:waivers` - drawn using the default fo... | lib/ggity/labels.ex | 0.930993 | 0.921003 | labels.ex | starcoder |
defmodule Brain.PIDController do
use GenServer
require Logger
alias Brain.{ BlackBox, Memory }
def init(_) do
{:ok, configuration} = load_configuration()
{:ok, Map.merge(configuration,
%{
last_input: 0,
integrative_term: 0,
setpoint: 0,
process_name: Process.info(s... | apps/brain/lib/pid_controller.ex | 0.781622 | 0.408896 | pid_controller.ex | starcoder |
defmodule LogWatcher.FileWatcher do
@moduledoc """
A GenServer that monitors a directory for file system changes,
and broadcasts progress over Elixir PubSub. The directory, called
the "session_log_path" is identified by a "session_id" that defines
the well-known PubSub topic, `session:session_id`.
Once sta... | apps/log_watcher/lib/log_watcher/file_watcher.ex | 0.742608 | 0.436442 | file_watcher.ex | starcoder |
defmodule Day23 do
def solveA(filename) do
instructions =
filename
|> parse
rec_solve(instructions, %{}, 0, 0, tuple_size(instructions) - 1)
|> elem(0)
end
def solveB(filename) do
# Looking at the instructions we can see that h will be incremented when f = 0,
# and f = 0 when b = ... | 2017/elixir/day23/lib/day23.ex | 0.560253 | 0.548492 | day23.ex | starcoder |
defmodule Honeybee.Handler do
@moduledoc """
`Honeybee.Handler` provides a simple way to invoke methods from a pluggable module.
When a handler is called, it expects to find the method to invoke in the `:action` option.
For instance, a handler invoked using `plug Handler, action: :create`, will invoke the crea... | lib/honeybee/handler.ex | 0.913165 | 0.874346 | handler.ex | starcoder |
defmodule AshPostgres.DataLayer do
@manage_tenant %Ash.Dsl.Section{
name: :manage_tenant,
describe: """
Configuration for the behavior of a resource that manages a tenant
""",
examples: [
"""
manage_tenant do
template ["organization_", :id]
create? true
update? ... | lib/data_layer.ex | 0.85747 | 0.479869 | data_layer.ex | starcoder |
defmodule YukiHelper.Download do
@moduledoc """
Provides a module related to downloading teastcases.
"""
alias YukiHelper.{Config, Problem, Api.Yukicoder}
alias YukiHelper.Exceptions.DownloadError
@typedoc """
Two types of testcase file, input file and output file.
"""
@type filetype() :: :in | :o... | lib/yuki_helper/donwload.ex | 0.762468 | 0.431345 | donwload.ex | starcoder |
defmodule Grid do
defstruct max_x: 0, max_y: 0, nodes: %{}
def all_possible_moves(grid) do
grid.nodes
|> Map.values
|> Enum.flat_map(fn(node) ->
possible_moves(node, grid)
|> Enum.map(fn(new_position) -> %{node: node, new_position: new_position} end)
end
)
|> MapSet.new
... | elixir-22/lib/grid.ex | 0.661048 | 0.646962 | grid.ex | starcoder |
defmodule StarkInfra.PixKey do
alias __MODULE__, as: PixKey
alias StarkInfra.Utils.Rest
alias StarkInfra.Utils.Check
alias StarkInfra.User.Project
alias StarkInfra.User.Organization
alias StarkInfra.Error
@moduledoc """
Groups PixKey related functions
"""
@doc """
PixKeys link bank account infor... | lib/pix_key/pix_key.ex | 0.91096 | 0.657786 | pix_key.ex | starcoder |
defmodule Want.Map do
@moduledoc """
Manages conversions to and from maps.
"""
@type input :: Keyword.t() | map()
@type schema :: map()
@type key :: binary() | atom()
@type opts :: Keyword.t()
@type result :: {:ok, result :: map()} | {:error, reason :: binary()}
defimpl Want.Du... | lib/want/map.ex | 0.859192 | 0.40592 | map.ex | starcoder |
defmodule Multichain do
@moduledoc """
This library is a thin wrapper for Multichain JSON RPC. Instead of manually craft HTTP call with all params, we can put the param in config and call one function as interface to all Multichain api.
Everything in this module represent lowest Multichain API. Any Multicha... | lib/multichain.ex | 0.728748 | 0.669779 | multichain.ex | starcoder |
defmodule Transmap do
@default_key :_default
@spread_key :_spread
@doc """
Transforms the given map.
`rule_map` is a map has elements `key => rule`.
case {key, rule} do
{:_default, rule} -> # Change the default rule for the map from false to the given rule
{:_spread, targets} -> # Pop... | lib/transmap.ex | 0.798854 | 0.613497 | transmap.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.