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 UTCDateTime.ISO do
@moduledoc false
# credo:disable-for-this-file
# Copied from Elixir 1.9, since no longer in 1.10
# Might need to look for them in a different spot.
@doc false
@spec __match_date__ :: [term]
def __match_date__ do
quote do
[
<<y1, y2, y3, y4, ?-, m1, m2, ?-,... | lib/utc_datetime/iso.ex | 0.540924 | 0.533823 | iso.ex | starcoder |
defmodule Contentful.Delivery do
@moduledoc """
The Delivery API is the main access point for fetching data for your customers.
The API is _read only_.
If you wish to manipulate data, please have a look at the `Contentful.Management`.
## Basic interaction
The `space_id`, the `environment` and your `acces... | lib/contentful_delivery/delivery.ex | 0.888735 | 0.887838 | delivery.ex | starcoder |
defmodule Oracleex.Protocol do
@moduledoc """
Implementation of `DBConnection` behaviour for `Oracleex.ODBC`.
Handles translation of concepts to what ODBC expects and holds
state for a connection.
This module is not called directly, but rather through
other `Oracleex` modules or `DBConnection` functions.
... | lib/oracleex/protocol.ex | 0.826327 | 0.427994 | protocol.ex | starcoder |
defmodule Markright.Parsers.Youtube do
@moduledoc ~S"""
Parses the input for the youtube video.
## Examples
iex> input = "✇https://www.youtube.com/watch?v=noQcPIeW6tE&size=5"
iex> Markright.Parsers.Youtube.to_ast(input)
%Markright.Continuation{ast: {:iframe,
%{allowfullscreen: nil... | lib/markright/parsers/youtube.ex | 0.695028 | 0.48499 | youtube.ex | starcoder |
defmodule Kaffy.ResourceAdmin do
alias Kaffy.ResourceSchema
alias Kaffy.Utils
@moduledoc """
ResourceAdmin modules should be created for every schema you want to customize/configure in Kaffy.
If you have a schema like `MyApp.Products.Product`, you should create an admin module with
name `MyApp.Products.Pr... | lib/kaffy/resource_admin.ex | 0.862945 | 0.743401 | resource_admin.ex | starcoder |
defmodule Pointers.ULID do
@moduledoc """
An Ecto type for ULID strings.
"""
use Ecto.Type
require Logger
def synthesise!(x) when is_binary(x) and byte_size(x) == 26, do: synth(x)
def synthesise!(x) when is_binary(x) and byte_size(x) > 26, do: synthesise!(String.slice(x, 0, 26))
def synthesise!(x) when... | lib/pointers_ulid.ex | 0.749637 | 0.499939 | pointers_ulid.ex | starcoder |
defmodule AdventOfCode.Solutions.Day05 do
@moduledoc """
Solution for day 5 exercise.
### Exercise
https://adventofcode.com/2021/day/5
"""
require Logger
@points_separator " -> "
@coords_separator ","
def ovarlap_points(filename, mode \\ :full) do
result =
filename
|> File.read!()
... | lib/advent_of_code/solutions/day05.ex | 0.630685 | 0.519765 | day05.ex | starcoder |
defmodule X3m.System.Scheduler do
@moduledoc """
This behaviour should be used to schedule `X3m.System.Message` delivery
at some point in time in the future. Implementation module should persist alarms so when process
is respawned they can be reloaded into memory.
Not all scheduled alarms are kept in memory.... | lib/scheduler.ex | 0.889271 | 0.433442 | scheduler.ex | starcoder |
defmodule Phoenix.LiveComponent do
@moduledoc """
Components are a mechanism to compartmentalize state, markup, and
events in LiveView.
Components are defined by using `Phoenix.LiveComponent` and are used
by calling `Phoenix.LiveView.Helpers.live_component/3` in a parent LiveView.
Components run inside the... | lib/phoenix_live_component.ex | 0.890758 | 0.700741 | phoenix_live_component.ex | starcoder |
defmodule EventStore.Streams.Stream do
@moduledoc false
alias EventStore.{EventData, RecordedEvent, Storage}
alias EventStore.Streams.Stream
defstruct [:stream_uuid, :stream_id, stream_version: 0]
def append_to_stream(conn, stream_uuid, expected_version, events, opts \\ []) do
{serializer, opts} = Key... | lib/event_store/streams/stream.ex | 0.748076 | 0.417984 | stream.ex | starcoder |
defmodule Blinkchain do
alias Blinkchain.{
Color,
HAL,
Point
}
@moduledoc """
This module defines the canvas-based drawing API for controlling one or more
strips or arrays of NeoPixel-compatible RGB or RGBW LEDs. The virtual drawing
surface consists of a single rectangular plane where each NeoP... | lib/blinkchain.ex | 0.937132 | 0.753603 | blinkchain.ex | starcoder |
defmodule Opencensus.Absinthe do
@moduledoc """
Extends `Absinthe` to automatically create `opencensus` spans. Designed to work with whatever
is producing spans upstream, e.g. `Opencensus.Plug`.
## Installation
Assuming you're using `Absinthe.Plug`:
Add `opencensus_absinthe` to your `deps` in `mix.exs`, ... | lib/opencensus/absinthe.ex | 0.928466 | 0.836555 | absinthe.ex | starcoder |
if Code.ensure_loaded?(Plug) do
defmodule Authex.Plug.Authentication do
@moduledoc """
A plug to handle authentication.
This plug must be passed an auth module in which to authenticate with. Otherwise,
it will raise an `Authex.Error`.
With it, we can easily authenticate a Phoenix controller:
... | lib/authex/plug/authentication.ex | 0.836421 | 0.402011 | authentication.ex | starcoder |
defmodule AOC.Day2.Intcode do
@moduledoc false
@type memory :: %{integer => integer}
def part1(path) do
stream_input(path)
|> input_to_map()
|> update(1, 12)
|> update(2, 2)
|> compute
end
def part2(path, output) do
{noun, verb} =
stream_input(path)
|> input_to_map()
... | aoc-2019/lib/aoc/day2/intcode.ex | 0.826852 | 0.500854 | intcode.ex | starcoder |
defmodule Uplink.Monitors.Phoenix do
use Uplink.Monitor
@default_buckets [
5,
10,
20,
50,
100,
200,
500,
:timer.seconds(1),
:timer.seconds(1.5),
:timer.seconds(2),
:timer.seconds(5),
:timer.seconds(10)
]
@default_socket_buckets [
1,
2,
5,
10,
... | examples/org_uplink/lib/org_uplink/monitors/phoenix.ex | 0.864825 | 0.498047 | phoenix.ex | starcoder |
defmodule Code.Identifier do
@moduledoc false
@doc """
Checks if the given identifier is an unary op.
## Examples
iex> Code.Identifier.unary_op(:+)
{:non_associative, 300}
"""
@spec unary_op(atom) :: {:non_associative, precedence :: pos_integer} | :error
def unary_op(op) do
cond do
... | lib/elixir/lib/code/identifier.ex | 0.895739 | 0.719334 | identifier.ex | starcoder |
defmodule Mux.Token do
@moduledoc """
This module provides helpers for working with Playback IDs with `signed` playback policies. [API Documentation](https://docs.mux.com/docs/security-signed-urls)
"""
@type signature_type :: :video | :thumbnail | :gif | :storyboard
@type option ::
{:type, signatur... | lib/mux/token.ex | 0.829837 | 0.424412 | token.ex | starcoder |
defmodule Coxir.Struct.Role do
@moduledoc """
Defines methods used to interact with guild roles.
Refer to [this](https://discord.com/developers/docs/topics/permissions#role-object)
for a list of fields and a broader documentation.
"""
@type role :: String.t | map
use Coxir.Struct
@doc false
def get... | lib/coxir/struct/role.ex | 0.90753 | 0.541833 | role.ex | starcoder |
defmodule Earmark.TagSpecificProcessors do
@moduledoc """
This struct represents a list of tuples `{tag, function}` from which a postprocessing function
can be constructed
General Usage Examples:
iex(0)> tsp = new({"p", &Earmark.AstTools.merge_atts_in_node(&1, class: "one")})
...(0)> tsp = prepen... | lib/earmark/tag_specific_processors.ex | 0.785473 | 0.524943 | tag_specific_processors.ex | starcoder |
defmodule Aino.Middleware.Routes do
@moduledoc """
An Aino set of middleware for dealing with routes and routing
## Examples
To use the routes middleware together, see the example below.
```elixir
routes([
get("/orders", &Orders.index/1, as: :orders),
get("/orders/:id", [&Orders.authorize/1, &Ord... | lib/aino/routes.ex | 0.921207 | 0.81648 | routes.ex | starcoder |
defmodule Elixlsx.Sheet do
alias __MODULE__
alias Elixlsx.Sheet
alias Elixlsx.Util
@moduledoc ~S"""
Describes a single sheet with a given name. The name can be up to 31 characters long.
The rows property is a list, each corresponding to a
row (from the top), of lists, each corresponding to
a column (fro... | lib/elixlsx/sheet.ex | 0.760206 | 0.544438 | sheet.ex | starcoder |
defmodule Lnrpc.GenSeedRequest do
@moduledoc false
use Protobuf, syntax: :proto3
@type t :: %__MODULE__{
aezeed_passphrase: String.t(),
seed_entropy: String.t()
}
defstruct [:aezeed_passphrase, :seed_entropy]
field(:aezeed_passphrase, 1, type: :bytes)
field(:seed_entropy, 2, ty... | lib/lnrpc/rpc.pb.ex | 0.829008 | 0.451568 | rpc.pb.ex | starcoder |
defmodule Geocoder.Providers.GoogleMaps do
use HTTPoison.Base
use Towel
@endpoint "https://maps.googleapis.com/"
def geocode(opts) do
request("maps/api/geocode/json", extract_opts(opts))
|> fmap(&parse_geocode/1)
end
def geocode_list(opts) do
request_all("maps/api/geocode/json", extract_opts(... | lib/geocoder/providers/google_maps.ex | 0.599485 | 0.470311 | google_maps.ex | starcoder |
defmodule Tesla.Middleware.DigestAuth do
@moduledoc """
Digest access authentication middleware.
[Wiki on the topic](https://en.wikipedia.org/wiki/Digest_access_authentication)
**NOTE**: Currently the implementation is incomplete and works only for MD5 algorithm
and auth "quality of protection" (qop).
##... | lib/tesla/middleware/digest_auth.ex | 0.850484 | 0.816772 | digest_auth.ex | starcoder |
defmodule NervesTime.SaneTime do
# One of the ways that nerves_time determines whether a particular time is
# possible is whether it's in a known good range.
@default_earliest_time ~N[2020-07-25 00:00:00]
@default_latest_time %{@default_earliest_time | year: @default_earliest_time.year + 20}
@moduledoc fals... | lib/nerves_time/sane_time.ex | 0.770292 | 0.626853 | sane_time.ex | starcoder |
defmodule Exhort.SAT.Expr do
@moduledoc """
Create an expression in the expression language.
If the expression contains a comparison operator, it will be a constraint.
Otherwise, it will be a linear expression.
Use the `new/2` macro to create a new expression.
Use the remaining functions to create variab... | lib/exhort/sat/expr.ex | 0.815306 | 0.739611 | expr.ex | starcoder |
defmodule Mint.HTTP2.Frame do
@moduledoc false
use Bitwise, skip_operators: true
import Record
shared_stream = [:stream_id, {:flags, 0x00}]
shared_conn = [stream_id: 0, flags: 0x00]
defrecord :data, shared_stream ++ [:data, :padding]
defrecord :headers, shared_stream ++ [:exclusive?, :stream_dependenc... | lib/mint/http2/frame.ex | 0.736211 | 0.520374 | frame.ex | starcoder |
defmodule X509.Certificate.Validity do
@moduledoc """
Convenience functions for creating `:Validity` records for use in
certificates. The `:Validity` record represents the X.509 Validity
type, defining the validity of a certificate in terms of `notBefore`
and `notAfter` timestamps.
"""
import X509.ASN1
... | lib/x509/certificate/validity.ex | 0.899442 | 0.557544 | validity.ex | starcoder |
defprotocol BehaviorTree.Node.Protocol do
@moduledoc """
A protocol so you can define your own custom behavior tree nodes.
If you would like to make your own nodes with custom traversal behavior, you need to implement this protocol. A node is just a wrapper around a collection of children, that defines a contex... | lib/behavior_tree/node.ex | 0.944702 | 0.640383 | node.ex | starcoder |
defmodule Flv.AudioData do
@moduledoc "Represents a packet of audio data."
@type sound_format ::
:pcm_platform_endian
| :adpcm
| :mp3
| :pcm_little_endian
| :nelly_16khz
| :nelly_8khz
| :nelly
| :g711_alaw
| :g711_mulaw
... | apps/flv/lib/flv/audio_data.ex | 0.75496 | 0.496643 | audio_data.ex | starcoder |
defmodule AWS.IoTSecureTunneling do
@moduledoc """
AWS IoT Secure Tunneling
AWS IoT Secure Tunnling enables you to create remote connections to devices
deployed in the field.
For more information about how AWS IoT Secure Tunneling works, see the
[User
Guide](https://docs.aws.amazon.com/secure-tunneling... | lib/aws/iot_secure_tunneling.ex | 0.785514 | 0.435481 | iot_secure_tunneling.ex | starcoder |
defmodule MarsWater.Algos.Heap do
alias MarsWater.Util.MaxHeap
@count_solutions_every 100
def run(input) when is_binary(input) do
[results_requested, grid_size | measurements] =
String.split(input, " ", trim: true)
|> Enum.map(& Integer.parse(&1) |> elem(0))
heap = build_heap(measurements, ... | elixir/elixir-mars-water/lib/algos/heap.ex | 0.671363 | 0.626681 | heap.ex | starcoder |
defmodule DeskClock.Faces.Lazy do
@moduledoc """
A face that optimizes writes to be minimal on every pass
"""
@behaviour DeskClock.Face
alias ExPaint.{Color, Font}
@impl DeskClock.Face
def create(upper_zone, lower_zone) do
%{
label_font: Font.load("fixed6x12"),
time_font: Font.load("Ter... | lib/desk_clock/faces/lazy.ex | 0.851891 | 0.508483 | lazy.ex | starcoder |
defmodule BroadwaySQS.Options do
@moduledoc """
Broadway Sqs Option definitions and custom validators.
"""
def definition() do
[
queue_url: [
required: true,
type: {
:custom,
__MODULE__,
:type_non_empty_string,
[[{:name, :queue_url}]]
},... | lib/broadway_sqs/options.ex | 0.851228 | 0.4436 | options.ex | starcoder |
defmodule Noizu.MnesiaVersioning.SchemaBehaviour do
@moduledoc """
This method provides information about the changesets we will be running.
Currently only the change_sets() method is provided which should return a list of
changesets structures to execute. In the future we will provide support for directory sc... | lib/mnesia_versioning/behaviour/schema_behaviour.ex | 0.761538 | 0.848471 | schema_behaviour.ex | starcoder |
defmodule Lifx.Types.HSBK do
defstruct hue: 65535, saturation: 100, brightness: 32768, kelvin: 5000
end
defmodule Lifx.Types.GetColor do
defstruct [:ignored]
end
defmodule Lifx.Types.SetColor do
alias Lifx.Types.HSBK
defstruct color: %HSBK{}, duration: 1000
end
defmodule Lifx.Types.StateColor do
alias Lif... | lib/lifx/types/light.ex | 0.609873 | 0.493958 | light.ex | starcoder |
defmodule NewRelic.Transaction.Sidecar do
use GenServer, restart: :temporary
@moduledoc false
alias NewRelic.Transaction.ErlangTrace
def setup_stores do
:ets.new(__MODULE__.ContextStore, [:named_table, :set, :public, read_concurrency: true])
:ets.new(__MODULE__.LookupStore, [:named_table, :set, :publ... | lib/new_relic/transaction/sidecar.ex | 0.729905 | 0.46393 | sidecar.ex | starcoder |
Describe the intended usage of this charm and anything unique about how this
charm relates to others here.
This README will be displayed in the Charm Store, it should be either Markdown
or RST. Ideal READMEs include instructions on how to use the charm, expected
usage, and charm features that your audience might be i... | voting-app/README.ex | 0.621656 | 0.690429 | README.ex | starcoder |
defmodule Unicode.Transform.Rule.Transform do
@moduledoc """
#### 10.3.6 [Transform Rules](https://unicode.org/reports/tr35/tr35-general.html#Transform_Rules)
Each transform rule consists of two colons followed by a transform name, which is of the form source-target. For example:
```
:: NFD ;
:: und_Latn-... | lib/unicode/transform/rule/transform.ex | 0.867696 | 0.891008 | transform.ex | starcoder |
defmodule Membrane.Clock do
@moduledoc """
Clock is a Membrane utility that allows elements to measure time according to
a particular clock, which can be e.g. a soundcard hardware clock.
Internally, Clock is a GenServer process that can receive _updates_ (see `t:update_message_t/0`),
which are messages conta... | lib/membrane/clock.ex | 0.930229 | 0.690523 | clock.ex | starcoder |
defmodule Concentrate.Parser.Helpers do
@moduledoc """
Helper functions for the GTFS-RT and GTFS-RT Enhanced parsers.
"""
require Logger
defmodule Options do
@moduledoc false
@type drop_fields :: %{module => map}
@type t :: %Options{
routes: :all | {:ok, MapSet.t()},
exclu... | lib/concentrate/parser/helpers.ex | 0.859943 | 0.454714 | helpers.ex | starcoder |
import TypeClass
defclass Witchcraft.Applicative do
@moduledoc """
`Applicative` extends `Apply` with the ability to lift value into a
particular data type or "context".
This fills in the connection between regular function application and `Apply`
data --------------- function --------------... | lib/witchcraft/applicative.ex | 0.839882 | 0.666316 | applicative.ex | starcoder |
defmodule QRCode.ByteMode do
@moduledoc """
Byte mode character capacities table.
"""
alias QRCode.QR
@level_low [
{17, 1},
{32, 2},
{53, 3},
{78, 4},
{106, 5},
{134, 6},
{154, 7},
{192, 8},
{230, 9},
{271, 10},
{321, 11},
{367, 12},
{425, 13},
{458, 1... | lib/qr_code/byte_mode.ex | 0.711932 | 0.463991 | byte_mode.ex | starcoder |
defmodule Delta.Op do
alias Delta.Attr
def new(action, value, attr \\ false)
def new("delete", length, _attr), do: %{"delete" => length}
def new(action, value, %{} = attr) when map_size(attr) > 0 do
%{action => value, "attributes" => attr}
end
def new(action, value, _attr), do: %{action => value}
... | lib/delta/op.ex | 0.616936 | 0.451145 | op.ex | starcoder |
defmodule Itest.Account do
@moduledoc """
Maintaining used accounts state so that we're able to run tests multiple times.
"""
alias Itest.Reorg
alias Itest.Transactions.Encoding
import Itest.Poller, only: [wait_on_receipt_confirmed: 1]
@spec take_accounts(integer()) :: map()
def take_accounts(numbe... | priv/cabbage/apps/itest/lib/account.ex | 0.631935 | 0.419499 | account.ex | starcoder |
defmodule MeshxNode do
@readme File.read!("docs/README.md") |> String.split("<!-- MDOC !-->") |> Enum.fetch!(1)
@moduledoc """
#{@readme}
## Configuration options
* `:mesh_adapter` - Required. Specifies service mesh adapter module. Example: `mesh_adapter: MeshxConsul`.
* `:service_params` - 2-arity functi... | lib/meshx_node.ex | 0.835013 | 0.622459 | meshx_node.ex | starcoder |
defmodule OMG.API.State.Transaction do
@moduledoc """
Internal representation of a spend transaction on Plasma chain
"""
alias OMG.API.Crypto
alias OMG.API.State.Transaction.Signed
@zero_address Crypto.zero_address()
@max_inputs 2
defstruct [
:blknum1,
:txindex1,
:oindex1,
:blknum2,
... | apps/omg_api/lib/state/transaction.ex | 0.826642 | 0.404772 | transaction.ex | starcoder |
defmodule Nostrum.Struct.Message.Component do
@moduledoc """
A component attached to a message.
Note that the fields present depend on the `t:type/0` of the component object.
See the [Discord API Component Object
Documentation](https://discord.com/developers/docs/interactions/message-components#component-ob... | lib/nostrum/struct/message/component.ex | 0.880932 | 0.490541 | component.ex | starcoder |
defmodule Exfmt.Ast.Util do
@moduledoc false
@doc """
Given the arguments of a function call node, split the `do end`
block arguments off, assuming any are present.
iex> split_do_block([])
{[], []}
iex> split_do_block([1])
{[1], []}
iex> split_do_block([1, 2])
{[1, 2], []... | lib/exfmt/ast/util.ex | 0.574156 | 0.405096 | util.ex | starcoder |
defmodule Tzdata.ReleaseReader do
@moduledoc false
def rules, do: simple_lookup(:rules) |> hd |> elem(1)
def zones, do: simple_lookup(:zones) |> hd |> elem(1)
def links, do: simple_lookup(:links) |> hd |> elem(1)
def zone_list, do: simple_lookup(:zone_list) |> hd |> elem(1)
def link_list, do: simple_lookup... | lib/tzdata/release_reader.ex | 0.51562 | 0.445771 | release_reader.ex | starcoder |
defmodule ExCypher.Statements.Generic do
@moduledoc false
# This module will provide the most generic AST conversion
# functions that'll be shared between different commands.
# Of course, such abstraction won't be possible to match
# all kinds of statements, because some cypher commands
# like the `WHERE`... | lib/ex_cypher/statements/generic.ex | 0.730194 | 0.634317 | generic.ex | starcoder |
defmodule Dune.Opts do
@moduledoc """
Defines and validates the options for `Dune`.
The available options are explained below:
### Parsing restriction options
- `atom_pool_size`:
Defines the maximum total number of atoms that can be created.
Must be an integer `>= 0`. Defaults to `5000`.
See th... | lib/dune/opts.ex | 0.916918 | 0.760072 | opts.ex | starcoder |
defmodule Cldr.Unit.Conversions do
@moduledoc false
alias Cldr.Unit.Conversion
alias Cldr.Unit.Parser
@conversions Map.get(Cldr.Config.units(), :conversions)
|> Kernel.++(Cldr.Unit.Additional.conversions())
|> Enum.map(fn
{k, v} -> {k, struct(Conversion, v)}
... | lib/cldr/unit/conversion/conversions.ex | 0.824356 | 0.469763 | conversions.ex | starcoder |
defmodule AWS.LookoutEquipment do
@moduledoc """
Amazon Lookout for Equipment is a machine learning service that uses advanced
analytics to identify anomalies in machines from sensor data for use in
predictive maintenance.
"""
alias AWS.Client
alias AWS.Request
def metadata do
%AWS.ServiceMetadat... | lib/aws/generated/lookout_equipment.ex | 0.895054 | 0.487978 | lookout_equipment.ex | starcoder |
defmodule JMES.Functions do
@moduledoc """
Contains builtin functions.
"""
defmodule Handler do
@callback call(String.t(), list, keyword) :: {:ok, term} | {:error, atom}
end
@behaviour Handler
# ==============================================================================================
# abs
... | lib/jmes/functions.ex | 0.707304 | 0.42054 | functions.ex | starcoder |
defmodule Automaton.Types.TWEANN.ExoSelf do
alias Automaton.Types.TWEANN.Sensor
alias Automaton.Types.TWEANN.Actuator
alias Automaton.Types.TWEANN.Cortex
alias Automaton.Types.TWEANN.Neuron
require Logger
@doc ~S"""
The map/1 function maps the tuple encoded genotype into a process based
phenotype.
T... | lib/automata/automaton_types/neuroevolution/exoself.ex | 0.718693 | 0.480662 | exoself.ex | starcoder |
defmodule Playwright.Config do
@moduledoc """
Configuration for Playwright.
## Overview
config :playwright, ConnectOptions,
[...]
config :playwright, LaunchOptions,
[...]
config :playwright, PlaywrightTest,
[...]
## Details for `ConnectOptions`
Configuration for... | lib/playwright/config.ex | 0.903826 | 0.422326 | config.ex | starcoder |
defmodule RethinkDB.Pseudotypes do
@moduledoc false
defmodule Binary do
@moduledoc false
defstruct data: nil
def parse(%{"$reql_type$" => "BINARY", "data" => data}) do
%__MODULE__{data: :base64.decode(data)}
end
end
defmodule Geometry do
@moduledoc false
defmodule Point do
... | lib/rethinkdb/pseudotypes.ex | 0.611266 | 0.546194 | pseudotypes.ex | starcoder |
defmodule Nacha.Batch do
@moduledoc """
A struct that represents a batch, containing the Batch Header, Batch Control,
and Entry Detail records.
Also includes utility functions for building and managing batches.
"""
import Kernel, except: [to_string: 1]
alias Nacha.Records.BatchHeader, as: Header
alia... | lib/nacha/batch.ex | 0.837088 | 0.488344 | batch.ex | starcoder |
defmodule MiniCBOR do
@moduledoc """
Wrapper for CBOR encoding library to work with values encoded using structures optimised by Rust
https://twittner.gitlab.io/minicbor/minicbor_derive/index.html library
Changes maps keys for encoded values to integers.
Encodes atoms as index integers.
Map keys... | implementations/elixir/ockam/ockam/lib/ockam/mini_cbor.ex | 0.86923 | 0.681548 | mini_cbor.ex | starcoder |
defmodule Node do
@moduledoc """
Functions related to Erlang nodes.
"""
@doc """
Returns the current node. It returns the same as the built-in node().
"""
def self do
:erlang.node()
end
@doc """
Returns true if the local node is alive; that is, if the node can be
part of a distributed system... | lib/elixir/lib/node.ex | 0.796253 | 0.531209 | node.ex | starcoder |
defmodule Xema.Ref do
@moduledoc """
This module contains a struct and functions to represent and handle
references.
"""
alias Xema.{Ref, Schema, Utils, Validator}
require Logger
@typedoc """
A reference contains a `pointer` and an optional `uri`.
"""
@type t :: %__MODULE__{
pointer: St... | lib/xema/ref.ex | 0.884461 | 0.639764 | ref.ex | starcoder |
defmodule Day16 do
def solveA(input, progs) do
dance(parse_moves(input), parse_progs(progs))
|> Enum.map(&Atom.to_string/1)
|> Enum.join("")
end
def parse_moves(input) do
input
|> String.trim
|> String.split(",")
|> Enum.map(fn move ->
case String.at move, 0 do
"s" ->
... | 2017/elixir/day16/lib/day16.ex | 0.605449 | 0.576482 | day16.ex | starcoder |
defmodule Identicon do
@moduledoc """
Builds a identicon from an input string. An Identicon is a visual representation of a
hash value, usually of an IP address, that serves to identify a user of a computer
system as a form of avatar while protecting the users' privacy. The original
Identicon was a 9... | lib/identicon.ex | 0.868715 | 0.664662 | identicon.ex | starcoder |
defmodule Roman do
@moduledoc """
Functions to work with roman numerals in the `1..3999` range
"""
@external_resource "lib/numerals.txt"
@numeral_pairs @external_resource
|> File.stream!()
|> Stream.map(&String.split/1)
|> Stream.map(fn [val, num] -> {Strin... | lib/roman.ex | 0.929087 | 0.785679 | roman.ex | starcoder |
defmodule AWS.ServiceDiscovery do
@moduledoc """
AWS Cloud Map lets you configure public DNS, private DNS, or HTTP
namespaces that your microservice applications run in. When an instance of
the service becomes available, you can call the AWS Cloud Map API to
register the instance with AWS Cloud Map. For publ... | lib/aws/generated/service_discovery.ex | 0.902958 | 0.475484 | service_discovery.ex | starcoder |
defmodule Rondo.Component do
defmacro __using__(_) do
quote do
use Rondo.Action
use Rondo.Element
use Rondo.Event
use Rondo.Store
use Rondo.Stream
def state(props, _) do
props
end
def context(_) do
%{}
end
def render(_) do
nil
... | lib/rondo/component.ex | 0.578091 | 0.41742 | component.ex | starcoder |
defmodule Extreme do
@moduledoc """
Extreme module is main communication point with EventStore using tcp connection. Extreme is implemented using
GenServer and is OTP compatible. If client is disconnected from server we are not trying to reconnect,
instead you should rely on your supervisor. For example:
... | lib/extreme.ex | 0.813868 | 0.425725 | extreme.ex | starcoder |
defmodule RDF.XML.Encoder do
@moduledoc """
An encoder for RDF/XML 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.XML` format
module or the generic `RDF.Serializat... | lib/rdf/xml/encoder.ex | 0.888154 | 0.641015 | encoder.ex | starcoder |
defmodule Day06 do
def hello() do
:hello
end
def manhattan_distance({x1, y1}, {x2, y2}) do
abs(x1 - x2) + abs(y1 - y2)
end
def string_to_coordinate(string) do
string
|> String.split("\n", trim: true)
|> Enum.map(&String.trim/1)
|> Enum.map(fn s -> String.split(s, ", ") end)
|> En... | lib/day06.ex | 0.724286 | 0.731322 | day06.ex | starcoder |
defmodule VintageNetWiFi.WPASupplicantLL do
use GenServer
require Logger
@moduledoc """
This modules provides a low-level interface for interacting with the `wpa_supplicant`
Example use:
```elixir
iex> {:ok, ws} = VintageNetWiFi.WPASupplicantLL.start_link(path: "/tmp/vintage_net/wpa_supplicant/wlan0", ... | lib/vintage_net_wifi/wpa_supplicant_ll.ex | 0.790045 | 0.523725 | wpa_supplicant_ll.ex | starcoder |
defmodule BasketAnalysis do
def measure_support do
main
end
def main(args \\ []) do
{opts, _, _} = OptionParser.parse(args,
switches: [src: :string, support: :float, target: :string],
aliases: [S: :src, s: :support, t: :target]
)
items = opts[:src] |> Data.load
"Fil... | lib/basket_analysis.ex | 0.521959 | 0.632134 | basket_analysis.ex | starcoder |
defmodule Chronik.Store do
@moduledoc """
Chronik event Store API
"""
@typedoc "The options given for reading events from the stream"
@type options :: Keyword.t()
@typedoc """
The version of a given event record in the Store.
A simple implementation is a integer starting from 0. The atom
`:empty` i... | lib/chronik/store.ex | 0.910719 | 0.652338 | store.ex | starcoder |
defmodule Hedwig.Robot do
@moduledoc """
Defines a robot.
Robots receive messages from a chat source (XMPP, Slack, Console, etc), and
dispatch them to matching responders. See the documentation for
`Hedwig.Responder` for details on responders.
When used, the robot expects the `:otp_app` as option. The `:o... | lib/hedwig/robot.ex | 0.850748 | 0.549036 | robot.ex | starcoder |
defmodule Cronex.Parser do
@moduledoc """
This modules is responsible for time parsing.
"""
@days_of_week [:monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday]
@doc """
Parses a given `frequency` and `time` to a tuple.
## Example
iex> Cronex.Parser.parse_regular_frequency(:hour... | lib/cronex/parser.ex | 0.902757 | 0.667619 | parser.ex | starcoder |
defmodule Runtime.Config.Helper do
@moduledoc """
## Helper
A utility for fetching environment variable values from System and parsing them into the correct types ready for
use in elixir without having to do all the parsing and validation yourself.
Helper.get_env("ENV_VAR_NAME", <options>)
## Va... | lib/runtime/config/helper.ex | 0.577376 | 0.567697 | helper.ex | starcoder |
defmodule DataMorph.Csv do
@moduledoc ~S"""
Functions for converting enumerable, or string of CSV to stream of rows.
"""
@doc ~S"""
Parse `csv` string, stream, or enumerable to stream of rows.
## Examples
Convert blank string to empty headers and empty stream.
iex> {headers, rows} = DataMorph.Csv... | lib/data_morph/csv.ex | 0.804713 | 0.409959 | csv.ex | starcoder |
defmodule Pandora.Parse do
require Pandora.Data, as: Data
require QueueWrapper, as: Queue
@type result(t) :: {:ok, t} | {:error, any}
@type parse_hint :: :text | :element | :cdata | :comment | :closing_node | :end_of_input
defprotocol Parser do
@spec move_cursor(parser :: any, amount :: pos_integer()) :... | lib/pandora/parse.ex | 0.796174 | 0.454533 | parse.ex | starcoder |
defmodule Grizzly.CommandClass.MultiChannelAssociation.Set do
@moduledoc """
Command module for working with MULTI_CHANNEL_ASSOCIATION_SET command.
Command Options:
* `:group` - The association group
* `:nodes` - List of node ids to receive messages about node events
* `:endpoints` - List of endpoi... | lib/grizzly/command_class/multi_channel_association/set.ex | 0.861655 | 0.411613 | set.ex | starcoder |
defmodule Cldr.Number.System do
@moduledoc """
Functions to manage number systems which describe the numbering characteristics for a locale.
A number system defines the digits (if they exist in this number system) or
or rules (if the number system does not have decimal digits).
The system name is also used ... | lib/cldr/number/system.ex | 0.933271 | 0.594375 | system.ex | starcoder |
defmodule Grizzly.ZWave.Commands.FailedNodeRemoveStatus do
@moduledoc """
This command reports on the attempted removal of a presumed failed node.
Params:
* `:node_id` - the id of the node which removal for failure was attempted
* `:seq_number` - the sequence number of the removal command
* `:status... | lib/grizzly/zwave/commands/failed_node_remove_status.ex | 0.868325 | 0.747316 | failed_node_remove_status.ex | starcoder |
defmodule Loom.AWORSet do
@moduledoc """
An add-removed (optimized) observed-remove set (without tombstones).
This CRDT respects adds over removes in the event a simultaneous update. It
most naturally matches what most users expect when they add/remove items. It
also forms the foundation for other kinds of C... | lib/loom/aworset.ex | 0.881672 | 0.447219 | aworset.ex | starcoder |
defmodule Absinthe.Introspection do
@moduledoc """
Introspection support.
You can introspect your schema using `__schema`, `__type`, and `__typename`,
as [described in the specification](https://facebook.github.io/graphql/#sec-Introspection).
## Examples
Seeing the names of the types in the schema:
``... | lib/absinthe/introspection.ex | 0.919136 | 0.754802 | introspection.ex | starcoder |
defmodule GenMetricsBench.Pipeline do
alias GenMetrics.GenStage.Pipeline
alias GenMetricsBench.GenStage.Producer
alias GenMetricsBench.GenStage.ProducerConsumer
alias GenMetricsBench.GenStage.Consumer
alias GenMetricsBench.Utils.Runtime
@moduledoc """
GenMetricsBench harness for GenStage Pipelines.
T... | lib/pipeline.ex | 0.830972 | 0.484075 | pipeline.ex | starcoder |
defmodule Mix.Tasks.Hex.Publish do
use Mix.Task
alias Mix.Tasks.Hex.Build
@shortdoc "Publishes a new package version"
@moduledoc """
Publishes a new version of the package.
$ mix hex.publish
The current authenticated user will be the package owner. Only package
owners can publish the package, ne... | lib/mix/tasks/hex.publish.ex | 0.866514 | 0.658088 | hex.publish.ex | starcoder |
defmodule EctoCommons.DateTimeValidator do
@moduledoc ~S"""
This module provides validators for `DateTime`s.
You can use the following checks:
* `:is` to check if a `DateTime` is exactly some `DateTime`. You can also provide a `:delta` option (in seconds)
to specify a delta around which the `DateTime... | lib/validators/date_time.ex | 0.905469 | 0.494629 | date_time.ex | starcoder |
defmodule AWS.FMS do
@moduledoc """
AWS Firewall Manager
This is the *AWS Firewall Manager API Reference*.
This guide is for developers who need detailed information about the AWS
Firewall Manager API actions, data types, and errors. For detailed information
about AWS Firewall Manager features, see the [... | lib/aws/generated/fms.ex | 0.841761 | 0.456773 | fms.ex | starcoder |
alias ExType.{Type, Typespec, Typespecable}
defprotocol ExType.Typespecable do
@moduledoc false
@spec to_quote(Type.t()) :: any()
def to_quote(x)
@spec resolve_vars(Type.t(), %{optional(Type.SpecVariable.t()) => Type.t()}) :: Type.t()
def resolve_vars(x, vars)
@spec get_protocol_path(Type.t()) :: {:o... | lib/ex_type/typespecable.ex | 0.779574 | 0.552419 | typespecable.ex | starcoder |
defmodule Color do
defstruct red: 0, blue: 0, green: 0
@colors %{
aliceBlue: [240, 248, 255],
antique_white1: [255, 239, 219],
antique_white2: [238, 223, 204],
antique_white3: [205, 192, 176],
antique_white4: [139, 131, 120],
antique_white: [250, 235, 215],
blanched_almond: [255, 235, 2... | lib/color.ex | 0.709221 | 0.611353 | color.ex | starcoder |
defmodule FFprobe do
@moduledoc """
Execute ffprobe CLI commands.
> `ffprobe` is a simple multimedia streams analyzer. You can use it to output
all kinds of information about an input including duration, frame rate, frame size, etc.
It is also useful for gathering specific information about an input to be us... | lib/ffprobe.ex | 0.784979 | 0.46721 | ffprobe.ex | starcoder |
defmodule QueryBuilder.Query.Where do
@moduledoc false
require Ecto.Query
import QueryBuilder.Utils
def where(query, assoc_fields, filters) do
token = QueryBuilder.Token.token(query, assoc_fields)
{query, token} = QueryBuilder.JoinMaker.make_joins(query, token)
apply_filters(query, token, List.w... | lib/query/where.ex | 0.703957 | 0.606935 | where.ex | starcoder |
defmodule Blockchain.Blocktree do
@moduledoc """
Blocktree provides functions for adding blocks to the
overall blocktree and forming a consistent blockchain.
We have two important issues to handle after we get a new
unknown block:
1. Do we accept the block? Is it valid and does it connect to
a known ... | lib/blockchain/blocktree.ex | 0.740925 | 0.656796 | blocktree.ex | starcoder |
defmodule Temple.Engine do
@behaviour Phoenix.Template.Engine
@moduledoc """
Temple provides a templating engine for use in Phoenix web applications.
You can configure your application to use Temple templates by adding the following configuration.
```elixir
# config.exs
config :phoenix, :template_engin... | lib/temple/engine.ex | 0.73307 | 0.599221 | engine.ex | starcoder |
defmodule Exceptional.Value do
@moduledoc ~S"""
Provide an escape hatch for propagating unraised exceptions
## Convenience `use`s
Everything:
use Exceptional.Value
Only named functions (`exception_or_continue`):
use Exceptional.Value, only: :named_functions
Only operators (`~>`):
us... | deps/exceptional/lib/exceptional/value.ex | 0.853226 | 0.40342 | value.ex | starcoder |
defmodule Data.Effect do
@moduledoc """
In game effects such as damage
Valid kinds of effects:
- "damage": Does an amount of damage
- "damage/type": Halves damage if the type does not align
- "damage/over-time": Does damage over time
- "recover": Heals an amount of health/skill/move points
- "stats": ... | lib/data/effect.ex | 0.903498 | 0.562898 | effect.ex | starcoder |
defmodule Mix.Tasks.Compile do
use Mix.Task
@shortdoc "Compile source files"
@recursive true
@moduledoc """
A meta task that compiles source files. It simply runs the
compilers registered in your project. At the end of compilation
it ensures load paths are set.
## Configuration
* `:compilers` - co... | lib/mix/lib/mix/tasks/compile.ex | 0.78535 | 0.672379 | compile.ex | starcoder |
defmodule CRC.Model do
@type t() :: %__MODULE__{
bits: 0x00..0xff,
sick: boolean(),
width: 0x00..0xff,
poly: 0x0000000000000000..0xffffffffffffffff,
init: 0x0000000000000000..0xffffffffffffffff,
refin: boolean(),
refout: boolean(),
xorout: 0x0000000000000000..0xffffffffffffffff,
c... | lib/crc/model.ex | 0.580471 | 0.402627 | model.ex | starcoder |
defmodule VintageNetMobile.Modem.QuectelBG96 do
@behaviour VintageNetMobile.Modem
require Logger
@moduledoc """
Quectel BG96 support
The Quectel BG96 is an LTE Cat M1/Cat NB1/EGPRS module. Here's an example
configuration:
```elixir
VintageNet.configure(
"ppp0",
%{
type: VintageNetMobil... | lib/vintage_net_mobile/modem/quectel_BG96.ex | 0.858733 | 0.672923 | quectel_BG96.ex | starcoder |
defmodule Membrane.Opus.PacketUtils do
@moduledoc false
alias Membrane.Opus
# Refer to https://tools.ietf.org/html/rfc6716#section-3.1
@toc_config_map %{
0 => {:silk, :narrow, 10_000},
1 => {:silk, :narrow, 20_000},
2 => {:silk, :narrow, 40_000},
3 => {:silk, :narrow, 60_000},
4 => {:silk,... | lib/membrane_opus/packet_utils.ex | 0.768342 | 0.439447 | packet_utils.ex | starcoder |
% DateTime represents both Date and Time. Currently it is not aware of
% timezones, but that should be added in the future, while Date and Time
% objects should always ignore timezones.
%
% This implementation is based on Erlang's calendar module: http://erlang.org/doc/man/calendar.html
module DateTime
def new(date_t... | lib/date_time.ex | 0.809577 | 0.471832 | date_time.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.