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 Erlef.Agenda do
@moduledoc false
@board_ics "https://user.fm/calendar/v1-d950fe3b2598245f424e3ddbff1a674a/Board%20Public.ics"
# 2 minutes
@check_interval 120_000
require Logger
use GenServer
alias Erlef.Agenda.Parser
# Client
@spec start_link(Keyword.t()) :: :ignore | {:error, term()} |... | lib/erlef/agenda.ex | 0.620507 | 0.432663 | agenda.ex | starcoder |
defmodule TinyEctoHelperMySQL do
@moduledoc """
Documentation for TinyEctoHelperMySQL
"""
@doc """
get columns lists in queryable
from(
q in Question,
select: {q.id, q.title, q.body}
) |> TinyEctoHelperMySQL.get_select_keys()
|
|
|
[:id, :title, :body]
"""
@error_not_queryable... | lib/tiny_ecto_helper_mysql.ex | 0.725065 | 0.440409 | tiny_ecto_helper_mysql.ex | starcoder |
defmodule Niesso.Assertion do
@moduledoc """
SAML assertion returned from the IdP upon succesful authentication.
"""
import SweetXml
use Timex
alias Niesso.Assertion
defstruct uid: "",
attributes: [],
success: false,
expires_at: nil
@type t :: %__MODULE__{
... | lib/assertion.ex | 0.766468 | 0.500183 | assertion.ex | starcoder |
defmodule BinaryNode do
@enforce_keys [:value]
defstruct value: nil,
right: nil,
left: nil
@type t :: %__MODULE__{
value: integer(),
right: BinaryNode.t(),
left: BinaryNode.t()
}
@doc """
Create new Node
#Example
iex> BinaryNode.new(1)
... | lib/binary_tree.ex | 0.887741 | 0.603815 | binary_tree.ex | starcoder |
defmodule Arrow.Type do
@moduledoc """
Conveniences for working with types.
A type is a two-element tuple with the name and the size.
The first element must be one of followed by the respective
sizes:
* `:s` - signed integer (8, 16, 32, 64)
* `:u` - unsigned integer (8, 16, 32, 64)
* `:f` - ... | lib/arrow/type.ex | 0.667906 | 0.439928 | type.ex | starcoder |
defmodule Genome.Sequence do
alias Genome.Nucleotide
def from_enumerable(stream), do: stream |> Enum.map(&Nucleotide.encode/1)
def from_string(string), do: string |> to_charlist() |> from_enumerable()
def to_string(seq), do: seq |> Enum.map(&Nucleotide.decode/1) |> Kernel.to_string()
def encode(seq), do: ... | lib/genome/sequence.ex | 0.642545 | 0.554651 | sequence.ex | starcoder |
defmodule Datamusex do
@moduledoc """
Elixir wrapper for the free [Datamuse](https://www.datamuse.com/api/) API.
## Exaple usage:
Datamusex.similar_meaning("computer")
|> Datamusex.triggered_by("device")
|> Datamusex.get_words
"""
defmodule ParamList do
@enforce_keys [:params]
defs... | lib/datamusex.ex | 0.765243 | 0.52476 | datamusex.ex | starcoder |
defmodule Aoc2021.Day10 do
@moduledoc """
See https://adventofcode.com/2021/day/10
"""
@type token() :: char()
defmodule Reader do
@moduledoc false
@spec read_input(Path.t()) :: [[Aoc2021.Day10.token()]]
def read_input(path) do
path
|> File.stream!()
|> Stream.map(&String.trim... | lib/aoc2021/day10.ex | 0.671147 | 0.447823 | day10.ex | starcoder |
defmodule DarkMatter.Inflections do
@moduledoc """
General utils for working with case conversions.
"""
@moduledoc since: "1.0.0"
alias DarkMatter.Namings.AbsintheNaming
alias DarkMatter.Namings.PhoenixNaming
@typedoc """
Available inflection conversions
"""
@type conversion() ::
:camel
... | lib/dark_matter/inflections.ex | 0.939081 | 0.466906 | inflections.ex | starcoder |
defmodule FlowAssertions.EnumA do
use FlowAssertions.Define
alias FlowAssertions.Messages
alias FlowAssertions.StructA
@moduledoc """
Assertions that apply to Enums.
"""
@doc """
Assert that an Enum has only a single element.
```
[1] |> assert_singleton # passes
[ ] |> assert_singleton # fai... | lib/enum_a.ex | 0.862844 | 0.917893 | enum_a.ex | starcoder |
defmodule Scenic.Component do
@moduledoc """
A Component is Scene that is optimized to be used as a child of another scene.
These are typically controls that you want to define once and use in multiple places.
## Standard Components
Scenic includes a several standard components that you can use in your
... | lib/scenic/component.ex | 0.929808 | 0.855489 | component.ex | starcoder |
defmodule LcovEx.Stats do
@moduledoc """
Output parser for `:cover.analyse/3`
"""
@type cover_analyze_function_output :: [{{module(), atom(), integer()}, integer()}, ...]
@type cover_analyze_line_output :: [{{module(), integer()}, integer()}, ...]
@type coverage_info :: {binary(), integer()}
@doc """
F... | lib/lcov_ex/stats.ex | 0.687 | 0.443661 | stats.ex | starcoder |
defmodule Pie.Pipeline.Step do
@moduledoc """
Pipeline step handling
"""
defstruct context: nil,
callback: nil,
input: nil,
output: nil,
error: nil,
executed?: false,
failed?: false,
label: nil
alias Pie.State
@typedoc """... | lib/pie/pipeline/step.ex | 0.795181 | 0.410697 | step.ex | starcoder |
defmodule Part1 do
def run() do
AOCHelper.read_input()
|> find_closest_intersection()
end
def find_closest_intersection(wires) do
wires
|> GridHelper.draw_wires(%{})
|> find_smallest_distance()
end
defp find_smallest_distance(grid) do
distances =
GridHelper.crossings(grid)
... | aoc-2019/day3/lib/part1.ex | 0.619932 | 0.470311 | part1.ex | starcoder |
defmodule Paramsx do
@moduledoc """
Paramsx provides functionally to whitelist and validate parameters
"""
@doc """
Filter params based on your required and optional keyword.
Important: You have to allow all params correctly, by default it allow only string or number
for a simple key, if you want spe... | lib/paramsx.ex | 0.725649 | 0.488893 | paramsx.ex | starcoder |
defmodule Adventofcode.Day23ExperimentalEmergencyTeleportation do
use Adventofcode
defmodule Part1 do
alias Adventofcode.Day23ExperimentalEmergencyTeleportation.Nanobots
def solve(input) do
input
|> Nanobots.parse()
|> nanobots_within_range_of_strongest_one()
|> Enum.count()
en... | lib/day_23_experimental_emergency_teleportation.ex | 0.670393 | 0.652619 | day_23_experimental_emergency_teleportation.ex | starcoder |
defmodule ExGherkin.Scanner.LanguageSupport do
@gherkin_languages_source Application.get_env(:my_ex_gherkin, :file).source
@gherkin_languages_resource Application.get_env(:my_ex_gherkin, :file).resource
@homonyms Application.get_env(:my_ex_gherkin, :homonyms)
@moduledoc_homonyms @homonyms |> Enum.map(&" * ... | lib/scanner/lib/language_support.ex | 0.804981 | 0.736424 | language_support.ex | starcoder |
defmodule AWS.Snowball do
@moduledoc """
AWS Snow Family is a petabyte-scale data transport solution that uses secure
devices to transfer large amounts of data between your on-premises data centers
and Amazon Simple Storage Service (Amazon S3).
The Snow commands described here provide access to the same fun... | lib/aws/generated/snowball.ex | 0.894222 | 0.694685 | snowball.ex | starcoder |
defmodule RedisGraph.Graph do
@moduledoc """
A Graph consisting of `RedisGraph.Node`s and `RedisGraph.Edge`s.
A name is required for each graph.
Construct graphs by adding `RedisGraph.Node`s followed
by `RedisGraph.Edge`s which relate existing nodes.
If a node does not have an alias, a random alias will
... | lib/redis_graph/graph.ex | 0.918968 | 0.907681 | graph.ex | starcoder |
defprotocol SimpleMarkdown.Renderer.HTML.AST do
@moduledoc """
A renderer protocol for HTML AST.
Individual rule renderers can be overriden or new ones may be
added. Rule types follow the format of structs defined under
`SimpleMarkdown.Attribute.*`. e.g. If there is a rule with the
na... | lib/simple_markdown/Renderer/html/ast.ex | 0.915034 | 0.440229 | ast.ex | starcoder |
defmodule Miss.String do
@moduledoc """
Functions to extend the Elixir `String` module.
"""
@doc ~S"""
Builds a string with the given values using IO lists.
In Erlang and Elixir concatenating binaries will copy the concatenated binaries into a new
binary. Every time you concatenate binaries (`<>`) or us... | lib/miss/string.ex | 0.902451 | 0.714952 | string.ex | starcoder |
defmodule WordsWithEnemies.Letters do
@moduledoc """
Provides a set of functions for intelligently creating
sets of letters. Uses <NAME>'s letter frequencies
and <NAME>'s common pairs.
"""
import Enum, only: [random: 1, take_random: 2]
import WordsWithEnemies.WordFinder, only: [word_list: 0, using: 2]
... | lib/words_with_enemies/language/letters.ex | 0.822403 | 0.691458 | letters.ex | starcoder |
defmodule Rajska.FieldAuthorization do
@moduledoc """
Absinthe middleware to ensure field permissions.
Authorizes Absinthe's object [field](https://hexdocs.pm/absinthe/Absinthe.Schema.Notation.html#field/4) according to the result of the `c:Rajska.Authorization.is_field_authorized?/3` function, which receives th... | lib/middlewares/field_authorization.ex | 0.876463 | 0.860838 | field_authorization.ex | starcoder |
defmodule Square.CashDrawers do
@moduledoc """
Documentation for `Square.CashDrawers`.
"""
@doc """
Provides the details for all of the cash drawer shifts for a location
in a date range.
```
def list_cash_drawer_shifts(client, [
location_id: "", # required
sort_order: nil,
begin_time: nil,... | lib/api/cash_drawers_api.ex | 0.935006 | 0.822439 | cash_drawers_api.ex | starcoder |
defmodule Scope do
@moduledoc """
Scope is a small module that provides two macros to facilitate
function overload and local import/aliases execution.
## Overload functions
```
import Scope
overload [+: 2, -: 2], from: Kernel, with: Test
1 + 3 - 2 # gives [2, [1, 3]]
```
## Local importation
... | lib/scope.ex | 0.612773 | 0.905239 | scope.ex | starcoder |
defmodule Sebex.ElixirAnalyzer.Span do
@type t :: %__MODULE__{
start_line: non_neg_integer(),
start_column: non_neg_integer(),
end_line: non_neg_integer(),
end_column: non_neg_integer()
}
@derive Jason.Encoder
@enforce_keys [:start_line, :start_column, :end_line, :... | sebex_elixir_analyzer/lib/sebex_elixir_analyzer/span.ex | 0.755817 | 0.413596 | span.ex | starcoder |
defmodule AWS.CostExplorer do
@moduledoc """
The Cost Explorer API enables you to programmatically query your cost and
usage data. You can query for aggregated data such as total monthly costs
or total daily usage. You can also query for granular data, such as the
number of daily write operations for Amazon ... | lib/aws/cost_explorer.ex | 0.928124 | 0.661684 | cost_explorer.ex | starcoder |
defmodule PaymentStream do
@moduledoc """
The PaymentStream module provides utilities for dealing with streams
of payments.
## Payment Streams
A *payment* is a tuple `{amount, date}` consisting of an amount (in
whatever currency) and a date. The amount can be positive or
negative.
For example, `{-20... | lib/payment_stream.ex | 0.924398 | 0.965381 | payment_stream.ex | starcoder |
defmodule Mix.Utils do
@moduledoc """
Utilities used throughout Mix and tasks.
## Conversions
This module handles two types of conversions:
* From command names to module names, i.e. how the command
`deps.get` translates to `Deps.Get` and vice-versa;
* From underscore to CamelCase, i.e. how the file... | lib/mix/lib/mix/utils.ex | 0.85166 | 0.628692 | utils.ex | starcoder |
defmodule Kino.JS.Live do
@moduledoc ~S'''
Introduces state and event-driven capabilities to JavaScript
powered widgets.
Make sure to read the introduction to JavaScript widgets in
`Kino.JS` for more context.
Similarly to static widgets, live widgets involve a custom
JavaScript code running in the brows... | lib/kino/js/live.ex | 0.876158 | 0.837188 | live.ex | starcoder |
defmodule Verk do
@moduledoc """
Verk is a job processing system that integrates well with Sidekiq jobs
Each queue will have a pool of workers handled by `poolboy` that will process jobs.
Verk has a retry mechanism similar to Sidekiq that keeps retrying the jobs with a reasonable backoff.
It has an API tha... | lib/verk.ex | 0.817429 | 0.559651 | verk.ex | starcoder |
defmodule AbsintheErrorPayload.Payload do
@moduledoc """
Absinthe Middleware to build a mutation payload response.
AbsintheErrorPayload mutation responses (aka "payloads") have three fields
- `successful` - Indicates if the mutation completed successfully or not. Boolean.
- `messages` - a list of validation... | lib/absinthe_error_payload/payload.ex | 0.907001 | 0.686127 | payload.ex | starcoder |
defmodule EctoFixtures do
@moduledoc """
Generates :map or JSON fixture from Ecto.Schema
It's useful for tests
"""
def ecto_json_fixtures(model) do
model
|> ecto_fixtures
|> Poison.encode!
end
def ecto_fixtures(model) when is_map(model), do: map_ecto_values(model)
def ecto_fixtures(model) ... | lib/ecto_fixtures.ex | 0.574275 | 0.432243 | ecto_fixtures.ex | starcoder |
defmodule Mongo.Cursor do
@moduledoc false
import Record, only: [defrecordp: 2]
@type t :: %__MODULE__{
conn: Mongo.conn,
coll: Mongo.collection,
query: BSON.document,
opts: Keyword.t
}
defstruct [:conn, :coll, :query, :opts]
defimpl Enumerable do
defrecordp :state, [:conn, :cursor,... | lib/mongo/cursor.ex | 0.759404 | 0.445107 | cursor.ex | starcoder |
defmodule OMG.Watcher.ExitProcessor do
@moduledoc """
Encapsulates managing and executing the behaviors related to treating exits by the child chain and watchers
Keeps a state of exits that are in progress, updates it with news from the root chain, compares to the
state of the ledger (`OMG.API.State`), issues ... | apps/omg_watcher/lib/exit_processor.ex | 0.815857 | 0.458227 | exit_processor.ex | starcoder |
defmodule AshGraphql.Resource.ManagedRelationship do
@moduledoc "Represents a managed relationship configuration on a mutation"
defstruct [
:argument,
:action,
:types,
:type_name,
:lookup_with_primary_key?,
:lookup_identities
]
@schema [
argument: [
type: :atom,
doc: "T... | lib/resource/managed_relationship.ex | 0.855836 | 0.428592 | managed_relationship.ex | starcoder |
defmodule KaufmannEx.ReleaseTasks.MigrateSchemas do
@moduledoc """
Task for registering all schemas in `priv/schemas` with the schema registry.
Expects
- schemas to be defined in `priv/schemas`.
- an `event_metadata.avsc` schema should be defined and required by all events
Can be called in a production... | lib/release_tasks/migrate_schemas.ex | 0.731538 | 0.62581 | migrate_schemas.ex | starcoder |
defmodule Sanbase.Alert.OperationText.KV do
@moduledoc ~s"""
A module providing a single function to_template_kv/3 which transforms an operation
to human readable text that can be included in the alert's payload
"""
def current_value(%{current: value, previous: previous}, opts) do
special_symbol = Keywor... | lib/sanbase/alerts/operation/operation_text_kv.ex | 0.740362 | 0.691094 | operation_text_kv.ex | starcoder |
defmodule AvroRPC.Response do
@moduledoc """
A parser for turning AvroRPC responses into Elixir data structures.
It uses the Avro specification's type definition to reconstruct the field names/data structure in
Elixir.
"""
@doc """
Converts an :eavro_rpc_fsm response into an Elixir data structure.
"""... | lib/avro_rpc/response.ex | 0.68721 | 0.641247 | response.ex | starcoder |
defmodule MasteringBitcoin.RPCBlock do
@moduledoc """
Example 3-5. Retrieving a block and adding all the transaction outputs.
Port over of `rpc_block.py` file (with fallback capabilities when Alice's
transaction isn't in the local blockchain).
"""
# Alias is as per the book's naming of its client as RawPr... | lib/mastering_bitcoin/rpc_block.ex | 0.802285 | 0.453806 | rpc_block.ex | starcoder |
defmodule Cldr.Calendar.Parse do
@moduledoc false
@split_reg ~r/[\sT]/
def parse_date(<<"-", year::bytes-4, "-", month::bytes-2, "-", day::bytes-2>>, calendar) do
with {:ok, {year, month, day}} <- return_date(year, month, day, calendar) do
{:ok, {-year, month, day}}
end
end
def parse_date(<<y... | lib/cldr/calendar/parse.ex | 0.665628 | 0.531757 | parse.ex | starcoder |
defmodule CoopMinesweeper.Game.GameRegistry do
@moduledoc """
This module is responsible for creating, saving and deleting supervised game
agents.
It makes sure that the game id is associated with its game agent and that the
game agents are supervised so that they can't crash the application.
"""
alias ... | lib/coop_minesweeper/game/game_registry.ex | 0.679179 | 0.446133 | game_registry.ex | starcoder |
defmodule Croma.Validation do
@moduledoc """
Module for code generation of argument validation (see `Croma.Defun.defun/2`).
This module is intended for internal use.
"""
def make(type_expr, v, caller) do
ast = validation_expr(type_expr, v, caller)
{name, _, _} = v
type_string = Macro.to_string(ty... | lib/croma/validation.ex | 0.604866 | 0.448487 | validation.ex | starcoder |
defmodule Grapex.Models.Utils do
@spec filter_by_label(map, integer) :: map
defp filter_by_label(batch, target_label) do
case Stream.zip([batch.heads, batch.tails, batch.relations, batch.labels])
|> Stream.filter(fn {_, _, _, label} -> label == target_label end)
|> Stream.map(fn {head, tail, relation,... | lib/grapex/models/utils.ex | 0.849644 | 0.559651 | utils.ex | starcoder |
defmodule Bitcoin.Protocol.Messages.GetHeaders do
@moduledoc """
Return a headers packet containing the headers of blocks starting right after the last known hash in the block
locator object, up to hash_stop or 2000 blocks, whichever comes first. To receive the next block headers, one needs
to issue geth... | lib/bitcoin/protocol/messages/get_headers.ex | 0.834542 | 0.513546 | get_headers.ex | starcoder |
defmodule Faker.Cannabis.En do
import Faker, only: [sampler: 2]
@moduledoc """
Functions for generating Cannabis related data in English
"""
@doc """
Returns a Cannabis strain string
## Examples
iex> Faker.Cannabis.En.strain()
"Critical Kush"
iex> Faker.Cannabis.En.strain()
"Bl... | lib/faker/cannabis/en.ex | 0.722331 | 0.502747 | en.ex | starcoder |
defmodule ExTorch.ModuleMixin do
@moduledoc """
Utilities used to define a module mixin that inherits documentation and specs.
"""
@signature_regex ~r/[a-zA-Z_]\w*[(]((\w,? ?)*)[)]/
@doc """
This macro enables a module to import the functions from another module
and expose them as they were defined on i... | lib/extorch/utils/module_mixin.ex | 0.748536 | 0.50531 | module_mixin.ex | starcoder |
defmodule Grizzly.Inclusions do
@moduledoc """
Module for adding and removing Z-Wave nodes
In Z-Wave the term "inclusions" means two things:
1. Adding a new Z-Wave device to the Z-Wave Network
2. Removing a Z-Wave device to the Z-Wave Network
In practice though it is more common to speak about adding a Z... | lib/grizzly/inclusions.ex | 0.90417 | 0.900048 | inclusions.ex | starcoder |
defmodule TheFuzz.Similarity.Tversky do
@moduledoc """
This module contains functions to calculate the [Tversky index
](https://en.wikipedia.org/wiki/Tversky_index) between two given
strings
"""
import TheFuzz.Util, only: [ngram_tokenize: 2, intersect: 2]
@behaviour TheFuzz.StringMetric
@default_ngram_... | lib/the_fuzz/similarity/tversky.ex | 0.89935 | 0.723602 | tversky.ex | starcoder |
defmodule ExRogue.Map do
defmodule Tile.Wall do
defstruct id: 0, position: {0, 0}
@type t :: %__MODULE__{id: integer, position: {integer, integer}}
end
defmodule Tile.Room do
defstruct id: 0, position: {0, 0}
@type t :: %__MODULE__{id: integer, position: {integer, integer}}
end
defmodule Til... | lib/ex_rogue/map.ex | 0.826187 | 0.562717 | map.ex | starcoder |
defmodule ECS.Sim.Engine do
use GenServer
@moduledoc """
The simulation engine is responsible for starting, pausing, stopping, and changing the speed of the simulation.
It is also responsible for starting all required services, like the entity registry or the messenger.
It keeps the main 'game' loop running... | packages/sim/apps/ecs/lib/ecs/sim/engine.ex | 0.572842 | 0.44571 | engine.ex | starcoder |
defmodule EllipticCurve.Utils.Math do
@moduledoc false
alias EllipticCurve.Utils.Integer, as: IntegerUtils
alias EllipticCurve.Utils.{Point}
@doc """
Fast way to multily point and scalar in elliptic curves
:param p: First Point to mutiply
:param n: Scalar to mutiply
:param cN: Order of the elliptic c... | lib/utils/math.ex | 0.884296 | 0.895019 | math.ex | starcoder |
defmodule Atlas.Schema do
import Atlas.FieldConverter
@moduledoc """
Provides schema definitions and Struct generation through a `field` macro and
`%__MODULE__{}` struct to hold model state.
`field` definitions provide handling conversion of binary database results
into schema defined types.
Field Types... | lib/atlas/schema.ex | 0.826467 | 0.432782 | schema.ex | starcoder |
defmodule Rop do
defmacro __using__(_) do
quote do
import Rop
end
end
@doc ~s"""
Extracts the value from a tagged tuple like {:ok, value}
Raises the value from a tagged tuple like {:error, value}
Raise the arguments else
For example:
iex> ok({:ok, 1})
1
iex> ok({:error... | lib/rop.ex | 0.62395 | 0.553324 | rop.ex | starcoder |
defmodule CoinmarketcapApi do
alias CoinmarketcapApi.Ticker
use Tesla
plug Tesla.Middleware.BaseUrl, "https://api.coinmarketcap.com/v2"
plug CoinmarketcapApi.ResponseMiddleware
plug Tesla.Middleware.JSON
plug Tesla.Middleware.FollowRedirects
@doc """
Returns cryptocurrency ticker data ordered by marke... | lib/coinmarketcap_api.ex | 0.873728 | 0.737158 | coinmarketcap_api.ex | starcoder |
defmodule LDAPoolex.Schema do
use GenServer
require Logger
def start_link(args) do
GenServer.start_link(__MODULE__,
args,
name: String.to_atom(Atom.to_string(args[:name]) <> "_schema_loader"))
end
@impl GenServer
def init(args) do
table_name = ta... | lib/ldapoolex/schema_loader.ex | 0.799403 | 0.655681 | schema_loader.ex | starcoder |
defmodule Classifiers.NaiveBayes.Bernoulli do
defstruct class_instances: %{},
training_instances: 0,
features: 0,
conditional_probabilities: %{}
@doc """
Get a new classifier pid.
"""
def new do
{:ok, pid} = Agent.start_link fn ->
%Classifiers.NaiveBayes.Bernou... | lib/classifiers/naive_bayes/bernoulli.ex | 0.806853 | 0.656039 | bernoulli.ex | starcoder |
defmodule Blockfrost.HTTP do
@moduledoc """
HTTP requests to Blockfrost APIs.
This module is not meant to be use directly. Use the higher level modules to do calls
to the Blockfrost API.
"""
@retryable_statuses [403, 429, 500]
@type error_response ::
{:error,
:bad_request
... | lib/blockfrost/http.ex | 0.808974 | 0.412767 | http.ex | starcoder |
defmodule Taggart.Tags do
@doc "See `taggart/1`"
defmacro taggart() do
quote location: :keep do
{:safe, ""}
end
end
@doc """
Allows grouping tags in a block.
Groups tags such that they all become part of the result. Normally,
with an Elixir block, only the last expression is part of the v... | lib/taggart/tags.ex | 0.869285 | 0.819496 | tags.ex | starcoder |
defmodule Interp.Canvas do
alias Interp.Functions
alias Interp.Interpreter
alias Reading.Reader
alias Parsing.Parser
require Interp.Functions
defstruct canvas: %{},
cursor: [0, 0],
on_stack: false
def is_single_direction_list?(directions) do
... | lib/interp/canvas.ex | 0.577019 | 0.576453 | canvas.ex | starcoder |
defmodule Snor.Parser do
@moduledoc """
Convert a string into an intermediate representation - a list of nodes.
A node could be one of (mainly) -
- A plaintext node
- A function node
- A block node
- An interpolation node
"""
@typedoc """
A parsed node
"""
@type parsed_node :: plaintext_node(... | lib/snor/parser.ex | 0.887125 | 0.6081 | parser.ex | starcoder |
defmodule Chronic.Tokenizer do
@moduledoc false
@day_names ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]
@abbr_months ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]
def tokenize([token | remainder]) do
[tokenize(token) | tokenize(remain... | lib/chronic/tokenizer.ex | 0.535584 | 0.434701 | tokenizer.ex | starcoder |
defmodule Base85.Decode do
@moduledoc """
Implements decoding functionality for Base85 encoding.
"""
import Base85.{Charsets, Padding}
@typedoc "available character sets"
@type charset() :: Base85.Charsets.charset()
@typedoc "available padding techniques"
@type padding() :: Base85.Padding.padding()
... | lib/base85/decode.ex | 0.947308 | 0.451145 | decode.ex | starcoder |
defmodule OliWeb.Common.ManualModal do
@moduledoc """
A reusable LivewComponent for a Bootstrap modal, one that is manually controlled via JavaScript, and that
must be added and removed from a parent LiveView programmatically when it needs to be shown.
This component should be used in place of `OliWeb.Common.M... | lib/oli_web/live/common/manual_modal.ex | 0.772917 | 0.636819 | manual_modal.ex | starcoder |
defmodule Sanbase.PricePair.MetricAdapter do
@behaviour Sanbase.Metric.Behaviour
alias Sanbase.PricePair
@aggregations [:any, :sum, :avg, :min, :max, :last, :first, :median, :ohlc]
@default_aggregation :last
@timeseries_metrics ["price_usd", "price_btc"]
@histogram_metrics []
@table_metrics []
@metri... | lib/sanbase/prices/price_pair/metric_adapter.ex | 0.803868 | 0.402803 | metric_adapter.ex | starcoder |
defmodule ReceiptDecoder.Verifier do
@moduledoc """
Verify receipt
"""
alias ReceiptDecoder.Extractor
alias ReceiptDecoder.Verifier.PublicKey
alias ReceiptDecoder.Verifier.AppleRootCertificate
require PublicKey
@wwdr_cert_policies_extension_oid {1, 2, 840, 113_635, 100, 6, 2, 1}
@itunes_cert_marker... | lib/receipt_decoder/verifier/verifier.ex | 0.739328 | 0.424054 | verifier.ex | starcoder |
defmodule Snitch.Tools.Helper.Order do
@moduledoc """
Helpers to insert variants and line items for handcrafted orders.
"""
@line_item %{
quantity: nil,
unit_price: nil,
product_id: nil,
order_id: nil,
inserted_at: DateTime.utc_now(),
updated_at: DateTime.utc_now()
}
@variant %{
... | apps/snitch_core/lib/core/tools/helpers/order.ex | 0.912893 | 0.83868 | order.ex | starcoder |
defmodule Liquex.Represent do
@moduledoc """
Helper methods for maps
"""
alias Liquex.Representable
defguard is_lazy_object(value) when is_map(value) or is_list(value)
@doc """
Convert any object and deeply maps atom keys to strings
The value `deep` determines if it should eagerly represent the obje... | lib/liquex/represent.ex | 0.841533 | 0.594375 | represent.ex | starcoder |
defmodule Quarry.Sort do
@moduledoc false
require Ecto.Query
alias Quarry.{Join, From}
@sort_direction [:asc, :desc]
@spec build({Ecto.Query.t(), [Quarry.error()]}, Quarry.sort()) ::
{Ecto.Query.t(), [Qurry.error()]}
def build({query, errors}, keys, load_path \\ []) do
root_binding = From.g... | lib/quarry/sort.ex | 0.627381 | 0.409988 | sort.ex | starcoder |
defmodule Geometry.WKB.Parser do
@moduledoc false
alias Geometry.{
GeometryCollection,
GeometryCollectionM,
GeometryCollectionZ,
GeometryCollectionZM,
Hex,
LineString,
LineStringM,
LineStringZ,
LineStringZM,
MultiLineString,
MultiLineStringM,
MultiLineStringZ,
Mu... | lib/geometry/wkb/parser.ex | 0.630571 | 0.588505 | parser.ex | starcoder |
defprotocol Contex.Scale do
@moduledoc """
Provides a common interface for scales generating plotting coordinates.
This enables Log & Linear scales, for example, to be handled exactly
the same way in plot generation code.
Example:
```
# It doesn't matter if x & y scales are log, linear or discretizing... | lib/chart/scale.ex | 0.940024 | 0.94887 | scale.ex | starcoder |
defmodule LcdDisplay.HD44780.GPIO do
@moduledoc """
Knows how to commuticate with HD44780 type display using GPIO pins directly.
Supports the 4-bit mode only.
You can turn on/off the backlight.
## Usage
```
config = %{
pin_rs: 2,
pin_rw: 3,
pin_en: 4,
pin_d4: 23,
pin_d5: 24,
pin_... | lib/lcd_display/driver/hd44780_gpio.ex | 0.811527 | 0.756852 | hd44780_gpio.ex | starcoder |
defmodule Membrane.Core.Element.PadModel do
@moduledoc false
# Utility functions for veryfying and manipulating pads and their data.
alias Membrane.Element.Pad
alias Membrane.Core.Element.State
use Bunch
@type pad_data_t :: map
@type pad_info_t :: map
@type pads_t :: %{data: pad_data_t, info: pad_info... | lib/membrane/core/element/pad_model.ex | 0.861844 | 0.582461 | pad_model.ex | starcoder |
defmodule Aecore.Oracle.OracleStateTree do
@moduledoc """
Top level oracle state tree.
"""
alias Aecore.Chain.{Chainstate, Identifier}
alias Aecore.Oracle.{Oracle, OracleQuery}
alias Aecore.Oracle.Tx.OracleQueryTx
alias Aeutil.{PatriciaMerkleTree, Serialization}
alias MerklePatriciaTree.Trie
@typedoc... | apps/aecore/lib/aecore/oracle/oracle_state_tree.ex | 0.829871 | 0.449997 | oracle_state_tree.ex | starcoder |
defmodule ExLTTB do
@moduledoc """
Documentation for ExLTTB.
"""
alias ExLTTB.SampleUtils
@doc """
Downsamples a sample list using [LTTB](https://skemman.is/bitstream/1946/15343/3/SS_MSthesis.pdf).
## Arguments
* `sample_list`: a `List` of samples. These can have any representation provided that acc... | lib/ex_lttb.ex | 0.881239 | 0.784979 | ex_lttb.ex | starcoder |
defmodule ExUnitSpan.Track do
@moduledoc false
defstruct [:lanes, :free_lanes, :started_at]
def from_events(events) do
Enum.reduce(events, %__MODULE__{}, fn event, track -> build(track, event) end)
end
defp build(%__MODULE__{}, {ts, {:suite_started, _}}) do
%__MODULE__{lanes: %{}, free_lanes: %{}, ... | lib/ex_unit_span/track.ex | 0.775392 | 0.436202 | track.ex | starcoder |
defmodule RMQ.RPC do
@moduledoc """
RPC via RabbitMQ.
In short, it's a `GenServer` which implements a publisher and a consumer at once.
You can read more about how this works in the
[tutorial](https://www.rabbitmq.com/tutorials/tutorial-six-python.html).
## Configuration
* `:connection` - the connec... | lib/rmq/rpc.ex | 0.853699 | 0.642096 | rpc.ex | starcoder |
defmodule Ockam.Router.Protocol.Encoding.Default.Codegen do
alias Ockam.Router.Protocol.Encoding.Default.Encode
alias Ockam.Router.Protocol.Encoding.Default.Decode
def build_kv_iodata(kv, encode_opts, encode_args) do
kv
|> Enum.map(&encode_pair(&1, encode_opts, encode_args))
|> List.flatten()
|> ... | implementations/elixir/lib/router/protocol/encoding/default/codegen.ex | 0.57069 | 0.501282 | codegen.ex | starcoder |
defmodule AdventOfCode.Day08 do
@type mapping :: %{required(String.t()) => String.t()}
@type line :: {[String.t()], [String.t()]}
@spec part1([binary()]) :: integer()
def part1(args) do
parse_args(args)
|> Enum.flat_map(&elem(&1, 1))
|> Enum.filter(&Enum.member?([2, 3, 4, 7], String.length(&1)))
... | lib/advent_of_code/day_08.ex | 0.886414 | 0.483039 | day_08.ex | starcoder |
defmodule PassiveSupport.Integer do
@moduledoc """
Functions and guards for working with integers
"""
import Integer, only: [is_odd: 1, is_even: 1]
@doc """
Qualifies if `integer` is an integer less than 0.
"""
defguard is_negative(integer)
when is_integer(integer)
and integer < 0
@doc """
... | lib/passive_support/base/integer.ex | 0.929336 | 0.570959 | integer.ex | starcoder |
defmodule PayDayLoan.LoadState do
@moduledoc """
Keeps track of which keys are loaded, requested, and loading
Acts as a state tracker and a queue for the loader.
You shouldn't need to call any of these functions manually but
they can be useful for debugging.
"""
@typedoc """
Load states that a key ca... | lib/pay_day_loan/load_state.ex | 0.803945 | 0.674081 | load_state.ex | starcoder |
defmodule DateTimeParser.Parser do
@moduledoc """
Interface for the DateTimeParser to use when parsing a string.
The flow is:
1. Preflight the string to see if the parser is appropriate. Sometimes the parsing can happen at
this stage if it's a simple parser, for example it can be done in a single regex. R... | lib/parser.ex | 0.847385 | 0.528838 | parser.ex | starcoder |
defmodule Formex.Ecto.Type do
@moduledoc """
Module that must be used in form types that uses Ecto.
# Installation
Just add `use Formex.Ecto.Type`
# Example
```
defmodule App.ArticleType do
use Formex.Type
use Formex.Ecto.Type
def build_form(form) do
form
|> add(:title, :text_... | lib/type.ex | 0.863909 | 0.574783 | type.ex | starcoder |
defmodule Cryptopunk.Derivation do
@moduledoc """
Implements key derivation logic.
See https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
"""
alias Cryptopunk.Derivation.Path
alias Cryptopunk.Key
alias Cryptopunk.Utils
import Path, only: [is_normal: 1, is_hardened: 1]
@order 0xFFFFFFFFF... | lib/cryptopunk/derivation.ex | 0.875887 | 0.512266 | derivation.ex | starcoder |
defmodule Jeaux.Params do
@moduledoc false
def compare(params, schema) do
params
|> ProperCase.to_snake_case
|> keys_to_atoms
|> apply_defaults(schema)
|> validate_required(schema)
|> parse_into_types(schema)
|> validate_types(schema)
|> validate_min(schema)
|> validate_max(sche... | lib/jeaux/params.ex | 0.546012 | 0.425665 | params.ex | starcoder |
defmodule Axon.CompilerError do
defexception [:exception, :graph]
@impl true
def message(%{graph: %Axon{op: op}, exception: exception}) do
op_inspect =
if is_atom(op) do
Atom.to_string(op)
else
"#{inspect(op)}"
end
"""
error while building prediction for #{op_inspec... | lib/axon/compiler.ex | 0.645455 | 0.413862 | compiler.ex | starcoder |
defmodule ExDiceRoller.Compilers.Math do
@moduledoc """
Handles compiling expressions using common mathematical operators.
iex> {:ok, tokens} = ExDiceRoller.Tokenizer.tokenize("1+x")
{:ok, [{:int, 1, '1'}, {:basic_operator, 1, '+'}, {:var, 1, 'x'}]}
iex> {:ok, parse_tree} = ExDiceRoller.Parser.pa... | lib/compilers/math.ex | 0.7696 | 0.697042 | math.ex | starcoder |
defmodule AOC.Day3.CrossedWires do
@moduledoc false
@type point :: {integer, integer}
@type segment :: [point, ...]
@type wire :: list(point)
def part1() do
[w1, w2] =
stream_input("./resources/day3_part1_input.txt")
|> process_input()
compute_part1(w1, w2)
end
def part2() do
[... | aoc-2019/lib/aoc/day3/crossed_wires.ex | 0.863435 | 0.521532 | crossed_wires.ex | starcoder |
defmodule RDF.Graph do
@moduledoc """
A set of RDF triples with an optional name.
`RDF.Graph` implements:
- Elixir's `Access` behaviour
- Elixir's `Enumerable` protocol
- Elixir's `Inspect` protocol
- the `RDF.Data` protocol
"""
defstruct name: nil, descriptions: %{}, prefixes: nil, base_iri: nil
... | lib/rdf/graph.ex | 0.92632 | 0.680003 | graph.ex | starcoder |
defmodule Kalevala.Verb.Conditions do
@moduledoc """
A verb is not allowed unless all conditions are met
- `location` is an array of all allowed locations, one must match
"""
@derive Jason.Encoder
defstruct [:location]
end
defmodule Kalevala.Verb.Context do
@moduledoc """
Context for running a verb
... | lib/kalevala/verb.ex | 0.793106 | 0.429549 | verb.ex | starcoder |
defmodule Chunkr.Cursor do
@moduledoc """
Behaviour for encoding and decoding of cursors.
Allows the default Base64 cursor to be replaced via a custom cursor type specific to your
application—for example, to allow signed cursors, etc. See `Chunkr.Cursor.Base64`
Cursors are created from a list of values. Eac... | lib/chunkr/cursor.ex | 0.931392 | 0.671953 | cursor.ex | starcoder |
defmodule Bitwise do
@moduledoc """
This module provides macro-based operators that perform calculations
on (sets of) bits. These macros can be used in guards. In general,
you should `use` the Bitwise module as a whole:
iex> use Bitwise
iex> bnot 1
-2
iex> 1 &&& 1
1
Alternative... | lib/elixir/lib/bitwise.ex | 0.843089 | 0.60903 | bitwise.ex | starcoder |
defmodule ElixirALE.I2C do
use GenServer
@moduledoc """
This module allows Elixir code to communicate with devices on an I2C bus.
"""
defmodule State do
@moduledoc false
defstruct port: nil, address: 0, devname: nil
end
@type i2c_address :: 0..127
# Public API
@doc """
Start and link the... | lib/elixir_ale/i2c.ex | 0.840062 | 0.735831 | i2c.ex | starcoder |
defmodule Membrane.AAC do
@moduledoc """
Capabilities for [Advanced Audio Codec](https://wiki.multimedia.cx/index.php/Understanding_AAC).
"""
@type profile_t :: :main | :LC | :SSR | :LTP | :HE | :HEv2
@type mpeg_version_t :: 2 | 4
@type samples_per_frame_t :: 1024 | 960
@typedoc """
Indicates whether ... | lib/membrane_aac_format/aac.ex | 0.874607 | 0.58056 | aac.ex | starcoder |
defmodule Plaid.Link do
@moduledoc """
Functions for Plaid `link` endpoint.
"""
import Plaid, only: [make_request_with_cred: 4, validate_cred: 1]
alias Plaid.Utils
@derive Jason.Encoder
defstruct link_token: nil,
expiration: nil,
created_at: nil,
metadata: nil
@ty... | lib/plaid/link.ex | 0.767516 | 0.563828 | link.ex | starcoder |
defmodule Gmex do
@moduledoc """
A simple wrapper for GraphicsMagick in Elixir.
"""
@default_open_options [
gm_path: "gm"
]
@default_resize_options [
width: :auto,
height: :auto,
resize: :fill
]
@type image :: { :ok, %Gmex.Image{} }
@type gmex_error :: { :error, any }
@type ima... | lib/gmex.ex | 0.880103 | 0.455622 | gmex.ex | starcoder |
defmodule Stripe.Converter do
@doc """
Takes a result map or list of maps from a Stripe response and returns a
struct (e.g. `%Stripe.Card{}`) or list of structs.
If the result is not a supported Stripe object, it just returns a plain map
with atomized keys.
"""
@spec convert_result(%{String.t() => any})... | lib/stripe/converter.ex | 0.84296 | 0.636226 | converter.ex | starcoder |
defmodule PasswordlessAuth do
@moduledoc """
PasswordlessAuth is a library gives you the ability to verify a user's
phone number by sending them a verification code, and verifying that
the code they provide matches the code that was sent to their phone number.
Verification codes are stored in an Agent along ... | lib/passwordless_auth.ex | 0.888777 | 0.556339 | passwordless_auth.ex | starcoder |
defmodule AWS.CloudWatchLogs do
@moduledoc """
You can use Amazon CloudWatch Logs to monitor, store, and access your log files
from EC2 instances, AWS CloudTrail, or other sources.
You can then retrieve the associated log data from CloudWatch Logs using the
CloudWatch console, CloudWatch Logs commands in th... | lib/aws/generated/cloud_watch_logs.ex | 0.889235 | 0.575946 | cloud_watch_logs.ex | starcoder |
defmodule Credo.CLI.Output.UI do
@moduledoc """
This module provides functions used to create the UI.
"""
@edge "┃"
@ellipsis "…"
@shell_service Credo.CLI.Output.Shell
if Mix.env() == :test do
def puts, do: nil
def puts(_), do: nil
def puts(_, color) when is_atom(color), do: nil
def war... | lib/credo/cli/output/ui.ex | 0.721154 | 0.400456 | ui.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.