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 CIDR do
use Bitwise
@moduledoc """
Classless Inter-Domain Routing (CIDR)
"""
defstruct first: nil, last: nil, mask: nil, hosts: nil
defimpl String.Chars, for: CIDR do
@doc """
Prints cidr objectes in human readable format
IPv4: 1.1.1.0/24
IPv6: 2001::/64
"""
def to_st... | deps/cidr/lib/cidr.ex | 0.793586 | 0.489259 | cidr.ex | starcoder |
defmodule Day24 do
@moduledoc """
Documentation for Day24.
"""
def part1 do
initial_black_tiles("input.txt")
|> Enum.to_list()
|> Enum.count()
|> IO.puts()
end
def part2 do
"input.txt" |> initial_black_tiles() |> days(100) |> Enum.count() |> IO.puts()
end
def read_input(filename) ... | day24/lib/day24.ex | 0.611962 | 0.487368 | day24.ex | starcoder |
defmodule ExAws.ElasticLoadBalancing do
@moduledoc """
Operations on AWS ElasticLoadBalancing
AWS ElasticLoadBalancing provides a reliable, scalable, and flexible monitoring solution
for your AWS resources. This module provides functionality for only classic load balancers.
See `ExAws.ElasticLoadBalancingV2`... | lib/ex_aws/elastic_load_balancing.ex | 0.921296 | 0.403978 | elastic_load_balancing.ex | starcoder |
defmodule Protobuf.JSON.Decode do
@moduledoc false
import Bitwise, only: [bsl: 2]
alias Protobuf.JSON.Utils
@compile {:inline,
field_value: 2,
decode_map: 2,
decode_repeated: 2,
decode_integer: 1,
decode_float: 1,
parse_float: 1,
... | lib/protobuf/json/decode.ex | 0.801781 | 0.473596 | decode.ex | starcoder |
defmodule SMSFactor.Contacts do
@moduledoc """
Wrappers around **Contacts** section of SMSFactor API.
"""
@typedoc """
Params for defining a contact.
## Example
```elixir
{
"value": "33612345676",
"info1": "Hedy",
"info2": "Lamarr",
"info3": "Extase",
"info4": "1933"
}
```
"... | lib/sms_factor/contacts.ex | 0.790449 | 0.684778 | contacts.ex | starcoder |
defmodule Cizen.Automaton do
@moduledoc """
A saga framework to create an automaton.
"""
alias Cizen.Dispatcher
alias Cizen.EffectHandler
alias Cizen.Event
alias Cizen.Saga
alias Cizen.SagaID
alias Cizen.Automaton.{PerformEffect, Yield}
@finish {__MODULE__, :finish}
def finish, do: @finish
... | lib/cizen/automaton.ex | 0.908349 | 0.737489 | automaton.ex | starcoder |
defmodule Blogit.Component do
@moduledoc """
Contains common logic for creating and naming `Blogit` component processes.
A component is a `GenServer`, but instead declaring:
```
use GenServer
```
it should declare:
```
use Blogit.Component
```
This will make it a `GenServer` and will create th... | lib/blogit/component.ex | 0.831485 | 0.816443 | component.ex | starcoder |
defmodule Algae.Writer do
@moduledoc ~S"""
`Algae.Writer` helps capture the pattern of writing to a pure log or accumulated
value, handling the bookkeeping for you.
If `Algae.Reader` is quasi-read-only, `Algae.Writer` is quasi-write-only.
This is often used for loggers, but could be anything as long as the h... | lib/algae/writer.ex | 0.881258 | 0.496704 | writer.ex | starcoder |
defimpl Transmog.Parser, for: BitString do
@moduledoc """
Implementation of `Transmog.Parser` for strings. Parses strings which are
represented as dot notation and maps them to values in a nested map, struct or
list.
## Examples
"a.:b.c" #=> References a map or list with key path ["a", :b, "c"]
... | lib/transmog/parser/bit_string.ex | 0.899207 | 0.443058 | bit_string.ex | starcoder |
defmodule Engine.DB.Transaction do
@moduledoc """
The Transaction record. This is one of the main entry points for the system, specifically accepting
transactions into the Childchain as `tx_bytes`. This expands those bytes into:
* `tx_bytes` - A binary of a transaction encoded by RLP.
* `inputs` - The output... | apps/engine/lib/engine/db/transaction.ex | 0.910526 | 0.547222 | transaction.ex | starcoder |
defmodule Aoc2021.Day4.BingoBoard do
@moduledoc """
A 5x5 bingo board containing numbers and marked positions.
"""
defmodule Position do
@moduledoc """
A position on the bingo board.
"""
@type row() :: non_neg_integer()
@type col() :: non_neg_integer()
@opaque t() :: {row(), col()}
... | lib/aoc2021/day4/bingo_board.ex | 0.862974 | 0.620579 | bingo_board.ex | starcoder |
defmodule Day7.Part1 do
use Bitwise
def start(input \\ "input.txt") do
inputs = File.read!(input)
|> String.split(~r{\n})
|> Enum.filter(&(&1 != ""))
|> Enum.map(&convert_signal/1)
results = inputs
|> process(HashDict.new)
IO.puts "Result A: #{r... | day7/lib/day7/part1.ex | 0.578567 | 0.491151 | part1.ex | starcoder |
defmodule Agent do
@moduledoc """
Agents are a simple abstraction around state.
Often in Elixir there is a need to share or store state that
must be accessed from different processes or by the same process
at different points in time.
The Agent module provides a basic server implementation that
allows s... | lib/elixir/lib/agent.ex | 0.897827 | 0.79736 | agent.ex | starcoder |
defmodule Commanded.Scheduler.Jobs do
@moduledoc false
use GenServer
import Ex2ms
alias Commanded.Scheduler.{Jobs, JobSupervisor, OneOffJob, RecurringJob}
defstruct [:schedule_table, :jobs_table]
def start_link(args) do
GenServer.start_link(__MODULE__, args, name: __MODULE__)
end
@doc """
Sc... | lib/commanded/scheduler/jobs/jobs.ex | 0.789761 | 0.411406 | jobs.ex | starcoder |
defmodule CodeSigning do
@moduledoc """
Code signing and verification functions for BEAM binaries using Ed25519 signatures.
All strings for paths need to be passed as charlists for Erlang compatibility.
"""
@typedoc """
The filename as a string or the BEAM module binary.
"""
@type beam :: charlist() |... | lib/code_signing.ex | 0.912109 | 0.619025 | code_signing.ex | starcoder |
defmodule Club.ColorParser do
@moduledoc """
Wikipedia color names/hex values parser.
All the colors data itself has [Wikipedia copyrights](https://en.wikipedia.org/wiki/Wikipedia:Copyrights)
and distributed under the [Creative Commons Attribution-ShareAlike 3.0 Unported License](https://en.wikipedia.org/wiki/... | lib/club/color_parser.ex | 0.782496 | 0.607692 | color_parser.ex | starcoder |
defmodule Utils.Types.WalletAddress do
@moduledoc """
A custom Ecto type that handles wallet addresses. A wallet address is a string
that consists of 4 case-insensitive letters followed by a 12-digit integer.
All non-alphanumerics are stripped and ignored.
Although this custom type is a straight-forward str... | apps/utils/lib/types/wallet_address.ex | 0.915884 | 0.44559 | wallet_address.ex | starcoder |
defmodule Protobuf do
@moduledoc """
`protoc` should always be used to generate code instead of writing the code by hand.
By `use` this module, macros defined in `Protobuf.DSL` will be injected. Most of thee macros
are equal to definition in .proto files.
defmodule Foo do
use Protobuf, syntax: :... | lib/protobuf.ex | 0.885341 | 0.494507 | protobuf.ex | starcoder |
defmodule Mix.Tasks.Ecto.Gen.Erd do
@moduledoc """
A mix task to generate an ERD (Entity Relationship Diagram) in various formats.
Supported formats:
* [DOT](#module-dot)
* [PlantUML](#module-plantuml)
* [DBML](#module-dbml)
* [QuickDBD](#module-quickdbd)
Configuration examples and output for a couple... | lib/mix/tasks/ecto.gen.erd.ex | 0.852383 | 0.904819 | ecto.gen.erd.ex | starcoder |
defmodule AWS.OpsWorks do
@moduledoc """
AWS OpsWorks
Welcome to the *AWS OpsWorks Stacks API Reference*. This guide provides
descriptions, syntax, and usage examples for AWS OpsWorks Stacks actions
and data types, including common parameters and error codes.
AWS OpsWorks Stacks is an application managem... | lib/aws/ops_works.ex | 0.8827 | 0.480966 | ops_works.ex | starcoder |
defmodule Cluster.Strategy.Kubernetes do
@moduledoc """
This clustering strategy works by loading all endpoints in the current Kubernetes
namespace with the configured label. It will fetch the addresses of all endpoints with
that label and attempt to connect. It will continually monitor and update its
connect... | lib/strategy/kubernetes.ex | 0.844985 | 0.583797 | kubernetes.ex | starcoder |
import Croma.Defun
defmodule Croma.BuiltinType do
@moduledoc false
@type_infos [
{Croma.Atom , "atom" , (quote do: atom ), (quote do: is_atom (var!(x)))},
{Croma.Boolean , "boolean" , (quote do: boolean ), (quote do: is_boolean (var!(x)))},
{Croma.Fl... | lib/croma/builtin_type.ex | 0.664649 | 0.434701 | builtin_type.ex | starcoder |
defmodule Recase.Enumerable do
@moduledoc """
Helper module to convert enumerable keys recursively.
"""
@doc """
Invoke fun for each keys of the enumerable and cast keys to atoms.
"""
@spec atomize_keys(Enumerable.t()) :: Enumerable.t()
def atomize_keys(enumerable),
do: atomize_keys(enumerable, fn ... | lib/recase/utils/enumerable.ex | 0.822724 | 0.591694 | enumerable.ex | starcoder |
defmodule GenRtmpServer do
@moduledoc """
A behaviour module for implementing an RTMP server.
A GenRtmpServer abstracts out the the handling of RTMP connection handling
and data so that modules that implement this behaviour can focus on
the business logic of the actual RTMP events that are received and
sh... | apps/gen_rtmp_server/lib/gen_rtmp_server.ex | 0.620507 | 0.402627 | gen_rtmp_server.ex | starcoder |
defmodule Xgit.Util.NB do
@moduledoc false
# Internal conversion utilities for network byte order handling.
use Bitwise
import Xgit.Util.ForceCoverage
@doc ~S"""
Parses a sequence of 4 bytes (network byte order) as a signed integer.
Reads the first four bytes from `intbuf` and returns `{value, buf}`... | lib/xgit/util/nb.ex | 0.877601 | 0.767777 | nb.ex | starcoder |
defmodule Serum.PostList do
@moduledoc """
Defines a struct representing a list of blog posts.
## Fields
* `tag`: Specifies by which tag the posts are filtered. Can be `nil`
* `current_page`: Number of current page
* `max_page`: Number of the last page
* `title`: Title of the list
* `posts`: A list of... | lib/serum/post_list.ex | 0.797241 | 0.460532 | post_list.ex | starcoder |
defmodule Pow.Store.Backend.MnesiaCache.Unsplit do
@moduledoc """
GenServer that handles network split recovery for
`Pow.Store.Backend.MnesiaCache`.
This should be run on node(s) that has the `Pow.Store.Backend.MnesiaCache`
GenServer running. It'll subscribe to the Mnesia system messages, and listen
for `:... | lib/pow/store/backend/mnesia_cache/unsplit.ex | 0.806205 | 0.44903 | unsplit.ex | starcoder |
defmodule Geometry.PolygonZM do
@moduledoc """
A polygon struct, representing a 3D polygon with a measurement.
A none empty line-string requires at least one ring with four points.
"""
alias Geometry.{GeoJson, LineStringZM, PolygonZM, WKB, WKT}
defstruct rings: []
@type t :: %PolygonZM{rings: [Geometr... | lib/geometry/polygon_zm.ex | 0.945538 | 0.657332 | polygon_zm.ex | starcoder |
defimpl JSON.Encoder, for: Tuple do
@doc """
Encodes an Elixir tuple into a JSON array
"""
def encode(term), do: term |> Tuple.to_list() |> JSON.Encoder.Helpers.enum_encode()
@doc """
Returns an atom that represents the JSON type for the term
"""
def typeof(_), do: :array
end
defimpl JSON.Encoder, for... | lib/json/encoder/default_implementations.ex | 0.852091 | 0.553566 | default_implementations.ex | starcoder |
defmodule Securion do
@moduledoc """
Elixir client library to the [SecurionPay](https://securionpay.com) payment
gateway REST APIs.
> Please refer to the [docs](https://securionpay.com/docs/api) of the original REST
APIs when in doubt. This client library is a thin wrapper around it and
most details are le... | lib/securion.ex | 0.766162 | 0.545346 | securion.ex | starcoder |
defmodule Typo.PDF.Annotation do
@moduledoc """
Functions to generate PDF annotations.
"""
import Typo.Utils.Guards
alias Typo.PDF
alias Typo.PDF.{IdMap, PageUse}
alias Typo.Utils.Colour
# decodes border style options, returning a border dictionary.
@spec border_style(Keyword.t(), atom(), atom()) :... | lib/typo/pdf/annotation.ex | 0.860442 | 0.421939 | annotation.ex | starcoder |
defmodule ElxValidation.Different do
@moduledoc """
### different:value
- The field under validation must have a different value than field.
### equal:value
- The field under validation must be equal to the given field. The two fields must be of the same type.
Strings and numerics are evaluated using the s... | lib/rules/different.ex | 0.922596 | 0.945147 | different.ex | starcoder |
defmodule IO.ANSI.Sequence do
@moduledoc false
defmacro defsequence(name, code // "", terminator // "m") do
quote bind_quoted: [name: name, code: code, terminator: terminator] do
def unquote(name)() do
"\e[#{unquote(code)}#{unquote(terminator)}"
end
defp escape_sequence(<< unquote(at... | lib/elixir/lib/io/ansi.ex | 0.744378 | 0.508971 | ansi.ex | starcoder |
defmodule Bundlex.CNode do
@moduledoc """
Utilities to ease interaction with Bundlex-based CNodes, so they can be treated
more like Elixir processes / `GenServer`s.
"""
use Bunch
alias Bundlex.Helper.MixHelper
@enforce_keys [:server, :node]
defstruct @enforce_keys
@typedoc """
Reference to the CN... | lib/bundlex/cnode.ex | 0.852767 | 0.448728 | cnode.ex | starcoder |
defmodule DBux.Type do
@type simple_type_name :: :byte | :boolean | :int16 | :uint16 | :int32 | :uint32 | :int64 | :uint64 | :double | :string | :object_path | :signature | :unix_fd
@type container_type_name :: :array | :struct | :variant | :dict_entry
@type simple_type :: simple_type_name
@type con... | lib/type.ex | 0.710628 | 0.42931 | type.ex | starcoder |
defmodule USGovData.Parsers.CommitteeMaster do
defstruct([
:address1,
:address2,
:candidate,
:city,
:connected_org,
:designation,
:filing_frequency,
:id,
:name,
:org_category,
:party,
:state,
:treasurer,
:type,
:zip_code
])
@type committee_designation :... | lib/parsers/committee_master.ex | 0.752468 | 0.537952 | committee_master.ex | starcoder |
defmodule CaboCha do
@moduledoc """
Elixir bindings for CaboCha, a Japanese dependency structure analyzer.
Parse function resturns a list of map.
The map's keys meaning is a follows.
- `chunk`: 文節(Chunk) -- This is map which includes follows.
+ `id`: 文節id(Chunk id)
+ `link`: 係り先の文節id(Linked chunk id... | lib/cabo_cha.ex | 0.60964 | 0.810591 | cabo_cha.ex | starcoder |
defmodule Commands.GeneralCommands do
use Memoize
alias Interp.Functions
alias Interp.Interpreter
alias Interp.Stack
alias Interp.Globals
alias Interp.Environment
alias Interp.RecursiveEnvironment
alias HTTPoison
alias Commands.ListCommands
alias Commands.IntCommands
alias C... | lib/commands/gen_commands.ex | 0.755637 | 0.648578 | gen_commands.ex | starcoder |
defmodule Krakex do
@moduledoc """
Kraken API Client.
The Kraken API is divided into several sections:
## Public market data
* `server_time/1` - Get server time.
* `assets/2` - Get asset info.
* `asset_pairs/2` - Get tradable asset pairs.
* `ticker/2` - Get ticker information.
* `ohlc/3` ... | lib/krakex.ex | 0.918496 | 0.655453 | krakex.ex | starcoder |
defmodule FarmbotFirmware.GCODE.Encoder do
@moduledoc false
alias FarmbotFirmware.{GCODE, Param}
@doc false
@spec do_encode(GCODE.kind(), GCODE.args()) :: binary()
def do_encode(:report_idle, []), do: "R00"
def do_encode(:report_begin, []), do: "R01"
def do_encode(:report_success, []), do: "R02"
def d... | farmbot_firmware/lib/farmbot_firmware/gcode/encoder.ex | 0.705684 | 0.40539 | encoder.ex | starcoder |
defmodule HedwigTrivia do
@moduledoc """
A GenServer to hold the state and provide a general API to the game.
"""
use GenServer
require Logger
alias HedwigTrivia.{
GameState,
Logic
}
@name __MODULE__
@error_fetching_question "There was an error fetching the question"
@error_fetching_answer... | lib/hedwig_trivia.ex | 0.814975 | 0.499329 | hedwig_trivia.ex | starcoder |
defmodule RDF.Turtle.Star.CompactGraph do
@moduledoc !"""
A compact graph representation in which annotations are directly stored under
the objects of the annotated triples.
This representation is not meant for direct use, but just for the `RDF.Turtle.Encoder`.
"""... | lib/rdf/serializations/turtle/star_compact_graph.ex | 0.886365 | 0.457864 | star_compact_graph.ex | starcoder |
defmodule Jerry.Utils.ListUtils do
@moduledoc false
@doc false
def nest_children([], _pred), do: []
def nest_children([x|xs], pred) do
{children, unrelated} = split_children(x, xs, pred)
[children | nest_children(unrelated, pred)]
end
# Given a parent, a list of entries and a predicate which evalu... | lib/jerry/utils/list_utils.ex | 0.558688 | 0.515803 | list_utils.ex | starcoder |
defmodule HomeWeb.ApiEnergyController do
use HomeWeb, :controller
alias HomeWeb.Models.GraphModel
def gas_usage(conn, %{"group" => group, "start" => start_time, "end" => end_time}) do
validate_group(group)
validate_timestamp(start_time)
validate_timestamp(end_time)
# data = GraphModel.gas_usage... | lib/home_web/controllers/api_energy_controller.ex | 0.604049 | 0.515498 | api_energy_controller.ex | starcoder |
defmodule Geohax do
@moduledoc """
Geohash encoding and decoding.
"""
use Bitwise
import Integer, only: [is_even: 1]
@type direction() :: :north | :south | :east | :west
@base32 '<KEY>'
@lon_range {-180, 180}
@lat_range {-90, 90}
@neighbors [
north: {'<KEY>', '<KEY>'},
south: {'<KEY>', ... | lib/geohax.ex | 0.91563 | 0.534248 | geohax.ex | starcoder |
defmodule ElixirRigidPhysics.Geometry.Util do
@moduledoc """
Module to handle oddball util functions for geometry stuff.
"""
alias Graphmath.Vec3
@doc """
Function to get the closest point to a point `p` on a line segment spanning points `a` and `b`.
Excellent derviation [here](https://math.stackexchan... | lib/geometry/util.ex | 0.907458 | 0.697374 | util.ex | starcoder |
defmodule RDF.PropertyMap do
@moduledoc """
A bidirectional mappings from atom names to `RDF.IRI`s of properties.
These mapping can be used in all functions of the RDF data structures
to provide the meaning of the predicate terms in input statements or
define how the IRIs of predicates should be mapped with ... | lib/rdf/property_map.ex | 0.928409 | 0.785679 | property_map.ex | starcoder |
# NOTICE: Adobe permits you to use, modify, and distribute this file in
# accordance with the terms of the Adobe license agreement accompanying
# it. If you have received this file from a source other than Adobe,
# then your use, modification, or distribution of it requires the prior
# written permission of Adobe.
de... | lib/actions.ex | 0.68215 | 0.448426 | actions.ex | starcoder |
defmodule GenSpoxy.Periodic.TasksExecutor do
@moduledoc """
a behaviour for running prerender tasks periodically.
when we execute a `spoxy` reqeust and have a cache miss returning a stale date,
we may choose to return the stale data and queue a background task.
"""
@callback execute_tasks!(req_key :: Stri... | lib/periodic/tasks_executor.ex | 0.844265 | 0.417568 | tasks_executor.ex | starcoder |
defmodule TheElixir.Components.Journal do
@moduledoc """
A place to keep quests in a handy and organized way!
"""
use GenServer
# Client API
def start_link(name \\ :journal) do
GenServer.start_link(__MODULE__, name, name: name)
end
@doc """
Lookup a quest with `quest_name` in `journal` if i... | lib/the_elixir/components/journal/journal.ex | 0.640299 | 0.477432 | journal.ex | starcoder |
defmodule BinaryDiagnostic do
@doc """
Part one: Find the power consumption of a submarine
"""
def power_consumption(path \\ "./puzzle_input.txt") do
diagnostic_report = parse(path)
num_column = String.length(List.first(diagnostic_report))
diagnostic_report = diagnostic_report
|> Enum.join()
... | 2021/elixir/day-3-binary-diagnostic/binary_diagnostic.ex | 0.700075 | 0.625667 | binary_diagnostic.ex | starcoder |
defmodule Size do
defstruct height: 0, width: 0
def new({x, y}), do: %Size{height: y, width: x}
end
defmodule Canvas do
defstruct [:pixels, :size]
def new(%Size{height: height, width: width} = size, color \\ Color.named(:black)) do
%Canvas{
pixels:
:array.new(
size: height * width... | lib/canvas.ex | 0.747892 | 0.805785 | canvas.ex | starcoder |
defmodule FloUI.Theme do
@moduledoc """
Basic theme for sets for FloUI
``` elixir
:base,
:dark,
:light,
:primary,
:scrollbar,
:secondary,
:success,
:danger,
:warning,
:info,
:text
```
Pick a preset
``` elixir
FloUI.Theme.preset(:primary)
```
"""
alias Scenic.Primitive.Styl... | lib/theme.ex | 0.746231 | 0.540257 | theme.ex | starcoder |
defmodule Redix.PubSub do
@moduledoc """
Interface for the Redis PubSub functionality.
The rest of this documentation will assume the reader knows how PubSub works
in Redis and knows the meaning of the following Redis commands:
* `SUBSCRIBE` and `UNSUBSCRIBE`
* `PSUBSCRIBE` and `PUNSUBSCRIBE`
* `P... | lib/redix/pubsub.ex | 0.893007 | 0.574454 | pubsub.ex | starcoder |
defmodule Sparql do
@moduledoc """
## Overview
This module offers some functionality to parse SPARQL queries. To do this I
have build a parser with the :leex and :yecc erlang libraries.
## :leex and :yecc
You can find the source files as well as the compiled erlang files
for this under ../parser-generato... | lib/sparql.ex | 0.695958 | 0.795301 | sparql.ex | starcoder |
defmodule Slip.Utils do
def to_route(path) do
String.split(String.strip(path, ?/), "/")
end
## Utilities to get parameters out of the request
def get_parameters(req_params) do
parameters = Process.get(:parameters, [])
Enum.reduce(req_params, %{}, fn(requirement = {name, _}, map) ->
result = g... | lib/slip_utils.ex | 0.57093 | 0.420272 | slip_utils.ex | starcoder |
defmodule Tap do
@default [formatter: &__MODULE__.format/1]
@doc ~S"""
Traces calls, return values and exceptions from the function call template
given as an argument.
## Examples
Trace calls to `&String.starts_with?/2` and print the first two events:
iex> Tap.call(String.starts_with?(_, _), 2)
... | lib/tap.ex | 0.66236 | 0.549399 | tap.ex | starcoder |
defmodule Day8 do
@moduledoc """
Two factor authentication screen emulator
"""
@default_width 50
@default_height 6
def count_pixels_from_file(path), do: count_pixels_from_file(@default_height, @default_width, path)
def count_pixels_from_file(rows, columns, path) do
compute(rows, columns, File.read!(... | day8/lib/day8.ex | 0.727007 | 0.499329 | day8.ex | starcoder |
defmodule Mix.Releases.Config.Provider do
@moduledoc """
This defines the behaviour for custom configuration providers.
Keys supplied to providers are a list of atoms which represent the path of the
configuration key, beginning with the application name:
> MyProvider.get([:myapp, :server, :port])
... | lib/mix/lib/releases/config/provider.ex | 0.737631 | 0.443841 | provider.ex | starcoder |
defmodule Grizzly.ZWave.Commands.FailedNodeListReport do
@moduledoc """
This command is used to advertise the current list of failing nodes in the network.
Params:
* `:seq_number` - Sequence number
* `:node_ids` - The ids of all nodes in the network found to be unresponsive
"""
@behaviour Grizzly.... | lib/grizzly/zwave/commands/failed_node_list_report.ex | 0.808446 | 0.41324 | failed_node_list_report.ex | starcoder |
defmodule Specify.Parsers do
@moduledoc """
Simple functions to parse strings to datatypes commonly used during configuration.
These functions can be used as parser/validator function in a call to `Specify.Schema.field`,
by using their shorthand name (`:integer` as shorthand for `&Specify.Parsers.integer/1`).
... | lib/specify/parsers.ex | 0.884968 | 0.706496 | parsers.ex | starcoder |
defmodule Onion.Common.DataValidator do
defp to_atom(value) when is_atom(value), do: {:ok, value }
defp to_atom(value) when is_binary(value), do: {:ok, String.to_atom(value) }
defp to_atom(value), do: {:error, value}
defp to_existing_atom(value) when is_atom(value), do: {:ok, value }
defp to_exist... | lib/common/datavalidator.ex | 0.560253 | 0.6899 | datavalidator.ex | starcoder |
defmodule VintageNetWiFi.WPSData do
@moduledoc """
Utilities for handling WPS data
"""
@typedoc """
A map containing WPS data
All keys are optional. Known keys use atoms. Unknown keys use their numeric
value and their value is left as a raw binary.
Known keys:
* `:credential` - a map of WiFi crede... | lib/vintage_net_wifi/wps_data.ex | 0.845145 | 0.479808 | wps_data.ex | starcoder |
defmodule Gentry.Worker do
@moduledoc """
The worker is responsible for actually running and coordinating the
retries of the task given in the form of a function called
`task_function`.
The task is spawened and monitored by the worker using
`Task.Supervisor.async_nolink`
The number of retries and the ba... | lib/gentry/worker.ex | 0.665084 | 0.645525 | worker.ex | starcoder |
defmodule Kashup.Store do
@moduledoc """
Internal API for the underlying storage mechanism.
`Kashup.Store` maps provided keys to a `pid()` whose process, if alive, contains the value
associated with the key.
Kashup ships with [mnesia](https://erlang.org/doc/man/mnesia.html) as the default storage.
You c... | lib/kashup/store.ex | 0.867892 | 0.57338 | store.ex | starcoder |
defmodule Prog do
@moduledoc """
Documentation for `Prog`.
"""
@doc """
Day 7
"""
def solve do
{:ok, raw} = File.read("data/day_7")
# raw = "shiny gold bags contain 2 dark red bags.
# dark red bags contain 2 dark orange bags.
# dark orange bags contain 2 dark yellow bags.
# dark yellow bags cont... | lib/days/day_7.ex | 0.623377 | 0.418073 | day_7.ex | starcoder |
defmodule Grid do
@type grid_t :: %{width: integer, height: integer, size: integer, data: tuple()}
@type point_t :: {integer, integer}
@spec new(String.t()) :: grid_t
def new(contents) do
lines = contents |> String.split(~r/\s+/, trim: true)
width = String.length(Enum.at(lines, 0))
height = length(... | aoc21/lib/grid.ex | 0.87247 | 0.674325 | grid.ex | starcoder |
require Syscrap.Helpers, as: H
defmodule Syscrap.MongoWorker do
use GenServer
@moduledoc """
This worker encapsulates a Mongo connection pooled using `:poolboy`.
No more, no less.
Well, maybe a little more. It includes some helpers to ease the work with that connection.
## Usage
### Using `... | lib/syscrap/mongo_worker.ex | 0.801081 | 0.842928 | mongo_worker.ex | starcoder |
defmodule Commander do
@moduledoc """
Documentation for Commander.
"""
@doc """
main - Main function of Commander. Takes an array of arguments and options and builds a configuration model based on them
## Examples
iex> Commander.handle_main(["test","-test","-othertest","--newtest=test","-nt=newtest... | lib/commander.ex | 0.625209 | 0.401658 | commander.ex | starcoder |
defmodule TelemetryMetricsAppsignal do
@moduledoc """
AppSignal Reporter for [`Telemetry.Metrics`](https://github.com/beam-telemetry/telemetry_metrics) definitions.
This reporter is useful for getting [custom metrics](https://docs.appsignal.com/metrics/custom.html)
into AppSignal from your application. These c... | lib/telemetry_metrics_appsignal.ex | 0.866641 | 0.44342 | telemetry_metrics_appsignal.ex | starcoder |
defmodule OMG.ChildChain.Fees.FeeUpdater do
@moduledoc """
Decides whether fees will be updated from the fetched fees from the feed.
"""
alias OMG.ChildChain.Fees.FeeMerger
alias OMG.Fees
@type feed_reading_t :: {pos_integer(), Fees.full_fee_t()}
@type can_update_result_t :: {:ok, feed_reading_t()} | :n... | apps/omg_child_chain/lib/omg_child_chain/fees/fee_updater.ex | 0.887717 | 0.524943 | fee_updater.ex | starcoder |
defmodule Snowflake.Database do
@moduledoc """
This module was written to simulate a k/v database layer
where a value per node could be seeded and retrieved
The node ids are stored in a custom dets file
The mostly arcane :dets was used as it was natively supported
The node ids can be created by running t... | lib/snowflake/database.ex | 0.757301 | 0.41481 | database.ex | starcoder |
defmodule Resx.Transformer do
@moduledoc """
A transformer is a referenceable interface for performing reproducible
modifications on resources.
A module that implements the transformer behaviour becomes usable by the
`Resx.Producers.Transform` producer.
"""
import Kernel, except: [a... | lib/resx/transformer.ex | 0.924338 | 0.463809 | transformer.ex | starcoder |
defmodule BitcoinSimulator.BitcoinCore do
alias BitcoinSimulator.BitcoinCore.{Blockchain, Mining, Network, RawTransaction, Wallet}
# Block Chain
def get_new_blockchain, do: Blockchain.get_new_blockchain()
def get_best_block_hash(blockchain), do: Blockchain.get_best_block_hash(blockchain)
def block_header... | lib/bitcoin_simulator/bitcoin_core.ex | 0.682785 | 0.425068 | bitcoin_core.ex | starcoder |
defmodule Zappa.Tag do
@moduledoc """
This struct holds information relevant to parsing a handlebars tag. All helper functions registered in the
`%Zappa.Helpers{}` struct are passed a `%Zappa.Tag{}` struct as their single argument.
## %Zappa.Tag{} Keys
- `:name` - the identifying name of the tag.
- `:raw_... | lib/zappa/tag.ex | 0.927929 | 0.675276 | tag.ex | starcoder |
defmodule Loom.TypedORMap do
@moduledoc """
Contains a macro that creates typed maps of CRDT's.
"""
@doc """
Creates a module that creates a map and implements the CRDT protocol for that
type.
"""
defmacro defmap(type) do
type = Macro.expand(type, __CALLER__)
name = :"#{type}Map"
quote loc... | lib/loom/typed_map.ex | 0.852522 | 0.612773 | typed_map.ex | starcoder |
defmodule Data.Item.Compiled do
@moduledoc """
An item is compiled after the item aspects are rolled together and merged
with the base item's stats.
"""
alias Data.Item
@fields [
:id,
:level,
:name,
:description,
:type,
:keywords,
:stats,
:effects,
:cost,
:user_text... | lib/data/item/compiled.ex | 0.793506 | 0.520131 | compiled.ex | starcoder |
import TypeClass
defclass Witchcraft.Semigroup do
@moduledoc ~S"""
A semigroup is a structure describing data that can be appendenated with others of its type.
That is to say that appending another list returns a list, appending one map
to another returns a map, and appending two integers returns an integer, a... | lib/witchcraft/semigroup.ex | 0.772574 | 0.536556 | semigroup.ex | starcoder |
defmodule Adventofcode.Day12RainRisk do
use Adventofcode
alias __MODULE__.{Captain, Position, State, Waypoint}
def part_1(input) do
input
|> parse
|> Captain.operate(State.part_1())
|> manhattan_distance
end
def part_2(input) do
input
|> parse
|> Captain.operate(State.part_2())
... | lib/day_12_rain_risk.ex | 0.748995 | 0.605712 | day_12_rain_risk.ex | starcoder |
defmodule Ecto.Adapters.SQL.Sandbox do
@moduledoc """
Start a pool with a single sandboxed SQL connection.
### Options
* `:shutdown` - The shutdown method for the connections (default: 5000) (see Supervisor.Spec)
"""
alias Ecto.Adapters.Connection
@behaviour Ecto.Pool
@typep log :: (%Ecto.LogEntry{... | deps/ecto/lib/ecto/adapters/sql/sandbox.ex | 0.770853 | 0.418162 | sandbox.ex | starcoder |
defmodule Bonny.CRD do
@moduledoc """
Represents the `spec` portion of a Kubernetes [CustomResourceDefinition](https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/) manifest.
> The CustomResourceDefinition API resource allows you to define custom resources. Definin... | lib/bonny/crd.ex | 0.888813 | 0.811452 | crd.ex | starcoder |
defmodule Supervisor.Spec do
@moduledoc """
Outdated functions for building child specifications.
The functions in this module are deprecated and they do not work
with the module-based child specs introduced in Elixir v1.5.
Please see the `Supervisor` documentation instead.
Convenience functions for defin... | lib/elixir/lib/supervisor/spec.ex | 0.85443 | 0.676807 | spec.ex | starcoder |
defmodule Snowflex.Connection do
@moduledoc """
Defines a Snowflake connection.
## Definition
When used, the connection expects the `:otp_app` option. You may also define a standard timeout. This will default to 60 seconds.
If `keep_alive?` is set to `true`, each worker in the connection pool will
period... | lib/snowflex/connection.ex | 0.852614 | 0.775477 | connection.ex | starcoder |
defmodule LiveAttribute do
use GenServer
defstruct [:refresher, :subscribe, :target, :filter]
@moduledoc """
LiveAttribute makes binding updateable values easier. To use it add it to your LiveView using `use LiveAttribute`
and then use the function `assign_attribute(socket, subscribe_callback, property_callb... | lib/live_attribute.ex | 0.921983 | 0.807157 | live_attribute.ex | starcoder |
defmodule Ritcoinex.Initial do
@doc """
The burn_nodes/3 is a functions that is used for build a table.
Parameters:
- 1° argument is an atom that your table of wallet get,
- 2° argument is a first name of wallet which Hash.hash_to_wallets use
to apply the name hashed of the wallet,
- 3° argument is a f... | lib/mnesia_chain/mnesia_functions/burn_chainself.ex | 0.78964 | 0.604487 | burn_chainself.ex | starcoder |
defmodule Nostrum.Cache.GuildCache do
@default_cache_implementation Nostrum.Cache.GuildCache.ETS
@moduledoc """
Cache behaviour & dispatcher for guilds.
You can call the functions provided by this module independent of which cache
is configured, and it will dispatch to the configured cache implementation.
... | lib/nostrum/cache/guild_cache.ex | 0.874185 | 0.772295 | guild_cache.ex | starcoder |
defmodule Ecto.Query.Builder.Join do
@moduledoc false
alias Ecto.Query.Builder
alias Ecto.Query.JoinExpr
@doc """
Escapes a join expression (not including the `on` expression).
It returns a tuple containing the binds, the on expression (if available)
and the association expression.
## Examples
... | lib/ecto/query/builder/join.ex | 0.869021 | 0.50891 | join.ex | starcoder |
defmodule Recase do
@moduledoc """
Recase allows you to convert string from any to any case.
This module contains public interface.
"""
alias Recase.{
CamelCase,
ConstantCase,
DotCase,
KebabCase,
PascalCase,
PathCase,
SentenceCase,
SnakeCase,
TitleCase
}
@doc """
C... | lib/recase.ex | 0.834744 | 0.540681 | recase.ex | starcoder |
defmodule Redix do
@moduledoc """
This module provides the main API to interface with Redis.
## Overview
`start_link/2` starts a process that connects to Redis. Each Elixir process
started with this function maps to a client TCP connection to the specified
Redis server.
The architecture is very simple:... | lib/redix.ex | 0.931252 | 0.748789 | redix.ex | starcoder |
defmodule Ecto.Model.Queryable do
@moduledoc """
Defines a model as queryable.
In order to create queries in Ecto, you need to pass a queryable
data structure as argument. By using `Ecto.Model.Queryable` in
your model, it imports the `queryable/2` macro.
Assuming you have an entity named `Weather.Entity`,... | lib/ecto/model/queryable.ex | 0.852798 | 0.611411 | queryable.ex | starcoder |
defmodule RRange.Ruby do
@moduledoc """
Summarized all of Ruby's Range functions.
Functions corresponding to the following patterns are not implemented
- When a function with the same name already exists in Elixir.
- When a method name includes `!`.
- %, ==, ===
"""
@spec __using__(any) :: list
def... | lib/r_range/ruby.ex | 0.861305 | 0.544499 | ruby.ex | starcoder |
defmodule SurfaceBootstrap.NavBar do
@moduledoc """
The NavBar component.
Due to the massive amount of permutations possible in NavBar,
this component focuses on the two main outer wrapping features
of setting up a NavBar.
1. The NavBar itself, with coloring etc
2. The inner collapsible component NavBar... | lib/surface_bootstrap/navbar.ex | 0.724091 | 0.542863 | navbar.ex | starcoder |
defmodule Assent.Strategy.OAuth2 do
@moduledoc """
OAuth 2.0 strategy.
This strategy only supports the Authorization Code flow per
[RFC 6749](https://tools.ietf.org/html/rfc6749#section-1.3.1).
`authorize_url/1` returns a map with a `:url` and `:session_params` key. The
`:session_params` should be stored ... | lib/assent/strategies/oauth2.ex | 0.890526 | 0.615406 | oauth2.ex | starcoder |
defmodule Nebulex.Adapters.Local do
@moduledoc """
Adapter module for Local Generational Cache.
It uses [Shards](https://github.com/cabol/shards) as in-memory backend
(ETS tables are used internally).
## Features
* Support for generational cache – inspired by
[epocxy](https://github.com/duomark/e... | lib/nebulex/adapters/local.ex | 0.922948 | 0.689407 | local.ex | starcoder |
defmodule BertInt do
@moduledoc """
Binary Erlang Term encoding for internal node-to-node encoding.
"""
@spec encode!(any()) :: binary()
def encode!(term) do
term
|> :erlang.term_to_binary()
|> zip()
end
# Custom impl of :zlib.zip() for faster compression
defp zip(data, level \\ 1) do
z... | lib/bert.ex | 0.716913 | 0.442576 | bert.ex | starcoder |
defmodule XDR.HyperUInt do
@moduledoc """
This module manages the `Unsigned Hyper Integer` type based on the RFC4506 XDR Standard.
"""
@behaviour XDR.Declaration
alias XDR.Error.HyperUInt, as: HyperUIntError
defstruct [:datum]
@typedoc """
`XDR.HyperUInt` structure type specification.
"""
@type ... | lib/xdr/hyper_uint.ex | 0.921623 | 0.615348 | hyper_uint.ex | starcoder |
defmodule ExDns.Resource.Validation do
def validate_ipv4(record, key) when is_list(record) do
address = String.to_charlist(record[key])
case :inet.parse_ipv4_address(address) do
{:ok, address} -> Keyword.put(record, key, address)
{:error, _} -> add_error(record, {address, "is not a valid IPv4 add... | lib/ex_dns/resource/validation.ex | 0.596903 | 0.431824 | validation.ex | starcoder |
defmodule Google.Protobuf.NullValue do
@moduledoc false
use Protobuf, enum: true, syntax: :proto3
@type t :: integer | :NULL_VALUE
field :NULL_VALUE, 0
end
defmodule Google.Protobuf.Struct.FieldsEntry do
@moduledoc false
use Protobuf, map: true, syntax: :proto3
@type t :: %__MODULE__{
key: St... | lib/google_protos/struct.pb.ex | 0.772445 | 0.402627 | struct.pb.ex | starcoder |
defmodule AWS.Support do
@moduledoc """
AWS Support
The AWS Support API reference is intended for programmers who need detailed
information about the AWS Support operations and data types.
This service enables you to manage your AWS Support cases programmatically. It
uses HTTP methods that return results... | lib/aws/generated/support.ex | 0.861727 | 0.678979 | support.ex | starcoder |
import Kernel, except: [to_binary: 1]
defprotocol Binary.Chars do
@moduledoc %B"""
The Binary.Chars protocol is responsible for
converting a structure to a Binary (only if applicable).
The only function required to be implemented is
`to_binary` which does the conversion.
The `to_binary` function automatic... | lib/elixir/lib/binary/chars.ex | 0.87982 | 0.690637 | chars.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.