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 Rummage.Ecto.Schema do
@moduledoc """
This module is meant to be `use`d by a module (typically an `Ecto.Schema`).
This isn't a required module for using `Rummage`, but it allows us to extend
its functionality.
"""
@rummage_scope_types ~w{search sort paginate custom_search custom_sort custom_pagi... | lib/rummage_ecto/schema.ex | 0.770162 | 0.824391 | schema.ex | starcoder |
defmodule EllipticCurve.Ecdsa do
@moduledoc """
Used to sign and verify signatures using the Elliptic Curve Digital Signature Algorithm (ECDSA)
Functions:
- `sign()`
- `verify?()`
"""
alias EllipticCurve.Utils.Integer, as: IntegerUtils
alias EllipticCurve.Utils.BinaryAscii
alias EllipticCurve.{Point... | lib/ecdsa.ex | 0.962054 | 0.697274 | ecdsa.ex | starcoder |
defmodule TypeCheck.TypeError.DefaultFormatter do
@behaviour TypeCheck.TypeError.Formatter
def format_wrap(problem_tuple) do
format(problem_tuple)
|> String.trim_trailing()
end
@doc """
Transforms a `problem_tuple` into a humanly-readable explanation string.
C.f. `TypeCheck.TypeError.Formatter` f... | lib/type_check/type_error/default_formatter.ex | 0.877935 | 0.5835 | default_formatter.ex | starcoder |
defmodule Snap do
@moduledoc """
Snap is split into 3 main components:
* `Snap.Cluster` - clusters are wrappers around the Elasticsearch HTTP API.
We can use this to perform low-level HTTP requests.
* `Snap.Bulk` - a convenience wrapper around bulk operations, using `Stream`
to stream actions (such as... | lib/snap.ex | 0.93007 | 0.949576 | snap.ex | starcoder |
defmodule OMG.API.BlockQueue.Core do
@moduledoc """
Maintains a queue of to-be-mined blocks. Has no side-effects or side-causes.
Note that first nonce (zero) of authority account is used to deploy RootChain.
Every next nonce is used to submit operator blocks.
(thus, it handles config values as internal var... | apps/omg_api/lib/block_queue/core.ex | 0.77928 | 0.42471 | core.ex | starcoder |
defmodule Jason.Formatter do
@moduledoc ~S"""
Pretty-printing and minimizing functions for JSON-encoded data.
Input is required to be in an 8-bit-wide encoding such as UTF-8 or Latin-1
in `t:iodata/0` format. Input must ve valid JSON, invalid JSON may produce
unexpected results or errors.
"""
@type opts... | lib/formatter.ex | 0.899796 | 0.740597 | formatter.ex | starcoder |
defmodule Plaid.Processor do
@moduledoc """
[Plaid Processor API](https://plaid.com/docs/api/processors) calls and schema.
"""
alias Plaid.Castable
defmodule CreateTokenResponse do
@moduledoc """
[Plaid API /processor/token/create response schema.](https://plaid.com/docs/api/processors/#processortok... | lib/plaid/processor.ex | 0.919163 | 0.402451 | processor.ex | starcoder |
defmodule Mockery.Macro do
@moduledoc """
Alternative macro-based way to prepare module for mocking/asserting.
"""
@doc """
Function used to prepare module for mocking/asserting.
For Mix.env other than :test it returns the first argument unchanged.
If Mix.env equal :test it creates a proxy to the origin... | lib/mockery/macro.ex | 0.827932 | 0.510863 | macro.ex | starcoder |
defmodule Meeseeks.Document do
@moduledoc """
A `Meeseeks.Document` represents a flattened, queryable view of an HTML
document in which:
- The nodes (element, comment, or text) have been provided an id
- Parent-child relationships have been made explicit
## Examples
The actual contents of a documen... | lib/meeseeks/document.ex | 0.86148 | 0.745306 | document.ex | starcoder |
defmodule Blockchain.Block do
@moduledoc """
Implements a blockchain block, which is a building block of the blockchain.
Blocks are limited to containing transactions.
"""
alias Blockchain.Hash
alias Blockchain.Transaction
@enforce_keys [:current_hash, :previous_hash, :data, :timestamp, :nonce]
defstr... | lib/blockchain/block.ex | 0.833257 | 0.641317 | block.ex | starcoder |
defmodule Frettchen.Trace do
@moduledoc """
A Trace is a process that collects spans. When a span
is created it registers with the process and when it is closed
it removes itself from the process and gets sent
to the reporter that is has been configured for. A Trace can be configured
to act differently b... | lib/frettchen/trace.ex | 0.815269 | 0.483344 | trace.ex | starcoder |
defmodule RDF.Diff do
@moduledoc """
A data structure for diffs between `RDF.Graph`s and `RDF.Description`s.
A `RDF.Diff` is a struct consisting of two fields `additions` and `deletions`
with `RDF.Graph`s of added and deleted statements.
"""
alias RDF.{Description, Graph}
@type t :: %__MODULE__{
... | lib/rdf/diff.ex | 0.857709 | 0.862004 | diff.ex | starcoder |
defmodule Rolodex.Utils do
@moduledoc false
@doc """
Pipeline friendly dynamic struct creator
"""
def to_struct(data, module), do: struct(module, data)
@doc """
Recursively convert a keyword list into a map
"""
def to_map_deep(data, level \\ 0)
def to_map_deep([], 0), do: %{}
def to_map_deep(li... | lib/rolodex/utils.ex | 0.756897 | 0.587588 | utils.ex | starcoder |
defmodule State.Helpers do
@moduledoc """
Helper functions for State modules.
"""
alias Model.Trip
@doc """
Returns true if the given Model.Trip is on a hidden (negative priority) shape.
"""
def trip_on_hidden_shape?(%{shape_id: shape_id}) do
case State.Shape.by_primary_id(shape_id) do
%{prio... | apps/state/lib/state/helpers.ex | 0.860164 | 0.511229 | helpers.ex | starcoder |
defmodule Msgpax do
@moduledoc ~S"""
This module provides functions for serializing and de-serializing Elixir terms
using the [MessagePack](http://msgpack.org/) format.
## Data conversion
The following table shows how Elixir types are serialized to MessagePack types
and how MessagePack types are de-serial... | lib/msgpax.ex | 0.874373 | 0.692063 | msgpax.ex | starcoder |
defmodule Hui.URL do
@moduledoc """
Struct and utilities for working with Solr URLs and parameters.
Use the module `t:Hui.URL.t/0` struct to specify
Solr core or collection URLs with request handlers.
### Hui URL endpoints
```
# binary
url = "http://localhost:8983/solr/collection"
Hui.search(... | lib/hui/url.ex | 0.91115 | 0.76366 | url.ex | starcoder |
defmodule GitHooks.Tasks.Mix do
@moduledoc """
Represents a Mix task that will be executed as a git hook task.
A mix task should be configured as `{:mix_task, task_name, task_args}`,
being `task_args` an optional configuration. See `#{__MODULE__}.new/1` for
more information.
For example:
```elixir
co... | lib/tasks/mix.ex | 0.890859 | 0.847148 | mix.ex | starcoder |
defmodule Mix.Tasks.Ecto.Migrate do
use Mix.Task
import Mix.Ecto
@shortdoc "Runs the repository migrations"
@moduledoc """
Runs the pending migrations for the given repository.
Migrations are expected at "priv/YOUR_REPO/migrations" directory
of the current application but it can be configured to be any... | lib/mix/tasks/ecto.migrate.ex | 0.811303 | 0.403537 | ecto.migrate.ex | starcoder |
defmodule Ecto.Validator do
@moduledoc """
Validates a given record or dict given a set of predicates.
Ecto.Validator.record(user,
name: present() when on_create?(user),
age: present(message: "must be present"),
age: greater_than(18),
also: validate_other
)
Validation... | lib/ecto/validator.ex | 0.920959 | 0.598459 | validator.ex | starcoder |
defmodule ExVCR.Adapter.Hackney do
@moduledoc """
Provides adapter methods to mock :hackney methods.
"""
use ExVCR.Adapter
alias ExVCR.Adapter.Hackney.Store
alias ExVCR.Util
defmacro __using__(_opts) do
quote do
Store.start
end
end
defdelegate convert_from_string(string), to: ExVCR.Ad... | lib/exvcr/adapter/hackney.ex | 0.766774 | 0.438785 | hackney.ex | starcoder |
defmodule Blockchain.Account do
@moduledoc """
Represents the account state,
as defined in Section 4.1 of the Yellow Paper
"""
alias ExthCrypto.Hash.Keccak
alias MerklePatriciaTree.Trie
alias MerklePatriciaTree.TrieStorage
alias Blockchain.Account.{Address, Storage}
@empty_keccak Keccak.kec(<<>>)
... | apps/blockchain/lib/blockchain/account.ex | 0.845337 | 0.45744 | account.ex | starcoder |
defmodule APIacFilterThrottler.Functions do
@moduledoc """
Throttling functions that construct keys for the `APIacFilterThrottler` plug.
Note that except `throttle_by_ip_subject_client_safe/1`, these functions do
not protect against collisions. See the *Security considerations* of the
`APIacFilterThrottler` ... | lib/apiac_filter_throttler/functions.ex | 0.940831 | 0.794982 | functions.ex | starcoder |
defmodule AWS.API.Pricing do
@moduledoc """
AWS Price List Service API (AWS Price List Service) is a centralized and
convenient way to programmatically query Amazon Web Services for services,
products, and pricing information. The AWS Price List Service uses
standardized product attributes such as `Location`... | lib/aws/api_pricing.ex | 0.806662 | 0.667331 | api_pricing.ex | starcoder |
defmodule MatrixReloaded.Matrix do
@moduledoc """
Provides a set of functions to work with matrices.
Don't forget, numbering of row and column starts from `0` and goes
to `m - 1` and `n - 1` where `{m, n}` is dimension (size) of matrix.
"""
alias MatrixReloaded.Vector
@type t :: [Vector.t()]
@type di... | lib/matrix_reloaded/matrix.ex | 0.943256 | 0.817647 | matrix.ex | starcoder |
defmodule Quadtreex.Node do
@moduledoc """
A node in a quadtree
A quadtree node represents a bounded volume of 2 dimensional space.
"""
alias Quadtreex.BoundingBox
alias Quadtreex.Entity
defstruct parent: nil, bbox: nil, min_size: 0.0, split_size: 0, children: %{}, entities: []
@type child_map() :: %... | lib/quadtreex/node.ex | 0.868799 | 0.6535 | node.ex | starcoder |
defmodule Aeutil.PatriciaMerkleTree do
@moduledoc """
This module provides and API for creating, updating, deleting
patricia merkle tries, The actual handler is https://github.com/aeternity/elixir-merkle-patricia-tree
"""
alias Aeutil.Serialization
alias MerklePatriciaTree.Trie
alias MerklePatriciaTree... | apps/aeutil/lib/patricia_merkle_tree.ex | 0.838151 | 0.482063 | patricia_merkle_tree.ex | starcoder |
defmodule PowAssent.Plug.Reauthorization do
@moduledoc """
This plug can reauthorize a user who signed in through a provider.
The plug is dependent on a `:handler` that has the following methods:
* `reauthorize?/2` - verifies the request for reauthorization condition. If
the condition exists for the requ... | lib/pow_assent/plug/reauthorization.ex | 0.736495 | 0.418281 | reauthorization.ex | starcoder |
defmodule RegexRs do
@moduledoc """
Documentation for `RegexRs`.
See Rust documentation for more information: https://docs.rs/regex/1.4.3/regex/index.html
Implemented so far:
- [x] as_str
- [ ] capture_locations
- [x] capture_names
- [x] captures (+ _named)
- [x] captures_iter (+ _named)
- [x] capt... | lib/regex_rs.ex | 0.86009 | 0.566498 | regex_rs.ex | starcoder |
defmodule Day04 do
@moduledoc """
Documentation for `Day04`.
"""
def bingo({draws, boards}) do
lookups = for _ <- 1..Enum.count(boards), do: List.duplicate(false, 25) |> Enum.chunk_every(5)
bingo(draws, boards, lookups, [], MapSet.new())
end
defp bingo([], _, _, scores, _), do: Enum.reverse(scores... | 2021/day04/lib/day04.ex | 0.603114 | 0.449513 | day04.ex | starcoder |
defmodule JsonDiffEx do
@moduledoc """
This is the documentation of JsonDiffEx.
There are no runtime dependencies and it should be easy
to use.
You can use the javascript library
[jsondiffpatch](https://github.com/benjamine/jsondiffpatch)
with it since it get's it's diff format from it.
It contains b... | lib/json_diff_ex.ex | 0.747339 | 0.66886 | json_diff_ex.ex | starcoder |
defmodule Flop.Phoenix do
@moduledoc """
Components for Phoenix and Flop.
## Introduction
Please refer to the [Readme](README.md) for an introduction.
## Customization
The default classes, attributes, texts and symbols can be overridden by
passing the `opts` assign. Since you probably will use the sam... | lib/flop_phoenix.ex | 0.812756 | 0.862004 | flop_phoenix.ex | starcoder |
defmodule Honeydew.FailureMode.Retry do
alias Honeydew.Job
alias Honeydew.Queue
alias Honeydew.Processes
alias Honeydew.FailureMode.Abandon
alias Honeydew.FailureMode.Move
@moduledoc """
Instructs Honeydew to retry a job a number of times on failure.
## Examples
Retry jobs in this queue 3 times:
... | lib/honeydew/failure_mode/retry.ex | 0.837454 | 0.619975 | retry.ex | starcoder |
defmodule OMG.Watcher.BlockValidator do
@moduledoc """
Operations related to block validation.
"""
alias OMG.Watcher.Block
alias OMG.Watcher.Merkle
alias OMG.Watcher.State.Transaction
alias OMG.Watcher.Utxo.Position
@transaction_upper_limit 2 |> :math.pow(16) |> Kernel.trunc()
@doc """
Executes ... | apps/omg_watcher/lib/omg_watcher/block_validator.ex | 0.866401 | 0.483466 | block_validator.ex | starcoder |
defmodule Timex.Ecto.DateTimeWithTimezone do
@moduledoc """
This is a special type for storing datetime + timezone information as a composite type.
To use this, you must first make sure you have the `datetimetz` type defined in your database:
```sql
CREATE TYPE datetimetz AS (
dt timestamptz,
tz... | lib/types/datetimetz.ex | 0.831451 | 0.667903 | datetimetz.ex | starcoder |
defmodule AshPostgres do
@moduledoc """
A postgres extension library for `Ash`.
`AshPostgres.DataLayer` provides a DataLayer, and a DSL extension to configure that data layer.
The dsl extension exposes the `postgres` section. See: `AshPostgres.DataLayer` for more.
"""
alias Ash.Dsl.Extension
@doc "The... | lib/ash_postgres.ex | 0.835819 | 0.449574 | ash_postgres.ex | starcoder |
defmodule Gather.Extraction do
@moduledoc """
Process to wrap and manage a dataset's extraction pipeline. This is operated
like a `Task`, in that it executes and shuts down.
"""
import Events
use GenServer, restart: :transient
require Logger
use Properties, otp_app: :service_gather
use Annotated.Retry... | apps/service_gather/lib/gather/extraction.ex | 0.781914 | 0.402011 | extraction.ex | starcoder |
defmodule Sanbase.Clickhouse.HistoricalBalance do
@moduledoc ~s"""
Module providing functions for historical balances and balance changes.
This module dispatches to underlaying modules and serves as common interface
for many different database tables and schemas.
"""
use AsyncWith
import Sanbase.Utils.T... | lib/sanbase/clickhouse/historical_balance/historical_balance.ex | 0.882656 | 0.546859 | historical_balance.ex | starcoder |
defmodule Glicko.Player do
@moduledoc """
Provides convenience functions that handle conversions between Glicko versions one and two.
## Usage
Create a *v1* player with the default values for an unrated player.
iex> Player.new_v1
{1.5e3, 350.0}
Create a *v2* player with the default values for ... | lib/glicko/player.ex | 0.868186 | 0.555676 | player.ex | starcoder |
defmodule Freddy.Core.Queue do
@moduledoc """
Queue configuration
## Fields
* `:name` - Queue name. If left empty, a server named queue with unique
name will be declared.
* `:opts` - Queue options, see below.
## Options
* `:durable` - If set, keeps the Queue between restarts of the broker.... | lib/freddy/core/queue.ex | 0.904479 | 0.41117 | queue.ex | starcoder |
defmodule Roger.Info do
@moduledoc """
Get information about the current partitions, queues and jobs of the entire cluster.
Most of the functions here are mirrored from `Roger.NodeInfo` but
calls these function for each node through `Roger.System.call/2`.
"""
alias Roger.{ApplySystem, Job}
@doc """
... | lib/roger/info.ex | 0.736874 | 0.62332 | info.ex | starcoder |
defmodule OMG.Performance.ByzantineEvents do
@moduledoc """
OMG network child chain server byzantine event test entrypoint. Runs performance byzantine tests.
## Usage
To setup, once you have your Ethereum node and a child chain running, from a configured `iex -S mix run --no-start`
shell do:
```
use O... | apps/omg_performance/lib/omg_performance/byzantine_events.ex | 0.881971 | 0.721351 | byzantine_events.ex | starcoder |
defmodule SvgBuilder.Text do
import XmlBuilder
alias SvgBuilder.{Element, Units}
@type text_t :: binary | Element.t() | [Element.t()]
@moduledoc """
Add and modify text elements.
"""
@doc """
Create a text element.
The `text` may be a binary, text element or list of text elements.
"""
@spec te... | lib/text.ex | 0.829008 | 0.455501 | text.ex | starcoder |
defmodule Nacha.Record do
@moduledoc """
A use macro for building and formatting NACHA records.
"""
defmacro __using__(opts) do
quote do
import Kernel, except: [to_string: 1]
@fields unquote(Keyword.get(opts, :fields))
if __MODULE__ |> Module.get_attribute(:required) |> is_nil() do
... | lib/nacha/record.ex | 0.635109 | 0.425695 | record.ex | starcoder |
defmodule Xcribe do
@moduledoc """
Xcribe is a library for API documentation. It generates docs from your test specs.
Xcribe use `Plug.Conn` struct to fetch information about requests and use them
to document your API. You must give requests examples (from your tests ) to Xcribe
be able to document your rou... | lib/xcribe.ex | 0.859251 | 0.52208 | xcribe.ex | starcoder |
defmodule AWS.MemoryDB do
@moduledoc """
MemoryDB for Redis is a fully managed, Redis-compatible, in-memory database that
delivers ultra-fast performance and Multi-AZ durability for modern applications
built using microservices architectures.
MemoryDB stores the entire database in-memory, enabling low laten... | lib/aws/generated/memory_db.ex | 0.883167 | 0.442637 | memory_db.ex | starcoder |
defmodule Scrivener.HTML do
use Phoenix.HTML
alias Scrivener.Page
alias Scrivener.HTML.Parse
alias Scrivener.HTML.Render
@parse_defaults Parse.defaults()
@render_defaults Render.defaults()
@moduledoc """
## Usage
Import `Scrivener.HTML` to your view:
defmodule SampleWeb.UserView do
... | lib/scrivener/html.ex | 0.845496 | 0.657612 | html.ex | starcoder |
defmodule Socket.UDP do
@moduledoc """
This module wraps a UDP socket using `gen_udp`.
## Options
When creating a socket you can pass a series of options to use for it.
* `:as` sets the kind of value returned by recv, either `:binary` or `:list`,
the default is `:binary`.
* `:mode` can be either `:p... | deps/socket/lib/socket/udp.ex | 0.893176 | 0.544559 | udp.ex | starcoder |
defmodule Gorpo.Service do
@moduledoc """
Consul service definition.
<dl>
<dt>id</dt>
<dd>a unique value for this service on the local agent</dd>
<dt>name</dt>
<dd>the name of this service</dd>
<dt>tags</dt>
<dd>a list of strings [opaque to consul] that can be used to further assist dis... | lib/gorpo/service.ex | 0.734024 | 0.562567 | service.ex | starcoder |
defmodule Comb do
# unfortunately exdoc doesnt support ``` fenced blocks
@moduledoc (
File.read!("README.md")
|> String.split("\n")
|> Enum.reject(&(String.match?(&1, ~r/```|Build Status|Documentation Status/)))
|> Enum.join("\n")
)
@doc """
This function returns a list containing all comb... | lib/comb.ex | 0.82963 | 0.792906 | comb.ex | starcoder |
defmodule Huth.Client do
alias Huth.Config
alias Huth.Token
@moduledoc """
`Huth.Client` is the module through which all interaction with Huawei's APIs flows.
## Available Options
The first parameter is either the token scopes or a tuple of the service
account client email and its scopes.
See
[Hua... | lib/huth/client.ex | 0.811601 | 0.403273 | client.ex | starcoder |
defmodule PSQ do
@moduledoc """
PSQ provides a purely-functional implementation of priority search queues. A
priority search queue is a data structure that efficiently supports both
associative operations (like those for `Map`) and priority-queue operations
(akin to heaps in imperative languages). The impleme... | lib/psq.ex | 0.914958 | 0.679027 | psq.ex | starcoder |
defmodule Day11 do
def part1(input, steps \\ 100) do
grid = parse(input)
Stream.iterate({grid, 0}, &next_step/1)
|> Stream.drop(steps)
|> Enum.take(1)
|> hd
|> elem(1)
end
def part2(input) do
grid = parse(input)
Stream.iterate({grid, 0}, &next_step/1)
|> Stream.with_index
... | day11/lib/day11.ex | 0.605099 | 0.588623 | day11.ex | starcoder |
defmodule Chapter9.BinarySearchTree do
defstruct [:value, :left, :right]
alias Chapter9.BinarySearchTree, as: BST
@type t :: %BST{value: number, left: BST.t, right: BST.t} | :empty_node
@spec new() :: :empty_node
def new(), do: :empty_node
@spec insert(BST.t, number) :: BST.t
def insert(:empty_node, va... | elixir/epi_book/lib/chapter_9/binary_search_tree.ex | 0.762336 | 0.883034 | binary_search_tree.ex | starcoder |
defmodule Elixium.Store.Ledger do
alias Elixium.Block
alias Elixium.BlockEncoder
alias Elixium.Utilities
use Elixium.Store
@moduledoc """
Provides an interface for interacting with the blockchain stored within LevelDB. This
is where blocks are stored and fetched
"""
@store_dir "chaindata"
@ets... | lib/store/ledger.ex | 0.827445 | 0.492188 | ledger.ex | starcoder |
defmodule Specify.Options do
require Specify
@moduledoc """
This struct represents the options you can pass
to a call of `Specify.load/2` (or `YourModule.load/1`).
### Metaconfiguration
Besides making it nice and explicit to have the options listed here,
`Specify.Options` has itself been defined using ... | lib/specify/options.ex | 0.89873 | 0.664171 | options.ex | starcoder |
defmodule Bonny.Controller do
@moduledoc """
`Bonny.Controller` defines controller behaviours and generates boilerplate for generating Kubernetes manifests.
> A custom controller is a controller that users can deploy and update on a running cluster, independently of the cluster’s own lifecycle. Custom controller... | lib/bonny/controller.ex | 0.915672 | 0.464537 | controller.ex | starcoder |
defmodule Aoc2019Day1 do
@moduledoc """
Documentation for Aoc2019.
"""
@doc """
Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2.
For example:
For a mass of 12, divid... | lib/aoc2019_1_1.ex | 0.795579 | 0.780035 | aoc2019_1_1.ex | starcoder |
defmodule Cassandra.Statement do
defstruct [
:query,
:options,
:params,
:prepared,
:request,
:response,
:keyspace,
:partition_key,
:partition_key_picker,
:values,
:connections,
:streamer,
]
def new(query, options \\ []) do
%__MODULE__{
query: query,
... | lib/cassandra/statement.ex | 0.698946 | 0.485966 | statement.ex | starcoder |
defmodule Snitch.Tools.Helper.Taxonomy do
@moduledoc """
Provides helper funtions to easily create taxonomy.
"""
alias Snitch.Domain.Taxonomy, as: TaxonomyDomain
alias Snitch.Data.Schema.{Taxon, Taxonomy}
alias Snitch.Core.Tools.MultiTenancy.Repo
@doc """
Creates taxonomy from the hierarchy passed.
... | apps/snitch_core/lib/core/tools/helpers/taxonomy.ex | 0.703957 | 0.549641 | taxonomy.ex | starcoder |
defmodule AdventOfCode.Day16 do
@moduledoc ~S"""
[Advent Of Code day 16](https://adventofcode.com/2018/day/16).
"""
alias __MODULE__.Ops
def solve("1", {raw_samples, _}) do
samples = parse_samples(raw_samples)
Enum.count(samples, fn sample -> Enum.count(opcodes_match(sample)) >= 3 end)
end
def ... | lib/advent_of_code/day_16.ex | 0.617743 | 0.710126 | day_16.ex | starcoder |
defmodule GenStage do
@moduledoc ~S"""
Stages are data-exchange steps that send and/or receive data
from other stages.
When a stage sends data, it acts as a producer. When it receives
data, it acts as a consumer. Stages may take both producer and
consumer roles at once.
## Stage types
Besides taking ... | deps/gen_stage/lib/gen_stage.ex | 0.874553 | 0.789031 | gen_stage.ex | starcoder |
defmodule AdventOfCode.Day09 do
import AdventOfCode.Utils
@typep heightmap :: [[integer()]]
@typep coordinates :: {integer(), integer()}
@spec part1([binary()]) :: integer()
def part1(args) do
heightmap = parse_args(args)
heightmap
|> all_coordinates()
|> Enum.filter(&low_point?(&1, heightm... | lib/advent_of_code/day_09.ex | 0.839339 | 0.571767 | day_09.ex | starcoder |
defmodule ExAlgo.List.CircularList do
@moduledoc """
Implementation of a circular list.
"""
@type neg_index_error :: {:error, :negative_index}
@type empty_error :: {:error, :empty_list}
@type value_type :: any()
@type t :: %__MODULE__{visited: [value_type()], upcoming: [value_type()]}
defstruct visited... | lib/ex_algo/list/circular_list.ex | 0.862496 | 0.564339 | circular_list.ex | starcoder |
defmodule Day12 do
def part1(path) do
File.stream!(path) |> simulate_steps(1000)
end
def part2(path) do
File.stream!(path) |> find_cycle()
end
def find_cycle(lines) do
moons = parse(lines)
0..2
|> Enum.map(fn dir ->
target = direction(moons, dir)
find_period(moons, dir, targ... | lib/day_12.ex | 0.59749 | 0.549943 | day_12.ex | starcoder |
defmodule Indicado.MFI do
@moduledoc """
This is the MFI module used for calculating Money Flow Index
"""
@typedoc """
The argument passed to eval functions should be a list of mfi_data_map type.
"""
@type mfi_data_map :: %{
low: float,
high: float,
close: float,
v... | lib/indicado/mfi.ex | 0.914463 | 0.827619 | mfi.ex | starcoder |
defmodule HeartCheck.Executor do
@moduledoc """
Handles the execution of the checks in a HeartCheck module.
Spawns several `Task`s for the checks, execute and wait for the result.
Handles timeouts for the checks with the `{:error, "TIMEOUT"}` result.
"""
require Logger
@type result ::
{Strin... | lib/heartcheck/executor.ex | 0.839273 | 0.640341 | executor.ex | starcoder |
defmodule Mix.Tasks.Ecto.Gen.Erd do
@moduledoc """
A mix task to generate an ERD (Entity Relationship Diagram) in a dot format
## Examples
$ mix ecto.gen.erd
$ mix ecto.gen.erd --output-path=ecto_erd.dot
$ mix ecto.gen.erd && dot -Tpng ecto_erd.dot -o erd.png && xdg-open erd.png
See output ... | lib/mix/tasks/ecto.gen.erd.ex | 0.811303 | 0.527256 | ecto.gen.erd.ex | starcoder |
defmodule Sentry.Logger do
require Logger
@moduledoc """
This is based on the Erlang [error_logger](http://erlang.org/doc/man/error_logger.html).
To set this up, add `:ok = :error_logger.add_report_handler(Sentry.Logger)` to your application's start function. Example:
```elixir
def start(_type, _opts) do
... | lib/sentry/logger.ex | 0.70202 | 0.633481 | logger.ex | starcoder |
defmodule ShopifyAPI.Plugs.AdminAuthenticator do
@moduledoc """
The ShopifyAPI.Plugs.AdminAuthenticator plug allows for easy admin authentication. The plug when included
in your route will verify Shopify signatures, that are added to the iframe call on admin page load, and
set a session cookie for the duration ... | lib/shopify_api/plugs/admin_authenticator.ex | 0.790652 | 0.47859 | admin_authenticator.ex | starcoder |
defmodule Process do
# This avoids crashing the compiler at build time
@compile {:autoload, false}
@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 relat... | libs/exavmlib/lib/Process.ex | 0.858852 | 0.65397 | Process.ex | starcoder |
defmodule Lab42.Message do
@moduledoc """
A container for error messages.
Defining some severities.
Create results depending on error messages.
Convenience functions for adding, filtering and sorting messages.
"""
defstruct location: "lnb or similar", message: "text", severity: :error
@type severi... | lib/lab42/message.ex | 0.692226 | 0.495422 | message.ex | starcoder |
defmodule Lab5.CustomTCPProtocol.Server do
@moduledoc """
Sever side of the CustomTCPProtocol library
:func: start
"""
alias Lab5.CustomTCPProtocol.Logger, as: Logger
require Logger
@regex ~r/([-+]?[0-9]*\.?[0-9]+[\/\+\-\*])+([-+]?[0-9]*\.?[0-9]+)/
@doc """
The options below ... | lab5/lib/custom_tcp_protocol/server/server.ex | 0.760161 | 0.434521 | server.ex | starcoder |
defmodule Chatbase do
@moduledoc """
Provides helper methods to log data to Chatbase Bot Analytics API
"""
@base_url "https://chatbase.com/api/"
@api_key Config.get(:chatbase, :api_key, System.get_env("CHATBASE_API_KEY"))
# Helper method to get time in milli seconds
defp milli_seconds do
:os.system_... | lib/chatbase.ex | 0.848628 | 0.445891 | chatbase.ex | starcoder |
defmodule StateServer.StateGraph do
@moduledoc """
tools for dealing with stategraphs.
State graphs take the form of a keyword list of keyword lists, wherein the
outer list is a comprehensive list of the states, and the inner lists are
keywords list of all the transitions, with the values of the keyword list... | lib/state_server/state_graph.ex | 0.916531 | 0.952486 | state_graph.ex | starcoder |
defmodule Nerves.Runtime.Log.KmsgParser do
@moduledoc """
Functions for parsing kmsg strings
"""
alias Nerves.Runtime.Log.SyslogParser
@doc """
Parse out the kmsg facility, severity, and message (including the timestamp
and host) from a kmsg-formatted string.
See https://elixir.bootlin.com/linux/late... | lib/nerves_runtime/log/kmsg_parser.ex | 0.792263 | 0.587825 | kmsg_parser.ex | starcoder |
defmodule UpcomingRouteDepartures do
@moduledoc """
UpcomingRouteDepartures are used to hold information about upcoming departures. UpcomingRouteDepartures
have a route, a direction, and a list
of departures. A Departure is a tuple {Headsign, [PredictedSchedule]}.
"""
alias Routes.Route
alias Predictions... | apps/site/lib/upcoming_route_departures.ex | 0.811863 | 0.431225 | upcoming_route_departures.ex | starcoder |
defmodule Forklift.Jobs.PartitionedCompaction do
@moduledoc """
This job handles compacting files together for long term storage. Running at a long period,
it takes data out of the main table and then reinserts it to reduce the total number of files in Hive.
No compaction will be performed if no data is presen... | apps/forklift/lib/forklift/jobs/partitioned_compaction.ex | 0.666822 | 0.443359 | partitioned_compaction.ex | starcoder |
defmodule Turtle.Motion do
@moduledoc """
Motion for Turtle
"""
alias Turtle.Vector
@type distance :: number
@type angle :: number
@doc """
Move the turtle forward by the given amount of distance.
Move the turtle forward by the specified distance, in the direction the
turtle is headed
## Exam... | turtle/lib/turtle/motion.ex | 0.939996 | 0.600979 | motion.ex | starcoder |
defmodule Cluster.Strategy.DNSPoll do
@moduledoc """
Assumes you have nodes that respond to the specified DNS query (A record), and which follow the node name pattern of
`<name>@<ip-address>`. If your setup matches those assumptions, this strategy will periodically poll DNS and connect
all nodes it finds.
##... | lib/strategy/dns_poll.ex | 0.861596 | 0.436922 | dns_poll.ex | starcoder |
defmodule Pathex do
@moduledoc """
Main module. Use it inside your project to call Pathex macros
To use it just insert
```elixir
defmodule MyModule do
require Pathex
import Pathex, only: [path: 1, path: 2, "~>": 2, ...]
...
end
```
Or you can use `use`
```elixir
defmodule MyModule d... | lib/pathex.ex | 0.825484 | 0.705994 | pathex.ex | starcoder |
defmodule Cldr do
@moduledoc """
Cldr provides the core functions to retrieve and manage
the CLDR data that supports formatting and localisation.
This module provides the core functions to access formatted
CLDR data, set and retrieve a current locale and validate
certain core data types such as locales, cu... | lib/cldr.ex | 0.89684 | 0.618809 | cldr.ex | starcoder |
defmodule Interpreter.Resources do
@moduledoc """
A module that exposes Ecto schema structs
"""
# Types
@typedoc """
ID that uniquely identifies the `struct`
"""
@type id :: term
@type params :: map
@typedoc """
* `:associations` - associations to load in the `struct`
"""
@type query_opt... | testData/org/elixir_lang/annotator/module_attribute/issue_469.ex | 0.88447 | 0.501831 | issue_469.ex | starcoder |
defmodule AWS.SESv2 do
@moduledoc """
Amazon SES API v2
Welcome to the Amazon SES API v2 Reference. This guide provides information
about the Amazon SES API v2, including supported operations, data types,
parameters, and schemas.
[Amazon SES](https://aws.amazon.com/pinpoint) is an AWS service that you
... | lib/aws/sesv2.ex | 0.873862 | 0.67816 | sesv2.ex | starcoder |
defmodule Cforum.Accounts.Badges do
@moduledoc """
The boundary for the Accounts system.
"""
import Ecto.Query, warn: false
import CforumWeb.Gettext
alias Cforum.Repo
alias Cforum.Accounts.{Badge, BadgeUser, BadgeGroup}
alias Cforum.Accounts.Notifications
alias Cforum.System
alias Cforum.Accounts.... | lib/cforum/accounts/badges.ex | 0.718693 | 0.438184 | badges.ex | starcoder |
defmodule Instream do
@moduledoc """
InfluxDB driver for Elixir
## Connections
To connect to an InfluxDB server you need a connection module:
defmodule MyApp.MyConnection do
use Instream.Connection, otp_app: :my_app
end
The `:otp_app` name and the name of the module can be freely chose... | lib/instream.ex | 0.893018 | 0.411406 | instream.ex | starcoder |
defmodule Resourceful.JSONAPI.Error do
@moduledoc """
Tools for converting errors formatted in accordance with `Resourceful.Error`
into [JSON:API-style errors](https://jsonapi.org/format/#errors).
JSON:API errors have a number of reserved top-level names:
* `code`
* `detail`
* `id`
* `links`
... | lib/resourceful/jsonapi/error.ex | 0.841517 | 0.585072 | error.ex | starcoder |
defmodule Fex do
@moduledoc """
Documentation for `Fex`.
This is an experimental package - do not use in production!
Many Elixir functions are returning two types of tuples:
- {:ok, data}
- {:error, error}
Together they maps quite closely to "either" structure.
Idea is to instead of using the `case` ... | lib/fex.ex | 0.909355 | 0.883588 | fex.ex | starcoder |
defmodule Re.Exporters.Trovit do
@moduledoc """
Listing XML exporter for trovit.
"""
@exported_attributes ~w(id url title sell_type description price listing_type area rooms
bathrooms garage_spots state city neighborhood address postal_code latitude longitude
owner agency virtual_tour pictures)a
@def... | apps/re/lib/exporters/trovit.ex | 0.667473 | 0.433142 | trovit.ex | starcoder |
defmodule Cldr.Unit.IncompatibleUnitsError do
@moduledoc false
defexception [:message]
def exception(message) do
%__MODULE__{message: message}
end
end
defmodule Cldr.Unit.UnknownUnitCategoryError do
@moduledoc false
defexception [:message]
def exception(message) do
%__MODULE__{message: message}... | lib/cldr/unit/exception.ex | 0.695235 | 0.401923 | exception.ex | starcoder |
defmodule Oban.Plugins.Pruner do
@moduledoc """
Periodically delete completed, cancelled and discarded jobs based on age.
## Using the Plugin
The following example demonstrates using the plugin without any configuration, which will prune
jobs older than the default of 60 seconds:
config :my_app, Oban... | lib/oban/plugins/pruner.ex | 0.879017 | 0.59928 | pruner.ex | starcoder |
defmodule Membrane.H264.FFmpeg.Encoder do
@moduledoc """
Membrane element that encodes raw video frames to H264 format.
The element expects each frame to be received in a separate buffer, so the parser
(`Membrane.Element.RawVideo.Parser`) may be required in a pipeline before
the encoder (e.g. when input is r... | lib/membrane_h264_ffmpeg/encoder.ex | 0.86757 | 0.560403 | encoder.ex | starcoder |
defmodule Graphmath.Vec3 do
@moduledoc """
This is the 3D mathematics library for graphmath.
This submodule handles 3D vectors using tuples of floats.
"""
@type vec3 :: {float, float, float}
@doc """
`create()` creates a zeroed `vec3`.
It takes no arguments.
It returns a `vec3` of the form `{ 0.0... | lib/graphmath/Vec3.ex | 0.960828 | 0.96859 | Vec3.ex | starcoder |
defmodule Guardian.Permissions do
@moduledoc """
Functions for dealing with permissions sets.
Guardian provides facilities for working with
many permission sets in parallel.
Guardian must be configured with it's permissions at start time.
config :guardian, Guardian,
permissions: %{
... | lib/guardian/permissions.ex | 0.71889 | 0.541954 | permissions.ex | starcoder |
defmodule Rig.Config do
@moduledoc """
Rig module configuration that provides `settings/0`.
There are two ways to use this module
### Specify a list of expected keys
```
defmodule Rig.MyExample do
use Rig.Config, [:some_key, :other_key]
end
```
`Rig.Config` expects a config entry similar to th... | apps/rig/lib/rig/config.ex | 0.915818 | 0.81468 | config.ex | starcoder |
defmodule GitHubActions.Versions do
@moduledoc """
Functions to select and filter lists and tables of versions.
The list of versions can have the following two forms.
- A simple list:
```elixir
["1", "2.0", "2.1", "3", "3.1", "3.1.1"]
```
- A table as list of keyword lists with compatible version... | lib/git_hub_actions/versions.ex | 0.912094 | 0.756313 | versions.ex | starcoder |
defmodule FakersApiWeb.GraphQL.Resolvers.Mutation do
alias FakersApi.People, as: Context
def create_person(arguments, _) do
case Context.create_person(arguments) do
{:ok, person} ->
{:ok, person}
_error ->
{:error,
"Couldn't create a person from given data. Unique fields m... | server/lib/fakers_api_web/graphql/resolvers/mutation.ex | 0.646795 | 0.445771 | mutation.ex | starcoder |
defmodule HoneylixirTracing do
@moduledoc """
Used to trace units of work and send the information to Honeycomb.
## Installation
Adding the library to your mix.exs as a dependency should suffice:
```
def deps() do
[
{:honeylixir_tracing, "~> 0.2.0"}
]
end
```
This is the main entrypo... | lib/honeylixir_tracing.ex | 0.910458 | 0.884838 | honeylixir_tracing.ex | starcoder |
defmodule Graph do
@moduledoc"""
This module serves as a graph library that enables to handle undirected weighted graphs (directed is in the works) in memory.
It features simple operations such as adding and removing `nodes` and `edges` and finding the shortest path between nodes.
Supported features:
- `Nod... | lib/graph.ex | 0.923493 | 0.977905 | graph.ex | starcoder |
defmodule Ash.DataLayer.Simple do
@moduledoc """
A data layer that simply returns structs
This is the data layer that is used under the hood
by embedded resources
"""
@transformers [
Ash.DataLayer.Simple.Transformers.ValidateDslSections
]
use Ash.Dsl.Extension, transformers: @transformers, sectio... | lib/ash/data_layer/simple/simple.ex | 0.781872 | 0.532243 | simple.ex | starcoder |
defmodule Grizzly.Transport do
@moduledoc """
Behaviour and functions for communicating to `zipgateway`
"""
defmodule Response do
@moduledoc """
The response from parse response
"""
alias Grizzly.ZWave.Command
@type t() :: %__MODULE__{
port: :inet.port_number() | nil,
... | lib/grizzly/transport.ex | 0.864925 | 0.456046 | transport.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.