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 EtsDeque do
@moduledoc """
EtsDeque is an Elixir implementation of a double-ended queue (deque), using
Erlang's ETS library as a backing store.
Using ETS ensures that all functions in the `EtsDeque` module execute in
amortized O(1) time with a minimum of memory allocations, offering bounded
or un... | lib/ets_deque.ex | 0.913392 | 0.678513 | ets_deque.ex | starcoder |
defmodule Exbackoff do
use Bitwise
@moduledoc """
ExBackoff is an Elixir library to deal with exponential backoffs and timers
to be used within OTP processes when dealing with cyclical events, such as
reconnections, or generally retrying things.
"""
@typep max :: pos_integer | :infinity
defstruct sta... | lib/exbackoff.ex | 0.931205 | 0.518485 | exbackoff.ex | starcoder |
defmodule Livebook.JSInterop do
@moduledoc false
alias Livebook.Delta
@doc """
Returns the result of applying `delta` to `string`.
The delta operation lenghts (retain, delete) are treated
such that they match the JavaScript strings behavior.
JavaScript uses UTF-16 encoding, in which every character is... | lib/livebook/js_interop.ex | 0.839915 | 0.746647 | js_interop.ex | starcoder |
defmodule Ecall.Framing do
@behaviour Circuits.UART.Framing
@moduledoc """
Based on Circuits.UART.Framing.Line, the difference is there is
one separator for sending data and another for receiving
"""
defmodule State do
@moduledoc false
defstruct max_length: nil,
in_separator: nil,
ou... | lib/port/ecall_framing.ex | 0.598077 | 0.453322 | ecall_framing.ex | starcoder |
defmodule Movement.Migrator do
@moduledoc """
Route migration to the module which will execute it or return
a value without a function call.
Using a simple DSL with an `up` and `down` function, it creates functions in the same
fashion as the `Plug` library.
Module use to execute operation should... | lib/movement/migrator.ex | 0.831964 | 0.504028 | migrator.ex | starcoder |
defmodule Commanded.Aggregate.Multi do
@moduledoc """
Use `Commanded.Aggregate.Multi` to generate multiple events from a single
command.
This can be useful when you want to emit multiple events that depend upon the
aggregate state being updated.
## Example
In the example below, money is withdrawn from ... | lib/commanded/aggregates/multi.ex | 0.88284 | 0.632574 | multi.ex | starcoder |
defmodule Parselix.Basic do
use Parselix
@moduledoc """
Provide basic parsers.
"""
defmacro __using__(_opts) do
quote do
import unquote(__MODULE__)
end
end
@doc "Replaces error messages."
def error_message(parser, message) do
fn target, position ->
case parser.(target, positio... | lib/parselix/basic.ex | 0.835215 | 0.512205 | basic.ex | starcoder |
defmodule K8s.Client.Runner.Watch do
@moduledoc """
`K8s.Client` runner that will watch a resource or resources and stream results back to a process.
"""
@resource_version_json_path ~w(metadata resourceVersion)
alias K8s.Client.Runner.Base
alias K8s.Operation
@doc """
Watch a resource or list of reso... | lib/k8s/client/runner/watch.ex | 0.888967 | 0.657404 | watch.ex | starcoder |
defmodule Kino.Ecto do
@moduledoc """
A widget for interactively viewing `Ecto` query results.
The data must be an enumerable of records, where each
record is either map, struct, keyword list or tuple.
## Examples
The widget primarly allows for viewing a database table
given a schema:
Kino.Ecto.... | lib/kino/ecto.ex | 0.903334 | 0.620808 | ecto.ex | starcoder |
defmodule Data.Exit do
@moduledoc """
Exit Schema
"""
use Data.Schema
alias Data.Room
alias Data.Zone
@directions [
"north",
"east",
"south",
"west",
"up",
"down",
"in",
"out",
"north west",
"north east",
"south west",
"south east"
]
schema "exits" d... | lib/data/exit.ex | 0.756627 | 0.524456 | exit.ex | starcoder |
defmodule Penelope.ML.Registry do
@moduledoc """
The ML pipeline registry decouples the names of pipeline components from
their module names, so that modules can be refactored without breaking
stored models. The built-in Penelope components are registered automatically,
but custom components can be added via ... | lib/penelope/ml/registry.ex | 0.882466 | 0.560102 | registry.ex | starcoder |
defmodule Bunt.ANSI.Sequence do
@moduledoc false
defmacro defalias(alias_name, original_name) do
quote bind_quoted: [alias_name: alias_name, original_name: original_name] do
def unquote(alias_name)() do
unquote(original_name)()
end
defp format_sequence(unquote(alias_name)) do
... | lib/bunt_ansi.ex | 0.641085 | 0.44348 | bunt_ansi.ex | starcoder |
defmodule Tarearbol.Scheduler do
@moduledoc """
Cron-like task scheduler. Accepts both static and dynamic configurations.
### Usage
Add `Tarearbol.Scheduler` to the list of supervised workers. It would attempt
to read the static configuration (see below) and start the `DynamicSupervisor`
with all the sche... | lib/tarearbol/scheduler.ex | 0.874131 | 0.893774 | scheduler.ex | starcoder |
defmodule Snek.Board do
@moduledoc """
A struct for representing a board position.
This may be used to keep track of state in a game, each turn of the
game producing the next board position.
"""
@moduledoc since: "0.1.0"
alias __MODULE__
alias Board.{Point, Size, Snake}
@typedoc """
A board posit... | lib/snek/board.ex | 0.931056 | 0.54462 | board.ex | starcoder |
defmodule ExIhdlSubscriptionBase.TrackedSchema do
@tracked_suffix "_last_sent_at"
def enforce_tracked_fields(%{action: :insert} = changeset, module, add_error, put_change) do
module_tracked_fields = tracked_fields(module)
changeset.changes
|> Enum.filter(fn {field, _} -> field in module_tracked_fields... | lib/ex_ihdl_subscription_base/tracked_schema.ex | 0.68658 | 0.423696 | tracked_schema.ex | starcoder |
defmodule FLHook.Params do
@moduledoc """
A module that provides helpers to decode command response and event params.
"""
alias FLHook.Duration
alias FLHook.ParamError
alias FLHook.Utils
defstruct data: %{}
@type key :: atom | String.t()
@type data :: %{optional(String.t()) => String.t()}
@type t... | lib/fl_hook/params.ex | 0.864754 | 0.50061 | params.ex | starcoder |
defmodule BPXE.BPMN.JSON do
import BPXE.BPMN.Interpolation
defstruct value: nil, current: nil, characters: nil, keyed: false, interpolate: false
use ExConstructor
def prepare(%__MODULE__{interpolate: false, value: value}), do: value
def prepare(%__MODULE__{value: value}) do
fn cb ->
interpolate(va... | lib/bpxe/bpmn/json.ex | 0.759894 | 0.47025 | json.ex | starcoder |
defmodule Kitsune.Aws.Config do
@moduledoc """
This module is used to load the default credentials from one or many [Configuration Providers](configuration-providers.html)
The credentials are internally stored in a table in the [Erlang Term Storage](http://www.erlang.org/doc/man/ets.html).
Since the ETS for `:... | apps/kitsune_aws_core/lib/kitsune/aws/config.ex | 0.811713 | 0.480296 | config.ex | starcoder |
defmodule Day17 do
@moduledoc """
--- Day 17: Spinlock ---
Suddenly, whirling in the distance, you notice what looks like a massive, pixelated hurricane: a deadly spinlock.
This spinlock isn't just consuming computing power, but memory, too; vast, digital mountains are being ripped from
the ground and consum... | lib/day17.ex | 0.633864 | 0.793106 | day17.ex | starcoder |
defmodule Day10 do
@moduledoc """
You come across some programs that are trying to implement a software emulation of a hash based on knot-tying. The
hash these programs are implementing isn't very strong, but you decide to help them anyway. You make a mental note to
remind the Elves later not to invent their ow... | lib/day10.ex | 0.760384 | 0.876687 | day10.ex | starcoder |
defmodule Polylens do
@moduledoc """
Functions for using Polylenses to manipulate and query data
"""
import ProtocolEx
import Kernel, except: [get_in: 2, update_in: 3]
defprotocol_ex Lens do
@moduledoc """
The protocol_ex around which Polylens is based.
Uses 2-tuples to fake multiple dispatch
... | lib/polylens.ex | 0.781706 | 0.577078 | polylens.ex | starcoder |
defmodule Blockchain.Block do
@moduledoc """
This module effectively encodes a block, the heart of the blockchain.
A chain is formed when blocks point to previous blocks,
either as a parent or an ommer (uncle).
For more information, see Section 4.3 of the Yellow Paper.
"""
alias Block.Header
alias Bloc... | apps/blockchain/lib/blockchain/block.ex | 0.859708 | 0.451689 | block.ex | starcoder |
defmodule Indicado.RSI do
@moduledoc """
This is the RSI module used for calculating Relative Strength Index
"""
@doc """
Calculates RSI for the list. It needs list of numbers and the length of
list argument should at least be 1 more than period.
Returns `{:ok, rsi_list}` or `{:error, reason}`
## Exa... | lib/indicado/rsi.ex | 0.90539 | 0.620694 | rsi.ex | starcoder |
defmodule Algorithms.Sorting.SelectionSort do
@moduledoc """
Implementation of SelectionSort algorithm (https://en.wikipedia.org/wiki/Selection_sort)
You will be given an array of numbers, you have to sort numbers in ascending order
using selection sort algorithm.
The algorithm divides the input list into t... | lib/sorting/selection_sort.ex | 0.79546 | 0.790975 | selection_sort.ex | starcoder |
defmodule Unicode.Category.QuoteMarks do
@moduledoc """
Functions to return codepoints that form quotation marks. These
marks are taken from the [Wikipedia definition](https://en.wikipedia.org/wiki/Quotation_mark)
which is more expansive than the Unicode categories [Pi](https://www.compart.com/en/unicode/catego... | lib/unicode/category/quote_marks.ex | 0.818773 | 0.511839 | quote_marks.ex | starcoder |
defmodule Matrex.MagicSquare do
@moduledoc false
# Magic square generation algorithms.
@lux %{L: [4, 1, 2, 3], U: [1, 4, 2, 3], X: [1, 4, 3, 2]}
def new(n) when n < 3, do: raise(ArgumentError, "Magic square less than 3x3 is not possible.")
def new(n) when rem(n, 2) == 1 do
for i <- 0..(n - 1) do
... | lib/matrex/magic_square.ex | 0.581184 | 0.589775 | magic_square.ex | starcoder |
defmodule Serum.Plugins.SitemapGenerator do
@moduledoc """
A Serum plugin that create a sitemap so that the search engine can index posts.
## Using the Plugin
# serum.exs:
%{
server_root: "https://example.io",
plugins: [
{Serum.Plugins.SitemapGenerator, only: :prod}
... | lib/serum/plugins/sitemap_generator.ex | 0.656218 | 0.4099 | sitemap_generator.ex | starcoder |
defmodule ExDns.Resource.A do
@moduledoc """
Manages the A resource record
The wire protocol is defined in [RFC1035](https://tools.ietf.org/html/rfc1035#section-3.4.1)
3.4.1. A RDATA format
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ADDRESS |
+... | lib/ex_dns/resource/a.ex | 0.649134 | 0.413152 | a.ex | starcoder |
defmodule AWS.Budgets do
@moduledoc """
The AWS Budgets API enables you to use AWS Budgets to plan your service
usage, service costs, and instance reservations. The API reference provides
descriptions, syntax, and usage examples for each of the actions and data
types for AWS Budgets.
Budgets provide you w... | lib/aws/generated/budgets.ex | 0.805441 | 0.590189 | budgets.ex | starcoder |
defmodule Content.Utilities do
@type track_number :: non_neg_integer()
@type green_line_branch :: :b | :c | :d | :e
defmacro max_time_seconds do
quote do: 20 * 60
end
def width_padded_string(left, right, width) do
max_left_length = width - (String.length(right) + 1)
left = String.slice(left, 0, ... | lib/content/utilities.ex | 0.800653 | 0.535766 | utilities.ex | starcoder |
defmodule Mix.Tasks.Cloak.Migrate do
@moduledoc """
Migrate all configured schemas to your new encryption configuration.
While Cloak will automatically decrypt rows which use an old decryption cipher
or key, this isn't usually enough. Usually, you want to retire the old key, so
it won't do to leave it config... | lib/mix/tasks/cloak.migrate.ex | 0.816626 | 0.497131 | cloak.migrate.ex | starcoder |
defmodule Bonny.PeriodicTask do
@moduledoc """
Register periodically run tasks.
Use for running tasks as a part of reconciling a CRD with a lifetime, duration, or interval field.
__Note:__ Must be started by your operator.
Add `Bonny.PeriodicTask.sttart_link(:ok)` to your application.
Functions are expec... | lib/bonny/periodic_task.ex | 0.930624 | 0.588002 | periodic_task.ex | starcoder |
defmodule ResourceCache do
@moduledoc ~S"""
Fast caching with clear syntax.
## Quick Setup
```elixir
def deps do
[
{:resource_cache, "~> 0.1"}
]
end
```
Define a cache by setting a resource (in this case Ecto schema)
and source. (The Ecto repo to query.)
```elixir
defmodule MyApp.... | lib/resource_cache.ex | 0.825167 | 0.651216 | resource_cache.ex | starcoder |
if Code.ensure_loaded?(:hackney) do
defmodule Tesla.Adapter.Hackney do
@moduledoc """
Adapter for [hackney](https://github.com/benoitc/hackney).
Remember to add `{:hackney, "~> 1.13"}` to dependencies (and `:hackney` to applications in `mix.exs`)
Also, you need to recompile tesla after adding `:hackn... | lib/tesla/adapter/hackney.ex | 0.845911 | 0.844152 | hackney.ex | starcoder |
defmodule Mnesiac.Store do
@moduledoc """
This module defines a mnesiac store and contains overridable callbacks.
"""
@doc """
This function returns the store's configuration as a keyword list.
For more information on the options supported here, see mnesia's documentation.
## Examples
```elixir
iex> ... | lib/mnesiac/store.ex | 0.895891 | 0.881462 | store.ex | starcoder |
defmodule Resemblixir.Breakpoint do alias Resemblixir.{Scenario, Compare, Paths, Screenshot, MissingReferenceError}
defstruct [:pid, :owner, :name, :width, :ref, :scenario, result: {:error, :not_finished}]
@type result :: Compare.success | Compare.failure | {:error, :not_finished} | {:error, :timeout}
@type t ::... | lib/resemblixir/breakpoint.ex | 0.793266 | 0.415492 | breakpoint.ex | starcoder |
import Realm.Semigroupoid.Algebra
defprotocol Realm.Arrow do
@moduledoc """
Arrows abstract the idea of computations, potentially with a context.
Arrows are in fact an abstraction above monads, and can be used both to
express all other type classes in Realm. They also enable some nice
flow-based reasoning ab... | lib/realm/arrow.ex | 0.840111 | 0.641998 | arrow.ex | starcoder |
defmodule ExVcf.Vcf.Info do
alias ExVcf.Vcf.Info
alias ExVcf.Vcf.HeaderLine
@header_type "INFO"
def type, do: @header_type
@reserved_info_keys MapSet.new([
"AA",
"AC",
"AF",
"AN",
"BQ",
"CIGAR",
"DB",
"DP",
"END",
"H2",
"H3",
"MQ",
"MQ0",
"NS",
"SB... | lib/vcf/info.ex | 0.663342 | 0.421076 | info.ex | starcoder |
defmodule Construct.Type do
@moduledoc """
Type-coercion module, originally copied and modified from
[Ecto.Type](https://github.com/elixir-ecto/ecto/blob/master/lib/ecto/type.ex)
and behaviour to implement your own types.
## Defining custom types
defmodule CustomType do
@behaviour Construct.Ty... | lib/construct/type.ex | 0.884133 | 0.477615 | type.ex | starcoder |
defmodule Solution do
def factorize(1, _), do: [1]
def factorize(n ,t) do
num = case div(t, n) do
0 -> []
x -> [x]
end
cond do
rem(n, 2) == 0 ->
[n] ++ num ++ (div(n,2) |> factorize(t))
rem(n, 3) == 0 ->
... | math/is_prime.ex | 0.536313 | 0.701764 | is_prime.ex | starcoder |
defmodule PersianCalendar do
@moduledoc """
convert shamsi/milady dates
"""
@doc """
returns shamsi date from given milady date in format {year, month, day}
"""
@spec from_milady({number, number, number}) :: {number, number, number}
def from_milady({year, month, day}) do
is_leap_yea... | lib/persian_calendar.ex | 0.795142 | 0.523664 | persian_calendar.ex | starcoder |
defmodule Explorer.Shared do
# A collection of **private** helpers shared in Explorer.
@moduledoc false
@doc """
All supported dtypes.
"""
def dtypes, do: [:float, :integer, :boolean, :string, :date, :datetime]
@doc """
Gets the backend from a `Keyword.t()` or `nil`.
"""
def backend_from_options!(... | lib/explorer/shared.ex | 0.880296 | 0.556098 | shared.ex | starcoder |
defmodule Sanbase.Influxdb.Measurement do
@moduledoc ~S"""
Module, defining the structure and common parts of a influxdb measurement
"""
defstruct [:timestamp, :fields, :tags, :name]
alias __MODULE__
alias Sanbase.ExternalServices.Coinmarketcap
alias Sanbase.Model.Project
@doc ~s"""
Converts the... | lib/sanbase/influxdb/measurement.ex | 0.765769 | 0.517693 | measurement.ex | starcoder |
defmodule Circuits.I2C do
@moduledoc """
`Circuits.I2C` lets you communicate with hardware devices using the I2C
protocol.
"""
alias Circuits.I2C.Nif
# Public API
@typedoc """
I2C device address
This is a "7-bit" address for the device. Some devices specify an "8-bit"
address in their documentati... | lib/i2c.ex | 0.873296 | 0.633609 | i2c.ex | starcoder |
defmodule ApiWeb.StopController do
use ApiWeb.Web, :api_controller
alias ApiWeb.LegacyStops
alias State.Stop
plug(ApiWeb.Plugs.ValidateDate)
@filters ~w(id date direction_id latitude longitude radius route route_type location_type service)s
@pagination_opts ~w(offset limit order_by distance)a
@includes... | apps/api_web/lib/api_web/controllers/stop_controller.ex | 0.858259 | 0.449574 | stop_controller.ex | starcoder |
defmodule AMQP.Connection do
@moduledoc """
Functions to operate on Connections.
"""
import AMQP.Core
alias AMQP.Connection
defstruct [:pid]
@type t :: %Connection{pid: pid}
@doc """
Opens a new connection.
Behaves like `open/2` but takes only either AMQP URI or options.
## Examples
i... | lib/amqp/connection.ex | 0.887186 | 0.428592 | connection.ex | starcoder |
defmodule RailwayIpc.Core.MessageFormat.BinaryProtobuf do
@moduledoc """
_This is an internal module, not part of the public API._
Messages that use the `BinaryProtobuf` format have the following
characteristics:
* The payload s a struct that contains two attributes: `type` and
`encoded_message`
* Th... | lib/railway_ipc/core/message_format/binary_protobuf.ex | 0.760917 | 0.480783 | binary_protobuf.ex | starcoder |
defprotocol Validix.Stage.Convert do
@spec as(any, field :: term, type :: Type.key, value :: term, Type.key)
:: {:ok, value :: term} | {:error, term} | :parent
def as(_, field, type, value, args)
end
defimpl Validix.Stage.Convert, for: Validix.Type.Core do
def as(_, field, type, value, to_type) do
... | lib/validix/stage/convert.ex | 0.676299 | 0.527499 | convert.ex | starcoder |
defmodule HyperEx.Abbreviation do
@moduledoc false
alias HyperEx.Util
@doc """
Expands an Emmet-like abbreviation to a tuple containing the tag name and
it's attributes (can contain an id and a class list).
## Examples
iex> HyperEx.Abbreviation.expand("div")
{"div", []}
iex> HyperEx.... | lib/hyper_ex/abbreviation.ex | 0.843911 | 0.431764 | abbreviation.ex | starcoder |
defmodule Snitch.Data.Model.PaymentMethod do
@moduledoc """
PaymentMethod API and utilities.
Snitch currently supports the following payment methods:
## Debit and Credit cards
See `Snitch.Data.Model.CardPayment`. Such payments are backed by the
"`snitch_card_payments`" table that references the `Card` us... | apps/snitch_core/lib/core/data/model/payment/payment_method.ex | 0.87046 | 0.488405 | payment_method.ex | starcoder |
defmodule Couch.Test.Suite do
@moduledoc """
Common code to configure ExUnit runner.
It replaces the usual invocation of `ExUnit.start()` in
`test_helper.exs` related to integration tests with:
```
Couch.Test.Suite.start()
```
"""
@doc """
This helper function can be used to create `suit... | test/elixir/lib/suite.ex | 0.767036 | 0.87289 | suite.ex | starcoder |
defmodule Interpreter.Diff do
alias InterpreterTerms.SymbolMatch, as: Sym
alias InterpreterTerms.WordMatch, as: Word
def similarity(a, b) do
{matching, total} = similarity_calc(a, b)
matching / total
end
@doc """
Returns a similarity number. Comparing how similar the two objects
are.
We comp... | lib/interpreter/diff/diff.ex | 0.650356 | 0.537223 | diff.ex | starcoder |
defmodule Module.Types.Helpers do
# AST and enumeration helpers.
@moduledoc false
@doc """
Guard function to check if an AST node is a variable.
"""
defmacro is_var(expr) do
quote do
is_tuple(unquote(expr)) and
tuple_size(unquote(expr)) == 3 and
is_atom(elem(unquote(expr), 0)) and... | lib/elixir/lib/module/types/helpers.ex | 0.730963 | 0.556219 | helpers.ex | starcoder |
defmodule Theater.Storage do
@moduledoc """
Defines a persistence storage provider.
Persistenced providers are responsible for keeping the state of Actors so
that when they are cleaned out of memory they can be restored to a previously
saved state.
Implementations can be generic, designed to store any kin... | lib/theater/storage.ex | 0.845624 | 0.631594 | storage.ex | starcoder |
defmodule Athink do
alias Lexthink.AST, as: L
defrecordp :query, __MODULE__, terms: []
defmacro __using__(_opts) do
quote do
import unquote(__MODULE__), only: [r: 0, r: 1]
end
end
defmacro r do
quote do
unquote(__MODULE__)
end
end
defmacro r(query) do
quote do
unq... | lib/athink.ex | 0.532182 | 0.450662 | athink.ex | starcoder |
defmodule Phoenix.Template do
@moduledoc """
Templates are used by Phoenix on rendering.
Since many views require rendering large contents, for example
a whole HTML file, it is common to put those files in the file
system into a particular directory, typically "web/templates".
This module provides conveni... | lib/phoenix/template.ex | 0.864268 | 0.491029 | template.ex | starcoder |
defmodule ExConfig.Source do
@moduledoc """
Interface for pluggable modules to get data from external sources.
It is very often case when parameter value is dynamic and is based on
something from outside an application, like OS environment variables,
file system objects, etc. When a parameter is read and it'... | lib/ex_config/source.ex | 0.669205 | 0.402128 | source.ex | starcoder |
defmodule OMG.Eth.RootChain.AbiEventSelector do
@moduledoc """
We define Solidity Event selectors that help us decode returned values from function calls.
Function names are to be used as inputs to Event Fetcher.
Function names describe the type of the event Event Fetcher will retrieve.
"""
@spec exit_sta... | apps/omg_eth/lib/omg_eth/root_chain/abi_event_selector.ex | 0.705684 | 0.472562 | abi_event_selector.ex | starcoder |
use Bitwise
defmodule D3 do
@moduledoc """
--- Day 3: Toboggan Trajectory ---
With the toboggan login problems resolved, you set off toward the airport. While travel by toboggan might be easy, it's certainly not safe: there's very minimal steering and the area is covered in trees. You'll need to see which angles... | lib/days/03.ex | 0.85987 | 0.784071 | 03.ex | starcoder |
defmodule Muscat.AugmentedMatrix do
alias Muscat.Matrix
alias Muscat.Fraction
import Muscat.Fraction, only: [is_zero_fraction: 1]
@type element :: Fraction.fraction_tuple() | integer()
@type matrix :: nonempty_list(Matrix.Cell.t())
@doc "Create augmented matrix by augmented matrix list"
@spec new(augme... | lib/muscat/augmented_matrix.ex | 0.843879 | 0.547948 | augmented_matrix.ex | starcoder |
defmodule RlStudy.DP.ValueIterationPlanner do
alias RlStudy.DP.Planner
alias RlStudy.MDP.Environment
require Logger
@type t :: %RlStudy.DP.ValueIterationPlanner{
env: RlStudy.MDP.Environment.t(),
log: [] | [String.t()]
}
defstruct Planner.planner_data()
defimpl RlStudy.DP.Plann... | lib/dp/value_iteration_planner.ex | 0.636353 | 0.640158 | value_iteration_planner.ex | starcoder |
defmodule Nectar.Query.Zone do
use Nectar.Query, model: Nectar.Zone
import Ecto, only: [assoc: 2]
def zoneable!(repo, %Nectar.Zone{type: "Country"} = _model, zoneable_id),
do: repo.get!(Nectar.Country, zoneable_id)
def zoneable!(repo, %Nectar.Zone{type: "State"} = _model, zoneable_id),
do: repo.get!(N... | web/queries/zone.ex | 0.558327 | 0.552721 | zone.ex | starcoder |
defmodule Geocalc.Calculator.Polygon do
@moduledoc false
alias Geocalc.Calculator
require Integer
@doc """
Check if point is inside a polygon
## Example
iex> import Geocalc.Calculator.Polygon
iex> polygon = [[1, 2], [3, 4], [5, 2], [3, 0]]
iex> point = [3, 2]
iex> point_in_polygon... | lib/geocalc/calculator/polygon.ex | 0.895128 | 0.742492 | polygon.ex | starcoder |
defmodule Function do
@moduledoc """
A set of functions for working with functions.
There are two types of captured functions: **external** and **local**.
External functions are functions residing in modules that are captured
with `&/1`, such as `&String.length/1`. Local functions are anonymous functions
d... | lib/elixir/lib/function.ex | 0.887522 | 0.950732 | function.ex | starcoder |
defmodule Ibanity.Xs2a.FinancialInstitution do
@moduledoc """
[Financial institutions](https://documentation.ibanity.com/xs2a/api#financial-institution) API wrapper
"""
use Ibanity.Resource
defstruct id: nil,
sandbox: true,
name: nil,
self_link: nil,
bic: nil,... | lib/ibanity/api/xs2a/financial_institution.ex | 0.796609 | 0.405802 | financial_institution.ex | starcoder |
defmodule AWS.DynamoDBStreams do
@moduledoc """
Amazon DynamoDB
Amazon DynamoDB Streams provides API actions for accessing streams and
processing stream records.
To learn more about application development with Streams, see [Capturing Table Activity with DynamoDB
Streams](https://docs.aws.amazon.com/amaz... | lib/aws/generated/dynamodb_streams.ex | 0.865409 | 0.400251 | dynamodb_streams.ex | starcoder |
defmodule Multichain.Super do
@moduledoc """
This module combine basic Multichain api to perform common tasks, such as create address and sending asset using external keypairs.
This function collection also contain handy function which used by Finance admin such as issue asset, reissue asset, block an addre... | lib/multichainsuper.ex | 0.747247 | 0.414958 | multichainsuper.ex | starcoder |
defmodule DiscordBot.Gateway.Heartbeat do
@moduledoc """
Handles the heartbeat protocol for a single websocket.
Utilizes a `DiscordBot.Broker`, to which a `DiscordBot.Gateway.Connection`
is actively posting events in order to schedule and provide
heartbeat messages over the websocket.
By default, Discord ... | apps/discordbot/lib/discordbot/gateway/heartbeat.ex | 0.917423 | 0.402774 | heartbeat.ex | starcoder |
defmodule Elasticsearch.Index.Bulk do
@moduledoc """
Functions for creating bulk indexing requests.
"""
alias Elasticsearch.{
DataStream,
Document
}
require Logger
@doc """
Encodes a given variable into an Elasticsearch bulk request. The variable
must implement `Elasticsearch.Document`.
... | lib/elasticsearch/indexing/bulk.ex | 0.86785 | 0.41944 | bulk.ex | starcoder |
defmodule AWS.OpsWorks do
@moduledoc """
AWS OpsWorks
Welcome to the *AWS OpsWorks Stacks API Reference*.
This guide provides descriptions, syntax, and usage examples for AWS OpsWorks
Stacks actions and data types, including common parameters and error codes.
AWS OpsWorks Stacks is an application manage... | lib/aws/generated/ops_works.ex | 0.878419 | 0.58261 | ops_works.ex | starcoder |
defmodule Poison do
readme_path = [__DIR__, "..", "README.md"] |> Path.join() |> Path.expand()
@external_resource readme_path
@moduledoc readme_path |> File.read!() |> String.trim()
alias Poison.{Decode, DecodeError, Decoder}
alias Poison.{EncodeError, Encoder}
alias Poison.{ParseError, Parser}
@doc ""... | lib/poison.ex | 0.838779 | 0.436322 | poison.ex | starcoder |
defmodule Meeseeks.Select do
@moduledoc false
alias Meeseeks.{Accumulator, Context, Document, Error, Result, Selector}
@return? Context.return_key()
@matches Context.matches_key()
@nodes Context.nodes_key()
@type queryable :: Document.t() | Result.t()
@type selectors :: Selector.t() | [Selector.t()]
... | lib/meeseeks/select.ex | 0.840095 | 0.46217 | select.ex | starcoder |
defmodule AWS.Logs do
@moduledoc """
You can use Amazon CloudWatch Logs to monitor, store, and access your log
files from EC2 instances, Amazon CloudTrail, or other sources. You can then
retrieve the associated log data from CloudWatch Logs using the Amazon
CloudWatch console, the CloudWatch Logs commands in... | lib/aws/logs.ex | 0.888057 | 0.786336 | logs.ex | starcoder |
defmodule Adventofcode.Day11ChronalCharge do
use Adventofcode
@grid_size 300
def most_powered_three_by_three(input) do
input
|> parse
|> build_grid
|> fuel_squares_largest(3)
|> Tuple.to_list()
|> Enum.take(2)
|> Enum.join(",")
end
def most_powered_any_size(input) do
input
... | lib/day_11_chronal_charge.ex | 0.745584 | 0.528473 | day_11_chronal_charge.ex | starcoder |
defmodule Performance.BencheeCase do
@moduledoc """
An ExUnit case that will set up a benchee run for you, in a more readable way
"""
use ExUnit.CaseTemplate
require Logger
using opts do
otp_app = Keyword.fetch!(opts, :otp_app)
endpoints = Keyword.get(opts, :endpoints, [])
topic_prefixes = Ke... | apps/performance/lib/performance/benchee_case.ex | 0.64131 | 0.417628 | benchee_case.ex | starcoder |
defmodule Deckhub.Hearthstone do
@moduledoc """
Context for dealing with all Hearthstone game data such as cards, card backs, and heroes.
"""
import Ecto.Query, warn: false
alias Deckhub.Repo
alias Deckhub.Hearthstone.Card
alias Deckhub.Hearthstone.Term
@doc """
Returns the list of cards.
## Exa... | lib/deckhub/hearthstone/hearthstone.ex | 0.860779 | 0.781456 | hearthstone.ex | starcoder |
defmodule Tox.Interval do
@moduledoc """
An `Interval` struct and functions.
A time interval is the intervening time between two time points. The amount of
intervening time is expressed by a combination of `DateTime`/`DateTime`,
`Datetime`/`Period` or `Period`/`DateTime`.
The key `boundaries` indicates wh... | lib/tox/interval.ex | 0.937311 | 0.698207 | interval.ex | starcoder |
defmodule RuleParser.Helper do
@moduledoc """
Helper functions for making parser work easy
"""
import NimbleParsec
@max_nested 3
@doc """
Ignore white space and tab, and make it optional
"""
@spec ignore_space() :: NimbleParsec.t()
def ignore_space do
parse_ws()
|> ignore()
end
@doc "... | lib/helper.ex | 0.722331 | 0.410461 | helper.ex | starcoder |
defmodule Galena.Producer do
@moduledoc """
**Galena.Producer** is a customized `GenStage` producer which uses
`GenStage.BroadcastDispatcher` as dispatcher.
### Definition
```elixir
defmodule MyProducer do
use Galena.Producer
def handle_produce({topic, message}) do
{topic, message}
end... | lib/galena/producer.ex | 0.668339 | 0.746647 | producer.ex | starcoder |
defmodule Imagineer.Image.PNG.Filter.Basic.Paeth do
import Imagineer.Image.PNG.Helpers, only: [null_binary: 1]
@doc """
Takes in the uncompressed binary representation of a row, the unfiltered row
row above it, and the number of bytes per pixel. Decodes according to the
Paeth filter.
For more information,... | lib/imagineer/image/png/filter/basic/paeth.ex | 0.826607 | 0.505127 | paeth.ex | starcoder |
defmodule Base.Sink do
alias Membrane.Buffer
defmacro __using__(_opts) do
quote do
use Membrane.Sink
import Base.Sink, only: [def_options_with_default: 1, def_options_with_default: 0]
end
end
defmacro def_options_with_default(further_options \\ []) do
quote do
def_options [
... | lib/Base/Sink.ex | 0.659734 | 0.506774 | Sink.ex | starcoder |
defmodule ResxBase.Encoder do
@moduledoc """
Encode data resources into a RFC 4648 encoding.
### Encoding
The type of encoding is specified by using the `:encoding` option.
Resx.Resource.transform(resource, ResxBase.Encoder, encoding: :base64)
The list of available encoding forma... | lib/resx_base/encoder.ex | 0.917469 | 0.479626 | encoder.ex | starcoder |
defmodule Modbux.Request do
@moduledoc """
Request helper, functions that handles Client & Master request messages.
"""
alias Modbux.Helper
@spec pack({:fc | :phr | :rc | :rhr | :ri | :rir, integer, integer, maybe_improper_list | integer}) ::
<<_::48, _::_*8>>
def pack({:rc, slave, address, count... | lib/helpers/request.ex | 0.645008 | 0.435962 | request.ex | starcoder |
defmodule Panpipe do
@moduledoc """
An Elixir wrapper around Pandoc.
The `Panpipe.Pandoc` module implements a wrapper around the Pandoc CLI.
The `Panpipe.AST.Node` behaviour defines the functions implemented by all
nodes of a Panpipe AST.
"""
alias Panpipe.Pandoc
defdelegate pandoc(input_or_opts, o... | lib/panpipe.ex | 0.781205 | 0.672308 | panpipe.ex | starcoder |
defmodule LibPE do
@moduledoc """
Implementation of the Windows PE executable format for reading and writing PE binaries.
Most struct member names are taken directly from the windows documentation:
https://docs.microsoft.com/en-us/windows/win32/debug/pe-format
This library has been created specifica... | lib/libpe.ex | 0.798265 | 0.451085 | libpe.ex | starcoder |
defmodule PINXS.Transfers.Transfer do
alias PINXS.HTTP.API
alias __MODULE__
@moduledoc """
Proived functions for creating and working with transfers
"""
@derive [Jason.Encoder]
defstruct [
:amount,
:bank_account,
:created_at,
:currency,
:description,
:paid_at,
:recipient,
... | lib/transfers/transfer.ex | 0.735071 | 0.587056 | transfer.ex | starcoder |
defmodule ArtemisWeb.ViewHelper.Async do
use Phoenix.HTML
import ArtemisWeb.ViewHelper.Print
import ArtemisWeb.ViewHelper.Status
@moduledoc """
View helpers for rendering data asynchronously using Phoenix LiveView
NOTE: This module contains async functions. Also see
`apps/artemis_web/lib/artemis_web.ex... | apps/artemis_web/lib/artemis_web/view_helpers/async.ex | 0.838366 | 0.457621 | async.ex | starcoder |
defmodule Relax.Resource do
use Behaviour
@moduledoc """
Provides functionality and defines a behaviour to help build jsonapi.org
resource endpoints.
## Using
When used, `Relax.Resource` works as an parent module that adds
common functionality and behaviours and plugs to your module.
### Submodules
... | lib/relax/resource.ex | 0.814938 | 0.453564 | resource.ex | starcoder |
defmodule Erlef.Agenda do
@moduledoc false
@board_ics "https://user.fm/calendar/v1-d950fe3b2598245f424e3ddbff1a674a/Board%20Public.ics"
# 2 minutes
@check_interval 120_000
use GenServer
# Client
@spec start_link(Keyword.t()) :: :ignore | {:error, term()} | {:ok, pid()}
def start_link(_opts) do
G... | lib/erlef/agenda.ex | 0.592784 | 0.463444 | agenda.ex | starcoder |
defmodule Authoritex.TestCase do
@moduledoc """
Shared tests for Authoritex modules
`Authoritex.TestCase` ensures that an authority module implements the
`Authoritex` behvaiour and that all of its functions behave as expected.
To run the shared tests, `use Authoritex.TestCase, opts` within your
test module... | test/support/authoritex_case.ex | 0.905432 | 0.911022 | authoritex_case.ex | starcoder |
defmodule Record do
@moduledoc """
Module to work, define and import records.
Records are simply tuples where the first element is an atom:
iex> Record.record? { User, "jose", 27 }
true
This module provides conveniences for working with records at
compilation time, where compile-time field name... | lib/elixir/lib/record.ex | 0.796886 | 0.687171 | record.ex | starcoder |
require Utils
require Program
defmodule D2 do
@moduledoc """
--- Day 2: 1202 Program Alarm ---
On the way to your gravity assist around the Moon, your ship computer beeps angrily about a "1202 program alarm". On the radio, an Elf is already explaining how to handle the situation: "Don't worry, that's perfectly n... | lib/days/02.ex | 0.718496 | 0.812979 | 02.ex | starcoder |
defmodule Quarry.Filter do
@moduledoc false
require Ecto.Query
alias Quarry.{Join, From}
@type filter :: %{optional(atom()) => String.t() | number() | filter()}
@spec build({Ecto.Query.t(), [Quarry.error()]}, Quarry.filter(), [atom()]) ::
{Ecto.Query.t(), [Quarry.error()]}
def build({query, err... | lib/quarry/filter.ex | 0.717111 | 0.428473 | filter.ex | starcoder |
defmodule Retrieval.PatternParser do
@moduledoc """
Parses and verifies patterns that can be matched against the trie data structure.
"""
# Enter initial state
def parse(pattern), do: parse(pattern, 1, [])
# Accept wildcard
def parse(<<"*", rest :: binary>>, col, acc) do
parse(rest, col + 1, [:wild... | lib/retrieval/patternparser.ex | 0.685002 | 0.469642 | patternparser.ex | starcoder |
defmodule ChartPatternDetection do
alias Decimal, as: D
alias List, as: L
alias Enum, as: E
alias Map, as: M
defp get_pairs(list),
do: E.zip(E.drop(list, -1), E.drop(list, 1))
defp normalize_one(val, min, max) when is_integer(val) and is_integer(min) and is_integer(max),
do: normalize_one(D.new(va... | lib/chart_pattern_detection.ex | 0.514644 | 0.440349 | chart_pattern_detection.ex | starcoder |
defmodule Alice.Conn do
@moduledoc """
Alice.Conn defines a struct that is used throughout alice to hold state
during the lifetime of a message handling.
An Alice.Conn struct contains 3 things: `message`, the incoming message
that is currently being handled; `slack`, a data structure from the Slack
library ... | lib/alice/conn.ex | 0.830009 | 0.550184 | conn.ex | starcoder |
defmodule ExNotification do
@moduledoc """
An elixir client for the notification system APIs used by the Australian, British, and Canadian governments.
## Installation
The package can be installed by adding `ex_notification` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:e... | lib/ex_notification.ex | 0.916563 | 0.876819 | ex_notification.ex | starcoder |
defmodule Indicado.MACD do
@moduledoc """
This is the MACD module used for calculating Moving Average Convergence Divergence
"""
@doc """
Calculates MACD for the list.
Returns list of map `[{macd: x, signal: y}]` or `{:error, reason}`
- `macd` represents macd calculation
- `signal` represents signal l... | lib/indicado/macd.ex | 0.918872 | 0.767908 | macd.ex | starcoder |
defmodule Penelope.ML.Word2vec.Index do
@moduledoc """
This module represents a word2vec-style vectorset, compiled into a
set of hash-partitioned DETS files. Each record is a tuple consisting
of the term (word) and a set of weights (vector). This module also
supports parsing the standard text representation o... | lib/penelope/ml/word2vec/index.ex | 0.82828 | 0.667497 | index.ex | starcoder |
defmodule ExPlasma.Output.Position do
@moduledoc """
Generates an Output position if given the:
`blknum` - The block number for this output
`txindex` - The index of the Transaction in the block.
`oindex` - The index of the Output in the Transaction.
"""
@behaviour ExPlasma.Output
alias __MODULE__.Val... | lib/ex_plasma/output/position.ex | 0.879231 | 0.708364 | position.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.