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 Quantum.Normalizer do
@moduledoc """
Normalize Config values into a `Quantum.Job`.
"""
alias Quantum.Job
alias Crontab.CronExpression.Parser, as: CronExpressionParser
alias Crontab.CronExpression
alias Quantum.RunStrategy.NodeList
@type config_short_notation :: {config_schedule, config_task}... | lib/quantum/normalizer.ex | 0.893269 | 0.412264 | normalizer.ex | starcoder |
defmodule ESpec.Assertions.RaiseException do
@moduledoc """
Defines 'raise_exception' assertion.
it do: expect(function).to raise_exception
it do: expect(function).to raise_exception(ErrorModule)
it do: expect(function).to raise_exception(ErrorModule, "message")
"""
use ESpec.Assertions.Interface
de... | lib/espec/assertions/raise_exception.ex | 0.546496 | 0.505676 | raise_exception.ex | starcoder |
defmodule AWS.StorageGateway do
@moduledoc """
Storage Gateway Service
Storage Gateway is the service that connects an on-premises software appliance
with cloud-based storage to provide seamless and secure integration between an
organization's on-premises IT environment and the Amazon Web Services storage
... | lib/aws/generated/storage_gateway.ex | 0.908734 | 0.596903 | storage_gateway.ex | starcoder |
defmodule Day7 do
def run(lines) do
with rules = parse_rules(lines),
p1 = part1(rules),
p2 = bags_inside("shiny gold", rules) do
"part1: #{p1} part2: #{p2}"
end
end
def part1(rules) do
rules
|> Enum.count(fn {color, _} -> can_contain(color, "shiny gold", rules) end)
en... | elixir_advent/lib/day7.ex | 0.737536 | 0.427516 | day7.ex | starcoder |
defmodule VintageNet.PowerManager do
@moduledoc """
This is a behaviour for implementing platform-specific power management.
From VintageNet's point of view, network devices have the following
lifecycle:
```
off ---> on ---> powering-off ---> off
```
Power management does not necessarily mean contro... | lib/vintage_net/power_manager.ex | 0.901402 | 0.889912 | power_manager.ex | starcoder |
defmodule Mongo.Find do
@moduledoc """
Find operation on MongoDB
"""
use Mongo.Helpers
defstruct [
mongo: nil,
collection: nil,
selector: %{},
projector: %{},
batchSize: 0,
skip: 0,
opts: %{},
mods: %{}]
@doc """
Creates a new find operation.
Not to be used directly, p... | lib/mongo_find.ex | 0.803714 | 0.414632 | mongo_find.ex | starcoder |
defimpl Timex.Protocol, for: DateTime do
@moduledoc """
A type which represents a date and time with timezone information (optional, UTC will
be assumed for date/times with no timezone information provided).
Functions that produce time intervals use UNIX epoch (or simly Epoch) as the
default reference date. ... | lib/datetime/datetime.ex | 0.878203 | 0.550426 | datetime.ex | starcoder |
defmodule Hive.Distribution.LabledRing do
@moduledoc """
A quorum is the minimum number of nodes that a distributed cluster has to
obtain in order to be allowed to perform an operation. This can be used to
enforce consistent operation in a distributed system.
## Quorum size
You must configure this distribu... | lib/hive/role_strategy.ex | 0.857798 | 0.67553 | role_strategy.ex | starcoder |
defmodule AWS.SSOOIDC do
@moduledoc """
AWS Single Sign-On (SSO) OpenID Connect (OIDC) is a web service that enables a
client (such as AWS CLI or a native application) to register with AWS SSO.
The service also enables the client to fetch the user’s access token upon
successful authentication and authorizat... | lib/aws/generated/ssooidc.ex | 0.733165 | 0.465205 | ssooidc.ex | starcoder |
defmodule Tensor.Tensor.Inspect do
alias Tensor.{Tensor}
def inspect(tensor, _opts) do
"""
#Tensor<(#{dimension_string(tensor)})
#{inspect_tensor_contents(tensor)}
>
"""
end
def dimension_string(tensor) do
tensor.dimensions |> Enum.join("×")
end
defp inspect_tensor_contents(tensor ... | lib/tensor/tensor/inspect.ex | 0.637369 | 0.642531 | inspect.ex | starcoder |
defmodule ChatApi.SlackAuthorizations do
@moduledoc """
The SlackAuthorizations context.
"""
import Ecto.Query, warn: false
alias ChatApi.Repo
alias ChatApi.SlackAuthorizations.SlackAuthorization
@doc """
Returns the list of slack_authorizations.
## Examples
iex> list_slack_authorizations()... | lib/chat_api/slack_authorizations.ex | 0.81309 | 0.437523 | slack_authorizations.ex | starcoder |
defmodule Membrane.Element.Base.Filter do
@moduledoc """
Module defining behaviour for filters - elements processing data.
Behaviours for filters are specified, besides this place, in modules
`Membrane.Element.Base.Mixin.CommonBehaviour`,
`Membrane.Element.Base.Mixin.SourceBehaviour`,
and `Membrane.Element... | lib/membrane/element/base/filter.ex | 0.887491 | 0.45641 | filter.ex | starcoder |
defmodule Imgproxy do
@moduledoc """
`Imgproxy` generates urls for use with an [imgproxy](https://imgproxy.net) server.
"""
defstruct source_url: nil, options: [], extension: nil, prefix: nil, key: nil, salt: nil
alias __MODULE__
@type t :: %__MODULE__{
source_url: nil | String.t(),
o... | lib/imgproxy.ex | 0.846149 | 0.489137 | imgproxy.ex | starcoder |
defmodule Abacus.Runtime.Scope do
@moduledoc """
Contains helper functions to work with the scope of an Abacus script at runtime
"""
@doc """
Tries to get values from a subject.
Subjects can be:
* maps
* keyword lists
* lists (with integer keys)
* nil (special case so access to undefined vari... | lib/runtime/scope.ex | 0.884155 | 0.816955 | scope.ex | starcoder |
defmodule SvgBuilder.Shape do
import XmlBuilder
alias SvgBuilder.{Element, Units}
@moduledoc """
This module enables creation of basic shapes.
"""
@doc """
Create a rectangle element.
x: The x-axis coordinate of the side of the rectangle which has the smaller
x-axis coordinate value in the curr... | lib/shape.ex | 0.934253 | 0.829216 | shape.ex | starcoder |
defmodule Riptide.Store.Composite do
@moduledoc """
This module provides a macro to define a store that splits up the data tree between various other stores. It is implemented via pattern matching paths that are being written or read and specifying which store to go to.
## Usage
```elixir
defmodule Todolist... | packages/elixir/lib/riptide/store/store_composite.ex | 0.811713 | 0.819424 | store_composite.ex | starcoder |
defmodule Liquex.Argument do
@moduledoc false
alias Liquex.Context
alias Liquex.Indifferent
@type field_t :: any
@type argument_t ::
{:field, [field_t]}
| {:literal, field_t}
| {:inclusive_range, [begin: field_t, end: field_t]}
@spec eval(argument_t | [argument_t], Context.t... | lib/liquex/argument.ex | 0.790288 | 0.526525 | argument.ex | starcoder |
defmodule AstroEx.Unit.Degrees do
@moduledoc """
Degrees
"""
alias AstroEx.Unit
alias AstroEx.Unit.{Arcmin, Arcsec, DMS, HMS, Radian}
@enforce_keys [:value]
defstruct [:value]
@typep degree :: -360..360 | float()
@type t :: %__MODULE__{value: degree()}
@doc """
Creates a new `AstroEx.Unit.Degr... | lib/astro_ex/unit/degrees.ex | 0.927248 | 0.540257 | degrees.ex | starcoder |
defmodule MatrexNumerix.Distance do
@moduledoc """
Distance functions between two vectors.
"""
import Matrex.Guards
import MatrexNumerix.LinearAlgebra
alias MatrexNumerix.{Common, Correlation, Statistics}
@doc """
Mean squared error, the average of the squares of the errors
betwen two vectors, i.e... | lib/distance.ex | 0.769817 | 0.778986 | distance.ex | starcoder |
defmodule Estated.Property.MarketAssessment do
@moduledoc "Market assessment information as provided by the assessor."
@moduledoc since: "0.2.0"
# MarketAssessment is very similar to Assessment, but they are separate in Estated and
# documented differently.
# credo:disable-for-this-file Credo.Check.Design.Du... | lib/estated/property/market_assessment.ex | 0.822617 | 0.482551 | market_assessment.ex | starcoder |
defmodule Prometheus.Metric.Summary do
@moduledoc """
Summary metric, to track the size of events.
Example use cases for Summaries:
- Response latency;
- Request size;
- Response size.
Example:
```
defmodule MyProxyInstrumenter do
use Prometheus.Metric
## to be called at app/supervi... | astreu/deps/prometheus_ex/lib/prometheus/metric/summary.ex | 0.955703 | 0.873377 | summary.ex | starcoder |
defmodule OMG.Performance.ByzantineEvents do
@moduledoc """
OMG network child chain server byzantine event test entrypoint. Setup and runs performance byzantine tests.
# Usage
See functions in this module for options available
## start_dos_get_exits runs a test to get exit data for given 10 positions for ... | apps/omg_performance/lib/omg_performance/byzantine_events.ex | 0.818556 | 0.801897 | byzantine_events.ex | starcoder |
defmodule FP.Intro do
@moduledoc """
Elixir solutions for HackerRank functional programming challenges.
"""
@doc """
Reverse a list - without using Enum.reverse
https://www.hackerrank.com/challenges/fp-reverse-a-list/problem
"""
@spec reverse(list, list) :: list(integer)
def reverse([], results), do... | lib/fp/intro.ex | 0.861057 | 0.706482 | intro.ex | starcoder |
defmodule OAAS.Job.Replay do
@moduledoc "A replay recording/uploading job."
alias OAAS.Osu
alias OAAS.Job
import OAAS.Utils
use Bitwise, only_operators: true
@derive Jason.Encoder
@enforce_keys [:player, :beatmap, :replay, :upload, :skin]
defstruct @enforce_keys ++ [:reddit_id]
@type t :: %__MODULE... | server/lib/oaas/job/replay.ex | 0.756268 | 0.599397 | replay.ex | starcoder |
defmodule Stripper.Whitespace do
@moduledoc """
This module exists for dealing with whitespace. A space is a space is a space,
right? Wrong. There are multiple [unicode](https://home.unicode.org/)
characters that represent whitespace: tabs, newlines, line-feeds, and a slew
of [lesser-known characters](http:/... | lib/stripper/whitespace.ex | 0.859103 | 0.60133 | whitespace.ex | starcoder |
defmodule Kino.DataTable do
@moduledoc """
A widget for interactively viewing enumerable data.
The data must be an enumerable of records, where each
record is either map, struct, keyword list or tuple.
## Examples
data = [
%{id: 1, name: "Elixir", website: "https://elixir-lang.org"},
... | lib/kino/data_table.ex | 0.865906 | 0.661942 | data_table.ex | starcoder |
defmodule Constants do
@moduledoc """
An alternative to use @constant_name value approach to defined reusable
constants in elixir.
This module offers an approach to define these in a
module that can be shared with other modules. They are implemented with
macros so they can be used in guards and matches
... | lib/ucx_chat/constants.ex | 0.744006 | 0.5144 | constants.ex | starcoder |
require Utils
require Program
defmodule D16 do
@moduledoc """
--- Day 16: Flawed Frequency Transmission ---
You're 3/4ths of the way through the gas giants. Not only do roundtrip signals to Earth take five hours, but the signal quality is quite bad as well. You can clean up the signal with the Flawed Frequency T... | lib/days/16.ex | 0.855202 | 0.918114 | 16.ex | starcoder |
defmodule Redisank do
defmodule Base do
use Rdtype,
uri: Application.get_env(:redisank, :redis)[:ranking],
coder: Redisank.Coder,
type: :sorted_set
end
@format "{YYYY}{0M}{0D}"
def namekey(date, key) do
"#{key}/#{Timex.format! date, @format}"
end
def incr(id, time \\ :calendar.l... | lib/redisank.ex | 0.540681 | 0.419678 | redisank.ex | starcoder |
defmodule PrivCheck.DocChecker do
@moduledoc """
Find docs of module, caching results for performance
Depends heavily on the documentation layout described and implemented in EEP 48:
http://erlang.org/eeps/eep-0048.html
"""
@type visibility :: :public | :private | :not_found
@doc """
Check if the giv... | lib/priv_check/doc_checker.ex | 0.766162 | 0.406302 | doc_checker.ex | starcoder |
defmodule ElixirRigidPhysics.Collision.Narrowphase do
@moduledoc """
Functions for generating collision manifolds for body pairs.
Supported:
* sphere-sphere
* sphere-capsule
* capsule-capsule
Planned:
* sphere-hull
* capsule-hull
* hull-hull
Check [here](http://media.steampowered.com/apps/valve... | lib/collision/narrowphase.ex | 0.829527 | 0.413211 | narrowphase.ex | starcoder |
defmodule Ratio.FloatConversion do
use Ratio
@max_decimals Application.get_env(:ratio, :max_float_to_rational_digits)
@doc """
Converts a float to a rational number.
Because base-2 floats cannot represent all base-10 fractions properly, the results might be different from what you might expect.
See [The P... | lib/ratio/float_conversion.ex | 0.892038 | 0.49707 | float_conversion.ex | starcoder |
defmodule Lacca.Protocol do
@moduledoc """
This module provides helper functions for communicating with external
processes which implement the `shellac` protocol. The wire format of
the protocol follows:
- u16 packet length (i.e: read next `n` bytes)
- u8 packet flags
- [u8,...] packet payl... | lib/lacca/protocol.ex | 0.697403 | 0.488832 | protocol.ex | starcoder |
defmodule Talib.RSI do
alias Talib.SMMA
alias Talib.Utility
@moduledoc ~S"""
Defines RSI.
"""
@doc """
Gets the RSI of a list.
Version: 1.0
Source: http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:relative_strength_index_rsi
Audited by:
| Name | Title ... | lib/talib/rsi.ex | 0.875887 | 0.57821 | rsi.ex | starcoder |
defmodule Cldr.LanguageTag.Sigil do
@moduledoc """
Implements a `sigil_l/2` macro to
constructing `t:Cldr.LanguageTag` structs.
"""
@doc """
Handles sigil `~l` for language tags.
## Arguments
* `locale_name` is either a [BCP 47](https://unicode-org.github.io/cldr/ldml/tr35.html#Identifiers)
locale... | lib/cldr/sigil.ex | 0.780579 | 0.421522 | sigil.ex | starcoder |
defmodule Oli.Delivery.Evaluation.Parser do
@moduledoc """
A parser for evaluation rules.
The macros present here end up defining a single public function
`rule` in this module that takes a string input and attempts to parse
the following grammar:
<rule> :== <expression> {<or> <expression>}
<expression>... | lib/oli/delivery/evaluation/parser.ex | 0.594551 | 0.515864 | parser.ex | starcoder |
defmodule Rir.Stat do
@moduledoc """
Functions to call endpoints on the [RIPEstat Data
API](https://stat.ripe.net/docs/02.data-api/).
## Them are the rules
These are the rules for the usage of the data API:
- no limit on the amount of requests
- but please register if you plan to regularly do more than... | lib/rir/stat.ex | 0.859 | 0.820577 | stat.ex | starcoder |
defmodule Groupsort do
@moduledoc """
Elixir module to group students efficiently, maxmizing the number of novel pairs
by looking at a given history, and minimizing the number of repeated historical
pairs.
WIP - current implementation is BRUTE FORCE. It gets the best solution, but explodes
for numbers grea... | lib/groupsort.ex | 0.870748 | 0.718249 | groupsort.ex | starcoder |
defmodule Clova do
@moduledoc """
A behaviour for Clova extentions.
An implementation of this behaviour will be called by the `Clova.DispatcherPlug`.
Each callback is called with a map representing the decoded clova request, and a struct representing the
clova response. Helpers from the `Clova.Request` and ... | lib/clova.ex | 0.890211 | 0.639237 | clova.ex | starcoder |
defmodule Unzip do
@moduledoc """
Module to get files out of a zip. Works with local and remote files
## Overview
Unzip tries to solve problem of accessing files from a zip which is not local (Aws S3, sftp etc). It does this by simply separating file system and zip implementation. Anything which implements `Un... | lib/unzip.ex | 0.792865 | 0.611962 | unzip.ex | starcoder |
defmodule Clova.DispatcherPlug do
import Plug.Conn
@behaviour Plug
@moduledoc """
A plug for dispatching CEK request to your `Clova` implementation.
For simple skills, `Clova.SkillPlug` provides a wrapper of this and related plugs.
Pass your callback module as the `dispatch_to` argument to the plug.
T... | lib/clova/dispatcher_plug.ex | 0.784113 | 0.728845 | dispatcher_plug.ex | starcoder |
defmodule Zaryn.Crypto.ID do
@moduledoc false
alias Zaryn.Crypto
@doc """
Get an identification from a elliptic curve name
## Examples
iex> ID.from_curve(:ed25519)
0
iex> ID.from_curve(:secp256r1)
1
"""
@spec from_curve(Crypto.supported_curve()) :: integer()
def from_curve(:... | lib/zaryn/crypto/id.ex | 0.907224 | 0.414691 | id.ex | starcoder |
defmodule Grizzly.ZWave.Commands.NodeRemoveStatus do
@moduledoc """
Z-Wave command for NODE_REMOVE_STATUS
This command is useful to respond to a `Grizzly.ZWave.Commands.NodeRemove`
command.
Params:
* `:seq_number` - the sequence number from the original node remove command
* `:status` - the status ... | lib/grizzly/zwave/commands/node_remove_status.ex | 0.811937 | 0.753217 | node_remove_status.ex | starcoder |
defmodule Tune.Demands do
@moduledoc """
The Tune.Demands context.
"""
import Ecto.Query, warn: false
alias Tune.Repo
alias Tune.Demands.OnlineConcertDemand
@doc """
Returns the list of online_concert_demands.
## Examples
iex> list_online_concert_demands()
[%OnlineConcertDemand{}, ...... | lib/tune/tune/demands.ex | 0.792464 | 0.404831 | demands.ex | starcoder |
defmodule EspEx.StreamName do
alias StreamName
@moduledoc """
A StreamName is a module to manage the location where events are written.
Think of stream names as a URL for where your events are located.
The StreamName struct provides an easy way to access the data that otherwise
would be in a String, which ... | lib/esp_ex/stream_name.ex | 0.882035 | 0.5835 | stream_name.ex | starcoder |
defmodule ChallengeGov.Analytics do
@moduledoc """
Analytics context
"""
@behaviour Stein.Filter
import Ecto.Query
alias ChallengeGov.Challenges.Challenge
alias ChallengeGov.Repo
alias Stein.Filter
def get_challenges(opts \\ []) do
Challenge
|> where([c], not is_nil(c.start_date))
|> wh... | lib/challenge_gov/analytics.ex | 0.742141 | 0.591251 | analytics.ex | starcoder |
defmodule Grizzly.ZWave.Commands.NodeAddDSKReport do
@moduledoc """
The Z-Wave Command `NODE_ADD_DSK_REPORT`
This report is used by the including controller to ask for the DSK
for the device that is being included.
## Params
- `:seq_number` - sequence number for the command (required)
- `:input_dsk... | lib/grizzly/zwave/commands/node_add_dsk_report.ex | 0.853257 | 0.417093 | node_add_dsk_report.ex | starcoder |
defmodule Resourceful.Type.Ecto do
@moduledoc """
Creates a `Resourceful.Type` from an `Ecto.Schema` module. The use case
is that internal data will be represented by the schema and client-facing data
will be represented by the resource definition. Additionally, field names may
be mapped differently to the cl... | lib/resourceful/type/ecto.ex | 0.913382 | 0.674265 | ecto.ex | starcoder |
defmodule Aja do
@moduledoc ~S"""
Convenience macros to work with Aja's data structures.
Use `import Aja` to import everything, or import only the macros you need.
"""
@doc ~S"""
A sigil to build [IO data](https://hexdocs.pm/elixir/IO.html#module-io-data) and avoid string concatenation.
Use `import Aja... | lib/aja.ex | 0.775817 | 0.653459 | aja.ex | starcoder |
defmodule MarsRover.Rover do
@moduledoc """
A rover implementation. It can be sent to planets.
"""
use GenServer
defstruct [:planet, :coordinates, :direction]
# Initialization
@spec start_link(atom() | pid(), Int.t(), Int.t(), atom()) :: :ignore | {:error, any()} | {:ok, pid()}
def start_link(planet, ... | lib/rover.ex | 0.86968 | 0.742935 | rover.ex | starcoder |
defmodule Aoc2018.Day01 do
alias Aoc2018.Day01
@doc """
--- Day 1: Chronal Calibration ---
"We've detected some temporal anomalies," one of Santa's Elves at the Temporal
Anomaly Research and Detection Instrument Station tells you. She sounded
pretty worried when she called you down here. "At 500-year inter... | 2018_elixir/aoc_2018/lib/aoc_2018/day_01.ex | 0.735262 | 0.763792 | day_01.ex | starcoder |
defmodule Phoenix.LiveView.JS do
@moduledoc ~S'''
Provides commands for executing JavaScript utility operations on the client.
JS commands support a variety of utility operations for common client-side
needs, such as adding or removing CSS classes, setting or removing tag attributes,
showing or hiding conten... | lib/phoenix_live_view/js.ex | 0.909944 | 0.545588 | js.ex | starcoder |
defmodule BlueJet.Query do
@moduledoc """
This module defines some common query functions used when implementing service functions.
This module also defines the functions that a query module should implement in
order to be used with default service functions.
"""
import Ecto.Query
alias Ecto.Query
@c... | lib/blue_jet/core/query.ex | 0.670069 | 0.53783 | query.ex | starcoder |
defmodule ControlNode.Host.SSH do
@moduledoc """
"""
require Logger
@enforce_keys [:host, :port, :user, :private_key_dir]
defstruct host: nil,
port: 22,
epmd_port: 4369,
user: nil,
private_key_dir: nil,
conn: nil,
hostname: nil,
... | lib/control_node/host/ssh.ex | 0.660501 | 0.433262 | ssh.ex | starcoder |
defmodule Game.Config do
@moduledoc """
Hold Config to not query as often
"""
alias Data.Config
alias Data.Repo
alias Data.Save
alias Data.Stats
@color_config %{
color_home_header: "#268bd2",
color_home_link: "#268bd2",
color_home_link_hover: "#31b5ff",
color_home_primary: "#268bd2",
... | lib/game/config.ex | 0.713032 | 0.419707 | config.ex | starcoder |
defmodule WebSockex.ApplicationError do
@moduledoc false
defexception [:reason]
def message(%__MODULE__{reason: :not_started}) do
"""
The :websockex application is not started.
Please start the applications with Application.ensure_all_started(:websockex)
"""
end
end
defmodule WebSockex.ConnErr... | lib/websockex/errors.ex | 0.699562 | 0.404272 | errors.ex | starcoder |
defmodule ExPaint.Image do
@moduledoc false
@type t :: pid
use GenServer
alias ExPaint.{Color, Font}
def start_link(opts \\ []) do
GenServer.start_link(__MODULE__, opts)
end
def destroy(pid) do
GenServer.stop(pid)
end
def dimensions(pid) do
GenServer.call(pid, :dimensions)
end
d... | lib/ex_paint/image.ex | 0.779364 | 0.449272 | image.ex | starcoder |
defmodule PhoenixChannelClient do
@moduledoc """
Phoenix Channels Client
### Example
```
{:ok, pid} = PhoenixChannelClient.start_link()
{:ok, socket} = PhoenixChannelClient.connect(pid,
host: "localhost",
path: "/socket/websocket",
params: %{token: "something"},
secure: false)
channel =... | lib/phoenix_channel_client.ex | 0.902166 | 0.59749 | phoenix_channel_client.ex | starcoder |
defmodule Mix.Tasks.Compile.Erlang do
alias :epp, as: Epp
alias :digraph, as: Graph
alias :digraph_utils, as: GraphUtils
use Mix.Task
@hidden true
@shortdoc "Compile Erlang source files"
@recursive true
@manifest ".compile.erlang"
@moduledoc """
A task to compile Erlang source files.
When this... | lib/mix/lib/mix/tasks/compile.erlang.ex | 0.846831 | 0.619327 | compile.erlang.ex | starcoder |
defmodule Xema.JsonSchema do
@moduledoc """
Converts a JSON Schema to Xema source.
"""
alias Xema.{
JsonSchema.Validator,
Schema,
SchemaError
}
@type json_schema :: true | false | map
@type opts :: [draft: String.t()]
@drafts ~w(draft4 draft6 draft7)
@schema ~w(
additional_items
... | lib/xema/json_schema.ex | 0.896457 | 0.436562 | json_schema.ex | starcoder |
defmodule Absinthe.Type.Enum do
@moduledoc """
Used to define an enum type, a special scalar that can only have a defined set
of values.
See the `t` type below for details and examples.
## Examples
Given a type defined as the following (see `Absinthe.Schema.Notation`):
```
@desc "The selected color ... | lib/absinthe/type/enum.ex | 0.925559 | 0.937153 | enum.ex | starcoder |
defmodule WHATWG.Infra do
@moduledoc """
Functions for [Infra Standard](https://infra.spec.whatwg.org).
"""
@doc """
Returns `true` if `term` is an integer for a surrogate; otherwise returns `false`.
> A **surrogate** is a code point that is in the range U+D800 to U+DFFF, inclusive.
"""
defguard is_su... | lib/whatwg/infra.ex | 0.906275 | 0.618939 | infra.ex | starcoder |
defmodule Faker.Name.En do
import Faker, only: [sampler: 2]
@moduledoc """
Functions for name data in English
"""
@doc """
Returns a complete name (may include a suffix/prefix or both)
## Examples
iex> Faker.Name.En.name()
"Mrs. <NAME> MD"
iex> Faker.Name.En.name()
"<NAME>"
... | lib/faker/name/en.ex | 0.650356 | 0.468487 | en.ex | starcoder |
defmodule AdventOfCode.Y2020.Day21 do
def run() do
parsed =
AdventOfCode.Helpers.Data.read_from_file_no_split("2020/day21.txt")
|> parse()
{solve1(parsed), solve2(parsed)}
end
def solve1(parsed) do
safe_ingredients = allergen_free(parsed)
parsed
|> Stream.flat_map(fn {_, ingredi... | lib/2020/day21.ex | 0.557966 | 0.538194 | day21.ex | starcoder |
defmodule RayTracer.Tasks.Chapter10 do
@moduledoc """
This module tests camera from Chapter 10
"""
alias RayTracer.RTuple
alias RayTracer.Sphere
alias RayTracer.Plane
alias RayTracer.Canvas
alias RayTracer.Material
alias RayTracer.Color
alias RayTracer.Light
alias RayTracer.World
alias RayTrace... | lib/tasks/chapter10.ex | 0.900876 | 0.566468 | chapter10.ex | starcoder |
defmodule Cloudinary.Transformation.Color do
@moduledoc """
The color type definition for transformation parameters.
"""
@typedoc """
The color represented by a RGB/RGBA hex triplet or a color name string.
It treats a `t:charlist/0` (like `'a0fc72'`) as a hex triplet and a `t:String.t/0` (like
`"green"`)... | lib/cloudinary/transformation/color.ex | 0.913768 | 0.412826 | color.ex | starcoder |
defmodule Game.Overworld do
@moduledoc """
Overworld helpers
"""
@type cell :: %{x: integer(), y: integer()}
@sector_boundary 10
@view_distance 10
@doc """
Break up an overworld id
"""
@spec split_id(String.t()) :: {integer(), cell()}
def split_id(overworld_id) do
try do
[zone_id, cel... | lib/game/overworld.ex | 0.69451 | 0.630685 | overworld.ex | starcoder |
defmodule Riptide.Store.LMDB do
@moduledoc """
This store persists data to [LMDB](https://symas.com/lmdb/) using a bridge built in Rust. LMDB is a is a fast, memory mapped key value store that is persisted to a single file. It's a great choice for many projects that need persistence but want to avoid the overhead o... | packages/elixir/lib/riptide/store/store_lmdb.ex | 0.88257 | 0.872619 | store_lmdb.ex | starcoder |
defmodule Maple.Helpers do
@moduledoc """
Helper functions to create the dybamic function in the macro. Helps
keep the code somewhat clean and maintainable
"""
require Logger
def apply_type(response, func) do
result = response[func[:name]]
cond do
is_list(result) ->
result
|> ... | lib/maple/helpers.ex | 0.708313 | 0.459743 | helpers.ex | starcoder |
defmodule BinaryHeap do
defstruct data: [], comparator: nil
@moduledoc """
BinaryHeapの実装
## ノード `n` (ノード番号0から開始)
`parent node` : div(n - 1, 2)
`children node` : 2n + 1, 2n + 2
## ノード `n` (ノード番号1から開始)
`parent node` : div(n, 2)
`children node` : 2n, 2n + 1
"""
@behaviour Heapable
... | lib/algs/heap/binary_heap.ex | 0.817064 | 0.484441 | binary_heap.ex | starcoder |
defmodule Telemetry.Metrics.ConsoleReporter do
@moduledoc """
A reporter that prints events and metrics to the terminal.
This is useful for debugging and discovering all available
measurements and metadata in an event.
For example, imagine the given metrics:
metrics = [
last_value("vm.memory.... | lib/telemetry_metrics/console_reporter.ex | 0.776877 | 0.443661 | console_reporter.ex | starcoder |
defmodule Ratatouille.Runtime do
@moduledoc """
A runtime for apps implementing the `Ratatouille.App` behaviour. See
`Ratatouille.App` for details on how to build apps.
## Runtime Context
The runtime provides a map with additional context to the app's
`c:Ratatouille.App.init/1` callback. This can be used,... | lib/ratatouille/runtime.ex | 0.84497 | 0.521045 | runtime.ex | starcoder |
defmodule Xandra.Protocol.V4 do
@moduledoc false
use Bitwise
require Decimal
alias Xandra.{
Batch,
Error,
Frame,
Page,
Prepared,
Simple,
TypeParser
}
alias Xandra.Cluster.{StatusChange, TopologyChange}
@unix_epoch_days 0x80000000
# We need these two macros to make
# a... | lib/xandra/protocol/v4.ex | 0.566378 | 0.456955 | v4.ex | starcoder |
defmodule AWS.DataBrew do
@moduledoc """
AWS Glue DataBrew is a visual, cloud-scale data-preparation service.
DataBrew simplifies data preparation tasks, targeting data issues that are hard
to spot and time-consuming to fix. DataBrew empowers users of all technical
levels to visualize the data and perform o... | lib/aws/generated/data_brew.ex | 0.77437 | 0.480235 | data_brew.ex | starcoder |
defmodule Tty2048.Grid do
@sides [:up, :down, :right, :left]
def new(size) when size > 0 do
make_grid(size)
|> seed |> seed
end
def move(grid, side)
when is_list(grid) and side in @sides do
case try_move(grid, side) do
:noop -> {grid, 0}
{:ok, grid, points} ->
{seed(grid), po... | lib/tty2048/grid.ex | 0.560734 | 0.734834 | grid.ex | starcoder |
if Code.ensure_loaded?(Oban) do
defmodule PromEx.Plugins.Oban do
@moduledoc """
This plugin captures metrics emitted by Oban. Specifically, it captures metrics from job events, producer events,
and also from internal polling jobs to monitor queue sizes
This plugin supports the following options:
... | lib/prom_ex/plugins/oban.ex | 0.877313 | 0.614914 | oban.ex | starcoder |
defmodule VintageNetMobile do
@behaviour VintageNet.Technology
alias VintageNet.Interface.RawConfig
@moduledoc """
Use cellular modems with VintageNet
This module is not intended to be called directly but via calls to `VintageNet`. Here's a
typical example:
```elixir
VintageNet.configure(
"ppp0"... | lib/vintage_net_mobile.ex | 0.846546 | 0.722772 | vintage_net_mobile.ex | starcoder |
defmodule ExVault do
@moduledoc """
TODO: Proper documentation for ExVault.
"""
alias ExVault.Response
@middleware [
Tesla.Middleware.JSON
]
@adapter Tesla.Adapter.Hackney
@typedoc """
Options:
* `:address` - Address of the Vault server to talk to. (Required)
* `:token` - The Vault token... | lib/exvault.ex | 0.607197 | 0.425038 | exvault.ex | starcoder |
defmodule XDR.Type.VariableArray do
@moduledoc """
A variable-length array of some other type
"""
alias XDR.Size
defstruct type_name: "VariableArray", data_type: nil, max_length: Size.max(), values: []
@type t() :: %__MODULE__{
type_name: String.t(),
data_type: XDR.Type.t(),
... | lib/xdr/types/variable_array.ex | 0.806967 | 0.486636 | variable_array.ex | starcoder |
defmodule HullSTL.Geometry do
alias Graphmath.Vec3, as: V
# dimensions in meters
@hboh 1.5 # half beam of hull at widest
@x_step_size 0.05
@x_steps trunc(@hboh / @x_step_size) # number of buttocks
@rib_spacing 20 # number of stations between transverse re-enforcement centers
@stringer_spacing 10 # numb... | lib/geometry.ex | 0.566498 | 0.677397 | geometry.ex | starcoder |
defmodule Goth do
@external_resource "README.md"
@moduledoc """
A Goth token server.
"""
use GenServer
require Logger
alias Goth.Backoff
alias Goth.Token
@registry Goth.Registry
@max_retries 20
@default_refresh_after 3_300_000
@doc """
Starts the server.
When the server is started, we... | lib/goth.ex | 0.878503 | 0.540621 | goth.ex | starcoder |
defmodule ExDiceRoller.Compilers.Roll do
@moduledoc """
Handles compiling dice roll expressions.
iex> expr = "1d6"
"1d6"
iex> {:ok, tokens} = ExDiceRoller.Tokenizer.tokenize(expr)
{:ok, [{:int, 1, '1'}, {:roll, 1, 'd'}, {:int, 1, '6'}]}
iex> {:ok, parse_tree} = ExDiceRoller.Parser.par... | lib/compilers/roll.ex | 0.831383 | 0.468304 | roll.ex | starcoder |
defmodule Wormwood.GQLCase do
@moduledoc """
This module defines a few helpful macros when testing against an Absinthe GraphQL schema.
It essentially registers an Absinthe schema and a GQL document to the module they're called in.
"""
alias Wormwood.GQLLoader
defmacro __using__(_opts) do
quote do
... | lib/gql_case.ex | 0.819785 | 0.841956 | gql_case.ex | starcoder |
defmodule Oban.Validation do
@moduledoc false
@type validator :: ({atom(), term()} -> :ok | {:error, term()})
@doc """
A utility to help validate options without resorting to `throw` or `raise` for control flow.
## Example
Ensure all keys are known and the correct type:
iex> Oban.Validation.valid... | lib/oban/validation.ex | 0.863852 | 0.505798 | validation.ex | starcoder |
defmodule Instream.Series.Hydrator do
@moduledoc false
alias Instream.Decoder.RFC3339
@doc """
Converts a plain map into a series definition struct.
Keys not defined in the series are silently dropped.
"""
@spec from_map(module, map) :: struct
def from_map(series, data) do
data_fields = Map.take(... | lib/instream/series/hydrator.ex | 0.826887 | 0.739681 | hydrator.ex | starcoder |
defmodule BatchElixir do
alias BatchElixir.RestClient.Transactional
alias BatchElixir.RestClient.Transactional.Message
alias BatchElixir.RestClient.Transactional.Recipients
alias BatchElixir.Serialisation
alias BatchElixir.Server.Producer
@moduledoc """
Documentation for BatchElixir.
Rest client for in... | lib/batch_elixir.ex | 0.781664 | 0.530419 | batch_elixir.ex | starcoder |
defmodule Omise.Schedule do
@moduledoc ~S"""
Provides Schedule API interfaces.
<https://www.omise.co/schedules-api>
"""
use Omise.HTTPClient, endpoint: "schedules"
defstruct object: "schedule",
id: nil,
livemode: nil,
location: nil,
status: nil,
... | lib/omise/schedule.ex | 0.923592 | 0.444022 | schedule.ex | starcoder |
defmodule OMG.ChildChain.BlockQueue do
@moduledoc """
Manages the process of submitting new blocks to the root chain contract.
On startup uses information persisted in `OMG.DB` and the root chain contract to recover the status of the
submissions.
Tracks the current Ethereum height as well as the mined chil... | apps/omg_child_chain/lib/omg_child_chain/block_queue.ex | 0.874097 | 0.635279 | block_queue.ex | starcoder |
defmodule Mix.Tasks.Uiar do
@moduledoc """
Formats given source codes to follow coding styles below:
* Directives are grouped and ordered as `use`, `import`, `alias` and `require`.
* Each group of directive is separated by an empty line.
* Directives of the same group are ordered alphabetically.
* I... | lib/mix/tasks/uiar.ex | 0.841809 | 0.447098 | uiar.ex | starcoder |
defmodule BitstylesPhoenix.Showcase do
@moduledoc false
import Phoenix.HTML, only: [safe_to_string: 1]
import Phoenix.HTML.Tag, only: [content_tag: 3]
@doctest_entries ["iex>", "...>"]
defmacro story(name, example, opts \\ []) do
code =
example
|> to_string()
|> String.split("\n")
... | lib/bitstyles_phoenix/showcase.ex | 0.614394 | 0.423726 | showcase.ex | starcoder |
defmodule :erl_syntax do
# Types
@type forms :: (syntaxTree() | [syntaxTree()])
@type padding :: (:none | integer())
@type syntaxTree :: (tree() | wrapper() | erl_parse())
@type syntaxTreeAttributes :: attr()
# Private Types
@typep encoding :: (:utf8 | :unicode | :latin1)
@typep erl_parse :: (:e... | testData/org/elixir_lang/beam/decompiler/erl_syntax.ex | 0.773644 | 0.472379 | erl_syntax.ex | starcoder |
import Kernel, except: [round: 1]
defmodule Float do
@moduledoc """
Functions for working with floating point numbers.
"""
@doc """
Parses a binary into a float.
If successful, returns a tuple of the form `{float, remainder_of_binary}`.
Otherwise `:error`.
If a float formated string wants to be dire... | lib/elixir/lib/float.ex | 0.934245 | 0.670325 | float.ex | starcoder |
defmodule Twirp.Telemetry do
@moduledoc """
Provides telemetry for twirp clients and servers
Twirp executes the following events:
* `[:twirp, :rpc, :start]` - Executed before making an rpc call to another service.
#### Measurements
* `:system_time` - The system time
#### Metadata
* `... | lib/twirp/telemetry.ex | 0.844922 | 0.609698 | telemetry.ex | starcoder |
## matched at unqualified no parentheses call
@one @two 3 do
end
## matched dot call
@one two . () do
end
## matched qualified no arguments call
@one Two . three do
end
## matched qualified no parentheses call
@one Two . three 4 do
end
## matched qualified parentheses call
@one Two . three() do
end
## matched unq... | testData/org/elixir_lang/formatting/incorrect_spaces_around_dot_operator.ex | 0.635675 | 0.507385 | incorrect_spaces_around_dot_operator.ex | starcoder |
defmodule StepFlow.WorkflowDefinitionView do
use StepFlow, :view
alias StepFlow.WorkflowDefinitionView
def render("index.json", %{workflow_definitions: %{data: workflow_definitions, total: total}}) do
%{
data: render_many(workflow_definitions, WorkflowDefinitionView, "workflow_definition.json"),
... | lib/step_flow/view/workflow_definition_view.ex | 0.616474 | 0.511229 | workflow_definition_view.ex | starcoder |
defmodule ExState.Ecto.Query do
@moduledoc """
`ExState.Ecto.Query` provides functions for querying workflow state in the
database through Ecto.
"""
import Ecto.Query
@doc """
where_state/2 takes a subject query and state and filters based on workflows that are in the
exact state that is passed. Neste... | lib/ex_state/ecto/query.ex | 0.772659 | 0.655295 | query.ex | starcoder |
defmodule Monet.Query.Select do
@moduledoc """
A simple query builder.
rows = Select.new()
|> Select.columns("u.id, u.name")
|> Select.from("users u")
|> Select.join("roles r on u.role_id = r.id")
|> Select.where("u.power", :gt, 9000)
|> Select.limit(100)
|> Select.exec!() // returns a Monet.Re... | lib/query/select.ex | 0.611266 | 0.521532 | select.ex | starcoder |
defmodule Snitch.Domain.Taxonomy do
@moduledoc """
Interface for handling Taxonomy. It provides functions to modify Taxonomy.
"""
use Snitch.Domain
use Snitch.Data.Model
import AsNestedSet.Modifiable
import AsNestedSet.Queriable, only: [dump_one: 2]
import Ecto.Query
alias Ecto.Multi
alias Snitch... | apps/snitch_core/lib/core/domain/taxonomy/taxonomy.ex | 0.700075 | 0.476214 | taxonomy.ex | starcoder |
defmodule TwitchApi.Client do
alias TwitchApi.Util.Params
@moduledoc """
Builds the client for the API wrapper
"""
@typedoc """
Credentials
"""
@type auth :: %{client_id: String.t(), client_secret: String.t()}
@typedoc """
The client struct
"""
@type t :: %__MODULE__{auth: auth | nil}
defs... | lib/client.ex | 0.874527 | 0.448487 | client.ex | starcoder |
defmodule Quadquizaminos.Instructions do
def game_instruction() do
"""
<h2>Explore Cyber Security's Most Important Emerging Strategic Focus with the Digital Era's Most Beloved Game</h2>
<h2>Power Up!</h2>
<p>You don't need to be a supply chain expert - this game assumes you are a novice
and it teaches ... | lib/quadquizaminos/instructions.ex | 0.551332 | 0.746116 | instructions.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.