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 Mix.Config do
@moduledoc ~S"""
Module for defining, reading and merging app configurations.
Most commonly, this module is used to define your own configuration:
use Mix.Config
config :plug,
key1: "value1",
key2: "value2"
import_config "#{Mix.env}.exs"
All `config... | lib/mix/lib/mix/config.ex | 0.834474 | 0.401453 | config.ex | starcoder |
defmodule Signs.Utilities.SourceConfig do
@moduledoc """
Configuration for a sign's data sourcess, via JSON. Configuration of a sign looks like:
## Sign (zone) config
{
"id": "roxbury_crossing_southbound",
"headway_group": "orange_trunk",
"type": "realtime",
"pa_ess_loc": "OROX",
"text_zon... | lib/signs/utilities/source_config.ex | 0.845688 | 0.581392 | source_config.ex | starcoder |
defmodule Minio do
@moduledoc """
This package implements the Minio API.
## Implemented API fucntions
The following api functions are implemented.
### Presigned Operations
+ presign_put_object
+ presign_get_object
*The package is being developed as necessary for my personal use. If
you require any ... | lib/minio.ex | 0.828592 | 0.760517 | minio.ex | starcoder |
defmodule AWS.Neptune do
@moduledoc """
Amazon Neptune
Amazon Neptune is a fast, reliable, fully-managed graph database service
that makes it easy to build and run applications that work with highly
connected datasets. The core of Amazon Neptune is a purpose-built,
high-performance graph database engine o... | lib/aws/neptune.ex | 0.885341 | 0.637962 | neptune.ex | starcoder |
defmodule DgraphEx.Util do
@moduledoc false
alias DgraphEx.Core.Expr.Uid
def as_rendered(value) do
case value do
x when is_list(x) -> x |> Poison.encode!()
%Date{} = x -> x |> Date.to_iso8601() |> Kernel.<>("T00:00:00.0+00:00")
%DateTime{} = x -> x |> DateTime.to_iso8601() |> String.replac... | lib/dgraph_ex/util.ex | 0.699973 | 0.451689 | util.ex | starcoder |
defmodule FexrYahoo.Utils do
@moduledoc """
Documentation for FexrYahoo.Utils.
"""
@doc false
@spec format(String.t, list(String.t)) :: map | no_return
def format({:ok, json}, symbols) do
json
|> Poison.decode!
|> extract_rates
|> format_rates
|> serialize
|> map_merge
|> filter... | lib/fexr_yahoo/utils.ex | 0.814459 | 0.406067 | utils.ex | starcoder |
defmodule Integer do
@moduledoc """
Functions for working with integers.
"""
import Bitwise
@doc """
Determines if an integer is odd.
Returns `true` if `n` is an odd number, otherwise `false`.
Allowed in guard clauses.
## Examples
iex> Integer.is_odd(3)
true
iex> Integer.is_od... | lib/elixir/lib/integer.ex | 0.934305 | 0.497192 | integer.ex | starcoder |
defmodule RomanNumerals do
@romans %{1 => "I", 5 => "V", 10 => "X", 50 => "L", 100 => "C", 500 => "D", 1000 => "M"}
@doc """
Convert the number to a roman number.
"""
@spec numeral(pos_integer) :: String.t()
def numeral(number) when number < 4 do
cond do
is_nil(@romans[number]) -> numeral(number -... | roman-numerals/lib/roman_numerals.ex | 0.539711 | 0.686731 | roman_numerals.ex | starcoder |
defmodule Cldr.Normalize.GrammaticalFeatures do
@moduledoc false
def normalize(content) do
content
|> Enum.map(fn
{<<language::binary-size(2), "-targets-nominal">>, case_data} ->
{language, format_case_data(case_data)}
{<<language::binary-size(3), "-targets-nominal">>, case_data} ->
... | mix/support/normalize/normalize_grammatical_features.ex | 0.50708 | 0.499817 | normalize_grammatical_features.ex | starcoder |
defmodule ExDag.Store.MemoryStoreData do
@moduledoc """
Backend data module for ExDag.Store.MemoryStore
"""
@enforce_keys [:dags, :runs, :options]
defstruct dags: %{},
runs: %{},
options: %{}
alias ExDag.DAG
alias ExDag.DAGRun
def new(options) do
struct!(__MODULE__, runs: %... | lib/ex_dag/store/memory_store.ex | 0.647018 | 0.442998 | memory_store.ex | starcoder |
defmodule Modbux.Tcp.Server do
@moduledoc """
API for Modbus TCP Server.
"""
alias Modbux.Tcp.Server
alias Modbux.Model.Shared
use GenServer, restart: :transient
require Logger
@port 502
@to :infinity
defstruct ip: nil,
model_pid: nil,
tcp_port: nil,
timeout: ni... | lib/tcp/server/server.ex | 0.878118 | 0.801548 | server.ex | starcoder |
defmodule Mix.Tasks.Phx.Gen.Elm do
use Mix.Task
@shortdoc "Generates an elm app inside a Phoenix (1.3) app with the necessary scaffolding"
@instructions """
1. add the following to the `plugins` section of your `brunch-config.js`
```js
elmBrunch: {
elmFolder: '.',
mainModules: ['... | lib/mix/tasks/phx.gen.elm.ex | 0.589835 | 0.685509 | phx.gen.elm.ex | starcoder |
defmodule Wadm.Model.AppSpec do
@moduledoc """
The root of an OAM Application Specification model
"""
alias __MODULE__
alias Wadm.Model.{
ActorComponent,
CapabilityComponent,
Decoder
}
@enforce_keys [:name]
defstruct [:name, :version, :description, components: []]
@typedoc """
Valid... | wadm/lib/wadm/model/app_spec.ex | 0.869341 | 0.421076 | app_spec.ex | starcoder |
defmodule EctoIPRange.Util.CIDR do
@moduledoc false
use Bitwise, skip_operators: true
alias EctoIPRange.Util.Inet
@doc """
Calculate first and last address for an IPv4 notation.
## Examples
iex> parse_ipv4("1.2.3.4", 32)
{{1, 2, 3, 4}, {1, 2, 3, 4}}
iex> parse_ipv4("192.168.0.0", 20)... | lib/ecto_ip_range/util/cidr.ex | 0.815306 | 0.61144 | cidr.ex | starcoder |
defmodule Liquex.Filter do
@moduledoc """
Contains all the basic filters for Liquid
"""
@type filter_t :: {:filter, [...]}
@callback apply(any, filter_t, map) :: any
alias Liquex.Context
defmacro __using__(_) do
quote do
@behaviour Liquex.Filter
@spec apply(any, Liquex.Filter.filter_t(... | lib/liquex/filter.ex | 0.913866 | 0.449272 | filter.ex | starcoder |
defmodule Catalog do
@external_resource "README.md"
@moduledoc "README.md"
|> File.read!()
|> String.split("<!-- MDOC !-->")
|> Enum.fetch!(1)
@doc false
defmacro __using__(_) do
quote do
@before_compile unquote(__MODULE__)
Module.register_attribute(__MODU... | lib/catalog.ex | 0.817028 | 0.433682 | catalog.ex | starcoder |
defmodule AFK.State.Keymap do
@moduledoc false
alias AFK.Keycode.Layer
alias AFK.Keycode.None
alias AFK.Keycode.Transparent
@enforce_keys [:layers, :counter]
defstruct [:layers, :counter]
@type t :: %__MODULE__{
layers: %{
optional(non_neg_integer) => %{
active: bool... | lib/afk/state/keymap.ex | 0.835718 | 0.516169 | keymap.ex | starcoder |
defmodule FinanceTS do
alias FinanceTS.OHLCV
alias FinanceTS.TimeSeries
@doc """
iex> FinanceTS.to_list({:ok, [[3600, 68.7, 70.1, 64.7, 67.9, 4.0e7], [7200, 68.3, 73.7, 65.8, 73.2, 3.2e7]], "AAPL", "USD", "NYSE"})
{:ok, %TimeSeries{
format: :list,
data: [%OHLCV{c: 67.9, h: 70.1, l: 64.7, o: 68.7, ts:... | lib/finance_ts.ex | 0.691289 | 0.450662 | finance_ts.ex | starcoder |
defmodule PhoenixComponents.View do
@moduledoc """
This module provides a way to easily generate helper functions to render
components.
The module can be included by others Phoenix.View modules to import components easily.
## Example
When working on a project with several components you can use this modu... | lib/phoenix_components/view.ex | 0.820037 | 0.611556 | view.ex | starcoder |
defmodule RDF.NQuads.Encoder do
@moduledoc """
An encoder for N-Quads 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.NQuads`
format module or the generic `RDF.Seri... | lib/rdf/serializations/nquads_encoder.ex | 0.890491 | 0.616763 | nquads_encoder.ex | starcoder |
defmodule Rak.Module.Service do
@moduledoc """
Defines the behavior expected from Rak module services.
Module services are responsible for:
1. Receiving client requests
2. Executing, routing and/or forwarding messages
3. Creating and terminating module instances as needed
In the case where a Rak ... | lib/rak/module/service.ex | 0.780202 | 0.760117 | service.ex | starcoder |
defmodule Sanbase.Clickhouse.MetricAdapter.SqlQuery do
@table "daily_metrics_v2"
@moduledoc ~s"""
Define the SQL queries to access to the v2 metrics in Clickhouse
The metrics are stored in the '#{@table}' clickhouse table where each metric
is defined by a `metric_id` and every project is defined by an `asse... | lib/sanbase/clickhouse/metric/sql_query/metric_sql_query.ex | 0.804636 | 0.430686 | metric_sql_query.ex | starcoder |
defmodule Cldr.Number.Format do
@moduledoc """
Functions to manage the collection of number patterns defined in Cldr.
Number patterns affect how numbers are interpreted in a localized context.
Here are some examples, based on the French locale. The "." shows where the
decimal point should go. The "," shows w... | lib/cldr/number/format.ex | 0.820649 | 0.773152 | format.ex | starcoder |
defmodule Day07.Connector do
@moduledoc """
A `t:Intcode.Computer.handler/0` that connects the input of one computer to the output
of another.
This module has functions for creating collections of handlers with different phase
settings and wiring those handlers together correctly. A Connector will usually ha... | aoc2019_elixir/apps/day07/lib/connector.ex | 0.819821 | 0.673266 | connector.ex | starcoder |
defmodule Set do
@moduledoc %S"""
This module specifies the Set API expected to be
implemented by different representations.
It also provides functions that redirect to the
underlying Set, allowing a developer to work with
different Set implementations using one API.
To create a new set, use the `new` f... | lib/elixir/lib/set.ex | 0.937826 | 0.690494 | set.ex | starcoder |
defmodule Bintreeviz.Renderer.Ascii do
@moduledoc """
Simple ASCII rendering module which, given a tree structure, render its nodes to STDOUT using ASCII characters such as dashes and pipes. Its implemented quite naively but we'll fix that in a next iteration.
"""
@behaviour Bintreeviz.Renderer
alias Bintreev... | lib/renderer/ascii.ex | 0.835249 | 0.505981 | ascii.ex | starcoder |
defmodule PhoenixInlineSvg.Helpers do
@moduledoc """
The module that adds the view helpers to fetch
and render SVG files into safe HTML.
## New Way
The preferred way of using this library is to add the helpers to the quoted
`view` in your `web.ex` file.
```elixir
def view do
quote do
use Ph... | lib/phoenix_inline_svg/helpers.ex | 0.898235 | 0.907926 | helpers.ex | starcoder |
defmodule PollutionDataStream do
@moduledoc false
def loadData() do
:pollution_sup.start_link()
data = importLinesFromCSV() |> Stream.map(&parseLine/1)
stations = identifyStations(data)
IO.puts("Loading stations time: #{getTime(fn -> loadStations(stations) end)}s")
IO.puts("Loading measurement... | src/pollution_data_stream.ex | 0.706596 | 0.450903 | pollution_data_stream.ex | starcoder |
defmodule Wargaming.Warships.Ship do
@moduledoc """
Ship provides functions for interacting with the
WarGaming.net World of Warships Warships API.
"""
use Wargaming.ApiEndpoint, api: Wargaming.Warships
@ship_stats "/ships/stats/"
@doc """
Ship.stats_for_all_ships/2 searches WarGaming ship stats (in t... | lib/wargaming/warships/ship.ex | 0.87582 | 0.506408 | ship.ex | starcoder |
defmodule ExTectonicdb.Connection do
@moduledoc """
Handles connection to the database socket
`tdb-server` uses first bit in the reply to denote success/failure, so `:gen_tcp` needs to connect with `packet: :raw`.
Incoming message format: 1 byte for success failure, 8 bytes big endian (64 bit) for length n, a... | lib/ex_tectonicdb/connection.ex | 0.706596 | 0.401834 | connection.ex | starcoder |
defmodule Himamo.BaumWelch.StepM do
@moduledoc ~S"""
Defines components of the M-step of the Baum-Welch algorithm (Maximization).
Maximizes the model's parameters.
"""
alias Himamo.{Matrix, Model, ObsSeq, Logzero}
alias Himamo.BaumWelch.Stats
import Logzero
@doc ~S"""
Re-estimates the `A` variable... | lib/himamo/baum_welch/step_m.ex | 0.830732 | 0.819713 | step_m.ex | starcoder |
defmodule Day24 do
@moduledoc """
AoC 2019, Day 24 - Planet of Discord
"""
@doc """
Calculate biodiversity rating for input
"""
def part1 do
Util.priv_file(:day24, "day24_input.txt")
|> File.read!()
|> first_repeated_bio()
end
@doc """
Count number of bugs in recursive grid after 200 m... | apps/day24/lib/day24.ex | 0.647464 | 0.543954 | day24.ex | starcoder |
defmodule Mix.Tasks.Compile.Unused do
use Mix.Task.Compiler
@shortdoc "Find unused public functions"
@moduledoc ~S"""
Compile project and find uncalled public functions.
### Warning
This isn't perfect solution and this will not find dynamic calls in form of:
apply(mod, func, args)
So this mean... | lib/mix/tasks/compile.unused.ex | 0.783326 | 0.539287 | compile.unused.ex | starcoder |
defmodule Oban.Worker do
@moduledoc """
Defines a behavior and macro to guide the creation of worker modules.
Worker modules do the work of processing a job. At a minimum they must define a `perform/1`
function, which will be called with an `args` map.
## Defining Workers
Define a worker to process jobs ... | lib/oban/worker.ex | 0.903457 | 0.680209 | worker.ex | starcoder |
defmodule Day12.Moon do
defstruct position: %Day12.Vector{}, velocity: %Day12.Vector{}
def run(1) do
# Hardcode positions, instead of trying to parse the input file
[
at(-7, -1, 6),
at(6, -9, -9),
at(-12, 2, -7),
at(4, -17, -12)
]
|> step(1_000)
|> total_energy
|> IO... | year_2019/lib/day_12/moon.ex | 0.732974 | 0.61057 | moon.ex | starcoder |
defmodule Routemaster.Drains.Notify do
@moduledoc """
Drain plug to declare listener modules that will be notified
of the received events. Listeners must implement the `call/1`
function, that will be invoked with a list of `Routemaster.Drain.Event`
structures as argument.
The listeners' `call/1` function i... | lib/routemaster/drain/drains/notify.ex | 0.848941 | 0.880746 | notify.ex | starcoder |
defmodule FE.Review do
@moduledoc """
`FE.Review` is a data type similar to `FE.Result`, made for representing
output of a computation that either succeed (`accepted`) or fail (`rejected`),
but that might continue despite of issues encountered (`issues`).
One could say that the type is a specific implementat... | lib/fe/review.ex | 0.933317 | 0.645413 | review.ex | starcoder |
defmodule Exceptional.TaggedStatus do
@moduledoc ~S"""
Convert back to conventional Erlang/Elixir `{:ok, _}` tuples
## Convenience `use`s
Everything:
use Exceptional.TaggedStatus
Only named functions (`to_tagged_status`, `ok`):
use Exceptional.TaggedStatus, only: :named_functions
Only oper... | lib/exceptional/tagged_status.ex | 0.749271 | 0.436322 | tagged_status.ex | starcoder |
defmodule Temple do
@engine Application.compile_env(:temple, :engine, EEx.SmartEngine)
@moduledoc """
Temple syntax is available inside the `temple`, and is compiled into efficient Elixir code at compile time using the configured `EEx.Engine`.
You should checkout the [guides](https://hexdocs.pm/temple/your-fi... | lib/temple.ex | 0.835047 | 0.641394 | temple.ex | starcoder |
defmodule Indicado.ADI do
@moduledoc """
This is the ADI module used for calculating Accumulation Distribution Line.
"""
@typedoc """
The argument passed to eval functions should be a list of adi_data_map type.
"""
@type adi_data_map :: %{
low: float,
high: float,
close: flo... | lib/indicado/adi.ex | 0.869424 | 0.598928 | adi.ex | starcoder |
defmodule GenServerAsync do
@moduledoc ~S"""
Gen Server for preventing blocking GenServer process on `c:handle_call/3` callbacks.
See more in `GenServer`.
## Example
```elixir
defmodule Queue do
use GenServerAsync
@server_name __MODULE__
def start_link(default) do
GenServerAsync.start_... | lib/gen_server_async.ex | 0.811788 | 0.618435 | gen_server_async.ex | starcoder |
defmodule Xandra.Compressor do
@moduledoc """
A behaviour to compress and decompress binary data.
Modules implementing this behaviour can be used to compress and decompress
data using one of the compression algorithms supported by Cassandra (see below).
## Supported algorithms and implementations
Native ... | lib/xandra/compressor.ex | 0.925592 | 0.784938 | compressor.ex | starcoder |
defmodule SecureHeaders.XXssProtection do
@moduledoc """
IO.inspect( SecureHeaders.XXssProtection.validate [x_xss_protection: [value: 0]])
IO.inspect( SecureHeaders.XXssProtection.validate [x_xss_protection: [value: 1]])
IO.inspect( SecureHeaders.XXssProtection.validate [x_xss_protection: [value: 1, mode: "blo... | lib/headers/x_xss_protection.ex | 0.550003 | 0.664613 | x_xss_protection.ex | starcoder |
defmodule FlowAssertions.Ecto.SchemaA do
use FlowAssertions.Define
use FlowAssertions
alias FlowAssertions.Ecto.Messages
@moduledoc """
Assertions for values defined by the macros in `Ecto.Schema`.
"""
@doc """
Assert that an association has been loaded.
Animal.typical(id, preload: [:service_ga... | lib/schema_a.ex | 0.843509 | 0.686035 | schema_a.ex | starcoder |
defmodule Sanbase.Signal.Scheduler do
@moduledoc ~s"""
This module is the entrypoint to the user custom signals.
It's main job is to execute the whole glue all modules related to signal processing
into one pipeline (the `run/0` function):
> Get the user triggers from the database
> Evaluate the signals
> ... | lib/sanbase/signals/evaluator/scheduler.ex | 0.722918 | 0.47098 | scheduler.ex | starcoder |
defmodule Bonbon.Model.Store do
use Bonbon.Web, :model
@moduledoc """
A model representing the different stores.
##Fields
###:id
Is the unique reference to the store entry. Is an `integer`.
###:public
Whether the store is publicly listed or whether it is private (for use b... | web/models/store.ex | 0.848486 | 0.788257 | store.ex | starcoder |
defmodule Flex.EngineAdapter.ANFIS do
@moduledoc """
An adaptive network-based fuzzy inference system (ANFIS) is a kind of artificial neural network that is based on Takagi–Sugeno fuzzy inference system,
this implementation use backpropagation, only Gaussian Membership function are allowed.
Reference:
https:/... | lib/engine_adapters/anfis.ex | 0.803675 | 0.525917 | anfis.ex | starcoder |
defmodule OptionsTrackerWeb.PositionLive.Helpers do
alias OptionsTracker.Accounts
alias OptionsTracker.Accounts.Position
alias OptionsTrackerWeb.Router.Helpers, as: Routes
@spec type_display(Position.t()) :: String.t()
def type_display(%Position{type: :stock, basis: basis}) when not is_nil(basis), do: "#{Opt... | lib/options_tracker_web/live/position_live/helpers.ex | 0.834069 | 0.494446 | helpers.ex | starcoder |
defmodule Pongo.Match.Game do
alias Pongo.Match.Vec
@parameters %{
paddle_length: 100,
paddle_height: 20,
ball_radius: 8,
field_width: 920,
field_height: 690,
wall_width: 15
}
@paddle_speed 700 / 1_000_000
@ball_initial_speed 300 / 1_000_000
@ball_max_speed 700 / 1_000_000
@ball_... | lib/pongo/match/game.ex | 0.781372 | 0.5526 | game.ex | starcoder |
defmodule Curvy.Signature do
@moduledoc """
Module for converting signature R and S values to DER encoded or compact
binaries.
"""
use Bitwise, only_operators: true
alias Curvy.Curve
defstruct crv: :secp256k1,
r: nil,
s: nil,
recid: nil
@typedoc "ECDSA Signature"
... | lib/curvy/signature.ex | 0.788909 | 0.442155 | signature.ex | starcoder |
defmodule ICalex.Props.VRecur do
@moduledoc false
use ICalex.Props
alias ICalex.Props
@canonical_keys [
"freq",
"until",
"count",
"interval",
"bysecond",
"byminute",
"byhour",
"byday",
"bymonthday",
"byyearday",
"byweekno",
"bymonth",
"bysetpos",
"wkst"
... | lib/props/v_recur.ex | 0.587233 | 0.419886 | v_recur.ex | starcoder |
defmodule AWS.Route53RecoveryCluster do
@moduledoc """
Welcome to the Routing Control (Recovery Cluster) API Reference Guide for Amazon
Route 53 Application Recovery Controller.
With Route 53 ARC, you can use routing control with extreme reliability to
recover applications by rerouting traffic across Availa... | lib/aws/generated/route53_recovery_cluster.ex | 0.937045 | 0.612773 | route53_recovery_cluster.ex | starcoder |
defmodule TypeCheck.Options do
import TypeCheck.Internals.Bootstrap.Macros
@moduledoc """
Defines the options that TypeCheck supports on calls to `use TypeCheck`.
Supported options:
- `:overrides`: A list of overrides for remote types. (default: `[]`)
- `:default_overrides`: A boolean. If false, will not ... | lib/type_check/options.ex | 0.834171 | 0.824108 | options.ex | starcoder |
defmodule JrtpBridge do
@moduledoc """
JrtpBridge - JSON/REST Transport Protocol Bridge
Supports the REST methodoy to access points on the Hub, using JSON as
the notation of the state.
GET /a/point Maps to Hub.deltas
PUT /a/point Maps to Hub.update
"""
alias :cowboy_req, as: CowboyReq
a... | lib/jrtp_bridge.ex | 0.590543 | 0.662223 | jrtp_bridge.ex | starcoder |
defmodule ExPlasma.Output do
@moduledoc """
An Output.
`output_id` - The identifier scheme for the Output. We currently have two: Position and Id.
`output_type` - An integer value of what type of output data is associated.
`output_data` - The main data for the output. This can be decode by the different ou... | lib/ex_plasma/output.ex | 0.908986 | 0.489748 | output.ex | starcoder |
defmodule Membrane.AudioMixer.ClipPreventingAdder do
@moduledoc """
Module responsible for mixing audio tracks (all in the same format, with the same number of
channels and sample rate). The result is a single path in the format mixed paths are encoded in.
If overflow happens during mixing, a wave will be scale... | lib/membrane_audio_mixer/clip_preventing_adder.ex | 0.874158 | 0.75401 | clip_preventing_adder.ex | starcoder |
defmodule Tensorflow.DebugTensorWatch do
@moduledoc false
use Protobuf, syntax: :proto3
@type t :: %__MODULE__{
node_name: String.t(),
output_slot: integer,
debug_ops: [String.t()],
debug_urls: [String.t()],
tolerate_debug_op_creation_failures: boolean
}
... | lib/tensorflow/core/protobuf/debug.pb.ex | 0.708918 | 0.427456 | debug.pb.ex | starcoder |
defmodule Knigge do
@moduledoc """
An opinionated way of dealing with behaviours.
Opinionated means that it offers an easy way of defining a "facade" for a
behaviour. This facade then delegates calls to the real implementation, which
is either given directly to `Knigge` or fetched from the configuration.
... | lib/knigge.ex | 0.913189 | 0.75316 | knigge.ex | starcoder |
defmodule Blockchain.Transaction.Receipt do
@moduledoc """
This module specifies functions to create and
interact with the transaction receipt, defined
in Section 4.4.1 of the Yellow Paper.
Transaction receipts track incremental state changes
after each transaction (e.g. how much gas has been
expended).
... | lib/blockchain/transaction/receipt.ex | 0.69035 | 0.596844 | receipt.ex | starcoder |
defmodule SnowplowTracker.Payload do
@moduledoc """
Represents the data structure used to store event information
"""
@derive Jason.Encoder
alias __MODULE__
alias SnowplowTracker.Payloads.Helper
@keys [
pairs: %{}
]
defstruct @keys
@type t :: %__MODULE__{
pairs: map()
}
... | lib/snowplow_tracker/payload.ex | 0.85496 | 0.453383 | payload.ex | starcoder |
defmodule Estated.Property do
@moduledoc "A property record."
@moduledoc since: "0.1.0"
alias Estated.Property.Address
alias Estated.Property.Assessment
alias Estated.Property.Deed
alias Estated.Property.MarketAssessment
alias Estated.Property.Metadata
alias Estated.Property.Owner
alias Estated.Prope... | lib/estated/property.ex | 0.83056 | 0.47658 | property.ex | starcoder |
defmodule Cizen.Saga do
@moduledoc """
The saga behaviour
## Example
defmodule SomeSaga do
use Cizen.Saga
defstruct []
@impl true
def on_start(%__MODULE__{}) do
saga
end
@impl true
def handle_event(_event, state) do
state
... | lib/cizen/saga.ex | 0.857231 | 0.640875 | saga.ex | starcoder |
defmodule Phoenix.PubSub.Redis do
@moduledoc """
Phoenix PubSub adapter based on Redis.
To start it, list it in your supervision tree as:
{Phoenix.PubSub,
adapter: Phoenix.PubSub.Redis,
host: "192.168.1.100",
node_name: System.get_env("NODE")}
You will also need to add `:phoenix_pu... | lib/phoenix_pubsub_redis/redis.ex | 0.787564 | 0.482429 | redis.ex | starcoder |
defmodule Queue do
@moduledoc """
This module crawls all pages and returns a list of pages as tuples.
The crawler will never go outside of the given URL host.
"""
@doc """
Asyncronously crawls all page linked from the initial URL.
It returns a list of tuples, each tuple containing:
- status code
... | lib/queue.ex | 0.735071 | 0.49823 | queue.ex | starcoder |
defmodule Replug do
@moduledoc """
```
# ---- router.ex ----
plug Replug,
plug: Corsica,
opts: {MyAppWeb.PlugConfigs, :corsica}
# ---- plug_configs.ex ----
defmodule MyAppWeb.PlugConfigs do
def corsica do
[
max_age: System.get_env("CORSICA_MAX_AGE"),
expose_headers: ~w(X-F... | lib/replug.ex | 0.602529 | 0.570182 | replug.ex | starcoder |
defmodule Ueberauth.Strategy.FreeAgent.OAuth do
@moduledoc """
An implementation of OAuth2 for FreeAgent, using the v2 API.
See `Ueberauth.Strategy.FreeAgent` for configuration details.
"""
use OAuth2.Strategy
@defaults [
strategy: __MODULE__,
site: "https://api.freeagent.com/v2",
authorize_ur... | lib/ueberauth/strategy/freeagent/oauth.ex | 0.851876 | 0.65902 | oauth.ex | starcoder |
defmodule Dwarlixir.World do
alias Dwarlixir.World
@type t :: [World.Location.t]
use GenServer
@ets_name :world
@world_map_key :world_map
def start_link(opts \\ %{}) do
GenServer.start_link(__MODULE__, opts, name: __MODULE__)
end
def init(%{init: false}) do
:ets.new(@ets_name, [:set, :named_t... | lib/dwarlixir/world/world.ex | 0.578329 | 0.444203 | world.ex | starcoder |
defmodule ExPrompt do
@moduledoc """
ExPrompt is a helper package to add interactivity to your
command line applications as easy as possible.
It allows common operations such as:
- Asking for an answer.
- Asking for a "required" answer.
- Choosing between several options.
- Asking for confirmat... | lib/ex_prompt.ex | 0.781331 | 0.523177 | ex_prompt.ex | starcoder |
defmodule J1605.Device do
use GenServer
@enforce_keys [:socket]
defstruct [:socket, :time_to_wait, relays: nil]
def start_link(arg) do
GenServer.start_link(__MODULE__, arg, name: __MODULE__)
end
@impl true
def init({address, port, time_to_wait}) do
with {:ok, socket} <- :gen_tcp.connect(address... | lib/j1605/device.ex | 0.5794 | 0.401219 | device.ex | starcoder |
defmodule SparkPost.SuppressionList do
@moduledoc """
The SparkPost Suppression List API for working with suppression lists.
Use `SparkPost.SuppressionList.delete/1` to delete a single entry from a list,
`SparkPost.SuppressionList.upsert_one/3` to insert or update a single list entry,
or `SparkPost.Suppressio... | lib/suppression_list.ex | 0.878673 | 0.701048 | suppression_list.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.881405 | 0.553928 | encoder.ex | starcoder |
defmodule Adventofcode.Day15OxygenSystem do
use Adventofcode
alias __MODULE__.{Direction, Droid, Maze, Position, Printer, Program, Runner, Tile}
def part_1(input) do
input
|> Program.parse()
|> Maze.new(view: {-19..21, -21..19})
|> Runner.find_oxygen_system()
|> Map.get(:oxygen_system)
|... | lib/day_15_oxygen_system.ex | 0.683208 | 0.570391 | day_15_oxygen_system.ex | starcoder |
defmodule Commands.ListCommands do
alias Interp.Functions
alias Interp.Interpreter
alias Commands.IntCommands
alias Commands.GeneralCommands
alias Commands.MatrixCommands
require Interp.Functions
def prefixes(a) do
case a do
_ when Functions.is_iterable(a) ->
... | lib/commands/list_commands.ex | 0.612773 | 0.684449 | list_commands.ex | starcoder |
defmodule GraphTh.Path do
@moduledoc """
GraphTh.Path is a path.
"""
defstruct path: []
@doc """
Generate an empty path.
## Examples
iex> GraphTh.Path.empty()
%GraphTh.Path{path: []}
"""
def empty() do
%GraphTh.Path{path: []}
end
@doc """
Generate a path from the given `path_lis... | lib/graph_th/path.ex | 0.923902 | 0.742282 | path.ex | starcoder |
defmodule Immortal.Ghost do
@moduledoc """
A process that persists temporarily after an original process dies.
## Rationale
Suppose you need to track users' online status. You have one process
per user per connection, and automatically kill the process if the user
disconnects.
This strategy is good as... | lib/immortal/ghost.ex | 0.800185 | 0.565419 | ghost.ex | starcoder |
defmodule Exq.Middleware.Server do
@moduledoc """
Middleware Server is responsible for storing middleware chain that is evaluated
when performing particular job. Middleware chain defaults to Stats, Job and Manager middlewares.
To push new middleware you must create module with common interface. Interface is si... | lib/exq/middleware/server.ex | 0.842037 | 0.776369 | server.ex | starcoder |
defmodule GameOfLifeCore.Universe do
@neighbours_places [:top_left, :top, :top_right, :left, :right, :bottom_left, :bottom, :bottom_right]
@valid_cells_values [:dead, :alive]
def evolve(universe) do
case check(universe) do
:ok -> evolve_safe(universe)
{error, extra_info} -> {:error, error, extra_... | apps/game_of_life_core/lib/game_of_life/universe.ex | 0.512693 | 0.538983 | universe.ex | starcoder |
defmodule Nebulex.Telemetry.StatsHandler do
@moduledoc """
Telemetry handler for aggregating cache stats; it relies on the default stats
implementation based on Erlang counters. See `Nebulex.Adapter.Stats`.
This handler is used by the built-in local adapter when the option `:stats`
is set to `true`.
"""
... | lib/nebulex/telemetry/stats_handler.ex | 0.764935 | 0.406126 | stats_handler.ex | starcoder |
defmodule ChromicPDF.ChromeError do
@moduledoc """
Exception in the communication with Chrome.
"""
defexception [:error, :opts, :message]
@impl true
def message(%__MODULE__{error: error, opts: opts}) do
"""
#{title_for_error(error)}
#{hint_for_error(error, opts)}
"""
end
defp title_f... | lib/chromic_pdf/api/chrome_error.ex | 0.717903 | 0.440409 | chrome_error.ex | starcoder |
defmodule Hui do
@moduledoc """
Hui 辉 ("shine" in Chinese) is an [Elixir](https://elixir-lang.org) client and library for
[Solr enterprise search platform](http://lucene.apache.org/solr/).
### Usage
- Searching Solr: `q/1`, `q/6`, `search/2`, `search/7`
- Updating: `update/3`, `delete/3`, `delete_by_quer... | lib/hui.ex | 0.895082 | 0.774114 | hui.ex | starcoder |
defmodule WorkerPool do
@moduledoc """
A pool module for user-defined workers.
## Example
The following module is a sample worker module, which sends `:ok` and a doubled list of each element to the host process after being called.
```elixir
defmodule SampleWorker do
use WorkerPool.Worker
@impl t... | lib/worker_pool.ex | 0.883601 | 0.774669 | worker_pool.ex | starcoder |
defmodule Game.Session.Effects do
@moduledoc """
Handle effects on a user
"""
use Game.Zone
require Logger
alias Game.Character
alias Game.Effect
alias Game.Environment
alias Game.Events.CharacterDied
alias Game.Format.Effects, as: FormatEffects
alias Game.Player
alias Game.Session.Process
... | lib/game/session/effects.ex | 0.891941 | 0.407451 | effects.ex | starcoder |
defmodule Carrier.Messaging.Tracker do
defstruct [reply_endpoints: %{}, subscriptions: %{}, monitors: %{}, unused_topics: []]
@spec add_reply_endpoint(Tracker.t, pid()) :: {Tracker.t, String.t}
def add_reply_endpoint(%__MODULE__{reply_endpoints: reps}=tracker, subscriber) do
case Map.get(reps, subscriber) d... | lib/carrier/messaging/tracker.ex | 0.759047 | 0.40751 | tracker.ex | starcoder |
defmodule Exsolr.Suggest do
@moduledoc """
Provides search functions to Solr
"""
require Logger
alias Exsolr.Config
alias Exsolr.HttpResponse
@doc """
Receives the query params, converts them to an url, queries a Solr suggestions and builds
the response
"""
def suggest(params) do
params
... | lib/exsolr/suggest.ex | 0.781372 | 0.466603 | suggest.ex | starcoder |
defmodule VisNetwork do
@moduledoc """
Elixir bindings to [vis-network](https://github.com/visjs/vis-network).
"""
defstruct spec: %{}
alias VisNetwork.Utils
@type t :: %__MODULE__{
spec: spec()
}
@type spec :: map()
@doc """
Returns a new specification wrapped in the `VisNetwor... | lib/vis_network.ex | 0.805326 | 0.601125 | vis_network.ex | starcoder |
require Logger
defmodule Tail do
@moduledoc """
Tail implements a simple file tail functionality.
Given a file, a function, and an interval, Tail will execute the function with a list of new lines found
in the file and continue checking for additional lines on the interval.
## Usage
{:ok, pid} = Tail.s... | lib/tail.ex | 0.839372 | 0.566498 | tail.ex | starcoder |
defmodule Dagex.Repo do
@moduledoc """
Adds Dagex-specific functionality to your application's `Ecto.Repo` module.
```elixir
defmodule MyApp.Repo do
use Ecto.Repo, otp_app: :my_app, adapter: Ecto.Adapters.Postgres
use Dagex.Repo
end
```
"""
alias Dagex.Operations.{CreateEdge, RemoveEdge}
@sp... | lib/dagex/repo.ex | 0.864882 | 0.693473 | repo.ex | starcoder |
defmodule Baiji.Request.Query.Encoder do
@moduledoc """
Encodes an input map into a query string based on the input shape
"""
import Baiji.Core.Utilities
alias Baiji.Operation
@doc """
Encode an input map into a query string
"""
def encode(%Operation{input_shape: nil} = op) do
[]
|> encode_ac... | lib/baiji/request/query/encoder.ex | 0.806472 | 0.541954 | encoder.ex | starcoder |
defmodule Throttlex do
@moduledoc """
Throttlex implements leaky bucket algorithm for rate limiting, it uses erlang ETS for storage.
"""
use GenServer
@buckets Application.get_env(:throttlex, :buckets) || []
@type key :: integer | binary | tuple | atom
@spec check(atom, key) :: :ok | :error
def check... | lib/throttlex.ex | 0.890809 | 0.454775 | throttlex.ex | starcoder |
defmodule Is.Validators.Length do
@moduledoc """
Length validator.
You can implement the protocol `Is.Validators.Length.Of` to get custom structure length.
## Examples
iex> Is.validate("1", length: 1)
[]
iex> Is.validate("123", length: [min: 3])
[]
iex> Is.validate("123", leng... | lib/is/validators/length.ex | 0.887966 | 0.693019 | length.ex | starcoder |
defmodule MapTileRenderer.TileGrid do
defstruct width: 0, height: 0, lat: 0, lon: 0, resolution: 0, tiles: %{}, bbox: {{0.0, 0.0}, {0.0, 0.0}}, row_bboxes: []
use GenServer
def start_link(width, height, lat, lon, resolution, default_tile) do
bbox = calc_bbox(lon, lat, width, height, resolution... | lib/map_tile_renderer/tile_grid.ex | 0.76708 | 0.737016 | tile_grid.ex | starcoder |
defmodule PlayfabEx.Server.Default.SharedGroupData do
@doc """
Adds users to the set of those able to update both the shared data, as well as the set of users in the group. Only users in the group (and the server) can add new members. Shared Groups are designed for sharing data between a very small number of pla... | lib/server/default/shared_group_data.ex | 0.61115 | 0.46557 | shared_group_data.ex | starcoder |
defmodule Tyyppi.Stats do
@moduledoc """
Process caching the loaded types information.
Whether your application often uses the types information, it makes sense
to cache it in a process state, because gathering it takes some time. In such
a case your application should start this process in the applicati... | lib/tyyppi/stats.ex | 0.711932 | 0.425665 | stats.ex | starcoder |
defmodule PandaDoc.PhoenixController do
@moduledoc """
Implements a PhoenixController that can be easily wired up and used.
## Examples
```elixir
defmodule YourAppWeb.PandaDocController do
use PandaDoc.PhoenixController
def handle_document_change(id, status, _details) do
id
|> Documents... | lib/panda_doc/phoenix_controller.ex | 0.776962 | 0.599163 | phoenix_controller.ex | starcoder |
defmodule JWT.Algorithm.Hmac do
@moduledoc """
Sign or verify a JSON Web Signature (JWS) structure using HMAC with SHA-2 algorithms
see http://tools.ietf.org/html/rfc7518#section-3.2
"""
require JWT.Algorithm.SHA, as: SHA
@doc """
Return a Message Authentication Code (MAC)
## Example
iex> shar... | lib/jwt/algorithm/hmac.ex | 0.883544 | 0.475605 | hmac.ex | starcoder |
defmodule Que.Job do
defstruct [:id, :arguments, :worker, :status, :ref, :pid, :created_at, :updated_at]
## Note: Update Que.Persistence.Mnesia after changing these values
@moduledoc """
Module to manage a Job's state and execute the worker's callbacks.
Defines a `Que.Job` struct an keeps track of the Job... | lib/que/job.ex | 0.617282 | 0.542257 | job.ex | starcoder |
defmodule ExAdvent.Day02 do
@moduledoc """
# Day 2: Inventory Management System
You stop falling through time, catch your breath, and check the screen on the device. "Destination reached. Current Year: 1518. Current Location: North Pole Utility Closet 83N10." You made it! Now, to find those anomalies.
Outside... | lib/ex_advent/day_02.ex | 0.504883 | 0.631537 | day_02.ex | starcoder |
defmodule Faker.DateTime do
@moduledoc false
@microseconds_per_day 86_400_000_000
@doc """
Returns a random date in the past up to N days, today not included
## Examples
iex> Faker.DateTime.backward(4)
#=> %DateTime{calendar: Calendar.ISO, day: 20, hour: 6,
#=> microsecond: {922180, 6},... | lib/faker/datetime.ex | 0.846403 | 0.44077 | datetime.ex | starcoder |
defmodule Optimal.Schema do
@moduledoc """
Functions for generating and validating the opts that generate a schema.
"""
defstruct opts: [],
defaults: [],
describe: [],
required: [],
extra_keys?: false,
types: [],
custom: [],
an... | lib/optimal/schema.ex | 0.897328 | 0.62134 | schema.ex | starcoder |
defmodule AWS.ResourceGroupsTaggingAPI do
@moduledoc """
Resource Groups Tagging API
"""
alias AWS.Client
alias AWS.Request
def metadata do
%AWS.ServiceMetadata{
abbreviation: nil,
api_version: "2017-01-26",
content_type: "application/x-amz-json-1.1",
credential_scope: nil,
... | lib/aws/generated/resource_groups_tagging_api.ex | 0.907499 | 0.40439 | resource_groups_tagging_api.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.