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 |
|---|---|---|---|---|---|
use Croma
defmodule RaftKV.ValuePerKey do
@moduledoc """
Behaviour module to define interface functions to manipulate stored value for each key.
The implementations of `c:command/4` and `c:query/4` must be pure (i.e., they must consist of only deterministic computations).
To introduce side effects for your ke... | lib/raft_kv/value_per_key.ex | 0.889972 | 0.541954 | value_per_key.ex | starcoder |
defmodule Game.Format.Table do
@moduledoc """
Format a table
"""
import Game.Format.Context
alias Game.Color
alias Game.Format
@doc """
Format an ASCII table
"""
def format(legend, rows, column_sizes) do
width = total_width(column_sizes)
context()
|> assign_many(:rows, rows, &row(&1,... | lib/game/format/table.ex | 0.817866 | 0.462291 | table.ex | starcoder |
defmodule Throttlex do
@moduledoc """
Throttler Main Interface.
It is possible to set up multiple time buckets at the same time. This is
useful when you want to have a non-linear behavior. For example, having
a single bucket, let's say per minute and with limit `10`, the throttling
logic is applied only wh... | lib/throttlex.ex | 0.911456 | 0.434281 | throttlex.ex | starcoder |
defmodule Adap.Unit do
@moduledoc "Behaviour describing an ADAP distributed processing unit"
@callback start_link(args :: term) :: {:ok,pid}
@callback cast(pid,fun) :: :ok
@callback node(args :: term) :: node
end
defmodule Adap.Unit.Router do
@moduledoc """
Route element to a node/process started on deman... | lib/unit.ex | 0.794903 | 0.527803 | unit.ex | starcoder |
defmodule Earmark.Transform do
import Earmark.Helpers, only: [replace: 3]
@moduledoc """
Public Interface to functions operating on the AST
exposed by `Earmark.as_ast`
"""
@doc """
**EXPERIMENTAL**
But well tested, just expect API changes in the 1.4 branch
Takes an ast, and optional options (I love... | lib/earmark/transform.ex | 0.713931 | 0.470189 | transform.ex | starcoder |
defmodule Univrse.Key do
@moduledoc """
A Univrse Key is a CBOR data structure that represents a cryptographic key.
Univrse Keys closely mirror JSON Web Keys, and it should prove simple to
convert keys between the two specifications.
Keys are used in the `t:Univrse.Signature.t/0` and `t:Univrse.Recipient.t/0... | lib/univrse/key.ex | 0.819533 | 0.596286 | key.ex | starcoder |
defmodule AWS.ServiceCatalog do
@moduledoc """
AWS Service Catalog
**Overview**
[AWS Service Catalog](https://aws.amazon.com/servicecatalog/) allows
organizations to create and manage catalogs of IT services that are
approved for use on AWS. This documentation provides reference material for
the AWS Se... | lib/aws/service_catalog.ex | 0.901438 | 0.468669 | service_catalog.ex | starcoder |
defmodule Rmc.FOne2018.CarMotion do
alias __MODULE__
@moduledoc false
# struct CarMotionData
# {
# float m_worldPositionX; // World space X position
# float m_worldPositionY; // World space Y position
# float m_worldPositionZ; // World space ... | lib/rmc/f_one2018/car_motion.ex | 0.560734 | 0.525551 | car_motion.ex | starcoder |
defmodule PipeTo do
@doc """
PipeTo operator.
This operator will replace the placeholder argument `_` in the right-hand
side function call with left-hand side expression.
### Examples
iex> 1 ~> Enum.at(1..3, _)
2
It can mix with `|>` operation
### Examples
iex> 1 ~> Enum.at(1... | lib/pipe_to.ex | 0.834811 | 0.574723 | pipe_to.ex | starcoder |
defmodule Playground.Scenario.Counters.Many.Atomics.Many do
use Playground.Scenario
def scenario_type do
{:iterations, Stream.map(10..20, &round(:math.pow(2, &1)))}
end
def scenario_banner do
"""
Scenario: Deeper Comparison of various Atomics access patterns
Tasks:
- Sequentially update ... | lib/playground/scenario/counters/many/atomics/many.ex | 0.678114 | 0.777764 | many.ex | starcoder |
defmodule DataQuacker.Schema.State do
@moduledoc false
alias DataQuacker.Schema.State
defstruct cursor: [], flags: %{}, schema: %{}, matchers: [], rows: [], fields: %{}
def new(), do: %State{}
def clear_fields(state) do
%State{state | fields: %{}}
end
def flag(%State{flags: flags} = state, flag, ... | lib/schema/state.ex | 0.596198 | 0.716479 | state.ex | starcoder |
defmodule Biggie do
@moduledoc """
Provides a client for programmatically interfacing with BigQuery
Relevant models:
https://hexdocs.pm/google_api_big_query/GoogleApi.BigQuery.V2.Api.Jobs.html#bigquery_jobs_list/3
https://hexdocs.pm/google_api_big_query/GoogleApi.BigQuery.V2.Model.Job.html#content
https:/... | lib/biggie.ex | 0.657209 | 0.485905 | biggie.ex | starcoder |
defmodule Abacus do
@moduledoc """
Abacus is a tool to simplify the handling of units.
For example :
```
# This module is used during the documentation to
# show some examples.
defmodule AbacusTest.Length do
use Abacus.SystemMetric
# :cm is the unit used as a reference in the metric syste... | lib/abacus.ex | 0.944625 | 0.878835 | abacus.ex | starcoder |
defmodule BSV.Address do
@moduledoc """
A Bitcoin address is a 26-35 character string beginning with the number 1,
that represents the hash of a pulic key.
An address is derived by calculating the RIPEMD hash of a SHA-256 hash of the
public key, and then Base58check encoding it.
Addresses are used in [`P2... | lib/bsv/address.ex | 0.923506 | 0.538559 | address.ex | starcoder |
defmodule D7 do
def parse(text) do
text
|> String.trim()
|> String.split("\n")
|> Enum.map(&String.split(&1, " contain "))
|> Enum.map(fn [outter, inners] ->
{String.trim_trailing(outter, " bags"),
inners
|> String.trim_trailing(".")
|> String.split(", ")
|> Enum.... | 2020/d7.ex | 0.555676 | 0.566738 | d7.ex | starcoder |
defmodule Pbuf.Tests.Sub.User do
@moduledoc false
alias Pbuf.Decoder
@derive {Jason.Encoder, []}
defstruct [
id: 0,
status: :USER_STATUS_UNKNOWN,
name: nil
]
@type t :: %__MODULE__{
id: non_neg_integer,
status: Pbuf.Tests.Sub.UserStatus.t,
name: Pbuf.Tests.Sub.User.Name.t
}
... | test/schemas/generated/user.pb.ex | 0.705886 | 0.463566 | user.pb.ex | starcoder |
defmodule Tensorflex do
@moduledoc """
A simple and fast library for running Tensorflow graph models in Elixir.
Tensorflex is written around the [Tensorflow C
API](https://www.tensorflow.org/install/install_c), and allows Elixir
developers to leverage Machine Learning and Deep Learning solutions in their
pr... | lib/tensorflex.ex | 0.934253 | 0.940517 | tensorflex.ex | starcoder |
defmodule ReplacingWalk do
@moduledoc """
A hastily constructed replacing walk for use
with `DeferredConfig`; not
very performant, but for transforming data
in options and config, can be convenient.
"""
require Logger
@doc """
Recursive replacing walk that uses `recognize` and
`transform` functi... | lib/replacing_walk.ex | 0.722233 | 0.584419 | replacing_walk.ex | starcoder |
defmodule Esolix.Langs.Befunge93 do
@moduledoc """
Documentation for the Befunge93 Module
"""
# + Addition: Pop two values a and b, then push the result of a+b
# - Subtraction: Pop two values a and b, then push the result of b-a
# * Multiplication: Pop two values a and b, then push the result of a*b
# / ... | lib/langs/befunge93.ex | 0.653238 | 0.609815 | befunge93.ex | starcoder |
defmodule PhoenixUp do
@moduledoc false
@doc """
Inflects path, scope, alias and more from the given name. (This function is stracted from phoenix framework source, and modified)
## Examples
How to use:
```
PhoenixUp.inflect("some_name")
PhoenixUp.inflect(SomeName)
PhoenixUp.inflect(Some.Name)
P... | lib/phoenix_up.ex | 0.808559 | 0.609088 | phoenix_up.ex | starcoder |
defmodule Xgit.Tag do
@moduledoc ~S"""
Represents a git `tag` object in memory.
"""
alias Xgit.ContentSource
alias Xgit.Object
alias Xgit.ObjectId
alias Xgit.ObjectType
alias Xgit.PersonIdent
alias Xgit.Ref
use Xgit.ObjectType
import Xgit.Util.ForceCoverage
import Xgit.Util.ParseHeader, only: ... | lib/xgit/tag.ex | 0.847889 | 0.406626 | tag.ex | starcoder |
defmodule DocuSign.Model.AccountTabSettings do
@moduledoc """
"""
@derive [Poison.Encoder]
defstruct [
:allowTabOrder,
:allowTabOrderMetadata,
:approveDeclineTabsEnabled,
:approveDeclineTabsMetadata,
:calculatedFieldsEnabled,
:calculatedFieldsMetadata,
:checkboxTabsEnabled,
:c... | lib/docusign/model/account_tab_settings.ex | 0.592902 | 0.401306 | account_tab_settings.ex | starcoder |
defmodule AdventOfCode.Day03 do
@moduledoc """
Day 3.
Part 1: We need to find overlapping square inches that are within two or more claims.
"""
@day3 Path.join(["day03.txt"])
def read do
File.stream!(@day3, [], :line)
|> Stream.map(&String.trim/1)
|> Stream.map(&parse_input/1)
|> Enum.redu... | 2018/elixir/advent_of_code/lib/day03/day03.ex | 0.757256 | 0.507507 | day03.ex | starcoder |
defmodule Poker do
defmodule Card do
# look ahead to non-digit character
@suit ~r/(?=\D)/
@ranks ~w[a 2 3 4 5 6 7 8 9 10 J Q K A]
@num_ranks length(@ranks)
# Assign a value to a card of less than 1 dependent on its rank
# so that:
# - cards can be compared to each other
# - the value c... | elixir/poker/lib/poker.ex | 0.628863 | 0.516047 | poker.ex | starcoder |
defmodule AWS.Ivschat do
@moduledoc """
## Introduction
The Amazon IVS Chat control-plane API enables you to create and manage Amazon
IVS Chat resources.
You also need to integrate with the [ Amazon IVS Chat Messaging API](https://docs.aws.amazon.com/ivs/latest/chatmsgapireference/chat-messaging-api.html),... | lib/aws/generated/ivschat.ex | 0.883198 | 0.503906 | ivschat.ex | starcoder |
defmodule Deque do
@moduledoc """
A fast deque implementation using 2 rotating lists.
"""
@opaque t :: %__MODULE__{
size: integer,
max_size: integer,
list1: list,
list2: list,
}
@type value :: term
defstruct size: 0, max_size: nil, list1: [], list2: []
@spec new(integer) :: t
def ne... | lib/deque.ex | 0.768993 | 0.609205 | deque.ex | starcoder |
defmodule SetTwo.ChallengeTwelve do
import SetTwo.ChallengeTen
@key SetTwo.ChallengeEleven.generate_random_aes_key()
@doc """
Cracks and discovers the secret encrypted with encryption_oracle_2
http://cryptopals.com/sets/2/challenges/12/
"""
@spec crack_code() :: binary
def crack_code do
ciphertext ... | lib/set_2/challenge_12.ex | 0.768386 | 0.462898 | challenge_12.ex | starcoder |
defmodule EliteInvestigations.Elite do
@moduledoc """
Context for dealing with actual Elite: Dangerous data.
"""
import Ecto.Query, warn: false
alias EliteInvestigations.Elite.Story
alias EliteInvestigations.Repo
@doc """
Returns the list of stories.
## Options
* `:order_by` How to sort the sto... | lib/elite_investigations/elite.ex | 0.858006 | 0.809012 | elite.ex | starcoder |
defmodule PhoenixStarter.Users.UserRole do
@moduledoc """
Authorizations for `PhoenixStarter.Users.User`.
`UserRole` is a struct with a `name` field as an atom and a `permissions`
field, which is a list of strings.
Permissions should be specified in the format: `"scope.action"`. For
example, `"me.update_p... | lib/phoenix_starter/users/user_role.ex | 0.855731 | 0.50238 | user_role.ex | starcoder |
defmodule TinyXml do
@moduledoc """
XML navigation and data extraction functions.
"""
import TinyXml.Utils, only: [from_string: 1]
require Record
Record.defrecord(:xmlText, Record.extract(:xmlText, from_lib: "xmerl/include/xmerl.hrl"))
Record.defrecord(
:xmlAttribute,
Record.extract(:xmlAttrib... | lib/tiny_xml.ex | 0.779951 | 0.476397 | tiny_xml.ex | starcoder |
defmodule Membrane.RTP.TWCCSender.CongestionControl do
@moduledoc """
The module implements [Google congestion control algorithm](https://datatracker.ietf.org/doc/html/draft-ietf-rmcat-gcc-02).
"""
alias Membrane.Time
require Membrane.Logger
# disable Credo naming checks to use the RFC notation
# credo:... | lib/membrane/rtp/twcc_sender/congestion_control.ex | 0.900217 | 0.542682 | congestion_control.ex | starcoder |
defmodule Day11 do
def part1(input) do
solve(input, &update_grid_part1/2)
end
def part2(input) do
solve(input, &update_grid_part2/2)
end
def solve(input, update) do
grid = parse(input)
seats = Map.keys(grid)
Stream.iterate(grid, fn grid ->
update.(grid, seats)
end)
|> Enum.... | day11/lib/day11.ex | 0.643217 | 0.648849 | day11.ex | starcoder |
defmodule FileUtils do
@moduledoc """
File utilities for Elixir. This is a collection of utilities for operating on
files and directories, some of which should probably be in the standard
library but aren't.
"""
@type posix :: :file.posix
@type badarg :: {:error, :badarg}
defp validate_opt({:error, ... | lib/fileutils.ex | 0.725843 | 0.428951 | fileutils.ex | starcoder |
defmodule TtrCore.Board.Routes do
@moduledoc false
use TtrCore.Board.Router
defroute Atlanta, to: Charleston, distance: 2
defroute Atlanta, to: Miami, distance: 5, trains: [:passenger]
defroute Atlanta, to: Raleigh, distance: 2, trains: [:any, :any]
defroute Atlant... | lib/ttr_core/board/routes.ex | 0.695958 | 0.68725 | routes.ex | starcoder |
defmodule Rajska.QueryScopeAuthorization do
@moduledoc """
Absinthe middleware to perform query scoping.
## Usage
[Create your Authorization module and add it and QueryAuthorization to your Absinthe.Schema](https://hexdocs.pm/rajska/Rajska.html#module-usage). Since Scope Authorization middleware must be used ... | lib/middlewares/scope_authorization.ex | 0.844489 | 0.856992 | scope_authorization.ex | starcoder |
defmodule Asteroid.ObjectStore.DeviceCode.Mnesia do
@moduledoc """
Mnesia implementation of the `Asteroid.ObjectStore.DeviceCode` behaviour
## Options
The options (`Asteroid.ObjectStore.DeviceCode.opts()`) are:
- `:table_name`: an `atom()` for the table name. Defaults to `:asteroid_device_code`
- `:tab_def... | lib/asteroid/object_store/device_code/mnesia.ex | 0.910814 | 0.842021 | mnesia.ex | starcoder |
defmodule ScenicStarter.Scene.Transforms do
use Scenic.Scene
alias Scenic.Graph
import Scenic.Primitives
import Scenic.Components
alias ScenicStarter.Component.Nav
alias ScenicStarter.Component.Notes
@notes """
\"Transforms\" demonstrates using transforms to position, rotate and scale.
The uppe... | lib/scenes/transforms.ex | 0.794385 | 0.508178 | transforms.ex | starcoder |
defmodule Sanbase.Price.MetricAdapter do
@behaviour Sanbase.Metric.Behaviour
alias Sanbase.Price
@aggregations [:any, :sum, :avg, :min, :max, :last, :first, :median]
@default_aggregation :last
@timeseries_metrics ["price_usd", "price_btc", "price_eth", "volume_usd", "marketcap_usd"]
@histogram_metrics []
... | lib/sanbase/prices/metric_adapter.ex | 0.807309 | 0.456713 | metric_adapter.ex | starcoder |
defmodule EQRCode.SpecTable do
@type error_correction_level :: :l | :m | :q | :h
@type version :: 1..40
@type mode :: :numeric | :alphanumeric | :byte | :kenji | :eci
def error_correction_level(), do: [:l, :m, :q, :h]
@mode [
numeric: 0b0001,
alphanumeric: 0b0010,
byte: 0b0100,
kanji: 0b1000... | lib/eqrcode/spec_table.ex | 0.614394 | 0.656466 | spec_table.ex | starcoder |
defprotocol Contex.PlotContent do
@moduledoc """
Defines what a charting component needs to implement to be rendered within a `Contex.Plot`
"""
@doc """
Generates svg as a string or improper list of strings *without* the SVG containing element.
"""
def to_svg(plot, plot_options)
@doc """
Generates s... | lib/chart/plot.ex | 0.872998 | 0.733535 | plot.ex | starcoder |
defmodule AWS.ServiceCatalog do
@moduledoc """
AWS Service Catalog
[AWS Service Catalog](https://aws.amazon.com/servicecatalog/) enables organizations to create and manage catalogs of IT services that are approved for
use on AWS.
To get the most out of this documentation, you should be familiar with the
... | lib/aws/generated/service_catalog.ex | 0.876727 | 0.474936 | service_catalog.ex | starcoder |
defmodule Conduit.Message do
@moduledoc """
The Conduit message.
This module defines a `Conduit.Message` struct and the main functions
for working with Conduit messages.
Note this struct is used for sending and receiving messages from a
message queue.
## Public fields
These fields are for you to use... | lib/conduit/message.ex | 0.886313 | 0.447521 | message.ex | starcoder |
defmodule Forth do
@opaque evaluator :: %{stack: [integer], ops: %{String.t() => [atom] | [String.t()]}}
@doc """
Create a new evaluator.
"""
@basic_ops %{
"dup" => [:dup],
"drop" => [:drop],
"swap" => [:swap],
"over" => [:over],
"+" => [:+],
"-" => [:-],
"*" => [:*],
"/" => ... | elixir/forth/lib/forth.ex | 0.641759 | 0.658486 | forth.ex | starcoder |
defmodule Scenic.Primitive.Style.Theme do
@moduledoc """
Themes are a way to bundle up a set of colors that are intended to be used
by components invoked by a scene.
There are a set of pre-defined themes.
You can also pass in a map of color values.
Unlike other styles, The currently set theme is given to... | lib/scenic/primitive/style/theme.ex | 0.850918 | 0.476397 | theme.ex | starcoder |
defmodule Automaton.Types.TWEANN.Cortex do
@moduledoc """
A NN synchronizing element. It knows the PID of every sensor and
actuator, so that it will know when all the actuators have received their
inputs, and that it's time for the sensors to again gather and
fanout sensory data to the neurons in the input la... | lib/automata/automaton_types/neuroevolution/cortex.ex | 0.710327 | 0.753126 | cortex.ex | starcoder |
defmodule AOC.Day11.SpacePolice do
alias AOC.Day11.Intcode
@moduledoc false
@type grid :: map
@type point :: {integer, integer}
def part1(path) do
Intcode.stream_puzzle_input(path)
|> Intcode.puzzle_input_to_map()
|> paint(%{{0, 0} => {0, 0}}, {0, 0}, :north)
|> count_painted_panels()
end... | aoc-2019/lib/aoc/day11/space_police.ex | 0.690559 | 0.540318 | space_police.ex | starcoder |
defmodule Statistics.Distributions.Binomial do
alias Statistics.Math
@moduledoc """
Binomial distribution.
This models the expected outcome of a number
of binary trials, each with known probability,
(often called a Bernoulli trial)
"""
@doc """
The probability mass function
## Examples
i... | lib/statistics/distributions/binomial.ex | 0.910112 | 0.710653 | binomial.ex | starcoder |
defmodule Cizen.Saga do
@moduledoc """
The saga behaviour
## Example
defmodule SomeSaga do
use Cizen.Saga
defstruct []
@impl true
def init(_id, %__MODULE__{}) do
saga
end
@impl true
def handle_event(_id, _event, state) do
state
... | lib/cizen/saga.ex | 0.804636 | 0.665723 | saga.ex | starcoder |
defmodule Tirexs.Resources.APIs do
@moduledoc """
This module provides a set of API helpers. Helpers are useful for buiding
an URN part of particular request. Most commonly the result of this would
be used for dealing directly with variety of available `Tirexs.HTTP` functions.
## Examples:
iex> APIs._... | lib/tirexs/resources/apis.ex | 0.762954 | 0.461927 | apis.ex | starcoder |
defmodule Flop do
@moduledoc """
Flop is a helper library for filtering, ordering and pagination with Ecto.
## Usage
The simplest way of using this library is just to use
`Flop.validate_and_run/3` and `Flop.validate_and_run!/3`. Both functions
take a queryable and a parameter map, validate the parameters,... | lib/flop.ex | 0.821223 | 0.572962 | flop.ex | starcoder |
defmodule HTTPRange.ParseError do
@type t :: %__MODULE__{part: atom, subject: binary | nil, value: binary}
defexception [:part, :subject, :value]
def message(%{part: :ranges, subject: nil, value: value}) do
"expected a range set to be defined in #{inspect(value)}"
end
def message(%{part: :ranges, subje... | lib/http_range_parser/parser.ex | 0.87079 | 0.63114 | parser.ex | starcoder |
defmodule Bf2nasm.Optimizer.PassTwo do
def pattern(ast) do
pattern([], ast)
end
def pattern(processed, []) do
processed
end
def pattern(processed, [inner | tail]) when is_list(inner) do
cond do
is_closed(inner)->
new_inner = optimize_closed(inner)
pattern( processed, new_... | lib/optimizer/pass_two.ex | 0.509276 | 0.615926 | pass_two.ex | starcoder |
defmodule ExWareki.Number do
@moduledoc """
Number module provides handlers of Japanese-formatted-number (kansuji) string.
"""
@doc """
parse/1 converts kansuji(kanji-number) into arabic numbers
## Examples
iex> ExWareki.Number.parse(1234567890)
{:ok, 1234567890}
iex> ExWareki.... | lib/ex_wareki/number.ex | 0.734405 | 0.474631 | number.ex | starcoder |
defmodule AshPhoenix.LiveView do
@moduledoc """
Utilities for keeping ash query results up to date in a live view.
"""
@type socket :: term
@type assign :: atom
@type assigns :: map
@type topic :: String.t()
@type liveness_options :: Keyword.t()
require Logger
@opts [
subscribe: [
type:... | lib/ash_phoenix/live_view.ex | 0.901495 | 0.651327 | live_view.ex | starcoder |
defmodule Vantagex.Forex do
@moduledoc """
Contains functions related to the Forex functions from Alpha Vantage
"""
import Vantagex.Helper
@module_id "FX"
@doc """
Uses Alpha Vantage's CURRENCY_EXCHANGE_RATE function.
Returns the realtime exchange rate for any pair of digital currency (e.g. Bitcoin)
... | lib/vantagex/forex.ex | 0.927716 | 0.642713 | forex.ex | starcoder |
if Code.ensure_loaded(Postgrex) do
Postgrex.Types.define(Flippant.PostgrexTypes, [], json: Jason)
defmodule Flippant.Adapter.Postgres do
@moduledoc """
This adapter provides Postgres 9.5+ backed rule storage.
The adapter relies on a table with the following structure:
* `name` - A `text` or `varc... | lib/flippant/adapters/postgres.ex | 0.682256 | 0.418875 | postgres.ex | starcoder |
defmodule Harald.HCI.ACLData do
@moduledoc """
Reference: version 5.2, vol 4, part E, 5.4.2.
"""
alias Harald.Host.L2CAP
alias Harald.HCI.Packet
@enforce_keys [
:handle,
:packet_boundary_flag,
:broadcast_flag,
:data_total_length,
:data
]
defstruct [
:handle,
:packet_bounda... | src/lib/harald/hci/acl_data.ex | 0.593963 | 0.40031 | acl_data.ex | starcoder |
defmodule Parselix do
@moduledoc """
Provides the macro for creating parser and some helper functions.
## Examples
### Function style
@doc "Replaces error messages."
def error_message(parser, message) do
fn target, position ->
case parser.(target, position) do
{:error... | lib/parselix.ex | 0.829319 | 0.451871 | parselix.ex | starcoder |
defmodule Snap.HTTPClient.Adapters.Finch do
@moduledoc """
Built in adapter using `Finch`.
You can also configure this adapter by explicitly setting the `http_client_adapter`
in the `Snap.Cluster` configuration with a tuple `{Snap.HTTPClient.Adapters.Finch, config}`.
For example:
```
config :my_app, MyA... | lib/snap/http_client/adapters/finch.ex | 0.885866 | 0.734691 | finch.ex | starcoder |
defmodule Authex do
@moduledoc """
Defines an auth module.
This module provides a simple set of tools for the authorization and authentication
required by a typical API through use of JSON web tokens. To get started, we
need to define our auth module:
defmodule MyApp.Auth do
use Authex, otp_ap... | lib/authex.ex | 0.816113 | 0.477615 | authex.ex | starcoder |
defmodule I18nHelpers.Ecto.TranslatableFields do
@moduledoc ~S"""
Provides macros for defining translatable fields and associations.
This module's purpose is to provide the `I18nHelpers.Ecto.Translator` module
with a way to access the list of fields and associations from the Ecto Schema
that needs to be tran... | lib/ecto/translatable_fields.ex | 0.858689 | 0.692122 | translatable_fields.ex | starcoder |
defmodule I18n2Elm do
@moduledoc ~S"""
Transforms a folder of i18n key/value JSON files into a series of Elm types \
and functions.
Expects a PATH to one or more JSON files from which to generate Elm code.
i18n2elm PATH [--module-name PATH]
The JSON files at the given PATH will be converted to Elm ty... | lib/i18n2elm.ex | 0.536799 | 0.429669 | i18n2elm.ex | starcoder |
defmodule WhiteBread.Context.StepFunction do
alias WhiteBread.RegexExtension
defstruct string: nil,
regex: nil,
function: nil,
type: nil
def new(%Regex{} = regex, func) when is_function(func, 2) do
%__MODULE__{
regex: regex,
function: func,
type: :regex... | lib/white_bread/context/step_function.ex | 0.74512 | 0.464719 | step_function.ex | starcoder |
defmodule ExCO2Mini.Reader do
require Logger
use GenServer
alias ExCO2Mini.Decoder
@moduledoc """
Reads data packets from the USB CO₂ sensor, decodes them, and sends events
to the subscribed process(es).
Due to the `ioctl` calls required, this module will open a `Port` to a tiny
C wrapper, rather tha... | lib/ex_co2_mini/reader.ex | 0.784855 | 0.612628 | reader.ex | starcoder |
defmodule Tensorex.Analyzer do
@moduledoc """
Functions for tensor (or matrix) analysis.
Matrices are represented as 2-rank tensors.
"""
import Tensorex
import Tensorex.Operator
@doc """
Performs the householder conversion.
Returns a tuple of the converted vecter and the reflection matrix (`P`). Th... | lib/tensorex/analyzer.ex | 0.839224 | 0.678855 | analyzer.ex | starcoder |
defmodule SFTPToolkit.Upload do
@moduledoc """
Module containing functions that ease uploading data to the SFTP server.
"""
use Bunch
@default_operation_timeout 5000
@default_chunk_size 32768
@default_remote_mode [:binary, :write, :creat]
@default_local_mode [:binary, :read, :read_ahead]
@doc """
... | lib/sftp_toolkit/upload.ex | 0.77373 | 0.531209 | upload.ex | starcoder |
defmodule Shellwords do
@moduledoc """
Functions for manipulating strings according to the word parsing rules of the UNIX Bourne shell.
**See:** [Shell & Utilities volume of the IEEE Std 1003.1-2008, 2016 Edition][standard]
[standard]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html
... | lib/shellwords.ex | 0.895125 | 0.771628 | shellwords.ex | starcoder |
defmodule LogicSim.Node do
@moduledoc """
A node is the basic building block of LogicSim. A node is a GenServer that has 0 or more
inputs, and 0 or more outputs. Each node keeps track of which nodes are connected to each
of its outputs. When an output changes the node sends a message to its connected nodes
te... | lib/logic_sim/node.ex | 0.869361 | 0.907885 | node.ex | starcoder |
defmodule Membrane do
@moduledoc ~S"""
Membrane provides a wrapper for filtering data with simplicity and efficiently.
It filters out list of structs or maps that satisfies the query. The Query is inspired by
Mongo, hence there's a lot of similarities.
## Installation
Make sure elixir >= 1.6, then... | lib/membrane.ex | 0.879981 | 0.66555 | membrane.ex | starcoder |
defmodule Oban.Notifiers.PG do
@moduledoc """
A PG/PG2 based notifier implementation that runs with Distributed Erlang.
Out of the box, Oban uses PostgreSQL's `LISTEN/NOTIFY` for PubSub. For most applications, that
is fine, but Postgres-based PubSub isn't sufficient in some circumstances. In particular,
Post... | lib/oban/notifiers/pg.ex | 0.84296 | 0.702007 | pg.ex | starcoder |
defmodule Cog.Commands.Cat do
use Cog.Command.GenCommand.Base,
bundle: Cog.Util.Misc.embedded_bundle
alias Cog.Command.Service.DataStore
# Note, we use the `tee` namespace because the namespace we read from
# must be the same one that data was written into.
@data_namespace [ "commands", "tee" ]
@desc... | lib/cog/commands/cat.ex | 0.698946 | 0.54359 | cat.ex | starcoder |
defmodule EllipticCurve.PublicKey do
@moduledoc """
Used to convert public keys between struct and .der or .pem formats.
Functions:
- toPem()
- toDer()
- fromPem()
- fromPem!()
- fromDer()
- fromDer!()
"""
alias __MODULE__, as: PublicKey
alias EllipticCurve.Utils.{Der, BinaryAscii}
alias Ell... | lib/publicKey.ex | 0.953546 | 0.516108 | publicKey.ex | starcoder |
defmodule Rajska.FieldAuthorization do
@moduledoc """
Absinthe middleware to ensure field permissions.
Authorizes Absinthe's object [field](https://hexdocs.pm/absinthe/Absinthe.Schema.Notation.html#field/4) according to the result of the `c:Rajska.Authorization.has_user_access?/3` function, which receives the us... | lib/middlewares/field_authorization.ex | 0.86306 | 0.848345 | field_authorization.ex | starcoder |
defmodule Cassette.Config do
@moduledoc """
Struct that represents Cassette configuration
"""
defstruct username: "",
password: "",
base_url: "",
base_authority: "",
service: "",
tgt_ttl: 14_400,
st_ttl: 252,
validation_ttl: 30... | lib/cassette/config.ex | 0.811303 | 0.749202 | config.ex | starcoder |
defmodule Grizzly.ZWave.Commands.TimeOffsetSet do
@moduledoc """
This command is used to set Time Zone Offset (TZO) and Daylight Savings Time (DST) at the supporting
node.
Params:
* `:sign_tzo` - This field is used to indicate the sign (:plus or :minus) to apply to the Hour TZO and Minute TZO fields. (req... | lib/grizzly/zwave/commands/time_offset_set.ex | 0.915978 | 0.739658 | time_offset_set.ex | starcoder |
defprotocol Swoosh.Email.Recipient do
@moduledoc """
Recipient Protocol controls how data is formatted into an email recipient
## Deriving
The protocol allows leveraging the Elixir's `@derive` feature to simplify protocol implementation
in trivial cases. Accepted options are:
* `:name` (optional)
*... | lib/swoosh/email/recipient.ex | 0.911256 | 0.551936 | recipient.ex | starcoder |
defmodule Needlework do
@moduledoc """
Needlework brings additional operators to Elixir that allows you to "thread" results of your functions into other function calls. Basically extending the `Kernel.|>/2` operator.
Just `use Needlework` in your modules and thread away!
Example:
```
defmodule MyModule do... | lib/needlework.ex | 0.884573 | 0.793346 | needlework.ex | starcoder |
defmodule Recurly.Plan do
@moduledoc """
Module for handling plans in Recurly.
See the [developer docs on plans](https://dev.recurly.com/docs/list-plans)
for more details
"""
use Recurly.Resource
alias Recurly.{Resource,Money,Plan,AddOn}
@endpoint "/plans"
schema :plan do
field :accounting_code,... | lib/recurly/plan.ex | 0.860794 | 0.790854 | plan.ex | starcoder |
defmodule BST do
@moduledoc """
A binary search tree abstract data structure.
"""
alias BST.Node
defstruct [:comparator, :root]
@typedoc "The data structure stored on the data key for each node in the tree"
@type element :: term()
@typedoc """
Function used to determine whether to place new nodes ... | lib/bst.ex | 0.931975 | 0.756875 | bst.ex | starcoder |
defmodule GGity.Stat do
@moduledoc false
@type dataset :: list(map())
@doc false
@spec identity(dataset(), map()) :: {dataset(), map()}
def identity(data, mapping), do: {data, mapping}
@spec count(dataset(), map()) :: {dataset(), map()}
def count(data, mapping) do
discrete_aesthetics = discrete_aes... | lib/ggity/stat.ex | 0.840406 | 0.659823 | stat.ex | starcoder |
defmodule Jeff.Reply do
@moduledoc """
Replies are sent from a PD to an ACU in response to a command
| Name | Code | Description | Data Type |
|-----------|------|--------------------------------------------|------------------|
| ACK | 0x40 | Command accepted,... | lib/jeff/reply.ex | 0.741019 | 0.689606 | reply.ex | starcoder |
defmodule FalconPlusApi.Api.Expression do
alias Maxwell.Conn
alias FalconPlusApi.{Util, Sig, Api}
@doc """
* [Session](#/authentication) Required
### Request
```{
"right_value": "0",
"priority": 2,
"pause": 0,
"op": "==",
"note": "this is a test exp",
"max... | lib/falcon_plus_api/api/expression.ex | 0.624523 | 0.741253 | expression.ex | starcoder |
defmodule Noray.Vector do
@moduledoc """
Functions for operating on points.
These functions operate on `t:Noray.Tetrad.t/0`, but without confirming that the tetrad is actually a point.
"""
import Noray.Tetrad
@opaque t :: Noray.Tetrad.t()
@doc """
Returns a new vector.
"""
@spec new(float(), flo... | lib/noray/vector.ex | 0.944587 | 0.904651 | vector.ex | starcoder |
defmodule Sanbase.Clickhouse.EthTransfers do
@moduledoc ~s"""
Uses ClickHouse to work with ETH transfers.
"""
@type t :: %__MODULE__{
datetime: %DateTime{},
from_address: String.t(),
to_address: String.t(),
trx_hash: String.t(),
trx_value: float,
bloc... | lib/sanbase/clickhouse/eth_transfers.ex | 0.853043 | 0.427456 | eth_transfers.ex | starcoder |
defmodule OpenHours.Schedule do
@moduledoc """
This module contains functions to work with schedules.
There are five settings to configure a schedule.
- `hours`: Map containing all the open hours intervals for a regular week.
- `holidays`: Dates in which the business is closed.
- `shifts`: Special dates w... | lib/open_hours/schedule.ex | 0.911071 | 0.79158 | schedule.ex | starcoder |
defmodule EVM.Builtin do
@moduledoc """
Implements the built-in functions as defined in Appendix E
of the Yellow Paper. These are contract functions that
natively exist in Ethereum.
"""
@doc """
A precompiled contract that recovers a public key from a signed hash
(Elliptic curve digital signature algor... | apps/evm/lib/evm/builtin.ex | 0.837188 | 0.461441 | builtin.ex | starcoder |
defmodule EctoSchemaStore.Proxy do
@moduledoc """
Generates proxy functions that pass off to the desired store module.
When used with a schema module, this is usually not possible with import because
we the store cannot be compiled until the schema is compiled. But the schema
cannot import until the store is... | lib/ecto_schema_store/proxy.ex | 0.698124 | 0.875148 | proxy.ex | starcoder |
defmodule Aecore.Chain.ChainState do
@moduledoc """
Module used for calculating the block and chain states.
The chain state is a map, telling us what amount of tokens each account has.
"""
alias Aecore.Structures.SignedTx
alias Aecore.Structures.Account
alias Aeutil.Serialization
alias Aeutil.Bits
r... | apps/aecore/lib/aecore/chain/chain_state.ex | 0.805594 | 0.557604 | chain_state.ex | starcoder |
defmodule Calendar.ISO do
@moduledoc """
A calendar implementation that follows to ISO 8601.
This calendar implements the proleptic Gregorian calendar and
is therefore compatible with the calendar used in most countries
today. The proleptic means the Gregorian rules for leap years are
applied for all time,... | lib/elixir/lib/calendar/iso.ex | 0.918116 | 0.598165 | iso.ex | starcoder |
defmodule Supervisor do
@moduledoc ~S"""
A behaviour module for implementing supervisors.
A supervisor is a process which supervises other processes, which we
refer to as *child processes*. Supervisors are used to build a hierarchical
process structure called a *supervision tree*. Supervision trees provide
... | lib/elixir/lib/supervisor.ex | 0.848502 | 0.68084 | supervisor.ex | starcoder |
defmodule AWS.Datapipeline do
@moduledoc """
AWS Data Pipeline configures and manages a data-driven workflow called a
pipeline.
AWS Data Pipeline handles the details of scheduling and ensuring that data
dependencies are met so that your application can focus on processing the data.
AWS Data Pipeline prov... | lib/aws/generated/datapipeline.ex | 0.898037 | 0.740878 | datapipeline.ex | starcoder |
defmodule BUPE.Config do
@moduledoc ~S"""
Configuration structure that holds all the available options for EPUB.
Most of these fields are used in the Package Definition document, this
document includes bibliographic and structural metadata about an EPUB
Publication, and is thus the primary source of informat... | lib/bupe/config.ex | 0.784979 | 0.660537 | config.ex | starcoder |
defmodule Deriv do
@type literal() :: {:const, number()}
| {:const, atom()}
| {:var, atom()}
@type expression() :: {:add, expression(), expression()}
| {:sub, expression(), expression()}
| {:mul, expression(), expression()}
... | exercises/derivative/deriv.ex | 0.55097 | 0.610918 | deriv.ex | starcoder |
defmodule ExTermbox.Bindings do
use InlineNif,
ex_termbox: :code.priv_dir(:ex_termbox) |> Path.join("termbox_bindings")
@moduledoc """
Provides the low-level bindings to the termbox library. This module loads the
NIFs defined in `c_src/` and thinly wraps the C interface.
For event-handling, it's recomme... | lib/ex_termbox/bindings.ex | 0.883638 | 0.59302 | bindings.ex | starcoder |
defmodule Serum.Post do
@moduledoc """
Defines a struct representing a blog post page.
## Fields
* `file`: Source path
* `title`: Post title
* `date`: Post date (formatted)
* `raw_date`: Post date (erlang tuple style)
* `tags`: A list of tags
* `url`: Absolute URL of the blog post in the website
*... | lib/serum/post.ex | 0.821939 | 0.446736 | post.ex | starcoder |
defmodule Geo.WKB.Decoder do
@moduledoc false
use Bitwise
alias Geo.{
Point,
PointZ,
PointM,
PointZM,
LineString,
Polygon,
GeometryCollection,
Utils
}
alias Geo.WKB.Reader
@doc """
Takes a WKB string and returns a Geometry
"""
@spec decode(binary, [Geo.geometry()]) ... | lib/geo/wkb/decoder.ex | 0.853516 | 0.650689 | decoder.ex | starcoder |
defmodule RethinkDB.Record do
@moduledoc false
defstruct data: "", profile: nil
end
defmodule RethinkDB.Collection do
@moduledoc false
defstruct data: [], profile: nil
defimpl Enumerable, for: __MODULE__ do
def reduce(%{data: data}, acc, fun) do
Enumerable.reduce(data, acc, fun)
end
def c... | lib/rethinkdb/response.ex | 0.644449 | 0.473962 | response.ex | starcoder |
defmodule Membrane.Element.Base.Mixin.SourceBehaviour do
@moduledoc """
Module defining behaviour for source and filter elements.
When used declares behaviour implementation, provides default callback definitions
and imports macros.
For more information on implementing elements, see `Membrane.Element.Base`.... | lib/membrane/element/base/mixin/source_behaviour.ex | 0.849316 | 0.467514 | source_behaviour.ex | starcoder |
defmodule PrimaAuth0Ex.Token do
@moduledoc """
Module to verify the integrity and validate the claims of tokens.
"""
use Joken.Config
add_hook JokenJwks, strategy: PrimaAuth0Ex.JwksStrategy
add_hook Joken.Hooks.RequiredClaims, [:aud, :iat, :exp]
@impl true
def token_config do
[skip: [:audience], ... | lib/prima_auth0_ex/token.ex | 0.830044 | 0.515864 | token.ex | starcoder |
defmodule Appsignal.Instrumentation.Decorators do
@moduledoc false
require Appsignal.Utils
@span Appsignal.Utils.compile_env(:appsignal, :appsignal_span, Appsignal.Span)
use Decorator.Define,
instrument: 0,
instrument: 1,
transaction: 0,
transaction: 1,
transaction_event: 0,
transacti... | lib/appsignal/instrumentation/decorators.ex | 0.528777 | 0.580709 | decorators.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.