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 KvStore.Bucket do
@moduledoc """
Module which is responsible for holding bucket state.
Identifiable both by a name and PID.
"""
@doc """
Starts a new named bucket.
"""
def start_link(name) when is_atom(name) do
Agent.start_link(fn() -> %{} end, name: name)
end
@doc """
Gets a strea... | lib/kv_store/bucket.ex | 0.76973 | 0.44734 | bucket.ex | starcoder |
defmodule BitPay.KeyUtils do
require Integer
@doc """
generates a pem file
"""
def generate_pem do
keys |>
entity_from_keys |>
der_encode_entity |>
pem_encode_der
end
@doc """
creates a base58 encoded SIN from a pem file
"""
def get_sin_from_pem pem do
compressed_public_key(pem... | lib/bitpay/key-utils.ex | 0.789842 | 0.412501 | key-utils.ex | starcoder |
defmodule Mix.Tasks.Iana.Specials do
use Mix.Task
alias Mix
@moduledoc """
Download and convert IANA's IPv4/6 Special-Purpose Address Registries
Usage:
```
mix iana.specials [force] [dryrun]
```
The `force` will force the download, even though the xml files are already
present in the `priv` subd... | dev/mix/tasks/iana.specials.ex | 0.752649 | 0.754395 | iana.specials.ex | starcoder |
defmodule Timber.Utils.HTTPEvents do
@moduledoc false
alias Timber.Config
@multi_header_delimiter ","
@header_keys_to_sanitize ["authorization", "x-amz-security-token"]
@header_value_byte_limit 256
@sanitized_value "[sanitized]"
def format_time_ms(time_ms) when is_integer(time_ms),
do: [Integer.to_... | lib/timber/utils/http_events.ex | 0.842928 | 0.458894 | http_events.ex | starcoder |
defmodule VintageNetQMI.ASUCalculator do
@moduledoc """
Convert raw ASU values to friendlier units
See https://en.wikipedia.org/wiki/Mobile_phone_signal#ASU for
more information.
The following conversions are done:
* dBm
* Number of "bars" out of 4 bars
"""
@typedoc """
Number of bars out of 4 t... | lib/vintage_net_qmi/asu_calculator.ex | 0.852583 | 0.554893 | asu_calculator.ex | starcoder |
defmodule NervesTimeZones do
@moduledoc """
Local time support for Nerves devices
The `nerves_time_zones` application provides support for local time on Nerves
devices. It does this by bundling a time zone database that's compatible with
the `zoneinfo` library and providing logic to set the local time zone w... | lib/nerves_time_zones.ex | 0.865991 | 0.622689 | nerves_time_zones.ex | starcoder |
defmodule SiteParser do
defstruct [:module, :method]
@type t :: %SiteParser{ module: module, method: atom }
@type host :: %{ host: String.t }
| %{ host: String.t, path: String.t }
@doc """
iex> parse_host("http://google.com/")
{:ok, "google.com"}
iex> parse_host("https://www.google... | apps/harvester/lib/site_parser.ex | 0.656108 | 0.404537 | site_parser.ex | starcoder |
defmodule GraphQL do
@moduledoc ~S"""
An Elixir implementation of Facebook's GraphQL.
This is the core GraphQL query parsing and execution engine whose goal is to be
transport, server and datastore agnostic.
In order to setup an HTTP server (ie Phoenix) to handle GraphQL queries you will
need:
* [Gra... | lib/graphql.ex | 0.867962 | 0.59249 | graphql.ex | starcoder |
defmodule AWS.Organizations do
@moduledoc """
AWS Organizations
"""
@doc """
Sends a response to the originator of a handshake agreeing to the action
proposed by the handshake request.
This operation can be called only by the following principals when they
also have the relevant IAM permissions:
<... | lib/aws/generated/organizations.ex | 0.784154 | 0.487795 | organizations.ex | starcoder |
defmodule Sled.Tree do
@moduledoc "Perform operations on sled trees."
@derive {Inspect, except: [:ref]}
@enforce_keys [:ref, :db, :name]
defstruct ref: nil, db: nil, name: nil
@typedoc """
A reference to a sled tenant tree.
"""
@opaque t :: %__MODULE__{ref: reference(), db: Sled.t(), name: String.t()}... | lib/sled/tree.ex | 0.910177 | 0.557845 | tree.ex | starcoder |
defmodule CSP.Channel do
@moduledoc """
Module used to create and manage channels.
## Options
There are some options that may be used to change a channel behavior,
but the channel's options can only be set during it's creation.
The available options are:
* `name` - Registers the channel proccess wit... | lib/csp/channel.ex | 0.908187 | 0.66651 | channel.ex | starcoder |
defmodule Xgit.FileMode do
@moduledoc ~S"""
Describes the file type as represented on disk.
"""
import Xgit.Util.ForceCoverage
@typedoc ~S"""
An integer describing the file type as represented on disk.
Git uses a variation on the Unix file permissions flags to denote a file's
intended type on disk. T... | lib/xgit/file_mode.ex | 0.85081 | 0.407805 | file_mode.ex | starcoder |
defmodule AoC.Intcode.PaintingRobot do
@moduledoc false
use Task
def initialize(initial_state \\ %{}) do
%{
state: :ready,
cpu: nil,
position: {0, 0},
heading: :up,
known_panels: %{},
default_color: :black,
pending_color: nil,
pending_direction: nil,
tra... | lib/aoc/intcode/painting_robot.ex | 0.792986 | 0.546315 | painting_robot.ex | starcoder |
defmodule Sentix.Bridge do
@moduledoc """
This module provides the bridge between Sentix and `fswatch`, via an Erlang
port. This is where any translation will be done in order to handle the types
of communication between the port and the program.
"""
# add internal aliases
alias __MODULE__.Command
alia... | lib/sentix/bridge.ex | 0.860677 | 0.609146 | bridge.ex | starcoder |
defmodule Booklist.Reports do
@moduledoc """
The Reports context.
"""
import Ecto.Query, warn: false
alias Booklist.Repo
alias Booklist.Admin.Rating
@doc """
Gets lowest rating for the year, or nil if none exists
"""
def get_lowest_rating(year) do
from(r in Rating, join: book in assoc(r, :boo... | lib/booklist/admin/reports.ex | 0.529993 | 0.507385 | reports.ex | starcoder |
defmodule Core.Utils.Converter do
@moduledoc """
Pure elixir trytes/trits/integer converter.
"""
alias Core.Utils.Struct.Transaction
@trytesAlphabet "9ABCDEFGHIJKLMNOPQRSTUVWXYZ" # All possible tryte values
# map of all trits representations
@trytesTrits [
[ 0, 0, 0],
[ 1, 0, 0],
[-1,... | apps/core/lib/utils/converter/converter.ex | 0.551815 | 0.459986 | converter.ex | starcoder |
defmodule Alfred.ResultList do
@moduledoc """
Represents a list of `Alfred.Result` items.
Since a result list can contain other information such as variables, it is useful sometimes to
create an explicit list for results.
"""
alias Alfred.Result
@type t :: %__MODULE__{
items: [Result.t()],
... | lib/alfred/result_list.ex | 0.883742 | 0.466785 | result_list.ex | starcoder |
defmodule Squitter.StatsTracker do
use GenServer
require Logger
@rate_buffer_size 500
def start_link(clock) do
GenServer.start_link(__MODULE__, [clock], name: __MODULE__)
end
def init([clock]) do
Logger.debug("Starting up #{__MODULE__}")
counts = :array.new(@rate_buffer_size, default: 0)
... | squitter/lib/squitter/stats_tracker.ex | 0.525612 | 0.484685 | stats_tracker.ex | starcoder |
defmodule MangoPay.PreAuthorization do
@moduledoc """
Functions for MangoPay [pre authorization](https://docs.mangopay.com/endpoints/v2.01/preauthorizations#e183_the-preauthorization-object).
"""
use MangoPay.Query.Base
set_path "preauthorizations"
@doc """
Get a preauthorization.
## Examples
{:... | lib/mango_pay/preauthorization.ex | 0.778144 | 0.459137 | preauthorization.ex | starcoder |
defmodule Membrane.AAC do
@moduledoc """
Capabilities for [Advanced Audio Codec](https://wiki.multimedia.cx/index.php/Understanding_AAC).
"""
@type profile_t :: :main | :LC | :SSR | :LTP | :HE | :HEv2
@type mpeg_version_t :: 2 | 4
@type samples_per_frame_t :: 1024 | 960
@typedoc """
Indicates whether ... | lib/membrane_aac_format/aac.ex | 0.865977 | 0.562417 | aac.ex | starcoder |
defmodule AWS.SNS do
@moduledoc """
Amazon Simple Notification Service
Amazon Simple Notification Service (Amazon SNS) is a web service that enables
you to build distributed web-enabled applications.
Applications can use Amazon SNS to easily push real-time notification messages
to interested subscribers ... | lib/aws/generated/sns.ex | 0.851922 | 0.493042 | sns.ex | starcoder |
defmodule Commando do
alias Commando.State
alias Commando.Help
@moduledoc """
Command line parser with default values, useful help messages, and other features.
Uses OptionParser for parsing, and extends it with:
- Simple and informative help messages
- Default values for switches
- Ability to ... | lib/commando.ex | 0.888172 | 0.608216 | commando.ex | starcoder |
defmodule ExZipper.Zipper.Navigation do
@moduledoc """
Utility module for functions that concern navigating through zippers
"""
alias ExZipper.Zipper
@doc """
Moves to the leftmost child of the current focus, or returns an error if
the current focus is a leaf or an empty branch.
## Example
iex... | lib/ex_zipper/zipper/navigation.ex | 0.869521 | 0.465509 | navigation.ex | starcoder |
defmodule Data.Json.Decode do
@type value :: any
@type error ::
{:field, String.t(), error}
| {:index, integer, error}
| {:one_of, list(error)}
| {:failure, String.t(), value}
@type decoder(a) ::
:boolean
| :integer
| :float
| :stri... | lib/data/json/decode.ex | 0.872 | 0.562958 | decode.ex | starcoder |
defmodule BlueJet.CRM.Customer do
@behaviour BlueJet.Data
use BlueJet, :data
import BlueJet.Utils, only: [put_parameterized: 2, downcase: 1, remove_space: 1, digit_only: 1]
alias __MODULE__.Proxy
alias BlueJet.CRM.PointAccount
schema "customers" do
field :account_id, UUID
field :account, :map, v... | lib/blue_jet/app/crm/customer.ex | 0.639398 | 0.40642 | customer.ex | starcoder |
defmodule FusionDsl.Runtime.Executor do
@moduledoc """
Functions to control and manage execution cycles of fusion dsl.
"""
alias FusionDsl.Helpers.FunctionNames
alias FusionDsl.Impl
alias FusionDsl.Processor.Program
alias FusionDsl.Processor.Environment
@jump_start_throttle Application.get_env(
... | lib/fusion_dsl/runtime/executor.ex | 0.707203 | 0.506836 | executor.ex | starcoder |
defmodule ProcessTreeDictionary do
require Logger
@moduledoc """
Implements a dictionary that is scoped to a process tree by replacing
the group leader with a process that:
- Maintains a dictionary of state
- Forwards all unrecognized messages to the original group leader so
that IO still works
... | lib/process_tree_dictionary.ex | 0.886681 | 0.482429 | process_tree_dictionary.ex | starcoder |
defmodule NimbleStrftime do
@moduledoc """
Simple datetime formatting based on the strftime format
found on UNIX-like systems.
## Formatting syntax
The formatting syntax for strftime is a sequence of characters in the following format:
%<padding><width><format>
where:
* `%`: indicates the sta... | lib/nimble_strftime.ex | 0.896484 | 0.627152 | nimble_strftime.ex | starcoder |
alias Graphqexl.Query.{
Operation,
ResultSet,
Validator,
}
alias Graphqexl.{
Schema,
Tokens,
}
alias Treex.Tree
defmodule Graphqexl.Query do
@moduledoc """
GraphQL query, comprised of one or more `t:Graphqexl.Query.Operation.t/0`s.
Built by calling `parse/1` with either a `t:Graphqexl.Query.gql/0` str... | lib/graphqexl/query.ex | 0.730866 | 0.496704 | query.ex | starcoder |
defmodule AWS.Codestarnotifications do
@moduledoc """
This AWS CodeStar Notifications API Reference provides descriptions and usage
examples of the operations and data types for the AWS CodeStar Notifications
API.
You can use the AWS CodeStar Notifications API to work with the following
objects:
Notifi... | lib/aws/generated/codestarnotifications.ex | 0.838481 | 0.405979 | codestarnotifications.ex | starcoder |
defmodule Surface.Components.Context do
@moduledoc """
A built-in component that allows users to set and retrieve values from the context.
"""
use Surface.Component
@doc """
Puts a value into the context.
## Usage
```
<Context put={{ scope, values }}>
...
</Context>
```
Where:
* `s... | lib/surface/components/context.ex | 0.928587 | 0.918626 | context.ex | starcoder |
defmodule Comms.Actor do
@moduledoc """
A behaviour module for implementing general purpose actors.
A `Comms.Actor` is designed to allow easy implementation of the actor model.
## Example
defmodule Ping do
use Comms.Actor
@impl Comms.Actor
def handle({:ping, pid}, state) do
... | lib/comms/actor.ex | 0.878783 | 0.529081 | actor.ex | starcoder |
defmodule BSV.PubKey do
@moduledoc """
A PubKey is a data structure representing a Bitcoin public key.
Internally, a public key is the `x` and `y` coordiantes of a point of the
`secp256k1` curve. It is derived by performaing elliptic curve multiplication
on a corresponding private key.
"""
alias BSV.Priv... | lib/bsv/pub_key.ex | 0.936793 | 0.711757 | pub_key.ex | starcoder |
defmodule Prometheus.PlugInstrumenter do
@moduledoc """
Helps you create a plug that instruments another plug(s).
Internally works like and uses Plug.Builder so can instrument many
plugs at once. Just use regular plug macro!
### Usage
1. Define your instrumenter:
```elixir
defmodule EnsureAuthentica... | lib/prometheus/plug_instrumenter.ex | 0.870418 | 0.836488 | plug_instrumenter.ex | starcoder |
defmodule RouteGuide.Client do
def main(channel) do
print_feature(channel, Routeguide.Point.new(latitude: 409_146_138, longitude: -746_188_906))
print_feature(channel, Routeguide.Point.new(latitude: 0, longitude: 0))
# Looking for features between 40, -75 and 42, -73.
print_features(
channel,
... | examples/route_guide/lib/client.ex | 0.569015 | 0.489015 | client.ex | starcoder |
defmodule Cog.TemplateCase do
use ExUnit.CaseTemplate, async: true
alias Cog.Template
alias Greenbar.Renderers.SlackRenderer
alias Greenbar.Renderers.HipChatRenderer
using do
quote do
# Extract the processor name from the module. We can then set the @moduletag
# to 'template: <processor>' so... | test/support/template_case.ex | 0.698844 | 0.468122 | template_case.ex | starcoder |
defmodule Ecto.Changeset do
@moduledoc """
Changesets allow filtering, casting and validation of model changes.
There is an example of working with changesets in the introductory
documentation in the `Ecto` module.
## The Ecto.Changeset struct
The fields are:
* `valid?` - Stores if the changeset ... | lib/ecto/changeset.ex | 0.939283 | 0.531635 | changeset.ex | starcoder |
defmodule Blinkchain.Config.Matrix do
@moduledoc """
Represents a contiguous matrix of pixels, composed of liner strips with a
regular spacing and orientation pattern.
* `count`: The number of pixels in each axis, expressed as `{x, y}`.
(default: `{1, 1}`)
* `direction`: The `t:Blinkchain.Config.Strip.di... | lib/blinkchain/config/matrix.ex | 0.941412 | 0.825625 | matrix.ex | starcoder |
defmodule Alambic.CountDown do
@moduledoc """
A simple countdown latch implementation useful for simple fan in scenarios.
It is initialized with a count and clients can wait on it to be signaled
when the count reaches 0, decrement the count or increment the count.
It is implemented as a `GenServer`.
In t... | lib/alambic/countdown.ex | 0.855655 | 0.631694 | countdown.ex | starcoder |
defmodule Game.Format.Quests do
@moduledoc """
Format function for quests
"""
alias Game.Format
alias Game.Format.Rooms
alias Game.Format.Table
alias Game.Quest
@doc """
Format a quest name
iex> Game.Format.quest_name(%{name: "Into the Dungeon"})
"{quest}Into the Dungeon{/quest}"
"""
de... | lib/game/format/quests.ex | 0.602646 | 0.434221 | quests.ex | starcoder |
defmodule Text.Streamer do
@moduledoc """
Functions to support streaming text samples
in various languages and to execute detection
test cases against them.
"""
@doc """
Returns an Enumerable stream
of random strings from a given corpus
and language.
## Arguments
* `corpus` is any module that ... | mix/text_streamer.ex | 0.910744 | 0.718841 | text_streamer.ex | starcoder |
defmodule Excommerce.Query.Zone do
use Excommerce.Query, schema: Excommerce.Addresses.Zone
import Ecto, only: [assoc: 2]
def zoneable!(repo, %Excommerce.Addresses.Zone{type: "Country"} = _schema, zoneable_id) do
repo.get!(Excommerce.Addresses.Country, zoneable_id)
end
def zoneable!(repo, %Excommerce.Add... | lib/excommerce/queries/zone.ex | 0.533154 | 0.411525 | zone.ex | starcoder |
defmodule Pummpcomm.History.BolusNormal do
@moduledoc """
A normal bolus, entered by the user.
"""
alias Pummpcomm.{DateDecoder, Insulin}
@typedoc """
The duration of the square wave bolus. `0` when not a normal bolus.
"""
# TODO determine units and document
@type duration :: non_neg_integer
@ty... | lib/pummpcomm/history/bolus_normal.ex | 0.587233 | 0.508422 | bolus_normal.ex | starcoder |
defmodule Solution.Enum do
@moduledoc """
Helper functions to work with ok/error tuples in Enumerables.
"""
require Solution
import Solution
@doc """
Changes a list of oks into `{:ok, list_of_values}`
If any element of the list is an error, returns this error element.
If all elements are oks, take... | lib/solution/enum.ex | 0.846213 | 0.674644 | enum.ex | starcoder |
defmodule PlugBest do
@moduledoc """
A library that parses HTTP `Accept-*` headers and returns the best match based
on a list of values.
## Examples
```elixir
iex> conn = %Plug.Conn{req_headers: [{"accept-language", "fr-CA,fr;q=0.8,en;q=0.6,en-US;q=0.4"}]}
iex> conn |> PlugBest.best_language(["en", "fr"... | lib/plug_best.ex | 0.895043 | 0.79542 | plug_best.ex | starcoder |
defmodule Carrot.Backoff do
@moduledoc """
Provides functions to facilitate exponential backoff.
"""
import Bitwise
alias Carrot.Backoff
@min 1_000
@max 30_000
defstruct min: @min,
max: @max,
state: nil
@type option :: {:max, pos_integer()} | {:min, pos_integer()}
@type ... | lib/carrot/backoff.ex | 0.940449 | 0.538073 | backoff.ex | starcoder |
defmodule Day12 do
defmodule Triplet do
defstruct x: 0, y: 0, z: 0
end
defmodule Moon do
defstruct pos: %Triplet{}, vel: %Triplet{}
end
@spec new_moon(String.t()) :: Moon.t()
def new_moon(line) do
[[x, y, z]] =
Regex.scan(~r/<x=([-0-9]*), y=([-0-9]*), z=([-0-9]*)>/, line, capture: :all_b... | lib/day12.ex | 0.803521 | 0.596492 | day12.ex | starcoder |
defmodule EdgeDB.NamedTuple do
@moduledoc """
An immutable value representing an EdgeDB named tuple value.
`EdgeDB.NamedTuple` implements `Access` behavior to access fields
by index or key and `Enumerable` protocol for iterating over tuple values.
```elixir
iex(1)> {:ok, pid} = EdgeDB.start_link()
iex... | lib/edgedb/types/named_tuple.ex | 0.887558 | 0.766949 | named_tuple.ex | starcoder |
defmodule AWS.Codestarnotifications do
@moduledoc """
This AWS CodeStar Notifications API Reference provides descriptions and
usage examples of the operations and data types for the AWS CodeStar
Notifications API. You can use the AWS CodeStar Notifications API to work
with the following objects:
Notificat... | lib/aws/generated/codestarnotifications.ex | 0.853776 | 0.469034 | codestarnotifications.ex | starcoder |
defmodule RayTracer.World do
@moduledoc """
This module defines world. World is a bag for elements like objects and light sources.
"""
alias RayTracer.Light
alias RayTracer.Sphere
alias RayTracer.Shape
alias RayTracer.Material
alias RayTracer.Transformations
alias RayTracer.RTuple
alias RayTracer.C... | lib/world.ex | 0.927388 | 0.565659 | world.ex | starcoder |
defmodule Toprox do
@moduledoc """
A simple proxy for different Logger backends which allows to filter messages based on metadata.
## Usage
In `config.exs`:
config :logger, backends: [
{Toprox, :graylog},
]
config :logger, :graylog,
level: :info,
... | lib/toprox.ex | 0.589716 | 0.42057 | toprox.ex | starcoder |
defmodule Phoenix.Router.Route do
# This module defines the Route struct that is used
# throughout Phoenix's router. This struct is private
# as it contains internal routing information.
@moduledoc false
alias Phoenix.Router.Route
@doc """
The `Phoenix.Router.Route` struct. It stores:
* :verb - the... | lib/phoenix/router/route.ex | 0.845002 | 0.473901 | route.ex | starcoder |
defmodule Ivy.Attribute do
import AtomUtils
alias Ivy.{Anomaly, Database, Datom, Transaction}
@type cardinality :: :one | :many
@type unique :: :identity | :value
@type type :: :integer | :float | :boolean |
:instant | :atom | :ref |
:string | :tuple | :uuid |
... | archive/ivy/attribute.ex | 0.548553 | 0.487917 | attribute.ex | starcoder |
if Code.ensure_loaded?(Plug) do
defmodule Guardian.Plug.SlidingCookie do
@moduledoc """
WARNING! Use of this plug MAY allow a session to be maintained
indefinitely without primary authentication by issuing new refresh
tokens off the back of previous (still valid) tokens. Especially if your
`resour... | lib/guardian/plug/sliding_cookie.ex | 0.773131 | 0.502502 | sliding_cookie.ex | starcoder |
defmodule Ockam.TypedCBOR do
@moduledoc """
Helpers encode/decode structs to/from CBOR, aimed at compatibility with minicbor rust library.
Prefered usage is through TypedStruct macros, see examples on test/plugin_test.exs
"""
@doc ~S"""
iex> to_cbor_term(:integer, 2)
2
iex> from_cbor_term(... | implementations/elixir/ockam/ockam_typed_cbor/lib/typed_cbor.ex | 0.606848 | 0.486941 | typed_cbor.ex | starcoder |
defmodule Beamchmark.Formatter do
@moduledoc """
The module defines a behaviour that will be used to format and output `#{inspect(Beamchmark.Suite)}`.
You can adopt this behaviour to implement custom formatters.
The module contains helper functions for validating and applying formatters defined in configurati... | lib/beamchmark/formatter.ex | 0.894531 | 0.613323 | formatter.ex | starcoder |
defmodule AWS.Route53Domains do
@moduledoc """
Amazon Route 53 API actions let you register domain names and perform related
operations.
"""
@doc """
Accepts the transfer of a domain from another AWS account to the current AWS
account.
You initiate a transfer between AWS accounts using
[TransferDom... | lib/aws/generated/route53_domains.ex | 0.896126 | 0.459743 | route53_domains.ex | starcoder |
defmodule Mix.UAInspector.Verify.Cleanup do
@moduledoc """
Cleans up testcases.
"""
alias UAInspector.ShortCodeMap.DeviceBrands
@empty_to_quotes [
[:bot, :category],
[:bot, :producer, :name],
[:bot, :producer, :url],
[:bot, :url]
]
@empty_to_unknown [
[:client],
[:client, :engin... | verify/lib/mix/ua_inspector/verify/cleanup.ex | 0.602179 | 0.553324 | cleanup.ex | starcoder |
defmodule Plymio.Fontais.Result do
@moduledoc ~S"""
Functions for Result Patterns: `{:ok, value}` or `{:error, error}`.
See `Plymio.Fontais` for overview and documentation terms.
"""
require Plymio.Fontais.Guard
@type opts :: Plymio.Fontais.opts()
@type error :: Plymio.Fontais.error()
@type result ::... | lib/fontais/result/result.ex | 0.914734 | 0.45308 | result.ex | starcoder |
defmodule XDR.VariableOpaque do
@moduledoc """
This module manages the `Variable-Length Opaque Data` type based on the RFC4506 XDR Standard.
"""
@behaviour XDR.Declaration
alias XDR.{FixedOpaque, UInt, VariableOpaqueError}
defstruct [:opaque, :max_size]
@type opaque :: binary() | nil
@typedoc """
... | lib/xdr/variable_opaque.ex | 0.918763 | 0.660456 | variable_opaque.ex | starcoder |
defmodule Multi do
@moduledoc """
A simple GenServer to run ConfigCat examples.
The ConfigCat GenServer is started by our application supervisor in `simple/application.ex`.
In the first ConfigCat config there is a 'keySampleText' setting with the following rules:
1. If the User's country is Hungary, the val... | samples/multi/lib/multi.ex | 0.825836 | 0.497986 | multi.ex | starcoder |
defmodule Militerm.Systems.Commands.Binder do
# %{
# command: ["look", "at", "the", "lit", "lamp", "through", "the", "big", "telescope"],
# adverbs: [],
# direct: [{:object, :singular, [:me, :near], ["the", "lit", "lamp"]}],
# instrument: [{:object, :singular, [:me, :near], ["the", "big", "telescope"]}],
... | lib/militerm/systems/commands/binder.ex | 0.614047 | 0.470919 | binder.ex | starcoder |
defmodule Cldr.DateTime.Format do
@moduledoc """
Manages the Date, TIme and DateTime formats
defined by CLDR.
The functions in `Cldr.DateTime.Format` are
primarily concerned with encapsulating the
data from CLDR in functions that are used
during the formatting process.
"""
alias Cldr.Calendar, as: K... | lib/cldr/datetime/datetime_format.ex | 0.946658 | 0.541227 | datetime_format.ex | starcoder |
defmodule BrDocs.Utils do
@moduledoc ~S"""
Utility module to hold all the calculations functions used to generate and validate data.
"""
@docs_digits_ranges %{
cpf: %{
# first digit
9 => [10, 9, 8, 7, 6, 5, 4, 3, 2],
# second digit
10 => [11, 10, 9, 8, 7, 6, 5, 4, 3, 2]
},
c... | lib/brdocs/utils.ex | 0.828696 | 0.585368 | utils.ex | starcoder |
defmodule ElixirRigidPhysics.Collision.Intersection.SphereSphere do
@moduledoc """
Module for sphere-sphere intersection tests.
"""
require ElixirRigidPhysics.Dynamics.Body, as: Body
require ElixirRigidPhysics.Geometry.Sphere, as: Sphere
require ElixirRigidPhysics.Collision.Contact, as: Contact
alias Gra... | lib/collision/intersection/sphere_sphere.ex | 0.852245 | 0.489992 | sphere_sphere.ex | starcoder |
defmodule OffBroadwayBeanstalkd.Producer do
@moduledoc """
A GenStage producer that continuously polls messages from a beanstalkd queue and
acknowledge them after being successfully processed.
By default this producer uses `OffBroadwayBeanstalkd.BeanstixClient` to talk to beanstalkd but
you can provide your ... | lib/off_broadway_beanstalkd/producer.ex | 0.883651 | 0.467149 | producer.ex | starcoder |
defmodule PollutionData do
@moduledoc false
def importLinesFromCSV(name \\ "pollution.csv", minCount \\ 5900) do
lines = File.read!(name) |> String.split("\n")
if length(lines) < minCount do
{:error, "Problem with importing, Wrong number of lines!"}
end
lines
end
def convertLine(line) do... | src/pollution_data.ex | 0.636014 | 0.45048 | pollution_data.ex | starcoder |
defmodule PolyPartition.Geometry do
alias PolyPartition.Helpers
@moduledoc """
Geometry functions for PolyPartition
"""
@doc """
Calculate the squared length of a segment
Returns float regardless of input
## Examples
iex> PolyPartition.Geometry.sq_length([[0,0], [1,1]])
2.0
"""
def s... | lib/Geometry.ex | 0.928141 | 0.830181 | Geometry.ex | starcoder |
defmodule GiftCardDemo.GiftCard do
@moduledoc """
A gift card is a prepaid stored-value money card, usually issued by a retailer
or bank, to be used as an alternative to cash for purchases within a
particular store or related businesses.
A card is issued with an amount and can be redeemed many times until th... | lib/gift_card_demo/gift_card/gift_card.ex | 0.67971 | 0.465266 | gift_card.ex | starcoder |
defmodule FloUI.SelectionListItem do
@moduledoc """
## Usage in SnapFramework
A selection list item used by SelectionList.
data is a tuple in the form of
``` elixir
{label, value, id}
```
``` elixir
<%= graph font_size: 20 %>
<%= component FloUI.SelectionListItem,
{@label, @value, @key}
... | lib/selection_list/selection_list_item.ex | 0.757884 | 0.627438 | selection_list_item.ex | starcoder |
defmodule Edeliver.Relup.Instructions.Sleep do
@moduledoc """
This upgrade instruction is intended for testing only
and just sleeps the given amount of seconds. This can
be used to test instructions which suspend processes
at the beginning of the upgrade before the new code is
installed. Usage:
... | lib/edeliver/relup/instructions/sleep.ex | 0.666605 | 0.756132 | sleep.ex | starcoder |
defmodule Stripe.Plans do
@moduledoc """
Basic List, Create, Delete API for Plans
"""
@endpoint "plans"
@doc """
Creates a Plan. Note that `currency` and `interval` are required parameters, and are defaulted to "USD" and "month"
## Example
```
{:ok, plan} = Stripe.Plans.create [id: "test-plan", ... | lib/stripe/plans.ex | 0.876416 | 0.913638 | plans.ex | starcoder |
defmodule LifeGame.World do
@moduledoc """
The Game of Life implemented in funcional style in Elixir.
https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
"""
@author "<NAME>"
defstruct [:grid, :width, :height]
@width 300
@height 300
@cell_size 5
@cell_color {0, 100, 0}
@bg_color {255, 255, 255... | elixir/lib/life_game/world.ex | 0.620737 | 0.766905 | world.ex | starcoder |
defmodule Epicenter.Test.RevisionAssertions do
import ExUnit.Assertions
def assert_audit_logged(%{id: model_id}) do
if Epicenter.AuditingRepo.entries_for(model_id) == [], do: flunk("Expected schema to have an audit log entry, but found none.")
end
def assert_revision_count(%{id: model_id}, count) do
e... | test/support/revision_assertions.ex | 0.614741 | 0.512815 | revision_assertions.ex | starcoder |
defmodule Granulix.Math do
@compile {:autoload, false}
@on_load :load_nifs
@pi :math.pi()
@doc "A useful number"
@spec pi() :: float()
def pi(), do: @pi
@twopi @pi * 2
@doc "A useful number times two"
@spec twopi() :: float()
def twopi(), do: @twopi
@pi2 @pi * 0.5
@doc "A useful number times... | lib/granulix/math.ex | 0.824709 | 0.478529 | math.ex | starcoder |
defmodule Plymio.Funcio.Enum.Map.Gather do
@moduledoc ~S"""
Map and Gather Patterns for Enumerables.
These functions map the elements of an *enum* and gather the
results according to one of the defined *patterns*.
Gathering means collecting all the `:ok` and `:error` results into a
*opts* with keys `:ok` ... | lib/funcio/enum/map/gather.ex | 0.804943 | 0.684185 | gather.ex | starcoder |
defmodule Membrane.Core.Child.PadModel do
@moduledoc false
# Utility functions for veryfying and manipulating pads and their data.
use Bunch
alias Bunch.Type
alias Membrane.Core.Child
alias Membrane.Pad
@type pads_data_t :: %{Pad.ref_t() => Pad.Data.t()}
@type pad_info_t :: %{
required(:a... | lib/membrane/core/child/pad_model.ex | 0.89458 | 0.655019 | pad_model.ex | starcoder |
defmodule Resourceful.Type.Relationship do
@moduledoc """
Relationships come in one of two types: `:one` or `:many`. Things like
foreign keys and how the relationships map are up to the underlying data
source. For the purposes of mapping things in `Resourceful`, it simply needs
to understand whether it's work... | lib/resourceful/type/relationship.ex | 0.682997 | 0.734572 | relationship.ex | starcoder |
defmodule Rock.ClusterMergeCriterion do
alias Rock.Struct.Point
alias Rock.Struct.Cluster
@moduledoc false
def measure(%Cluster{size: size1}, %Cluster{size: size2}, theta, cross_link_count) do
power = 1 + 2 * f_theta(theta)
summand1 = :math.pow(size1 + size2, power)
summand2 = :math.pow(size1, powe... | lib/rock/cluster_merge_criterion.ex | 0.671901 | 0.601389 | cluster_merge_criterion.ex | starcoder |
defmodule Crux.Structs.Overwrite do
@moduledoc """
Represents a Discord [Overwrite Object](https://discordapp.com/developers/docs/resources/channel#overwrite-object-overwrite-structure).
"""
@behaviour Crux.Structs
alias Crux.Structs
alias Crux.Structs.{Overwrite, Role, Snowflake, User, Util}
require ... | lib/structs/overwrite.ex | 0.813313 | 0.561065 | overwrite.ex | starcoder |
defmodule Quarry do
@moduledoc """
A data-driven ecto query builder for nested associations.
Quarry allows you to interact with your database thinking only about your data, and generates queries
for exactly what you need. You can specify all the filters, loads, and sorts with any level of granularity
and at ... | lib/quarry.ex | 0.805632 | 0.813313 | quarry.ex | starcoder |
if Code.ensure_loaded?(Plug) do
defmodule BtrzAuth.Plug.VerifyToken do
@moduledoc """
It depends on `BtrzAuth.Plug.VerifyApiKey`, looks for a token in the `Authorization` header and verify it using first the account's private key, if not valid, then main and secondary secrets provided by your app for interna... | lib/plug/verify_token.ex | 0.810779 | 0.805403 | verify_token.ex | starcoder |
defmodule Terp.AST do
@moduledoc """
Interface for working with the Terp.AST.
"""
alias RoseTree.Zipper
alias Terp.Parser
@doc """
Parse source code and convert it to an ast.
"""
@spec from_src(String.t) :: [RoseTree.t]
def from_src(str) do
str
|> Parser.parse()
|> Enum.flat_map(&to_tre... | lib/terp/ast.ex | 0.766687 | 0.524638 | ast.ex | starcoder |
defmodule Cb.Bot do
use Slacker
use Slacker.Matcher
match ~r/^c(ultivate)?? help/i, :help
match ~r/^c(ultivate)?? hi/i, :say_hello
match ~r/^c(ultivate)?? where are you/i, :show_inet_addr
match ~r/^c(ultivate)?? (forward|reverse|back|left|right|stop)/i, :control
match ~r/^c(cultivate)?? step (\d+)/i, :se... | apps/cb_slack/lib/cb_slack/cb_bot.ex | 0.557604 | 0.47171 | cb_bot.ex | starcoder |
defmodule Dependency do
@moduledoc """
Fuctions to build soft dependencies between modules. This is useful when you want to test different implementations in test mode.
The resolution is dynamic in test mode (uses a `Registry`).
In dev and production modes, the dependency in compiled inline.
"""
@doc """... | lib/dependency.ex | 0.867457 | 0.484441 | dependency.ex | starcoder |
defmodule TicTacToe.Game do
@moduledoc """
Functions to modify the game state.
"""
alias TicTacToe.Ai
alias TicTacToe.Board
alias TicTacToe.Scoring
defstruct(
board: Board.new(),
winner: nil,
current_player: nil,
game_mode: :original
)
@type t :: %__MODULE__{
board: Board.... | lib/tic_tac_toe/game.ex | 0.813794 | 0.426441 | game.ex | starcoder |
defmodule ShiftRegister do
@moduledoc """
Controls a 74hc595 shift register
Connect GPIO pins on your PI to pins 11, 12, 14 of the 74hc595.
For an 74hc595n, if you put the package pins down, the pin layout looks like this (`U` is the
notch on the end of the package.)
```
output1 -> 1 U 16 <- 5V power i... | apps/ui/lib/ui/shift_register.ex | 0.83128 | 0.89765 | shift_register.ex | starcoder |
defmodule Jaxon.Decoders.Values do
alias Jaxon.{ParseError}
def values(event_stream) do
event_stream
|> Stream.transform(&initial_fun/1, fn events, fun ->
do_resume_stream_values(events, fun, [])
end)
end
defp initial_fun(events) do
do_stream_value(events, [], [])
end
defp do_resume... | lib/jaxon/decoders/values.ex | 0.677474 | 0.544922 | values.ex | starcoder |
defmodule Dactyl do
@moduledoc """
Very much inspired by the [Dactyl
Keyboard](https://github.com/adereth/dactyl-keyboard). This is an attempt to
provide a complex example for my
[OpenSCAD](https://github.com/joedevivo/open_scad) library by porting that
clojure model. I've made personal changes where I saw ... | models/dactyl.ex | 0.68458 | 0.487856 | dactyl.ex | starcoder |
defmodule FusionDsl.Impl do
@moduledoc """
Implementation module for FusionDsl. This module helps with developing packages for fusion dsl.
Read [packages](packages.html) docs for more info.
"""
alias FusionDsl.Runtime.Executor
alias FusionDsl.Runtime.Environment
defmacro __using__(_opts) do
quote d... | lib/fusion_dsl/impl.ex | 0.877706 | 0.877267 | impl.ex | starcoder |
defmodule Strukt.Test.Fixtures do
use Strukt
defmodule Classic do
@moduledoc "This module uses Kernel.defstruct/1, even though our defstruct/1 is in scope, since it is given only a list of field names"
use Strukt
defstruct [:name]
end
defmodule Simple do
@moduledoc "This module represents the... | test/support/defstruct_fixtures.ex | 0.859221 | 0.527195 | defstruct_fixtures.ex | starcoder |
defmodule Que do
use Application
@moduledoc """
`Que` is a simple background job processing library backed by `Mnesia`.
Que doesn't depend on any external services like Redis for persisting job
state, instead uses the built-in erlang application
[`mnesia`](http://erlang.org/doc/man/mnesia.html). This make... | lib/que.ex | 0.787032 | 0.862468 | que.ex | starcoder |
defmodule Credo.Check.Refactor.ABCSize do
@moduledoc false
@checkdoc """
The ABC size describes a metric based on assignments, branches and conditions.
A high ABC size is a hint that a function might be doing "more" than it
should.
As always: Take any metric with a grain of salt. Since this one was origi... | lib/credo/check/refactor/abc_size.ex | 0.825449 | 0.503479 | abc_size.ex | starcoder |
defmodule AdventOfCode.Day17 do
@moduledoc ~S"""
[Advent Of Code day 17](https://adventofcode.com/2018/day/17).
"""
@sand "."
@clay "#"
@flow "|"
@rest "~"
import AdventOfCode.Utils, only: [map_increment: 2]
def solve("1", input) do
with %{"~" => a, "|" => b} <- do_solve(input), do: a + b
end... | lib/advent_of_code/day_17.ex | 0.715424 | 0.687931 | day_17.ex | starcoder |
defmodule AWS.Chime do
@moduledoc """
The Amazon Chime API (application programming interface) is designed for
developers to perform key tasks, such as creating and managing Amazon Chime
accounts, users, and Voice Connectors.
This guide provides detailed information about the Amazon Chime API, including
o... | lib/aws/generated/chime.ex | 0.859884 | 0.577674 | chime.ex | starcoder |
defmodule Commanded.Commands.Router do
@moduledoc """
Command routing macro to allow configuration of each command to its command handler.
## Example
Define a router module which uses `Commanded.Commands.Router` and configures
available commands to dispatch:
defmodule BankRouter do
use Comman... | lib/commanded/commands/router.ex | 0.940674 | 0.711782 | router.ex | starcoder |
defmodule Axon.Losses do
@moduledoc """
Loss functions.
Loss functions evaluate predictions with respect to true
data, often to measure the divergence between a model's
representation of the data-generating distribution and the
true representation of the data-generating distribution.
Each loss function ... | lib/axon/losses.ex | 0.958683 | 0.918187 | losses.ex | starcoder |
defmodule Mix.Tasks.Snoop do
use Mix.Task
@moduledoc """
A tool for snooping on DHCP transactions that are passing by this particular
connected device.
## Usage
Run this mix task on a device on the same layer-2 network as the network
where you'd like to watch DHCP packets go by. It's probably a good ... | lib/mix.tasks/snoop.ex | 0.797557 | 0.760451 | snoop.ex | starcoder |
defmodule Protobuf.JSON.Encode do
@moduledoc false
alias Protobuf.JSON.{EncodeError, Utils}
@compile {:inline,
encode_field: 3,
encode_key: 2,
maybe_repeat: 3,
encode_float: 1,
encode_enum: 3,
safe_enum_key: 2}
@duration_seconds_range -3... | lib/protobuf/json/encode.ex | 0.688364 | 0.434641 | encode.ex | starcoder |
defmodule Optimizer do
@moduledoc """
Provides a optimizer for [AST](https://elixirschool.com/en/lessons/advanced/metaprogramming/)
"""
import SumMag
@term_options [enum: true]
@doc """
Optimize funcions which be enclosed `defptermay`, using `optimize_***` function.
Input is funcion definitions.
`... | lib/pelemay/optimizer.ex | 0.793586 | 0.899696 | optimizer.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.