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 Brando.Query do
@moduledoc """
Query macros to DRY up contexts
# Mutations
```
mutation :create, Post
mutation :update, Post
mutation :delete, Post
mutation :duplicate, {
Post,
change_fields: [:title],
delete_fields: [:comments],
merge_fiel... | lib/brando/query.ex | 0.873242 | 0.760651 | query.ex | starcoder |
defmodule Broadway do
@moduledoc ~S"""
Broadway is a concurrent, multi-stage tool for building
data ingestion and data processing pipelines.
It allows developers to consume data efficiently from different
sources, such as Amazon SQS, RabbitMQ and others.
## Built-in features
* Back-pressure - by rely... | lib/broadway.ex | 0.859428 | 0.854642 | broadway.ex | starcoder |
defmodule ExVatcheck.Countries do
@moduledoc """
A module for checking to see whether or not a VAT matches one of the expected
patterns for EU countries. Countries handled include:
```
AT: Austria
BE: Belgium
BG: Bulgaria
CY: Cyprus
CZ: Czech Republic
DE: Germany
DK: Denmark
EE: Estonia
EL: G... | lib/ex_vatcheck/countries.ex | 0.733547 | 0.734524 | countries.ex | starcoder |
defmodule Mongo.Ecto.Conversions do
@moduledoc false
import Mongo.Ecto.Utils
def to_ecto_pk(%Ecto.Query.Tagged{type: type, value: value}) do
{:ok, dumped} = Ecto.Type.adapter_dump(Mongo.Ecto, type, value)
dumped
end
def to_ecto_pk(%{__struct__: _} = value, _pk), do: value
def to_ecto_pk(map, pk)... | lib/mongo_ecto/conversions.ex | 0.61231 | 0.439386 | conversions.ex | starcoder |
defmodule Day24 do
def part1(input) do
parse(input)
|> Enum.reduce(MapSet.new(), &flip_tiles/2)
|> MapSet.size
end
def part2(input) do
parse(input)
|> Enum.reduce(MapSet.new(), &flip_tiles/2)
|> Stream.iterate(&one_day/1)
|> Stream.drop(100)
|> Enum.take(1)
|> hd
|> Enum.c... | day24/lib/day24.ex | 0.702224 | 0.4436 | day24.ex | starcoder |
defmodule CRUDimentary.Policy do
@moduledoc """
This module generates and defines set of overridable functions which regulate scope of access
and action authorization based on the current account properties.
"""
defmacro __using__(_) do
quote do
def scope(queryable, _current_account, _parent) do
... | lib/crudimentary/policy.ex | 0.574514 | 0.402568 | policy.ex | starcoder |
defmodule Rolodex do
@moduledoc """
Rolodex generates documentation for your Phoenix API.
Rolodex inspects a Phoenix Router and transforms the `@doc` annotations on your
controller actions into documentation data in the format of your choosing.
`Rolodex.run/1` encapsulates the full documentation generation ... | lib/rolodex.ex | 0.875814 | 0.614452 | rolodex.ex | starcoder |
defmodule LogicalFile.Macros.LineComment do
@behaviour LogicalFile.Macro
alias LogicalFile.Section
@moduledoc """
A sample implementation of a macro that supports single-line comments where
a comment expression is recognised at the beginning of a line and it
transforms the entire content of that line into... | lib/logical_file/macros/line_comment.ex | 0.631594 | 0.60855 | line_comment.ex | starcoder |
defmodule Sanbase.Influxdb.Store do
@moduledoc """
Contains common logic for operating working with InfluxDB.
This module should be used be declaring:
```
use Sanbase.Influxdb.Store
```
"""
defmacro __using__(_options \\ []) do
quote do
use Instream.Connection, otp_app: :sanbase
... | lib/sanbase/influxdb/store.ex | 0.817429 | 0.576602 | store.ex | starcoder |
defmodule Aoc2019.Day10 do
@behaviour DaySolution
def solve_part1(),
do: input_map() |> parse_asteroids() |> best_location() |> (fn {_, count} -> count end).()
def solve_part2() do
{station_coord, _} = input_map() |> parse_asteroids() |> best_location()
input_map()
|> parse_asteroids()
|> v... | lib/aoc2019/day10.ex | 0.718594 | 0.549943 | day10.ex | starcoder |
defmodule Process do
@moduledoc """
Conveniences for working with processes and the process dictionary.
Besides the functions available in this module, the `Kernel` module
exposes and auto-imports some basic functionality related to processes
available through the following functions:
* `Kernel.spawn/1`... | lib/elixir/lib/process.ex | 0.884358 | 0.652878 | process.ex | starcoder |
defmodule Poison.Decode do
def decode(value, options) when is_map(value) or is_list(value) do
case options[:as] do
nil -> value
as -> transform(value, options[:keys], as, options)
end
end
def decode(value, _options) do
value
end
defp transform(nil, _keys, _as, _options), do: nil
d... | lib/poison/decoder.ex | 0.536799 | 0.457258 | decoder.ex | starcoder |
defmodule ExDiceRoller.ListComprehension do
@moduledoc """
Contains functionality for list comphrensions in ExDiceRoller.
ExDiceRoller also has a certain amount of list comprehension support when
calculating dice roll equations and 'keeping' rolls. The default behavior when
working with kept rolls is as foll... | lib/list_comprehension.ex | 0.877089 | 0.827967 | list_comprehension.ex | starcoder |
defmodule AWS.KinesisVideoMedia do
@moduledoc """
<p/>
"""
@doc """
Use this API to retrieve media content from a Kinesis video stream. In the
request, you identify the stream name or stream Amazon Resource Name (ARN),
and the starting chunk. Kinesis Video Streams then returns a stream of
chunks in or... | lib/aws/generated/kinesis_video_media.ex | 0.821438 | 0.569224 | kinesis_video_media.ex | starcoder |
defmodule Aino.Token do
@moduledoc """
The token is what flows through the entire web request
This module contains helper functions for dealing with the token, setting
common fields for responses or looking up request fields.
At the end of a middleware chain, the token _must_ contain three keys:
- `:resp... | lib/aino/token.ex | 0.839471 | 0.72594 | token.ex | starcoder |
defprotocol Calendar.ContainsTime do
@doc """
Returns a Calendar.Time struct for the provided argument
"""
def time_struct(data)
end
defmodule Calendar.Time do
@moduledoc """
The Time module provides a struct to represent a simple time without
specifying a date, nor a time zone.
"""
@doc """
Takes... | lib/calendar/time.ex | 0.913551 | 0.57821 | time.ex | starcoder |
defmodule Raxx.Session.SignedCookie do
@moduledoc """
Use signed cookies to store the session for a client.
Sessions stored this way are signed to ensure that they have not been tampered.
The secret given to config must be kept secure to prevent sessions being tampered
**NOTE:** the session is not encrypted... | lib/raxx/session/signed_cookie.ex | 0.820182 | 0.403214 | signed_cookie.ex | starcoder |
defmodule FarmbotCore.Log do
@moduledoc """
This is _not_ the same as the API's log asset.
"""
alias FarmbotCore.{Log, Project}
defmodule LogLevelType do
@moduledoc false
@level_atoms [:debug, :info, :error, :warn, :busy, :success, :fun, :assertion]
@level_strs ["debug", "info", "error", "warn", ... | farmbot_core/lib/farmbot_core/log_storage/log.ex | 0.732113 | 0.552419 | log.ex | starcoder |
import Kernel, except: [inspect: 1]
import Inspect.Algebra
defrecord Inspect.Opts, raw: false, limit: 50, pretty: false, width: 80
defprotocol Inspect do
@moduledoc """
The `Inspect` protocol is responsible for converting any Elixir
data structure into an algebra document. This document is then
formatted, eit... | lib/elixir/lib/inspect.ex | 0.840455 | 0.644505 | inspect.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.713631 | 0.40642 | taxonomy.ex | starcoder |
defmodule Benchee.Conversion.Duration do
@moduledoc """
Unit scaling for duration converting from microseconds to minutes and others.
"""
alias Benchee.Conversion.{Format, Scale, Unit}
@behaviour Scale
@behaviour Format
@nanoseconds_per_microsecond 1000
@microseconds_per_millisecond 1000
@milliseco... | lib/benchee/conversion/duration.ex | 0.923256 | 0.696188 | duration.ex | starcoder |
defmodule LearnKit.Regression.Linear.Calculations do
@moduledoc """
Module for fit functions
"""
alias LearnKit.{Math, Regression.Linear}
defmacro __using__(_opts) do
quote do
defp do_fit("gradient descent", %Linear{factors: factors, results: results}) do
gradient_descent_iteration(
... | lib/learn_kit/regression/linear/calculations.ex | 0.854278 | 0.764979 | calculations.ex | starcoder |
defmodule FlowAssertions.NoValueA do
use FlowAssertions.Define
alias FlowAssertions.Messages
@moduledoc """
These assertions assume a convention of initializing keys in a map
to an "I have no value" value, with the expectation that they
will later be given real values.
Such a convention is useful in mul... | lib/no_value_a.ex | 0.846879 | 0.868437 | no_value_a.ex | starcoder |
defmodule ExAlgebra.Vector do
@moduledoc """
The ExAlgebra Vector module is a collection of functions that perform
computations on vectors. Vectors are represented by lists of numbers.
"""
import :math, only: [sqrt: 1, acos: 1]
alias ExAlgebra.Matrix, as: Matrix
@doc """
Computes the addition of two v... | lib/Vector/vector.ex | 0.943517 | 0.856992 | vector.ex | starcoder |
defmodule Specify.Provider.Process do
@moduledoc """
A Configuration Provider source based on the current process' Process Dictionary.
### Examples
The following examples use the following specification for reference:
defmodule Elixir.Pet do
require Specify
Specify.defconfig do
... | lib/specify/provider/process.ex | 0.659734 | 0.457318 | process.ex | starcoder |
defmodule AlertProcessor.Reminders.Processor.SubscriptionsToRemind do
@moduledoc """
Responsible for determining which subscriptions should be sent a reminder for
a given alert and list of most recently sent notifications.
"""
alias AlertProcessor.NotificationWindowFilter
alias AlertProcessor.Model.{Alert... | apps/alert_processor/lib/reminders/processor/subscriptions_to_remind.ex | 0.743354 | 0.422832 | subscriptions_to_remind.ex | starcoder |
defmodule Surface.API do
@moduledoc false
alias Surface.IOHelper
@types [
:any,
:css_class,
:list,
:event,
:boolean,
:string,
:time,
:date,
:datetime,
:naive_datetime,
:number,
:integer,
:decimal,
:map,
:fun,
:atom,
:module,
:changeset,
... | lib/surface/api.ex | 0.71602 | 0.406509 | api.ex | starcoder |
defmodule Metalove.Enclosure do
@moduledoc """
Defines a `Metalove.Enclosure` struct representing enclosures in `Metalove.Episode`s. Provides access to parsed metadata.
"""
# <enclosure length="8727310" type="audio/x-m4a" url="http://example.com/podcasts/everything/AllAboutEverythingEpisode3.m4a"/>
alias Met... | lib/metalove/enclosure.ex | 0.888057 | 0.405449 | enclosure.ex | starcoder |
defmodule ParallelTask do
@moduledoc """
Elixir library to run multiple functions in parallel and capture the results.
Suitable for multiple slow tasks such as API calls and database queries which can be performed concurrently. The process will be blocked until all functions have returned or the timeout has been... | lib/parallel_task.ex | 0.832849 | 0.597461 | parallel_task.ex | starcoder |
defmodule State do
@moduledoc """
State used by all server types.
### Persistent state on all servers
(Updated on stable storage before responding to RPCs)
- `current_term`
- `voted_for`
- `log`
### Volatile state on all servers
- `commit_index`
- `last_applied`
### Volatile state on leaders... | lib/raft/server/state.ex | 0.810216 | 0.629604 | state.ex | starcoder |
defmodule Mix.Tasks.Hex.Build do
use Mix.Task
@shortdoc "Builds a new package version locally"
@moduledoc """
Builds a new local version of your package.
The package .tar file is created in the current directory, but is not pushed
to the repository. An app named `foo` at version `1.2.3` will be built as
... | lib/mix/tasks/hex.build.ex | 0.857887 | 0.456046 | hex.build.ex | starcoder |
defmodule Membrane.Realtimer do
@moduledoc """
Sends buffers to the output in real time, according to buffers' timestamps.
If buffers come in slower than realtime, they're sent as they come in.
"""
use Membrane.Filter
def_input_pad :input, caps: :any, demand_unit: :buffers
def_output_pad :output, caps: ... | lib/membrane/realtimer.ex | 0.842863 | 0.438545 | realtimer.ex | starcoder |
defmodule Rummage.Ecto.Schema.Sort do
@moduledoc """
Usage:
```elixir
defmodule MyApp.Rummage.MyModel.Sort do
use Rummage.Schema.Sort,
default_name: "inserted_at",
handlers: [
category_name: %{field: :name, assoc: [inner: :category], ci: true},
name: %{ci: true},
price:... | lib/rummage_ecto/schema/sort.ex | 0.63409 | 0.708944 | sort.ex | starcoder |
defmodule Plaid.Employer do
@moduledoc """
[Plaid Employer API](https://plaid.com/docs/api/employers/) calls and schema.
🏗 I haven't tested this yet against the actual plaid API because I can't get the
`deposit_switch` product in plaid yet. If you test it, let me know and I can take
off the in-progress stat... | lib/plaid/employer.ex | 0.739799 | 0.458652 | employer.ex | starcoder |
defmodule AbsintheSdl do
import AbsintheSdl.Utils
@moduledoc """
Convert the json output of an introspection query into Graphql SDL syntax.
## Example
```
AbsintheSdl.encode!(Jason.decode!("swapi.json"))
```
Can be used to convert an Absinthe schema to SDL by using AbsintheSdl as the JSON
encoder.
... | lib/absinthe_sdl.ex | 0.771026 | 0.654664 | absinthe_sdl.ex | starcoder |
defmodule RDF.Statement do
@moduledoc """
Helper functions for RDF statements.
A RDF statement is either a `RDF.Triple` or a `RDF.Quad`.
"""
alias RDF.{BlankNode, IRI, Literal, Quad, Term, Triple}
import RDF.Guards
@type subject :: IRI.t | BlankNode.t
@type predicate :: IRI.t | BlankNode.t
@typ... | lib/rdf/statement.ex | 0.811228 | 0.557845 | statement.ex | starcoder |
defmodule Eva do
@moduledoc """
Eva interpreter.
"""
require Environment
@type expression() ::
integer()
| String.t()
| list()
| expression()
@doc """
Evaluates an expression in the given environment.
## Examples
iex> pid = Environment.global()
ie... | lib/eva.ex | 0.766687 | 0.591487 | eva.ex | starcoder |
defmodule ExWirecard.Middleware.XML do
@behaviour Tesla.Middleware
alias Tesla.Middleware.Headers
alias Tesla.Multipart
@moduledoc """
Encode requests and decode responses as XML.
This middleware requires [erlsom](https://hex.pm/packages/erlsom) as dependency.
Remember to add `{:erlsom, "~> 1.4"}` to ... | lib/ex_wirecard/middleware/xml.ex | 0.839997 | 0.691693 | xml.ex | starcoder |
defmodule Mix.Tasks.Compile.ElixirMake do
use Mix.Task
@recursive true
@moduledoc """
Runs `make` in the current project.
This task runs `make` in the current project; any output coming from `make` is
printed in real-time on stdout.
## Configuration
This compiler can be configured through the retur... | lib/mix/tasks/compile.make.ex | 0.83056 | 0.52902 | compile.make.ex | starcoder |
defmodule Rock do
alias Rock.Utils
alias Rock.Algorithm
@moduledoc """
ROCK: A Robust Clustering Algorithm for Categorical Attributes
"""
@doc """
Clusterizes points using the Rock algorithm with the provided arguments:
* `points`, points that will be clusterized
* `number_of_clusters`, the number ... | lib/rock.ex | 0.895071 | 0.767385 | rock.ex | starcoder |
defmodule AlertProcessor.Model.InformedEntity do
@moduledoc """
Entity to map to the informed entity information provided in an
Alert used to match to a subscription.
"""
alias AlertProcessor.Model.Subscription
@type facility_type ::
:bike_storage
| :electric_car_chargers
| :... | apps/alert_processor/lib/model/informed_entity.ex | 0.830457 | 0.401805 | informed_entity.ex | starcoder |
defmodule Explotter do
@moduledoc """
Documentation for Explotter.
"""
def new, do: Explot.new
def xlabel(agent, label), do: Explot.xlabel(agent, label)
def ylabel(agent, label), do: Explot.ylabel(agent, label)
def title(agent, label), do: Explot.title(agent, label)
def add_list(agent, list, l... | lib/explotter.ex | 0.647798 | 0.661942 | explotter.ex | starcoder |
defmodule StaffNotes.Notes do
@moduledoc """
Represents the business-logic layer of working with the records around the staff notes.
There are a few different record types:
* Comments - A comment on an Identity, Member, or Note
* Identity - Information on an identity of a member (whether GitHub, Twitter, em... | lib/staff_notes/notes.ex | 0.826292 | 0.815673 | notes.ex | starcoder |
defmodule Status do
@moduledoc false
@options [
commit: {false, &Status.System.commit/0},
timestamp: [
{true, &Status.Time.deploy/0},
{false, &Status.Time.build/0}
],
uptime: {true, &Status.Time.uptime/0},
version: {false, &Status.System.commit/0},
system: [
{true, &Status... | lib/status.ex | 0.588889 | 0.41837 | status.ex | starcoder |
defmodule QuickStruct do
@moduledoc """
Creates a struct with enforced keys, the type of the struct and
a make function to create the struct.
You have to "use" this module and give a list of fields or a
keyword list with fields and specs to create a struct.
As an alternative you can create a module and a ... | lib/quick_struct.ex | 0.854308 | 0.861945 | quick_struct.ex | starcoder |
defmodule Jorb do
@moduledoc ~S"""
# Jorb
I uh, I say you did a great _jorb_ out there
## What
Jorb is a simple queue-based jobs processing system for Elixir.
Works great with Amazon SQS.
## How
Define your job module:
```
defmodule HelloWorld.Job do
use Jorb.Job
def read_queues do
... | lib/jorb.ex | 0.802903 | 0.81637 | jorb.ex | starcoder |
defmodule TicTacToe.Board do
alias TicTacToe.Board
defstruct spots: {:blank, :blank, :blank, :blank, :blank, :blank, :blank, :blank, :blank},
dimension: 3
def winner(%Board{spots: {x, x, x,
_, _, _,
_, _, _}}) when x != :blank, do: x
def winn... | lib/tic_tac_toe/board.ex | 0.624179 | 0.706937 | board.ex | starcoder |
defmodule Bech32 do
@moduledoc """
This is an implementation of BIP-0173
Bech32 address format for native v0-16 witness outputs.
See https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki for details
"""
@gen {0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3}
use Bitwise
char_table... | lib/bech32.ex | 0.867584 | 0.535098 | bech32.ex | starcoder |
defmodule RDF.Turtle.Encoder do
@moduledoc """
An encoder for Turtle serializations of RDF.ex data structures.
As for all encoders of `RDF.Serialization.Format`s, you normally won't use these
functions directly, but via one of the `write_` functions on the `RDF.Turtle`
format module or the generic `RDF.Seria... | lib/rdf/serializations/turtle_encoder.ex | 0.874801 | 0.591487 | turtle_encoder.ex | starcoder |
defmodule WxObject do
@moduledoc """
wx_object - Generic wx object behaviour
This is a behaviour module that can be used for "sub classing"
wx objects. It works like a regular gen_server module and creates
a server per object.
NOTE: Currently no form of inheritance is implemented.
The user module should export:
i... | lib/WxObject.ex | 0.542621 | 0.683472 | WxObject.ex | starcoder |
defmodule Cassandra.Types do
@moduledoc """
Represents custom Cassandra types.
## Example
schema "posts" do
field :title, :string
field :text, :string
field :public, :boolean
field :tags, {:array, :string}
field :location, Cassandra.Types.Tuple
... | lib/cassandra_ecto/types.ex | 0.64579 | 0.497253 | types.ex | starcoder |
defmodule Harald.HCI.ErrorCodes do
@moduledoc """
Reference: version 5.2, vol 1, part f.
"""
@error_codes %{
0x00 => "Success",
0x01 => "Unknown HCI Command",
0x02 => "Unknown Connection Identifier",
0x03 => "Hardware Failure",
0x04 => "Page Timeout",
0x05 => "Authentication Failure",
... | lib/harald/hci/error_codes.ex | 0.650023 | 0.423875 | error_codes.ex | starcoder |
defmodule FusionDsl.Processor.AstProcessor do
@moduledoc """
Functions for converting tokens to Abstract syntax trees
## Ast structure:
```
{action_name_atom, [line_number], args_list}
```
"""
alias FusionDsl.Processor.CompileConfig
@clause_beginners ["if", "for", "while"]
@noops ["noop"]
@ope... | lib/fusion_dsl/processor/ast_processor.ex | 0.616705 | 0.790894 | ast_processor.ex | starcoder |
defmodule Reindeer do
defp distance(speed, run_time, rest_time, duration) do
iter_time = run_time + rest_time
speed * ((run_time * div(duration, iter_time)) + min(rem(duration, iter_time), run_time))
end
def run(reindeers = %{}, name, duration) do
{speed, run_time, rest_time} = Map.get(reindeers, nam... | advent_umbrella_2016/apps/day14/lib/reindeer.ex | 0.546254 | 0.470372 | reindeer.ex | starcoder |
defmodule AWS.StepFunctions do
@moduledoc """
AWS Step Functions
AWS Step Functions is a web service that enables you to coordinate the
components of distributed applications and microservices using visual
workflows. You build applications from individual components that each
perform a discrete function, ... | lib/aws/step_functions.ex | 0.884782 | 0.765582 | step_functions.ex | starcoder |
defmodule Calcinator.Authorization.Can do
@moduledoc """
`Calcinator.Authorization` where `filter_associations_can/3` and `filter_can/3` are implemented in terms of `can/3`,
so only `can/3` needs to be implemented.
"""
alias Calcinator.Authorization
# Types
@typedoc """
A module that implements the `... | lib/calcinator/authorization/can.ex | 0.891169 | 0.493592 | can.ex | starcoder |
defmodule Rolodex do
@moduledoc """
Rolodex generates documentation for your Phoenix API.
Rolodex transforms the structured `@doc` annotations on your Phoenix Controller
action functions into documentation API documentation in the format of your
choosing. Rolodex ships with default support for OpenAPI 3.0 (S... | lib/rolodex.ex | 0.850903 | 0.551815 | rolodex.ex | starcoder |
defmodule Perudex.Game do
@moduledoc """
Provides functions to manipulate a game of Perudex.
"""
alias __MODULE__
alias Perudex.Hand
defstruct [
:current_player_id,
:all_players,
:remaining_players,
:current_bid,
:players_hands,
:max_dice,
:instructions
]
@opaque t :: %Gam... | lib/game.ex | 0.89427 | 0.441312 | game.ex | starcoder |
defmodule Judgment.Majority do
@moduledoc """
Majority Judgment is a poll deliberation method with many benefits.
"""
@doc """
Resolve a poll according to Majority Judgment,
in order to get the rank of each proposal.
Returns a Judgment.Majority.PollResult struct.
## Example
Say you have two propos... | lib/judgment/majority.ex | 0.801548 | 0.541409 | majority.ex | starcoder |
defmodule Day12 do
def part1(input, steps) do
positions = read_positions(input)
moons = Enum.map(positions, & {&1, {0, 0, 0}})
Stream.iterate(moons, &update_moons/1)
|> Enum.at(steps)
|> Enum.map(&moon_energy/1)
|> Enum.sum
end
def part2(input) do
positions = read_positions(input)
... | day12/lib/day12.ex | 0.57332 | 0.526708 | day12.ex | starcoder |
defmodule Styx.SchemaRegistry.Definition.Value do
@nulltype "null"
@moduledoc """
Implements macros to generate required and optional fields
Available macros:
* required/2
* optional/2
## Use:
```
use Styx.SchemaRegistry.Definition.Value
required :username, :string
opt... | lib/styx/schema_registry/definition/value.ex | 0.797714 | 0.762291 | value.ex | starcoder |
defmodule Indulgences.Coordinator do
alias Indulgences.{Simulation, Activation}
def start(%Simulation{} = simulation) do
execute(simulation)
end
defp execute(
%Simulation{
activations: [%Activation{} = activation | others],
scenario: scenario,
configure: nil
... | lib/indulgences/coordinator.ex | 0.526586 | 0.502686 | coordinator.ex | starcoder |
defmodule Exgencode.Sizeof do
@moduledoc """
Helper functions for generating `sizeof/2` protocol function implementation.
"""
def build_sizeof(field_list) do
field_list
|> Enum.map(&build_size/1)
|> Enum.map(&build_conditional/1)
|> Enum.map(fn
{name, _props, {:fn, _, _} = size} ->
... | lib/exgencode/sizeof.ex | 0.564459 | 0.434701 | sizeof.ex | starcoder |
defmodule Day11.Robot do
defstruct direction: :up, location: {0, 0}
def panel_count() do
paint(0) |> Map.values |> Enum.count
end
def registration() do
canvas = paint(1)
{min_x, max_x} = canvas |> Map.keys |> Enum.map(fn({x, _y}) -> x end) |> Enum.min_max
{min_y, max_y} = canvas |> Map.keys |>... | year_2019/lib/day_11/robot.ex | 0.737631 | 0.575618 | robot.ex | starcoder |
defmodule AdaptableCostsEvaluator.Outputs do
@moduledoc """
The Outputs context.
"""
import Ecto.Query, warn: false
alias AdaptableCostsEvaluator.Repo
alias AdaptableCostsEvaluator.Outputs.Output
alias AdaptableCostsEvaluator.Computations.Computation
@doc """
Returns the list of outputs in the comp... | lib/adaptable_costs_evaluator/outputs.ex | 0.867191 | 0.454351 | outputs.ex | starcoder |
defmodule Forage.QueryBuilder.Filter do
@moduledoc false
import Forage.QueryBuilder.Filter.AddFilterToQuery
@doc """
Compile a list of filters from a forage plan into an Ecto query
"""
def joins_and_where_clause(filters) do
assocs = extract_non_empty_assocs(filters)
simple_filters = extrac... | lib/forage/query_builder/filter.ex | 0.698535 | 0.444083 | filter.ex | starcoder |
defmodule Matcha.Context.Common do
@moduledoc """
Functions and operators that any match specs can use in their bodies.
### Limitations
Neither `tuple_size/2` nor `is_record/2` are available here, though you'd expect them to be.
For various reasons, Matcha cannot support `is_record/2` and erlang does not su... | lib/matcha/context/common.ex | 0.676192 | 0.601125 | common.ex | starcoder |
defmodule OggVorbisParser do
@moduledoc """
A parser for VorbisComments in Ogg containers.
While it's possible to use Vorbis streams without Ogg containers or with different kinds of containers, this parser expects Ogg.
The relevant part of an Ogg Vorbis file starts with an Ogg capture pattern (a file signatu... | lib/ogg_vorbis_parser.ex | 0.808446 | 0.431405 | ogg_vorbis_parser.ex | starcoder |
defmodule Cashtrail.Entities.EntityMember do
@moduledoc """
This is an `Ecto.Schema` struct that represents a member of a
`Cashtrail.Entity` that links authorized users to the `Cashtrail.Entity`,
except the owner.
The EntityMember is a member of the entity. As a member of the entity, the user
can have perm... | apps/cashtrail/lib/cashtrail/entities/entity_member.ex | 0.835953 | 0.473231 | entity_member.ex | starcoder |
defmodule StarkInfra.IssuingRule do
alias __MODULE__, as: IssuingRule
@moduledoc """
# IssuingRule struct
"""
@doc """
The IssuingRule struct displays the spending rules of IssuingCards and IssuingHolders created in your Workspace.
## Parameters (required):
- `:name` [string]: rule name. ex: "Tra... | lib/issuing_rule/issuing_rule.ex | 0.844953 | 0.479626 | issuing_rule.ex | starcoder |
defmodule LexibombServer.Board.Square do
@moduledoc """
Manages the low-level state data associated with an individual board square.
A square can either be hidden or revealed, which indicates whether its state
data should be available externally. Placing a tile on a square automatically
sets it to the reveal... | apps/lexibomb_server/lib/lexibomb_server/board/square.ex | 0.886862 | 0.655312 | square.ex | starcoder |
defmodule Mix.Tasks.Profile.Fprof do
use Mix.Task
@shortdoc "Profiles the given file or expression with fprof"
@moduledoc """
Profiles the given file or expression using Erlang's `fprof` tool.
`fprof` can be useful when you want to discover the bottlenecks of a
sequential code.
Before running the code... | lib/mix/lib/mix/tasks/profile.fprof.ex | 0.880283 | 0.537709 | profile.fprof.ex | starcoder |
defmodule RDF.XSD.Double do
@moduledoc """
`RDF.XSD.Datatype` for XSD doubles.
"""
@type special_values :: :positive_infinity | :negative_infinity | :nan
@type valid_value :: float | special_values
@special_values ~W[positive_infinity negative_infinity nan]a
use RDF.XSD.Datatype.Primitive,
name: "d... | lib/rdf/xsd/datatypes/double.ex | 0.721743 | 0.632772 | double.ex | starcoder |
defmodule Git.Commit do
@keys [:sha, :author, :gpg_fingerprint, :message]
@enforce_keys @keys
defstruct @keys
defmodule(Author, do: defstruct([:email, :name, :date]))
@doc ~S"""
The format passed to the Git CLI for a commit
see: https://git-scm.com/docs/pretty-formats
%H: commit hash
%aI: ... | architect/lib/git/commit.ex | 0.652463 | 0.460107 | commit.ex | starcoder |
defmodule Retry do
@moduledoc """
Provides a convenient interface to retrying behavior. All durations are
specified in milliseconds.
Examples
use Retry
import Stream
retry with: exponential_backoff |> randomize |> cap(1_000) |> expiry(10_000) do
# interact with external service
... | lib/retry.ex | 0.915242 | 0.616618 | retry.ex | starcoder |
defmodule MMDB2Decoder.LookupTree do
@moduledoc false
use Bitwise, only_operators: true
alias MMDB2Decoder.Metadata
@doc """
Locates the data pointer associated for a given IP.
"""
@spec locate(:inet.ip_address(), Metadata.t(), binary) ::
{:ok, non_neg_integer} | {:error, :node_below_count | ... | lib/mmdb2_decoder/lookup_tree.ex | 0.768733 | 0.471588 | lookup_tree.ex | starcoder |
defmodule Elsa.Group.Manager.WorkerManager do
@moduledoc """
Provides functions to encapsulate the management of worker
processes by the consumer group manager.
"""
import Record, only: [defrecord: 2, extract: 2]
import Elsa.Supervisor, only: [registry: 1]
defrecord :brod_received_assignment, extract(:br... | lib/elsa/group/manager/worker_manager.ex | 0.720565 | 0.557303 | worker_manager.ex | starcoder |
defmodule XDR.Error do
@moduledoc """
This module contains the definitions of the errors resulted from XDR encode or decode operations.
"""
defmodule Int do
@moduledoc """
This module contains the definition of `XDR.Error.Int` exception that may be raised by the `XDR.Int` module.
"""
defexcept... | lib/error/error.ex | 0.941533 | 0.654508 | error.ex | starcoder |
defmodule OSC.Parser do
@type t :: OSC.Bundle.t | OSC.Message.t | OSC.Packet.t
@spec parse(iodata, Keyword.t) :: {:ok, t} | {:error, :invalid}
| {:error, {:invalid, String.t}}
def parse(iodata, options \\ []) do
string = IO.iodata_to_binary(iodata)
case values(string, options) do
[value] ->
... | lib/osc/parser.ex | 0.775732 | 0.510252 | parser.ex | starcoder |
defmodule TzWorld.Backend.Dets do
@moduledoc false
@behaviour TzWorld.Backend
use GenServer
alias Geo.Point
@timeout 10_000
@tz_world_version :tz_world_version
@doc false
def start_link(options \\ []) do
GenServer.start_link(__MODULE__, options, name: __MODULE__)
end
@doc false
def init(... | lib/tz_world/backend/dets.ex | 0.733261 | 0.452234 | dets.ex | starcoder |
defmodule Sise.Discovery do
# SPDX-License-Identifier: Apache-2.0
@moduledoc """
A struct for describing found devices or services together with some
useful functions
"""
@enforce_keys [:location, :nt, :usn]
defstruct [:location, :nt, :usn, :server, :boot_id, :config_id, :secure_location, :next_boot_id]
... | lib/sise/discovery.ex | 0.8505 | 0.582966 | discovery.ex | starcoder |
defmodule Spear.Acl do
@moduledoc """
A struct representing an access control list (ACL)
See the [Security guide](guides/security.md) for more information on ACLs
"""
@typedoc """
An access control list (ACL) type
See the [Security guide](guides/security.md) for more information on ACLs
ACLs may pro... | lib/spear/acl.ex | 0.830147 | 0.461138 | acl.ex | starcoder |
defmodule Minex.Command do
alias __MODULE__
@moduledoc """
Execute shell commands
"""
@doc """
Execute a command and wait for it to finish
## Options
* `:echo_cmd` - boolean indicating if the executed command should be printed
* `:interact` - boolean to enable interact. This will read input li... | lib/minex/command.ex | 0.770335 | 0.415403 | command.ex | starcoder |
defmodule Rummage.Phoenix.Plug do
@moduledoc """
This plug ensures that the `rummage` params are properly set before
`index` action of the controller. If they are not, then it formats them
accordingly.
This plug only works with the default `Rummmage.Ecto` hooks.
"""
@doc """
`init` initializes the plu... | lib/rummage_phoenix/plug.ex | 0.797083 | 0.497742 | plug.ex | starcoder |
defmodule Re.Filtering.Relax do
@moduledoc """
Module to group logic to relax filter parameters
"""
alias Re.{
Filtering,
Addresses.Neighborhoods
}
defguardp is_not_nil(value) when not is_nil(value)
@types ~w(price area room neighborhoods garage_spots)a
def apply(params) do
Enum.reduce(@... | apps/re/lib/filtering/relax.ex | 0.745769 | 0.531149 | relax.ex | starcoder |
defmodule DecimalArithmetic do
@moduledoc """
Module extends embedded arithmetic with decimal one. If at least one operand of operation
is of type Decimal.t the second one is promoted to Decimal struct too.
## Examples
iex> a = ~m(98.01)
#Decimal<98.01>
iex> b = ~m(10.01)
#Decimal<10.01... | lib/decimal_arithmetic.ex | 0.7641 | 0.444324 | decimal_arithmetic.ex | starcoder |
defmodule Rill.Messaging.Message.Dictionary do
@moduledoc """
Converts messages from database representation to the related struct
"""
defstruct type_names: %{}
@callback dictionary() :: %__MODULE__{}
alias Rill.MessageStore.MessageData.Read
@typedoc """
Used as a dictionary to convert a type name (... | lib/rill/messaging/message/dictionary.ex | 0.857261 | 0.482429 | dictionary.ex | starcoder |
defmodule Timber.Utils.Plug do
@moduledoc false
@doc """
Fetches the request ID from the connection using the given header name
The request ID may be added to the connection in a number of ways which
complicates how we retrieve it. It is usually set by calling the
Plug.RequestId module on the connection w... | lib/timber/utils/plug.ex | 0.832577 | 0.412323 | plug.ex | starcoder |
defmodule Sanbase.Signal.OperationText.KV do
@moduledoc ~s"""
A module providing a single function to_template_kv/3 which transforms an operation
to human readable text that can be included in the signal's payload
"""
def current_value(%{current: value, previous: previous}, _operation, opts) do
special_s... | lib/sanbase/signals/operation/operation_text_kv.ex | 0.728941 | 0.571587 | operation_text_kv.ex | starcoder |
defmodule Filtrex.Condition.Number do
use Filtrex.Condition
@type t :: Filtrex.Condition.Number
@moduledoc """
`Filtrex.Condition.Number` is a specific condition type for handling
integer and decimal filters with various configuration options.
Comparators:
greater than, less than or,
greater than ... | lib/filtrex/conditions/number.ex | 0.844505 | 0.569613 | number.ex | starcoder |
import ExType.Typespec, only: [deftypespec: 2]
deftypespec Enum do
@spec all?(T.p(Enumerable, x)) :: boolean() when x: any()
@spec all?(T.p(Enumerable, x), (x -> boolean())) :: boolean() when x: any()
@spec any?(T.p(Enumerable, x)) :: boolean() when x: any()
@spec any?(T.p(Enumerable, x), (x -> boolean())) ... | lib/ex_type/typespec/elixir/enum.ex | 0.832441 | 0.832543 | enum.ex | starcoder |
defmodule Holidefs do
@moduledoc """
Holdefs is a holiday OTP application for multiple locales that loads the
dates from definition files on the startup.
"""
alias Holidefs.Definition
alias Holidefs.Definition.Store
alias Holidefs.Holiday
alias Holidefs.Options
@type error_reasons :: :no_def | :inva... | lib/holidefs.ex | 0.856558 | 0.442877 | holidefs.ex | starcoder |
defmodule Estructura.LazyMap do
@moduledoc """
The implementation of lazy map implementing lazy `Access` for its keys.
`Estructura.LazyMap` is backed by the “raw” object and a key-value pairs
where values might be instances of `Estructura.Lazy`. If this is a case,
they will be accessed through `Lazy` imp... | lib/estructura/lazy_map.ex | 0.885625 | 0.574962 | lazy_map.ex | starcoder |
defmodule Alerts.InformedEntity do
@fields [:route, :route_type, :stop, :trip, :direction_id, :activities]
@empty_activities MapSet.new()
defstruct route: nil,
route_type: nil,
stop: nil,
trip: nil,
direction_id: nil,
activities: @empty_activities
@ty... | apps/alerts/lib/informed_entity.ex | 0.696991 | 0.418459 | informed_entity.ex | starcoder |
defmodule Nabo.Metadata do
@moduledoc """
A struct that represents post metadata.
Represents metadata that specified in the top of the post.
## Format
Metadata should be in JSON, and must have `title`, `slug`, and `date` set.
{
"title": "Nabo Post",
"slug": "First Nabo post",
... | lib/nabo/metadata.ex | 0.794903 | 0.487856 | metadata.ex | starcoder |
defmodule Surface.Components.Link do
@moduledoc """
Generates a link to the given URL.
Provides similar capabilities to Phoenix's built-in `link/2`
function.
Options `label` and `class` can be set directly and will override anything in `opts`.
All other options are forwarded to the underlying <a> tag.
... | lib/surface/components/link.ex | 0.895829 | 0.853547 | link.ex | starcoder |
defmodule EnvConfigProvider do
@moduledoc """
[Distillery](https://github.com/bitwalker/distillery) config provider reading configuration data
from environment variables.
The information how system environment variables map to application environment variables is
contained in the schema. Schema is a map, whe... | lib/env_config_provider.ex | 0.85814 | 0.509459 | env_config_provider.ex | starcoder |
defmodule Weaver.Absinthe.Phase.Document.Result do
@moduledoc """
Produces data fit for streaming from annotated value tree.
Sets a `Weaver.Step.Result` as result.
"""
# credo:disable-for-this-file Credo.Check.Consistency.ParameterPatternMatching
alias Absinthe.{Blueprint, Phase, Type}
alias Absinthe.B... | lib/weaver/absinthe/phase/document/result.ex | 0.766425 | 0.427636 | result.ex | starcoder |
defmodule Harald.DataType.ManufacturerData.Apple do
@moduledoc """
Serialization module for Apple.
## iBeacon
Reference: https://en.wikipedia.org/wiki/IBeacon#Packet_Structure_Byte_Map
"""
alias Harald.{ManufacturerDataBehaviour, Serializable}
@behaviour ManufacturerDataBehaviour
@behaviour Seriali... | lib/harald/data_type/manufacturer_data/apple.ex | 0.739422 | 0.578091 | apple.ex | starcoder |
defmodule Ace.HTTP2.Frame do
@moduledoc """
**Basic protocol unit of HTTP/2.**
All frames begin with a fixed 9-octet header followed by a variable-
length payload.
```txt
+-----------------------------------------------+
| Length (24) |
+---------------+--------------... | lib/ace/http2/frame.ex | 0.823931 | 0.693356 | frame.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.