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 FE.Result do
@moduledoc """
`FE.Result` is a data type for representing output of a computation that either succeeded or failed.
"""
@type t(a, b) :: {:ok, a} | {:error, b}
@type t(a) :: t(a, any)
alias FE.{Maybe, Review}
defmodule Error do
defexception [:message]
end
@doc """
Creat... | lib/fe/result.ex | 0.938962 | 0.609175 | result.ex | starcoder |
defmodule RTypes.Extractor do
@doc """
Recursively extract and instantiate AST representation of a type.
## Arguments
* `mod` - a module name or a tuple of a module name and object code
* `type_name` - type name
* `type_args` - arguments, if any, for the type. The arguments should be
represe... | lib/rtypes/extractor.ex | 0.78695 | 0.687818 | extractor.ex | starcoder |
defmodule Mix.Tasks.Expo.Msgfmt do
@shortdoc "Generate binary message catalog from textual translation description."
@moduledoc """
Generate binary message catalog from textual translation description.
mix expo.msgfmt [PO_FILE] [OPTIONS]
## Options
* `--use-fuzzy` - use fuzzy entries in output
* `... | lib/mix/tasks/expo.msgmft.ex | 0.813461 | 0.426441 | expo.msgmft.ex | starcoder |
defmodule Transform.Wkt.Point do
@moduledoc """
`Transform.Step.t()` impl for transformation of latitude/longitude into a
well-known text (WKT) point object.
## Init options
* `longitude` - String or list of strings as path to `Dictionary.Type.Longitude` field.
* `latitude` - String or list of strings as ... | apps/transform_wkt/lib/transform/wkt/point.ex | 0.929152 | 0.809125 | point.ex | starcoder |
defmodule LevelWeb.Schema.Mutations do
@moduledoc false
use Absinthe.Schema.Notation
@desc "Interface for payloads containing validation data."
interface :validatable do
field :success, non_null(:boolean)
field :errors, list_of(:error)
resolve_type fn _, _ -> nil end
end
@desc "A validation e... | lib/level_web/schema/mutations.ex | 0.868241 | 0.443179 | mutations.ex | starcoder |
defmodule MuchData do
use MuchData.Types
import ExAequo.KeywordParams, only: [tuple_from_params: 3]
@moduledoc """
Documentation for `MuchData`.
## MuchData
Reassemble and merge map like data from many sources and many formats.
- Sources supported in this version: files
- Formats supported in this ... | lib/much_data.ex | 0.727201 | 0.513668 | much_data.ex | starcoder |
defmodule RobotSimulator do
@directions [:north, :east, :south, :west]
@command ["A", "L", "R"]
@doc """
Create a Robot Simulator given an initial direction and position.
Valid directions are: `:north`, `:east`, `:south`, `:west`
"""
def create(), do: {:north, {0, 0}}
def create({x, y}), do: {:north, ... | robot-simulator/lib/robot_simulator.ex | 0.90432 | 0.865281 | robot_simulator.ex | starcoder |
defmodule Ello.Core.Discovery.Editorial do
use Ecto.Schema
alias Ello.Core.Content.Post
alias Ello.Core.Image
@type t :: %__MODULE__{}
schema "editorials" do
field :published_position, :integer
field :preview_position, :integer
field :kind, :string
field :content, :map
field :one_by_one... | apps/ello_core/lib/ello_core/discovery/editorial.ex | 0.68721 | 0.447823 | editorial.ex | starcoder |
defmodule Jylis.TLOG do
@moduledoc """
A timestamped log.
<sup>[[link](https://jemc.github.io/jylis/docs/types/tlog/)]</sup>
"""
@doc """
Get the latest `value` and `timestamp` for the register at `key`.
Returns `{:ok, [{value, timestamp}, ...]}` on success.
"""
def get(connection, key, count \\ nil... | lib/data_types/tlog.ex | 0.913879 | 0.713332 | tlog.ex | starcoder |
defmodule TextDelta.Difference do
@moduledoc """
Document diffing.
Given valid document states A and B, generate a delta that when applied to A
will result in B.
"""
alias TextDelta.{Operation, Attributes, ConfigurableString}
@typedoc """
Reason for an error.
"""
@type error_reason :: :bad_docume... | lib/text_delta/difference.ex | 0.844489 | 0.639989 | difference.ex | starcoder |
defmodule Money.Subscription do
@moduledoc """
Provides functions to create, upgrade and downgrade subscriptions
from one plan to another.
Since moving from one plan to another may require
prorating the payment stream at the point of transition,
this module is introduced to provide a single point of
calc... | lib/money/subscription.ex | 0.886119 | 0.860955 | subscription.ex | starcoder |
defmodule Patch.Mock.Code do
@moduledoc """
Patch mocks out modules by generating mock modules and recompiling them for a `target` module.
Patch's approach to mocking a module provides some powerful affordances.
- Private functions can be mocked.
- Internal function calls are effected by mocks regardless of... | lib/patch/mock/code.ex | 0.942507 | 0.923143 | code.ex | starcoder |
defmodule Legion.Identity.Information.AddressBook do
@moduledoc """
Functions for using the address book.
## Shared options
Functions `create_address/5` and `update_address/5` are subject to options below.
- `:type`: The new type of the address.
- `:name`: The new name of the address.
- `:country_name`... | apps/legion/lib/identity/information/address_book/address_book.ex | 0.891655 | 0.477371 | address_book.ex | starcoder |
defmodule Zipper do
@type t :: %Zipper{root: BinTree.t(), focus: BinTree.t(), path: [{BinTree.t(), :left | :right}] }
defstruct [:root, :path, :focus]
@doc """
Get a zipper focused on the root node.
"""
@spec from_tree(BinTree.t()) :: Zipper.t()
def from_tree(bin_tree) do
%Zipper{root: bin_tree, foc... | zipper/lib/zipper.ex | 0.861538 | 0.731778 | zipper.ex | starcoder |
defmodule TimeAgo do
@moduledoc """
Module for getting the amount of days/hours/minutes/seconds since past a specific date.
This module is inspired of functionality in many social networks
"""
@doc """
Returns tuple
first value is the unit as an atom
second value is the amount of days/hours/minutes/se... | lib/time_ago.ex | 0.88054 | 0.612368 | time_ago.ex | starcoder |
defmodule Ornia.Core.Driver do
use GenServer, restart: :transient
alias Ornia.Core.{
Grid,
RideSupervisor,
Passenger,
Pickup,
Ride,
}
def start_link([user, coordinates]) do
state = %{
user: user,
coordinates: coordinates,
pickup: nil,
passenger: nil,
ride:... | apps/core/lib/core/driver.ex | 0.647687 | 0.409309 | driver.ex | starcoder |
defmodule Sagax.Test.Builder do
alias __MODULE__
alias Sagax.Test.Log
import ExUnit.Assertions
import Sagax.Test.Assertions
defstruct log: nil, args: nil, context: nil
def new_builder(opts), do: struct!(Builder, opts)
def effect(builder, value, outer_opts \\ []) do
fn results, args, context, opts ... | test/support/builder.ex | 0.640748 | 0.448607 | builder.ex | starcoder |
defmodule Chex.Move.SmithParser do
@moduledoc false
@doc """
Parses the given `binary` as move.
Returns `{:ok, [token], rest, context, position, byte_offset}` or
`{:error, reason, rest, context, line, byte_offset}` where `position`
describes the location of the move (start position) as `{line, column_on_... | lib/chex/move/smith/smith_parser.ex | 0.893337 | 0.506652 | smith_parser.ex | starcoder |
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`.
## Examples
iex> Float.parse("34")
{34.0,""}
iex> Float.p... | lib/elixir/lib/float.ex | 0.950949 | 0.571916 | float.ex | starcoder |
defmodule OpenStax.Swift.Ecto.Model do
@moduledoc """
This module simplifies using OpenStax Swift storage with Ecto Models.
It exposes several functions that allow to easily upload/download files
that should be logically bound to certain record.
It automatically performs MIME type checks and ensures that up... | lib/openstax_swift_ecto/model.ex | 0.76908 | 0.451447 | model.ex | starcoder |
defmodule Caylir.Graph.Config do
@moduledoc """
## How To Configure
Configuration values can be stored in two locations:
- hardcoded inline
- application environment
If you combine inline configuration with an `:otp_app` setting the
inline defaults will be overwritten by and/or merged with the
applic... | lib/caylir/graph/config.ex | 0.844521 | 0.53692 | config.ex | starcoder |
alias ICouch.Document
defmodule ICouch.Collection do
@moduledoc """
Collection of documents useful for batch tasks.
This module helps collecting documents together for batch uploading. It keeps
track of the document byte sizes to allow a size cap and supports replacing a
document already in the collection.... | lib/icouch/collection.ex | 0.927642 | 0.620018 | collection.ex | starcoder |
defmodule ParamMap do
@moduledoc """
A subset of the `Map` module that operates on string-keyed maps using
atom key arguments.
## Examples
iex> params = %{"color" => "red", "size" => "large", "age" => 100}
iex> ParamMap.get(params, :color)
"red"
iex> ParamMap.delete(params, :size)
... | lib/param_map.ex | 0.87057 | 0.578121 | param_map.ex | starcoder |
defmodule Snipe do
@moduledoc """
Functions for transferring and managing files through SFTP
"""
alias Snipe.Sftp.{Access, Management, Transfer, Stream}
alias Snipe.Conn, as: Conn
@default_opts [
user_interaction: false,
silently_accept_hosts: true,
rekey_limit: 1_000_000_000_000,
port: 22... | lib/snipe.ex | 0.793546 | 0.432003 | snipe.ex | starcoder |
defmodule Confex.Transforms.Key do
@moduledoc """
A behaviour module for defining a key transformer for a pipeline.
Key transformers are used by a pipeline to alter the requested key before
passing it on to its underlying source.
Using this module automatically adopts the behaviour, defines a struct, and
... | lib/confex/transforms/key.ex | 0.887177 | 0.61633 | key.ex | starcoder |
defmodule Membrane.WAV.Parser do
@moduledoc """
Element responsible for parsing WAV files.
It requires WAV file in uncompressed, PCM format on the input (otherwise error is raised) and
provides raw audio on the output. WAV header is parsed to extract metadata for creating caps.
Then it is dropped and only sa... | lib/membrane_wav/parser.ex | 0.892484 | 0.837021 | parser.ex | starcoder |
defmodule Rambla.Http do
@moduledoc """
Default connection implementation for 🕸️ HTTP.
It expects a message to be a map, containing the following fields:
`:method`, `:path`, `:query`, `:body` _and_ the optional `:type`
that otherwise would be inferred from the body type.
For instance, this call would sen... | lib/rambla/connections/http.ex | 0.907563 | 0.652864 | http.ex | starcoder |
defmodule Griffin.Model.GraphQL do
@moduledoc """
Module for converting models to graphql.
"""
@doc """
Converts a list of models into a plug that can be used to serve GraphQL
with GraphiQL.
"""
def plugify(conn, schema) do
opts = Absinthe.Plug.init(schema: schema)
Absinthe.Plug.call(conn, opts... | lib/griffin/model/graphql.ex | 0.692018 | 0.407363 | graphql.ex | starcoder |
defmodule Galaxy.Host do
@moduledoc """
This topologying strategy relies on Erlang's built-in distribution protocol by
using a `.hosts.erlang` file (as used by the `:net_adm` module).
Please see [the net_adm docs](http://erlang.org/doc/man/net_adm.html) for more details.
In short, the following is the gist ... | lib/galaxy/host.ex | 0.806738 | 0.701777 | host.ex | starcoder |
defmodule FloUI.Tab do
alias FloUI.Util.FontMetricsHelper
@moduledoc ~S"""
## Usage in SnapFramework
Tab should be passed into the Tabs module as follows.
``` elixir
<%= graph font_size: 20 %>
<%= component FloUI.Tabs, {@active_tab, @tabs}, id: :tabs do %>
<%= component FloUI.Grid, %{
... | lib/tabs/tab.ex | 0.714827 | 0.581778 | tab.ex | starcoder |
defmodule Eval do
@moduledoc """
Contains the evaluation functions used with lisir.
"""
@doc """
Evaluates the given tree in an environment. Returns a 2 element tuple,
the first element is the result, the second is the new environment.
"""
def eval([:+ | l], env) do
res = get_bindings(l, env) |> En... | lib/eval.ex | 0.642769 | 0.60437 | eval.ex | starcoder |
defmodule Ymlr.Encoder do
@moduledoc """
Encodes data into YAML strings.
"""
# credo:disable-for-this-file Credo.Check.Refactor.CyclomaticComplexity
@type data :: map() | [data] | atom() | binary() | number()
@quote_when_first [
"!", # tag
"&", # anchor
"*", # alias
"{", "}", # flow mappi... | lib/ymlr/encoder.ex | 0.810854 | 0.487307 | encoder.ex | starcoder |
defmodule FuzzDist.Telemetry do
@moduledoc """
Telemetry integration.
Match `:ok = :telemetry/all` as telemetry is expected as part of test.
`FuzzDist` executes the following events:
* `[:fuzz_dist, :beam]` - Executed on receipt of BEAM monitored message/signal.
#### Measurements
* `%{}`
#... | beam.fuzz_dist/lib/fuzz_dist/telemetry.ex | 0.735926 | 0.694704 | telemetry.ex | starcoder |
defmodule Distributed.Scaler.Node do
@moduledoc """
The functions in `Distributed.Scaler.Node` module helps to scale projects by processing every event on the next node, in order.
**Note**: Since this module is only a wrapper for `Node` module, there is no need to write a detailed documentation for this module.
Pl... | lib/distributed/scaler/node.ex | 0.761982 | 0.611034 | node.ex | starcoder |
defmodule Jeeves.Named do
@moduledoc """
Implement a singleton (global) named service.
### Usage
To create the service:
* Create a module that implements the API you want. This API will be
expressed as a set of public functions. Each function will automatically
receive the current state in a varia... | lib/jeeves/named.ex | 0.814643 | 0.676693 | named.ex | starcoder |
defmodule Xtree.Algorithms do
alias Xtree
@type xtree() :: Xtree.t()
@type tree() :: xtree() | %{children: list(tree)}
@type fn_traverse() ::
(node :: xtree(), accumulator :: any() ->
{:ok, accumulator :: any()} | {:halt, accumulator :: any()})
@doc """
Builds a hash map based on `t... | lib/xtree/algorithms.ex | 0.80406 | 0.510619 | algorithms.ex | starcoder |
defmodule Day3 do
@moduledoc """
--- Day 3: Toboggan Trajectory ---
Part1 -> how many trees would you encounter, while traversing the map, with (3, 1) slope.
Part2 -> What do you get if you multiply together the number of
trees encountered on each of the listed slopes?
"""
@num_of_rows 323
@row_lengt... | day3.ex | 0.807385 | 0.710427 | day3.ex | starcoder |
defmodule JSONC.Parser do
@moduledoc false
import JSONC.Tokenizer
def parse!(content) when is_binary(content) do
case parse(content) do
{:ok, result} ->
result
{:error, reason} ->
raise reason
end
end
def parse(content) when is_binary(content) do
case parse_value({c... | lib/parser.ex | 0.709623 | 0.501404 | parser.ex | starcoder |
defmodule Topo.Contains do
@moduledoc false
import Topo.Intersects
alias Topo.PointRing
alias Topo.LineLine
alias Topo.LineRing
alias Topo.RingRing
@type geo_struct ::
%Geo.Point{}
| %Geo.MultiPoint{}
| %Geo.LineString{}
| %Geo.MultiLineString{}
| %Geo.... | lib/topo/contains.ex | 0.777046 | 0.40645 | contains.ex | starcoder |
defmodule ExWire.Adapter.UDP do
@moduledoc """
Starts a UDP server to handle incoming and outgoing
peer to peer messages according to RLPx.
"""
use GenServer
@doc """
When starting a UDP server, we'll store a network to use for all
message handling.
"""
@spec start_link(atom(), {module(), term()}, ... | apps/ex_wire/lib/ex_wire/adapter/udp.ex | 0.837686 | 0.469885 | udp.ex | starcoder |
defmodule Bincode.Structs do
@moduledoc """
Module defining macros related to structs and enums.
"""
@doc """
Declares a new struct. This macro generates a struct with serialization and
deserialization methods according to the given fields.
## Options
* `absolute` - When set to true, the given struct... | lib/bincode/structs.ex | 0.880155 | 0.461259 | structs.ex | starcoder |
defmodule Tensorflow.FunctionDefLibrary do
@moduledoc false
use Protobuf, syntax: :proto3
@type t :: %__MODULE__{
function: [Tensorflow.FunctionDef.t()],
gradient: [Tensorflow.GradientDef.t()]
}
defstruct [:function, :gradient]
field(:function, 1, repeated: true, type: Tensorflow... | lib/tensorflow/core/framework/function.pb.ex | 0.80567 | 0.661951 | function.pb.ex | starcoder |
defmodule ScChecksumHelper do
@moduledoc """
This module contain function which generate payment requests to the SafeCharge servers.
"""
# This will enable us to test the private functions.
# Note that testing private function is BAD, as we are testing implementation details not behaviour!
@compile if Mix.e... | lib/sc_checksum_helper.ex | 0.729038 | 0.470858 | sc_checksum_helper.ex | starcoder |
defmodule Pathfinding do
@moduledoc """
This module is the entry point to access the more important `Pathfinding.Grid` and provides the search methods used against a Grid struct.
"""
alias Pathfinding.{
Coord,
Grid,
Node,
Search
}
@doc """
Returns the path from one coordinate to another.... | lib/pathfinding.ex | 0.918151 | 0.761428 | pathfinding.ex | starcoder |
defmodule Ecto.Changeset do
@moduledoc ~S"""
Changesets allow filtering, casting, validation and
definition of constraints when manipulating structs.
There is an example of working with changesets in the introductory
documentation in the `Ecto` module. The functions `cast/4` and
`change/2` are the usual en... | lib/ecto/changeset.ex | 0.884919 | 0.736116 | changeset.ex | starcoder |
defmodule Elastix.Mapping do
@moduledoc """
The mapping API is used to define how documents are stored and indexed.
[Elastic documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html)
"""
import Elastix.HTTP, only: [prepare_url: 2]
alias Elastix.{HTTP, JSON}
@doc """
... | lib/elastix/mapping.ex | 0.848643 | 0.425068 | mapping.ex | starcoder |
defmodule ZenMonitor do
@moduledoc """
ZenMonitor provides efficient monitoring of remote processes and controlled dissemination of
any resulting `:DOWN` messages.
This module provides a convenient client interface which aims to be a drop in replacement for
`Process.monitor/1` and `Process.demonitor/2`
# ... | lib/zen_monitor.ex | 0.886871 | 0.807385 | zen_monitor.ex | starcoder |
defmodule GenStateMachine do
@moduledoc """
A behaviour module for implementing a state machine.
The advantage of using this module is that it will have a standard set of
interface functions and include functionality for tracing and error reporting.
It will also fit into a supervision tree.
## Example
... | lib/gen_state_machine.ex | 0.892064 | 0.793706 | gen_state_machine.ex | starcoder |
defmodule AWS.Batch do
@moduledoc """
Batch
Using Batch, you can run batch computing workloads on the Amazon Web Services
Cloud.
Batch computing is a common means for developers, scientists, and engineers to
access large amounts of compute resources. Batch uses the advantages of this
computing workload... | lib/aws/generated/batch.ex | 0.921298 | 0.616705 | batch.ex | starcoder |
defmodule Xlsxir.ParseWorksheet do
alias Xlsxir.{ConvertDate, ConvertDateTime, SaxError}
import Xlsxir.ConvertDate, only: [convert_char_number: 1]
require Logger
@moduledoc """
Holds the SAX event instructions for parsing worksheet data via `Xlsxir.SaxParser.parse/2`
"""
defstruct row: %{}, cell_ref: "",... | lib/xlsxir/parse_worksheet.ex | 0.788868 | 0.665449 | parse_worksheet.ex | starcoder |
defmodule Ash.Query.Operator do
@moduledoc """
An operator is a predicate with a `left` and a `right`
For more information on being a predicate, see `Ash.Filter.Predicate`. Most of the complexities
are there. An operator must meet both behaviours.
"""
@doc """
Create a new predicate. There are various r... | lib/ash/query/operator/operator.ex | 0.896597 | 0.763263 | operator.ex | starcoder |
defmodule Day16 do
@moduledoc """
Advent of Code 2019
Day 16: Flawed Frequency Transmission
"""
alias Day16.{Part1, Part2}
def get_signal() do
Path.join(__DIR__, "inputs/day16.txt")
|> File.read!()
|> String.trim()
|> String.graphemes()
|> Enum.map(&String.to_integer/1)
end
def ex... | lib/day16.ex | 0.805135 | 0.54462 | day16.ex | starcoder |
defmodule Guardian.DB do
@moduledoc """
Guardian.DB is a simple module that hooks into guardian to prevent playback of tokens.
In vanilla Guardian, tokens aren't tracked so the main mechanism
that exists to make a token inactive is to set the expiry and wait until it arrives.
Guardian.DB takes an active rol... | lib/guardian/db.ex | 0.810591 | 0.858481 | db.ex | starcoder |
defmodule Clone.CLI do
@moduledoc """
Handles the command-line interface for the program.
This module contains the entry point, parses the command-line arguments and options, and houses
the main control flow of the program.
"""
alias Clone.Repo
alias Clone.State
require Logger
@doc """
The entry... | lib/cli.ex | 0.658308 | 0.41256 | cli.ex | starcoder |
defmodule Ecto.Adapters.Postgres do
@moduledoc """
This is the adapter module for PostgreSQL. It handles and pools the
connections to the postgres database with poolboy.
## Options
The options should be given via `Ecto.Repo.conf/0`.
`:hostname` - Server hostname;
`:port` - Server port (default: 5432);
... | lib/ecto/adapters/postgres.ex | 0.832985 | 0.436202 | postgres.ex | starcoder |
defmodule Cldr.Number.Symbol do
@moduledoc """
Functions to manage the symbol definitions for a locale and
number system.
"""
alias Cldr.Locale
alias Cldr.LanguageTag
alias Cldr.Number.System
defstruct [
:decimal,
:group,
:exponential,
:infinity,
:list,
:minus_sign,
:nan,
... | lib/cldr/number/symbol.ex | 0.928805 | 0.618032 | symbol.ex | starcoder |
defmodule Timex.Parse.DateTime.Parsers.ISO8601Extended do
use Combine.Helpers
alias Combine.ParserState
defparser parse(%ParserState{status: :ok, column: col, input: input, results: results} = state) do
case parse_extended(input) do
{:ok, parts, len, remaining} ->
%{state | :column => col + len... | lib/parse/datetime/parsers/iso8601_extended.ex | 0.533397 | 0.48499 | iso8601_extended.ex | starcoder |
defmodule LDAPoolex do
@doc """
Calls `:eldap.add/3` using a worker of the `pool_name` pool
"""
def add(pool_name, dn, attributes) do
:poolboy.transaction(pool_name, fn worker ->
Connection.call(worker, {:add, dn, attributes})
end)
end
@doc """
Calls `:eldap.modify/3` using a worker of t... | lib/ldapoolex.ex | 0.852997 | 0.600657 | ldapoolex.ex | starcoder |
defmodule ExOpenAI.Completion do
import ExOpenAI
@moduledoc """
All of the OpenAI API Completion endpoints.
"""
@doc """
The `POST /completions` endpoint for the OpenAI API.
Returns the wrapped response with either an `ok` or `error` tuple along
with the `HTTPoison.Response` as the second element in ... | lib/ex_openai/completion.ex | 0.857872 | 0.859546 | completion.ex | starcoder |
defmodule Fastimage do
@moduledoc """
Fastimage finds the dimensions/size or file type of a remote url,
local image file or a binary object given the url, file path or
binary itself respectively.
It streams the smallest amount of data necessary to ascertain the file size.
Supports ".bmp", ".gif", ".jpeg",... | lib/fastimage.ex | 0.938548 | 0.634543 | fastimage.ex | starcoder |
defmodule Yacto.Repo.Helper.Helper do
# this module is copied from Ecto.Repo.Queryable
@moduledoc false
require Ecto.Query
# defp field(ix, field) when is_integer(ix) and is_atom(field) do
# {{:., [], [{:&, [], [ix]}, field]}, [], []}
# end
defp assert_schema!(%{from: {_source, schema}}) when schema !... | lib/yacto/repo.ex | 0.628863 | 0.680905 | repo.ex | starcoder |
defmodule Workflow.Persistence do
@read_event_batch_size 100
@moduledoc """
Database side effects from Aggregates and Process Managers servers. Having them in a segregated
file helps to test, debug and share the uncommon code between them
"""
alias Workflow.Container
alias Workflow.Storage
require Logg... | lib/persistence.ex | 0.60871 | 0.499817 | persistence.ex | starcoder |
defmodule Custodian.Github do
@moduledoc """
The GitHub context provides a boundary into the GitHub API client interface
and associated domain logic. The top-level class provides a way to process
webhook payloads from GitHub.
"""
import Ecto.Query, warn: false
alias Custodian.Github.Processor
alias Cu... | lib/custodian/github/github.ex | 0.619586 | 0.525856 | github.ex | starcoder |
defmodule Towwwer.Websites do
@moduledoc """
The Websites context.
"""
require Logger
import Ecto.Query, warn: false
alias Towwwer.Repo
alias Towwwer.Websites.Site
alias Towwwer.Websites.Monitor
alias Towwwer.Tools.Helpers
alias Towwwer.Websites.Report
@doc """
Returns the list of sites.
##... | lib/towwwer/websites.ex | 0.835886 | 0.407805 | websites.ex | starcoder |
defmodule Elixirdo.Instance.MonadTrans.Writer do
alias Elixirdo.Instance.MonadTrans.Writer, as: WriterT
use Elixirdo.Base
use Elixirdo.Typeclass.Monad.Trans, import_typeclasses: true
use Elixirdo.Typeclass.Monad.Writer, import_monad_writer: true
use Elixirdo.Typeclass.Monoid, import_typeclasses: true
defs... | lib/elixirdo/instance/monad_trans/writer.ex | 0.532911 | 0.406685 | writer.ex | starcoder |
defmodule AWS.WorkSpaces do
@moduledoc """
Amazon WorkSpaces Service
Amazon WorkSpaces enables you to provision virtual, cloud-based Microsoft
Windows and Amazon Linux desktops for your users.
"""
@doc """
Associates the specified connection alias with the specified directory to
enable cross-Region r... | lib/aws/generated/work_spaces.ex | 0.883532 | 0.458106 | work_spaces.ex | starcoder |
defmodule State.Schedule do
@moduledoc "State for Schedules"
use State.Server,
indices: [:trip_id, :stop_id],
recordable: Model.Schedule
require Logger
alias Events.Gather
alias Model.Schedule
alias Parse.StopTimes
alias State.Trip
@fetch_stop_times {:fetch, "stop_times.txt"}
@subscriptions... | apps/state/lib/state/schedule.ex | 0.838151 | 0.409988 | schedule.ex | starcoder |
defmodule Mint.WebSocket.PerMessageDeflate do
@moduledoc """
A WebSocket extension which compresses each message before sending it across
the wire
This extension is defined in
[rfc7692](https://www.rfc-editor.org/rfc/rfc7692.html).
## Options
* `:zlib_level` - (default: `:best_compression`) the compres... | lib/mint/web_socket/per_message_deflate.ex | 0.818193 | 0.443299 | per_message_deflate.ex | starcoder |
defmodule AshPhoenix.Form.Auto do
@moduledoc """
A (slightly) experimental tool to automatically generate available nested forms based on a resource and action.
To use this, specify `forms: [auto?: true]` when creating the form.
There are two things that this builds forms for:
1. Attributes/arguments who's... | lib/ash_phoenix/form/auto.ex | 0.819063 | 0.791459 | auto.ex | starcoder |
defmodule Farmbot.Firmware.UartHandler.Framing do
@behaviour Nerves.UART.Framing
import Farmbot.Firmware.Gcode.Parser
use Farmbot.Logger
# credo:disable-for-this-file Credo.Check.Refactor.FunctionArity
@moduledoc """
Each message is one line. This framer appends and removes newline sequences
as part of ... | lib/farmbot/firmware/uart_handler/framing.ex | 0.631481 | 0.440529 | framing.ex | starcoder |
use Croma
defmodule Antikythera.Aws.CloudfrontSignedUrl do
@moduledoc """
This module provides functions to generate [a signed URL for CloudFront](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-urls.html)
"""
@doc """
Generates a signed URL to access a file via Cl... | lib/util/aws/cloudfront_signed_url.ex | 0.856812 | 0.406391 | cloudfront_signed_url.ex | starcoder |
defmodule Akd.Dsl.Pipeline do
@moduledoc """
Defines an Akd Pipeline.
This modules provides a DSL to interact with Akd in a readable and simple
manner.
The module provides a set of macros for generating hooks that could either
be dispatched to a hook module (native or custom created) or a set of
operati... | lib/akd/dsl/pipeline.ex | 0.87804 | 0.944074 | pipeline.ex | starcoder |
defmodule Bunch.Binary do
@moduledoc """
A bunch of helpers for manipulating binaries.
"""
use Bunch
@doc """
Chunks given binary into parts of given size.
Remaining part is cut off.
## Examples
iex> <<1, 2, 3, 4, 5, 6>> |> #{inspect(__MODULE__)}.chunk_every(2)
[<<1, 2>>, <<3, 4>>, <<5,... | lib/bunch/binary.ex | 0.878835 | 0.448789 | binary.ex | starcoder |
defmodule Kaguya.Channel do
use GenServer
alias Kaguya.ChannelSupervisor, as: ChanSup
alias Kaguya.Util, as: Util
@moduledoc """
Channel GenServer, with a few utility functions for working with
channels. As a GenServer, it can be called in the following ways:
* {:send, message}, where message is the mes... | lib/kaguya/channel.ex | 0.721939 | 0.403302 | channel.ex | starcoder |
defmodule Sippet do
@moduledoc """
Holds the Sippet stack.
Network transport protocols should be registered during initialization:
def init(_) do
Sippet.register_transport(:udp, false)
...
end
Messages are dispatched to transports by sending the following message:
send(pid,... | lib/sippet.ex | 0.895711 | 0.431584 | sippet.ex | starcoder |
defmodule Multiverses.Phoenix.PubSub do
@moduledoc """
Implements the `Multiverses` pattern for `Phoenix.PubSub`.
Messages topics are sharded by postfixing the topic with a universe id.
Processes in any given universe are then only capable of subscribing to
messages sent within the same universe.
## Usage... | lib/multiverses.phoenix.pubsub.ex | 0.85408 | 0.833257 | multiverses.phoenix.pubsub.ex | starcoder |
defmodule NervesHub.Connection do
@moduledoc """
Agent used to keep the simple state of the devices connection
to [nerves-hub.org](https://www.nerves-hub.org).
The state is a tuple where the first element is an atom of `:connected` or
`:disconnected` and the second element is the value of `System.monotonic_t... | lib/nerves_hub/connection.ex | 0.871338 | 0.944995 | connection.ex | starcoder |
defmodule Rummage.Ecto.Services.BuildSearchQuery do
@moduledoc """
`Rummage.Ecto.Services.BuildSearchQuery` is a service module which serves the
default search hook, `Rummage.Ecto.Hooks.Search` that comes shipped with `Rummage.Ecto`.
Has a `Module Attribute` called `search_types`:
```elixir
@search_types ... | lib/rummage_ecto/services/build_search_query.ex | 0.802013 | 0.884888 | build_search_query.ex | starcoder |
defmodule AdventOfCode2019.TheNBodyProblem do
@moduledoc """
Day 12 — https://adventofcode.com/2019/day/12
"""
@spec part1(Enumerable.t(), integer) :: integer
def part1(in_stream, steps \\ 1000) do
in_stream
|> Stream.map(&read_moons/1)
|> Enum.map(&start_moon/1)
|> connect_moons([])
|> S... | lib/advent_of_code_2019/day12.ex | 0.855263 | 0.518241 | day12.ex | starcoder |
defmodule EventStore.Notifications.Listener do
@moduledoc false
# Listener subscribes to event notifications using PostgreSQL's `LISTEN`
# command. Whenever events are appended to storage a `NOTIFY` command is
# executed by a trigger. The notification payload contains the first and last
# event number of the... | lib/event_store/notifications/listener.ex | 0.779867 | 0.434041 | listener.ex | starcoder |
defmodule ExVCR.Converter do
@moduledoc """
Provides helpers for adapter converters.
"""
defmacro __using__(_) do
quote do
@doc """
Parse string format into original request / response tuples.
"""
def convert_from_string(%{"request" => request, "response" => response}) do
%{... | lib/exvcr/converter.ex | 0.650356 | 0.46794 | converter.ex | starcoder |
defmodule Saucexages.Sauce do
@moduledoc """
Functions for working with [SAUCE](http://www.acid.org/info/sauce/sauce.htm).
"""
@sauce_version "00"
@sauce_id "SAUCE"
@comment_id "COMNT"
@comment_line_byte_size 64
@sauce_record_byte_size 128
@max_comment_lines 255
@eof_character 0x1a
@file_size_lim... | lib/saucexages/sauce.ex | 0.551815 | 0.468851 | sauce.ex | starcoder |
defmodule Sim.Grid do
alias Sim.Grid
def create(width, height, default \\ nil)
def create(width, height, func) when is_function(func) do
0..(width - 1)
|> Map.new(fn x ->
{x,
0..(height - 1)
|> Map.new(fn y ->
{y, func.(x, y)}
end)}
end)
end
def create(width,... | apps/sim/lib/sim/object/grid.ex | 0.667798 | 0.715772 | grid.ex | starcoder |
defmodule SensorHub.DataReader do
@moduledoc """
Opens the first I2C bus ("i2c-1") and reads from SensorHub device address (0x17).
Updates its internal state periodically (every second in the example below).
Below you can find a table of registers, that we found on their website:
https://wiki.52pi.com/index... | lib/sensor_hub/data_reader.ex | 0.692122 | 0.521776 | data_reader.ex | starcoder |
defmodule Xlsxir.Unzip do
alias Xlsxir.XmlFile
@moduledoc """
Provides validation of accepted file types for file path,
extracts required `.xlsx` contents to memory or files
"""
@filetype_error "Invalid file type (expected xlsx)."
@xml_not_found_error "Invalid File. Required XML files not found."
@wor... | lib/xlsxir/unzip.ex | 0.766512 | 0.404772 | unzip.ex | starcoder |
defmodule Day02 do
use Aoc2018
@doc ~S"""
Counts checksum as [specified](https://adventofcode.com/2018/day/2).
## Example
iex> Day02.part_one(~s(abcdef\nbababc\nabbcde\nabcccd\naabcdd\nabcdee\nababab))
12
"""
@spec part_one(binary()) :: number()
def part_one(input) when is_binary(input) do... | lib/day02.ex | 0.861611 | 0.45042 | day02.ex | starcoder |
defmodule CouchGears.Initializer do
@moduledoc """
This module is responsible for starting a CouchGears framework
inside a particular Couch DB note as a independent daemon.
A `CouchGears.Initializer` starts its own base supervisor. Each application (actually also a supervisor)
becomes a part of base supervis... | lib/couch_gears/initializer.ex | 0.723016 | 0.441011 | initializer.ex | starcoder |
defmodule Mint.HTTP1 do
@moduledoc """
Processless HTTP client with support for HTTP/1 and HTTP/1.1.
This module provides a data structure that represents an HTTP/1 or HTTP/1.1 connection to
a given server. The connection is represented as an opaque struct `%Mint.HTTP1{}`.
The connection is a data structure ... | deps/mint/lib/mint/http1.ex | 0.809577 | 0.600891 | http1.ex | starcoder |
defmodule ExTermbox.Constants do
@moduledoc """
Defines constants from the termbox library. These can be used e.g. to set a
formatting attributes or to identify keys passed in an event.
"""
use Bitwise, only_operators: true
@type constant :: integer
@type key :: constant
@keys %{
f1: 0xFFFF - 0,
... | lib/ex_termbox/constants.ex | 0.810779 | 0.456168 | constants.ex | starcoder |
defmodule Cldr.Calendar.Kday do
@moduledoc """
Provide K-Day functions for Dates, DateTimes and NaiveDateTimes.
"""
import Cldr.Calendar,
only: [
date_to_iso_days: 1,
date_from_iso_days: 2,
iso_days_to_day_of_week: 1,
weeks_to_days: 1
]
@doc """
Return the date of the `day... | lib/cldr/calendar/kday.ex | 0.945651 | 0.643833 | kday.ex | starcoder |
defmodule Acs.Improper do
@moduledoc """
A set of utilities for interacting with improper lists.
"""
@doc """
Converts a proper list into an improper list, popping of the tail of the
list and using it as the improper tail of the new improper list.
The given list must have at least 2 elements.
"""
@s... | lib/acs.ex | 0.902744 | 0.923936 | acs.ex | starcoder |
defmodule NBT.Parser do
@moduledoc """
Parsing functions that turn an NBT binary into native elixir types.
"""
import NBT.Util, only: [partial_unfold: 3]
@type next :: nil | {:end, binary} | {{atom, binary, binary}, binary}
@doc """
Given a partial NBT binary, returns the next TAG and the rest of the b... | lib/nbt/parser.ex | 0.814938 | 0.555857 | parser.ex | starcoder |
defmodule Cloudinary.Transformation.Effect.Vectorize do
@moduledoc false
defguardp is_colors(colors) when colors in 2..30
defguardp is_detail(detail) when (detail <= 1 and detail >= 0) or detail in 2..1000
defguardp is_despeckle(despeckl) when (despeckl <= 1 and despeckl >= 0) or despeckl in 2..100
defguardp ... | lib/cloudinary/transformation/effect/vectorize.ex | 0.73914 | 0.557725 | vectorize.ex | starcoder |
defmodule Flawless.SchemaValidator do
@moduledoc """
Defines a schema to validate that schemas are valid.
"""
import Flawless.Helpers
def schema_schema() do
fn
%Flawless.Spec{} -> spec_schema()
%Flawless.Union{} -> union_schema()
[] -> literal([])
l when is_list(l) -> list_schema(... | lib/flawless/schema_validator.ex | 0.698844 | 0.461927 | schema_validator.ex | starcoder |
defmodule MapSchema.Examples.CustomTypeLang do
@moduledoc """
MapSchema.Examples.CustomTypeLang
Imagine here a query to Database or any place where you have
the list https://www.iso.org/iso-639-language-codes.html
https://es.wikipedia.org/wiki/ISO_639-1
only if the value exist it will be valid in o... | lib/example/custom_type_lang.ex | 0.774328 | 0.542984 | custom_type_lang.ex | starcoder |
defmodule AnalysisPrep do
@moduledoc """
Analysis preparation for data series.
Incorporates the excellent elixir-statistics with the types of things needed for exploratory
analysis and preparing to use data in machine learning algorithms.
"""
alias AnalysisPrep.Encode
alias AnalysisPrep.Frequency
alia... | lib/analysis_prep.ex | 0.900188 | 0.696139 | analysis_prep.ex | starcoder |
defmodule Riak.Pool do
@moduledoc """
Defines a pool of Riak connections.
A pool can be defined as:
defmodule MyPool do
use Riak.Pool,
adapter: Riak.Pool.Poolboy,
hostname: "localhost"
end
Options will be passed to the pool adapter and to `Mongo.Connection`.
## Log... | lib/riak/pool.ex | 0.601828 | 0.546194 | pool.ex | starcoder |
defmodule Crux.Cache do
@moduledoc """
Behaviour all caches must implement. (Looking at custom ones you may want to write)
There are exceptions:
* User cache:
* Implement a `me/1` function setting the own user id
* A `me/0` and `me!/0` function getting the own user
* Guild cache:
* ... | lib/cache.ex | 0.879315 | 0.785473 | cache.ex | starcoder |
defmodule Errol.Consumer.Server do
@moduledoc """
`GenServer` that creates a `queue`, binds it to a given `routing_key` and
consumes messages from that queue.
The preferred way of spinning up consumer this is through `Errol.Wiring.consume/3`
when declaring your _Wiring_, but you can also use this module to ... | lib/errol/consumer/server.ex | 0.888904 | 0.418637 | server.ex | starcoder |
defmodule Brando.Revisions do
@moduledoc """
**NOTE**: if you use revisions on a schema that has a relation you are
preloading i.e:
`mutation :update, {Project, preload: [:related_projects]}`
You must pass `use_parent: true` to the field's dataloader to prevent
dataloader loading the relation from th... | lib/brando/revisions/revisions.ex | 0.841858 | 0.701777 | revisions.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.