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 ApiWeb.EventStream.DiffServer do
@moduledoc """
GenServer responsible for sending EventStream diffs back to the process holding the conn.
The original implemntation of this feature had each client doing the diff
itself. However, when multiple clients are subscribed to the same data,
this results in... | apps/api_web/lib/api_web/event_stream/diff_server.ex | 0.788298 | 0.684962 | diff_server.ex | starcoder |
defmodule EctoMnesia.Record.Context.MatchSpec do
@moduledoc """
This module provides a context that is able to rebuild Mnesia `match_spec` by `Ecto.Query` AST whenever new query
is assigned to a context.
Specs:
- [QLC](http://erlang.org/doc/man/qlc.html)
- [Match Specification](http://erlang.org/doc/ap... | lib/ecto_mnesia/record/context/match_spec.ex | 0.768125 | 0.442396 | match_spec.ex | starcoder |
defmodule SBoM.CycloneDX.Xml do
@moduledoc false
alias SBoM.{CycloneDX, License}
def bom(components, options) do
bom =
case options[:schema] do
"1.1" ->
{:bom,
[
serialNumber: options[:serial] || CycloneDX.uuid(),
xmlns: "http://cyclonedx.org/schem... | lib/sbom/cyclonedx/xml.ex | 0.622918 | 0.431884 | xml.ex | starcoder |
defmodule Timex.Calendar.Julian do
@moduledoc """
This module contains functions for working with dates in the Julian calendar.
"""
require Bitwise
import Timex.Macros
alias Timex.Types
@doc """
Returns the Julian day number for the given Erlang date (gregorian)
The Julian date (JD) is a continuous ... | lib/calendar/julian.ex | 0.877175 | 0.738009 | julian.ex | starcoder |
defmodule Temple do
defmacro __using__(_) do
quote location: :keep do
import Temple
import Temple.Tags
import Temple.Form
import Temple.Link
end
end
@doc """
Creates a markup context.
All tags must be called inside of a `Temple.temple/1` block.
Returns a safe result of the... | lib/temple.ex | 0.810329 | 0.65139 | temple.ex | starcoder |
defmodule VendingMachine.CurrencyData do
alias VendingMachine.QueryHelper
def add_currency_note(currency_note) do
[
node_name: "CurrencyNote",
param: ~s({
backgroundColor: "#{Keyword.fetch!(currency_note, :background_color)}",
fluorescentStripColor: "#{Keyword.fetch!(currency_note, ... | lib/vending_machine/data/currency_data.ex | 0.757436 | 0.665988 | currency_data.ex | starcoder |
defmodule Infer do
@moduledoc """
This is the main entry for using the Infer API.
- `get/3` evaluates the given predicate(s) using only the (pre)loaded data available, and returns the result(s)
- `load/3` is like `get`, but loads any additional data as needed
- `put/3` is like `load`, but puts the results in... | lib/infer.ex | 0.919177 | 0.914252 | infer.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.865096 | 0.564339 | support.ex | starcoder |
defmodule Game.Format.Players do
@moduledoc """
Format functions related to players
"""
import Game.Format.Context
alias Data.Save
alias Data.User
alias Game.Color
alias Game.Format
alias Game.Format.Table
@doc """
Colorize a player's name
"""
@spec player_name(User.t()) :: String.t()
def... | lib/game/format/players.ex | 0.725162 | 0.40072 | players.ex | starcoder |
defmodule AWS.Workspaces do
@moduledoc """
Amazon WorkSpaces Service
This reference provides detailed information about the Amazon WorkSpaces
operations.
"""
@doc """
Creates tags for a WorkSpace.
"""
def create_tags(client, input, options \\ []) do
request(client, "CreateTags", input, options)... | lib/aws/workspaces.ex | 0.858051 | 0.551272 | workspaces.ex | starcoder |
defmodule Poison.DecodeError do
@type t :: %__MODULE__{message: String.t(), value: any}
defexception message: nil, value: nil
def message(%{message: nil, value: value}) do
"unable to decode value: #{inspect(value)}"
end
def message(%{message: message}) do
message
end
end
defmodule Poison.Decode ... | lib/poison/decoder.ex | 0.755457 | 0.494568 | decoder.ex | starcoder |
defmodule RedshiftEcto do
@moduledoc """
Ecto adapter for [AWS Redshift](https://aws.amazon.com/redshift/).
It uses `Postgrex` for communicating to the database and a connection pool,
such as `DBConnection.Poolboy`.
This adapter is based on Ecto's builtin `Ecto.Adapters.Postgres` adapter. It
delegates som... | lib/redshift_ecto.ex | 0.877004 | 0.655129 | redshift_ecto.ex | starcoder |
defmodule Momento do
require Momento.Guards
@moduledoc """
Momento is an Elixir port of [Moment.js](https://github.com/moment/moment) for the purpose of parsing, validating,
manipulating, and formatting dates.
"""
@doc """
Provides a DateTime struct representing the current date and time.
## Examples... | lib/momento.ex | 0.911372 | 0.546799 | momento.ex | starcoder |
defimpl Timex.Protocol, for: Tuple do
alias Timex.Types
import Timex.Macros
@epoch :calendar.datetime_to_gregorian_seconds({{1970,1,1},{0,0,0}})
@spec to_julian(Types.date | Types.datetime | Types.microsecond_datetime) :: float | {:error, term}
def to_julian(date) do
with {y,m,d} <- to_erl_datetime(date... | lib/datetime/erlang.ex | 0.823506 | 0.507385 | erlang.ex | starcoder |
defmodule Engine.Callbacks.Deposit do
@moduledoc """
Contains the business logic of persisting a deposit event and creating the
appropriate UTXO.
When you deposit into the network, you send a 'deposit' transaction to the
contract directly. Upon success, the contract generates a block just for that
single t... | apps/engine/lib/engine/callbacks/deposit.ex | 0.845576 | 0.448547 | deposit.ex | starcoder |
defmodule Unicode.Transform.Rule.Definition do
@moduledoc """
#### 10.3.7 [Variable Definition Rules](https://unicode.org/reports/tr35/tr35-general.html#Variable_Definition_Rules)
Each variable definition is of the following form:
```
$variableName = contents ;
```
The variable name can contain letters... | lib/unicode/transform/rule/definition.ex | 0.741112 | 0.906031 | definition.ex | starcoder |
defmodule Unicode.String.Segment do
@moduledoc """
Implements the compilation of the Unicode
segment rules.
"""
import SweetXml
require Unicode.Set
@suppressions_variable "$Suppressions"
# This is the formal definition but it takes a while to compile
# and all of the known variable names are in th... | lib/unicode/segment.ex | 0.717111 | 0.476884 | segment.ex | starcoder |
defmodule Day11 do
def part1(file_name \\ "test1.txt") do
file_name
|> parse()
|> grid()
|> steps(100)
|> total_flashes()
end
def part2(file_name \\ "test2.txt") do
file_name
|> parse()
|> grid()
|> find_step_all_flashing()
end
def find_step_all_flashing(grid, step \\ 1)
... | jpcarver+elixir/day11/lib/day11.ex | 0.50708 | 0.522568 | day11.ex | starcoder |
defmodule Kino.Input do
@moduledoc """
Various input elements for entering data.
## Examples
First, create an input and make sure it is rendered,
either by placing it at the end of a code cell or by
explicitly rendering it with `Kino.render/1`.
input = Kino.Input.text("Name")
Then read the value... | lib/kino/input.ex | 0.923566 | 0.650662 | input.ex | starcoder |
defmodule Haversine do
@moduledoc ~S"""
Calculate great circle distances (shortest travel distance on the surface of
a spherical Earth) given a two longitude-latitude pairs. This is an implementation
of the [Haversine formula](https://en.wikipedia.org/wiki/Haversine_formula)
"""
@pi_over_180 :math.pi() / 1... | lib/haversine.ex | 0.942744 | 0.796807 | haversine.ex | starcoder |
defmodule MerkleTree.Proof do
@moduledoc """
Generate and verify merkle proofs
## Usage Example
iex> proof = MerkleTree.new(~w/a b c d/) |>
...> MerkleTree.Proof.prove(1)
["40e2511a6323177e537acb2e90886e0da1f84656fd6334b89f60d742a3967f09",
"022a6979e6dab7aa5ae4c3e5e45f7e977112a7e6... | lib/merkle_tree/proof.ex | 0.779238 | 0.417984 | proof.ex | starcoder |
defmodule Tyx.Traversal.Lookup do
@moduledoc false
use Boundary, deps: [Tyx.Traversal.Typemap, Tyx.Traversal.Preset]
alias Tyx.Traversal.{Preset, Typemap}
require Logger
# FIXME introduce an easy way to plug in the functionality to custom lookup elements
@lookup_plugins [Preset]
@behaviour Tyx.Traver... | lib/tyx/traversal/lookup.ex | 0.539954 | 0.509764 | lookup.ex | starcoder |
defmodule Game.Format.Quests do
@moduledoc """
Format function for quests
"""
import Game.Format.Context
alias Game.Format
alias Game.Format.Table
alias Game.Quest
@doc """
Format a quest name
iex> Game.Format.quest_name(%{name: "Into the Dungeon"})
"{quest}Into the Dungeon{/quest}"
"""
... | lib/game/format/quests.ex | 0.61878 | 0.465752 | quests.ex | starcoder |
defmodule Crawler.Linker.PathFinder do
@moduledoc """
Finds different components of a given URL, e.g. its domain name, directory
path, or full path.
The `safe` option in some the functions indicates whether the return value
should be transformed in order to be safely used as folder and file names.
"""
@... | lib/crawler/linker/path_finder.ex | 0.897339 | 0.437283 | path_finder.ex | starcoder |
defmodule Godfist.DataDragon do
@moduledoc """
Module to interact with the static data provided by Data Dragon instead of
the default one by Riot.
The names provided for champions in this Module are case sensitive because of
the way that Data Dragon handles it's files. For now it's up to you to get the
cha... | lib/godfist/requests/data_dragon/data_dragon.ex | 0.764232 | 0.82566 | data_dragon.ex | starcoder |
defmodule AWS.CloudWatch.Events do
@moduledoc """
Amazon CloudWatch Events helps you to respond to state changes in your AWS
resources. When your resources change state they automatically send events
into an event stream. You can create rules that match selected events in
the stream and route them to targets... | lib/aws/cloudwatch_events.ex | 0.910387 | 0.572006 | cloudwatch_events.ex | starcoder |
defmodule Openflow.Action.NxResubmit do
@moduledoc """
Searches the flow table again, using a flow that is slightly modified from the original lookup:
Following the lookup, the original in_port is restored.
If the modified flow matched in the flow table, then the corresponding
actions are executed. Afterwa... | lib/openflow/actions/nx_resubmit.ex | 0.87749 | 0.758958 | nx_resubmit.ex | starcoder |
defmodule ESpec.To do
@moduledoc """
Defines `to`, `to_not` and `not_to` helper functions.
The functions implement syntax: 'expect 1 |> to eq 1'
These functions wrap arguments for `ESpec.ExpectTo` module.
Also defines `to` helper function for mocking without parenthesis:
`allow SomeModule |> to accept(:f, ... | lib/espec/to.ex | 0.780871 | 0.804751 | to.ex | starcoder |
defmodule Cluster.Strategy.KubernetesPods do
@moduledoc """
This clustering strategy works by loading all pods in the current Kubernetes
namespace with the configured tag. It will fetch the addresses of all pods with
that tag and attempt to connect. It will continually monitor and update its
connections every... | lib/strategy/kubernetes_pods.ex | 0.78899 | 0.780286 | kubernetes_pods.ex | starcoder |
defmodule Commanded.Aggregate.Multi.BankAccount do
defstruct [:account_number, :status, balance: 0]
alias Commanded.Aggregate.Multi
alias Commanded.Aggregate.Multi.BankAccount
defmodule Commands do
defmodule OpenAccount do
defstruct [:account_number, :initial_balance]
end
defmodule Withdraw... | test/aggregates/support/multi_bank_account.ex | 0.600423 | 0.58436 | multi_bank_account.ex | starcoder |
defmodule BlueHeronScan do
@moduledoc """
A scanner to collect Manufacturer Specific Data from AdvertisingReport packets.
A useful reference:
[Overview of BLE device identification](https://reelyactive.github.io/ble-identifier-reference.html)
Tested with:
- [Raspberry Pi Model Zero W](https://github.com... | examples/scanner.ex | 0.747524 | 0.524516 | scanner.ex | starcoder |
defmodule Clex.CL.ImageDesc do
@moduledoc ~S"""
This module defines a `Record` type that represents the `cl_image_desc` as specified in the Open CL specification:
```c
typedef struct _cl_image_desc {
cl_mem_object_type image_type;
size_t image_width;
size_t image_height;
size_t image_depth;
... | lib/clex/cl/image_desc.ex | 0.914544 | 0.96622 | image_desc.ex | starcoder |
defmodule Automaton.Types.TWEANN.Constructor do
alias Automaton.Types.TWEANN.Sensor
alias Automaton.Types.TWEANN.Actuator
alias Automaton.Types.TWEANN.Cortex
alias Automaton.Types.TWEANN.Neuron
@doc """
The `construct_genotype` function accepts the name of the file to which we'll
save the genotype, senso... | lib/automata/automaton_types/neuroevolution/constructor.ex | 0.767341 | 0.63987 | constructor.ex | starcoder |
defmodule Toby.App.Views.Tables do
@moduledoc """
Builds a view for displaying information about ETS tables
TODO: Show DETS & Mnesia tables
"""
alias Toby.Util.Selection
import Toby.Util.Formatting, only: [format_bytes: 1]
import Ratatouille.View
import Ratatouille.Constants, only: [attribute: 1, col... | lib/toby/app/views/tables.ex | 0.5083 | 0.419707 | tables.ex | starcoder |
defmodule Cldr.Number.Backend.Transliterate do
@moduledoc false
def define_number_module(config) do
module = inspect(__MODULE__)
backend = config.backend
config = Macro.escape(config)
quote location: :keep, bind_quoted: [module: module, backend: backend, config: config] do
defmodule Number.T... | lib/cldr/number/backend/transliterate.ex | 0.85817 | 0.623864 | transliterate.ex | starcoder |
defmodule Warpath.Element.Path do
@moduledoc """
This module contains functions to accumulate and transform item path tokens.
The path are built during a expression evaluation by `Warpath.query/3`.
"""
@type token ::
{:root, String.t()}
| {:property, String.t() | atom()}
| ... | lib/warpath/element/path.ex | 0.859531 | 0.50653 | path.ex | starcoder |
defmodule DartSass do
@moduledoc """
DartSass is a installer and runner for [Sass](https://sass-lang.com/dart-sass).
## Profiles
You can define multiple configuration profiles. By default, there is a
profile called `:default` which you can configure its args, current
directory and environment:
conf... | lib/dart_sass.ex | 0.742702 | 0.441974 | dart_sass.ex | starcoder |
defmodule Windtrap.Normalizer do
import Windtrap.Varint
@moduledoc """
Turn a WASM binary format stream into a normalized binary stream
in which function arguments have their own size. This is useful
for execuction.
"""
@doc """
This is the function that takes as an input the stream of a function's
... | lib/windtrap/normalizer.ex | 0.690872 | 0.564369 | normalizer.ex | starcoder |
defmodule Geometry.FeatureCollection do
@moduledoc """
A collection of `Geometry.Featre`s.
`GeometryCollectionZM` implements the protocols `Enumerable` and `Collectable`.
## Examples
iex> Enum.filter(
...> FeatureCollection.new([
...> Feature.new(
...> geometry: Point.new(... | lib/geometry/feature_collection.ex | 0.949553 | 0.637595 | feature_collection.ex | starcoder |
defmodule TicTacToe.Strategy.FourByFour do
@moduledoc false
alias TicTacToe.Strategy.Minimax
alias TicTacToe.Board
@scale 4
@center_tiles [6, 7, 10, 11]
@doc """
AI strategy for 4x4 game
"""
def strategy(board, ai_player) do
moves_left = Board.possible_moves(board) |> length()
cond do
... | lib/tic_tac_toe/strategy/four_by_four.ex | 0.846101 | 0.547887 | four_by_four.ex | starcoder |
defmodule Sanity.Cache do
@doc false
defmacro __using__([]) do
quote do
import Sanity.Cache, only: [defq: 2]
Module.register_attribute(__MODULE__, :sanity_cache_update_opts, accumulate: true)
@before_compile Sanity.Cache
end
end
@doc false
defmacro __before_compile__(_env) do
... | lib/sanity/cache.ex | 0.626124 | 0.409516 | cache.ex | starcoder |
defmodule KafkaGenStage.Consumer do
@moduledoc """
Producer GenStage for reading from Kafka topic, using [Klarna's Brod](https://github.com/klarna/brod).
> Note that is its **consumer** from Kafka's perspective, but **producer** from GenStage's.
## Messages
Events emited are in 4-tuple format
@type ... | lib/kafka_gen_stage/consumer.ex | 0.921601 | 0.516291 | consumer.ex | starcoder |
defmodule AOC.Day5Bad do
@moduledoc """
Solution to Day 4 of the Advent of code 2021
https://adventofcode.com/2021/day/4
"""
@doc """
Read the input file
Returns the data as a tuple with inputs as first element and bingo boards as second
"""
@spec get_inputs(File) :: [String.t()]
def get_inputs(f \... | elixir/advent_of_code/lib/2021/day5_bad.ex | 0.714827 | 0.69233 | day5_bad.ex | starcoder |
defmodule Reprise.Runner do
require Logger
@moduledoc """
Module discovery and reloading.
The main entry point is `go/2` function.
"""
@type time :: :calendar.datetime
@type path :: [String.t]
@type beam :: String.t
@spec load_path(Regex.t) :: path
def load_path(pattern \\ ~r[/_build/]) do
f... | lib/runner.ex | 0.86148 | 0.417954 | runner.ex | starcoder |
defmodule Sanbase.Clickhouse.Exchanges.MarketDepth do
use Ecto.Schema
@exchanges ["Binance", "Bitfinex", "Kraken", "Poloniex", "Bitrex"]
alias Sanbase.ClickhouseRepo
@table "exchange_market_depth"
schema @table do
field(:timestamp, :utc_datetime)
field(:source, :string)
field(:symbol, :string)
... | lib/sanbase/clickhouse/exchanges/market_depth.ex | 0.716119 | 0.51818 | market_depth.ex | starcoder |
defmodule VexValidators.Uuid do
@moduledoc """
Ensure a value is a valid UUID string.
## Options
The `options` can be a keyword list with the following keys:
* `:format`: An atom or boolean that defines the validation & format of the UUID:
* `:default`: The value must a string with format `x... | lib/vex_validators/uuid.ex | 0.871932 | 0.62798 | uuid.ex | starcoder |
defmodule Ecto.Validator do
@moduledoc """
Validates a given struct or dict given a set of predicates.
Ecto.Validator.struct(user,
name: present() when on_create?(user),
age: present(message: "must be present"),
age: greater_than(18),
also: validate_other
)
Validation... | lib/ecto/validator.ex | 0.914463 | 0.634642 | validator.ex | starcoder |
defmodule Grouper do
@moduledoc """
Isolates groups of process subtrees together for configuration and name
registration purposes.
* Do you struggle with Elixir's global namespace for process names?
* Do all of your tests run synchronously because of this collisions?
* Do you mutate your application enviro... | lib/grouper.ex | 0.874332 | 0.468183 | grouper.ex | starcoder |
defmodule Charts.DataProvider do
@moduledoc """
`Charts.DataProvider` is a callback module for use in
client applications. Implement the callbacks defined here
in your application to provide the data that drives a chart's
underlying `Charts.dataset`.
Let's say we have a list of data we want to render in an... | charts/lib/charts/data_provider.ex | 0.877909 | 0.865452 | data_provider.ex | starcoder |
defmodule Resourceful.Collection.Filter do
@moduledoc """
Provides a common interface for filtering collections. See `call/2` for use
and examples.
This module is intended to dispatch arguments to the appropriate `Filter`
module for the underlying data source.
Filtering is not meant to replace and be anyt... | lib/resourceful/collection/filter.ex | 0.911731 | 0.606003 | filter.ex | starcoder |
defmodule Croma.TypeUtil do
@moduledoc """
Utilities to work with internal representation of types.
"""
alias Kernel.Typespec
@primitive_types [
:pid,
:port,
:reference,
:atom,
:binary,
:bitstring,
:boolean,
:byte,
:char,
:integer,
:pos_integer,
:neg_integer,
... | lib/croma/type_util.ex | 0.667906 | 0.449755 | type_util.ex | starcoder |
defmodule Guss do
@moduledoc """
Guss generates Signed URLs for Google Cloud Storage.
Signed URLs provide a mechanism for query-string authentication for storage objects.
For more information, see the Storage Docs for [Signed URLs](https://cloud.google.com/storage/docs/access-control/signed-urls).
"""
ali... | lib/guss.ex | 0.881583 | 0.539954 | guss.ex | starcoder |
defmodule Raft do
@moduledoc """
Raft provides users with an api for building consistent (as defined by CAP), distributed
state machines. It does this using the raft leader election and concensus
protocol as described in the [original paper](https://raft.github.io/raft.pdf).
## Example
Lets create a dis... | lib/raft.ex | 0.913276 | 0.960249 | raft.ex | starcoder |
defmodule UUIDTools.UUID do
@moduledoc """
UUIDTools.UUID is a module that handles the generation of UUIDs for [Elixir](http://elixir-lang.org/).
It follows the [RFC 4122](http://www.ietf.org/rfc/rfc4122.txt).
"""
use Bitwise, only_operators: true
@compile {:inline, e: 1}
# 15 Oct 1582 to 1 Jan 1970.
... | lib/uuid_tools/uuid.ex | 0.886629 | 0.63023 | uuid.ex | starcoder |
defmodule Joq.Job do
@moduledoc """
Internal representation of a job instance.
See [below](#t:t/0) for the format of Job structs.
"""
import Joq.Timing
alias Joq.Retry
defstruct [:id, :worker, :args, :retry, :delay_until]
@typedoc """
The type of a Job struct.
Job structs contain the following... | lib/joq/job.ex | 0.891721 | 0.63077 | job.ex | starcoder |
defmodule AdventOfCode.Y2020.Day18v2 do
@supported_ops ["+", "-", "*", "/"]
def run() do
AdventOfCode.Helpers.Data.read_from_file("2020/day18.txt")
|> Enum.map(&calculate/1)
|> Enum.sum()
end
def calculate(input) do
input
|> parse()
|> rpn()
end
def parse(input) do
input
|... | lib/2020/day18v2.ex | 0.677367 | 0.494507 | day18v2.ex | starcoder |
defmodule Type.Function do
@moduledoc """
Represents a function type.
There are two fields for the struct defined by this module.
- `params` a list of types for the function arguments. Note that the arity
of the function is the length of this list. May also be the atom `:any`
which corresponds to "... | lib/type/function.ex | 0.936249 | 0.971019 | function.ex | starcoder |
defmodule Tablespoon.Transport.PMPPMultiplex do
@moduledoc """
Transport which serves to multiplex several senders over a single transport.
Since we don't know who responses are for directly, we treat them as a FIFO queue. The first response is for the first sender, &c.
"""
@behaviour Tablespoon.Transport
... | lib/tablespoon/transport/pmpp_multiplex.ex | 0.673943 | 0.434161 | pmpp_multiplex.ex | starcoder |
defmodule Chronik.Aggregate.Multi do
@moduledoc """
`Chronik.Aggregate.Multi` can be used to generate a single commmand
that affects multiple entities.
As can be seen on the test a multiple-entity command can be defined
as:
## Example
```
alias Chronik.Aggregate.Multi
def handle_command({:update_n... | lib/chronik/aggregate/multi.ex | 0.884389 | 0.813461 | multi.ex | starcoder |
defmodule Phoenix.LiveView do
@moduledoc ~S'''
LiveView provides rich, real-time user experiences with
server-rendered HTML.
LiveView programming model is declarative: instead of
saying "once event X happens, change Y on the page",
events in LiveView are regular messages which may cause
changes to its st... | lib/phoenix_live_view.ex | 0.818483 | 0.669042 | phoenix_live_view.ex | starcoder |
defprotocol Collectable do
@moduledoc """
A protocol to traverse data structures.
The `Enum.into/2` function uses this protocol to insert an
enumerable into a collection:
iex> Enum.into([a: 1, b: 2], %{})
%{a: 1, b: 2}
## Why Collectable?
The `Enumerable` protocol is useful to take values ou... | lib/elixir/lib/collectable.ex | 0.903224 | 0.81721 | collectable.ex | starcoder |
defmodule VintageNet.NameResolver do
@moduledoc """
This module manages the contents of "/etc/resolv.conf".
This file is used by the C standard library and by Erlang for resolving
domain names. Since both C programs and Erlang can do resolution, debugging
problems in this area can be confusing due to varyin... | lib/vintage_net/name_resolver.ex | 0.781664 | 0.444685 | name_resolver.ex | starcoder |
defmodule String do
@moduledoc %B"""
A String in Elixir is a UTF-8 encoded binary.
## String and binary operations
The functions in this module act according to the
Unicode Standard, version 6.2.0. For example,
`titlecase`, `downcase`, `strip` are provided by this
module.
Besides this module, Elixir ... | lib/elixir/lib/string.ex | 0.902211 | 0.608739 | string.ex | starcoder |
defmodule Google.Protobuf.FileDescriptorSet do
@moduledoc false
alias Pbuf.Decoder
@derive {Jason.Encoder, []}
defstruct [
file: []
]
@type t :: %__MODULE__{
file: [Google.Protobuf.FileDescriptorProto.t]
}
@spec new(Enum.t) :: t
def new(data \\ []), do: struct(__MODULE__, data)
@sp... | test/schemas/proto/google/protobuf/descriptor.pb.ex | 0.75392 | 0.520801 | descriptor.pb.ex | starcoder |
defmodule Day12 do
@moduledoc """
Assembunny code interpreter
"""
defmodule State do
defstruct pc: 0, a: 0, b: 0, c: 1, d: 0
end
def evaluate_file(path) do
path
|> File.read!
|> evaluate
end
@doc """
Evaluate the given instruction set
"""
def evaluate(str) do
str
|> pars... | day12/lib/day12.ex | 0.60288 | 0.511107 | day12.ex | starcoder |
defmodule Advent.Sixteen.TinyLCD do
alias Advent.Agents.Screen
def init(width, height) do
Screen.init(width, height)
end
def update(%{type: :rect, x: x, y: y}) do
for i <- 0..(x - 1) do
for j <- 0..(y - 1) do
Screen.set i, j, "█"
end
end
end
def update(%{type: :rotate, o... | lib/2016/8.ex | 0.659624 | 0.527256 | 8.ex | starcoder |
defmodule AtomTweaksWeb.PrimerHelpers do
@moduledoc """
View helper functions for generating elements that work with
[GitHub's Primer](https://primer.github.io/) CSS framework.
All functions can be used either within a template or composed together in code. Each function
should always emit `t:Phoenix.HTML.sa... | lib/atom_tweaks_web/helpers/primer_helpers.ex | 0.891559 | 0.813609 | primer_helpers.ex | starcoder |
defmodule VintageNetMobile.Modem.QuectelEC25 do
@behaviour VintageNetMobile.Modem
@moduledoc """
Quectel EC25 support
The Quectel EC25 is a series of LTE Cat 4 modules. Here's an example
configuration:
```elixir
VintageNet.configure(
"ppp0",
%{
type: VintageNetMobile,
vintage_net_mo... | lib/vintage_net_mobile/modem/quectel_EC25.ex | 0.8549 | 0.702032 | quectel_EC25.ex | starcoder |
defmodule Mux.Deadline do
@moduledoc """
Deadline context for Mux.Context.
This module provides deadlines over (multiple) Mux dispatch contexts and
passes the deadline downstream.
"""
@behaviour Mux.Context
@wire_key "com.twitter.finagle.Deadline"
@time_unit :nanosecond
@enforce_keys [:start, :fin... | lib/mux/deadline.ex | 0.759538 | 0.46308 | deadline.ex | starcoder |
defmodule 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 the... | day02/lib/day02.ex | 0.597256 | 0.648974 | day02.ex | starcoder |
defmodule ExWareki.Era do
@moduledoc """
Era module provides conversion functions between Japanese-formatted date (wareki) and A.D. formatted date (seireki).
"""
alias ExWareki.Data
alias ExWareki.Structs.Wareki
alias ExWareki.Structs.Seireki
@doc """
search_wareki_by_name/1 finds an era by name
#... | lib/ex_wareki/era.ex | 0.589953 | 0.661713 | era.ex | starcoder |
defmodule Parser do
@spec lines(String.t()) :: [String.t()]
def lines(contents) do
contents
|> String.downcase()
|> String.split("\n", trim: true)
end
@spec data(String.t()) :: %{String.t() => %Signal{}}
def data(contents) do
lines(contents)
|> Enum.reduce(%{signals: %{}, line: 0}, fn x, ... | 2015/day7/lib/parser.ex | 0.798972 | 0.590336 | parser.ex | starcoder |
defmodule Exeration.Validation do
alias Exeration.Operation.Argument
def check([%Argument{name: name, type: type} = argument | arguments], function_arguments) do
value = Keyword.get(function_arguments, name)
with :ok <- check_required(argument, value),
:ok <- check_type(argument, value) do
... | lib/exeration/validation.ex | 0.572962 | 0.530845 | validation.ex | starcoder |
defmodule AWS.S3Control do
@moduledoc """
AWS S3 Control provides access to Amazon S3 control plane operations.
"""
@doc """
Creates an access point and associates it with the specified bucket. For
more information, see [Managing Data Access with Amazon S3 Access
Points](https://docs.aws.amazon.com/Amaz... | lib/aws/generated/s3_control.ex | 0.864067 | 0.497131 | s3_control.ex | starcoder |
defmodule StarkInfra.PixChargeback do
alias __MODULE__, as: PixChargeback
alias StarkInfra.Utils.Rest
alias StarkInfra.Utils.Check
alias StarkInfra.User.Project
alias StarkInfra.User.Organization
alias StarkInfra.Error
@moduledoc """
Groups PixChargeback related functions
"""
@doc """
A Pix char... | lib/pix_chargeback/pix_chargeback.ex | 0.910784 | 0.632531 | pix_chargeback.ex | starcoder |
defmodule ExPlasma.Transaction.Type.PaymentV1 do
@moduledoc false
@behaviour ExPlasma.Transaction
alias ExPlasma.Transaction
@type validation_responses() ::
ExPlasma.Output.Type.PaymentV1.validation_responses()
| {:error, {:inputs, :cannot_exceed_maximum_value}}
| {:error, {:out... | lib/ex_plasma/transaction/type/payment_v1.ex | 0.799481 | 0.512327 | payment_v1.ex | starcoder |
defmodule Snitch.Data.Model.Payment do
@moduledoc """
Payment API and utilities.
Payment is a polymorphic entity due to the many different kinds of "sources"
of a payment. Hence, Payments are not a concrete entity in Snitch, and thus
can be created or updated only by their concrete subtypes.
To fetch the ... | apps/snitch_core/lib/core/data/model/payment/payment.ex | 0.851768 | 0.54056 | payment.ex | starcoder |
defmodule Cldr.Calendar.Duration do
@moduledoc """
Functions to create and format a difference between
two dates, times or datetimes.
The difference between two dates (or times or datetimes) is
usually defined in terms of days or seconds.
A duration is calculated as the difference in time in calendar
un... | lib/cldr/calendar/duration.ex | 0.951953 | 0.917303 | duration.ex | starcoder |
defmodule RMap.ActiveSupport do
@moduledoc """
Summarized all of Hash functions in Rails.ActiveSupport.
If a function with the same name already exists in Elixir, that is not implemented.
Defines all of here functions when `use RMap.ActiveSupport`.
"""
@spec __using__(any) :: list
defmacro __using__(_opts... | lib/r_map/active_support.ex | 0.691185 | 0.596257 | active_support.ex | starcoder |
defmodule Delugex.Projection do
@moduledoc """
Project events upon an entity to convert it to an up-to-date value.
## use Delugex.Projection
Will provide a default `apply` implementation that will catch any event and
just return the entity as is. It will also log a warn, reporting that the
event is unhand... | lib/delugex/projection.ex | 0.822973 | 0.776665 | projection.ex | starcoder |
defprotocol Transformable do
@moduledoc """
Transform arbitrary maps and keyword lists into structs.
Transformable is a wrapper around `struct/2`. Out of the box, it supports
easily converting Maps and Keyword Lists into structs. Like with `struct/2`,
only the keys in the struct will be pulled out of your in... | lib/transformable.ex | 0.920083 | 0.7641 | transformable.ex | starcoder |
defmodule Routemaster.Fetcher.Caching do
@moduledoc """
Response caching middleware.
For each HTTP request (the `Fetcher` only supports GET requests)
it looks up a response in the cache using the URL as key.
If a cached response is found, it is immediately returned. If
nothing is found, it executes the HT... | lib/routemaster/fetcher/caching.ex | 0.802826 | 0.400603 | caching.ex | starcoder |
defmodule Lapin.Producer do
@moduledoc """
Extensible behaviour to define producer configuration.
Lapin provides a number of submodules which implement the patterns found in
the [RabbitMQ Tutorials](http://www.rabbitmq.com/getstarted.html).
```
defmodule ExampleApp.SomePatter do
use Lapin.Producer
... | lib/lapin/producer.ex | 0.874104 | 0.728821 | producer.ex | starcoder |
defmodule ExPng.Image.Encoding do
@moduledoc """
Utility module containing functtions necessary to encode an `ExPng.Image`
back into a PNG file.
"""
use ExPng.Constants
import ExPng.Utilities, only: [reduce_to_binary: 1]
alias ExPng.Chunks.{End, Header, ImageData, Palette, Transparency}
alias ExPng.{... | lib/ex_png/image/encoding.ex | 0.822046 | 0.530601 | encoding.ex | starcoder |
defmodule Hive.H3 do
@moduledoc """
Interfaces with Erlang H3 and provides abstraction
layer to work with vehicles or `%GeoPosition{}`.
## Usage
iex> Hive.H3.num_hexagons(resolution)
"""
use Hive.Base
@type vehicle_id() :: binary()
@type h3_index() :: non_neg_integer()
@type resolution() :: 0 |... | lib/hive/h3.ex | 0.924594 | 0.808786 | h3.ex | starcoder |
defmodule Day9 do
def from_file(path) do
File.read!(path)
|> String.split(",")
|> Enum.map(&Integer.parse/1)
|> Enum.map(&(elem(&1, 0)))
end
def modify(memory, address, value) do
memory |> Map.put(address, value)
end
def read_instruction(value) do
{params, inst} = Integer.digits(val... | lib/day9.ex | 0.589007 | 0.48749 | day9.ex | starcoder |
defmodule Canvas.Resources.Accounts do
@moduledoc """
Provides functions to interact with the
[assignment endpoints](https://canvas.instructure.com/doc/api/assignments).
"""
alias Canvas.{Client, Listing, Response}
alias Canvas.Resources.{Account, Course, EnrollmentTerm}
@doc """
A paginated list of a... | lib/canvas/resources/accounts.ex | 0.814901 | 0.475666 | accounts.ex | starcoder |
defmodule MicroTimer do
@moduledoc """
A timer module with microsecond resolution.
"""
@sleep_done :___usleep_done
@type executable :: {module(), atom()} | function()
@doc """
Suspend the current process for the given `timeout` and then returns `:ok`.
`timeout` is the number of microsends to sleep as... | lib/micro_timer.ex | 0.832713 | 0.555496 | micro_timer.ex | starcoder |
defmodule SanbaseWeb.Graphql.Schema.BlockchainMetricQueries do
use Absinthe.Schema.Notation
import SanbaseWeb.Graphql.Cache, only: [cache_resolve: 1]
alias SanbaseWeb.Graphql.Resolvers.{EtherbiResolver, ClickhouseResolver, ExchangeResolver}
alias SanbaseWeb.Graphql.Complexity
alias Sanbase.Billing.Product
... | lib/sanbase_web/graphql/schema/queries/blockchain_metric_queries.ex | 0.863866 | 0.489686 | blockchain_metric_queries.ex | starcoder |
defmodule EctoSearcher.Searcher do
@moduledoc """
Module for searching
## Usage
```elixir
search = %{"name_eq" => "<NAME>", "description_cont" => "My president"}
query = EctoSearcher.Searcher.search(MyMegaModel, search)
MySuperApp.Repo.all(query)
```
"""
require Ecto.Query
alias Ecto.Query
ali... | lib/ecto_searcher/searcher.ex | 0.816589 | 0.649676 | searcher.ex | starcoder |
defmodule XDR.Float do
@moduledoc """
This module manages the `Floating-Point` type based on the RFC4506 XDR Standard.
"""
@behaviour XDR.Declaration
alias XDR.Error.Float, as: FloatError
defstruct [:float]
defguard valid_float?(value) when is_float(value) or is_integer(value)
@typedoc """
`XDR.F... | lib/xdr/float.ex | 0.929103 | 0.662099 | float.ex | starcoder |
defmodule Mix.Tasks.Ggity.Visual.Geom.Line do
@shortdoc "Launch a browser and draw sample line geom plots."
@moduledoc @shortdoc
use Mix.Task
alias GGity.{Examples, Plot}
@default_browser "firefox"
@doc false
@spec run(list(any)) :: any
def run([]), do: run([@default_browser])
def run(argv) do
... | lib/mix/tasks/ggity_visual_geom_line.ex | 0.839422 | 0.420838 | ggity_visual_geom_line.ex | starcoder |
defmodule Gradient.AstData do
@moduledoc """
Stores the test cases data for expressions line specifying. To increase the flexibility
the data need normalization before equality assertion. Thus we check only the line change,
not the exact value and there is no need to update expected values when the file content... | test/support/ast_data.ex | 0.782081 | 0.60092 | ast_data.ex | starcoder |
defmodule Eljiffy do
@moduledoc """
Documentation for Eljiffy.
Eljiffy (Elixir Jiffy) is an Elixir wrapper around the erlang JSON nif library Jiffy.
It also provides functions to convert json to maps directly rather than having to pass the option return_maps explicitly
(https://github.com/davisp/jiffy) (deco... | lib/eljiffy.ex | 0.921145 | 0.651743 | eljiffy.ex | starcoder |
defmodule MarsRoverKata.Input do
@moduledoc """
Converting input instruction strings into actionable terms.
The input should be someting like:
5:3
0:0 0:1
1:1:E
FBFBFBF
Where
- the first line represent the maximux X and Y in the grid;
- the second lie represent a list of obstacle points;
- the ... | lib/mars_rover_kata/input.ex | 0.845863 | 0.612063 | input.ex | starcoder |
defmodule Telegraf.Transport.UnixSocket do
@children_opts_definition [
socket_path: [
type: :string,
doc: "Path to the unix socket.",
default: "/tmp/telegraf.sock"
],
pool_size: [
type: :pos_integer,
doc: "The size of the pool tcp sockets. Defaults to `System.schedulers_onlin... | lib/telegraf/transport/unix_socket.ex | 0.800107 | 0.710013 | unix_socket.ex | starcoder |
defmodule Bagg do
alias Bagg.{Aggday, Datapoint}
@valid_aggdays for {name, 1} <- Aggday.__info__(:functions), do: Atom.to_string(name)
@type aggregate_opt() ::
{:aggday, atom() | String.t()}
| {:kyoom, boolean()}
| {:odom, boolean()}
@type aggregate_error() :: {:invalid_aggday, ... | lib/bagg.ex | 0.767254 | 0.475544 | bagg.ex | starcoder |
defmodule Nebulex.Adapter.Entry do
@moduledoc """
Specifies the entry API required from adapters.
This behaviour specifies all read/write key-based functions,
the ones applied to a specific cache entry.
"""
@typedoc "Proxy type to the adapter meta"
@type adapter_meta :: Nebulex.Adapter.adapter_meta()
... | lib/nebulex/adapter/entry.ex | 0.9345 | 0.47025 | entry.ex | starcoder |
defmodule ExAlgo.Stack.MinMaxStack do
@moduledoc """
A min-max stack. In addition to being a LIFO, this stack also keeps track of
the smallest and largest values. And can efficiently show them. In addition to
`push`, `pop`, and `peek`, a `MinMaxStack` also pop_minimum and pop_maximum
values.1
"""
defstru... | lib/ex_algo/stack/min_max_stack.ex | 0.951718 | 0.462959 | min_max_stack.ex | starcoder |
defmodule Terp.TypeSystem.Type do
@moduledoc """
Type
Constructors:
- Tconst -> Constants
- Tvar -> type variables
- Tarrow -> arrow type; function
- Tlist -> list
"""
alias __MODULE__
alias Terp.TypeSystem.Environment
defstruct [:constructor, :t, :vars, :type_constructor]
@type t... | lib/type_system/type.ex | 0.53048 | 0.550487 | type.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.