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 WeebPotion.Api do
@moduledoc """
Contains all the functionality of WeebPotion, such as requesting random images (via `random_image!/2` and `random_image/2`) etc.
All function names ending with an exclamation mark indicate functions that fail-fast, as is Erlang tradition.
"""
alias WeebPotion.Struct... | lib/weebpotion/api.ex | 0.902256 | 0.877214 | api.ex | starcoder |
defmodule Ueberauth.Strategy.TeamSnap do
@moduledoc """
Provides an Ueberauth strategy for authenticating with TeamSnap.
### Setup
Create an application in TeamSnap for you to use.
Register a new application at: [TeamSnap Authentication](https://auth.teamsnap.com/oauth/applications) and get the `client_id`... | lib/ueberauth/strategy/team_snap.ex | 0.740174 | 0.480601 | team_snap.ex | starcoder |
defmodule Vivid.Point do
alias __MODULE__
defstruct ~w(x y)a
@moduledoc ~S"""
Represents an individual point in (2D) space.
## Example
iex> use Vivid
...> point = Point.init(2,2)
...> Frame.init(5,5, RGBA.white())
...> |> Frame.push(point, RGBA.black())
...> |> to_string()
"@@@@@\n"... | lib/vivid/point.ex | 0.936372 | 0.588032 | point.ex | starcoder |
defmodule BreakerBox.BreakerConfiguration do
@moduledoc """
Structure and behaviour for configuring circuit breakers.
"""
alias __MODULE__
@default_max_failures 5
@default_failure_window 1_000
@default_reset_window 5_000
defstruct max_failures: @default_max_failures,
failure_window: @defau... | lib/breaker_configuration.ex | 0.908976 | 0.592961 | breaker_configuration.ex | starcoder |
defmodule Ecto.Query.Normalizer do
@moduledoc false
# Normalizes a query so that it is as consistent as possible.
alias Ecto.Query.Query
alias Ecto.Query.QueryExpr
alias Ecto.Query.AssocJoinExpr
alias Ecto.Query.JoinExpr
alias Ecto.Query.Util
alias Ecto.Reflections.BelongsTo
def normalize(Query[] =... | lib/ecto/query/normalizer.ex | 0.726329 | 0.420302 | normalizer.ex | starcoder |
defmodule Wordza.BotBits do
@moduledoc """
A set of possibly shared "bits" for all Bots...
These are utilities for aiding in common functionalities for all/many bots.
- start_yx_possible?
- build_all_words_for_letters
"""
alias Wordza.GameBoard
alias Wordza.GameTiles
@doc """
Is the y+x a possibl... | lib/bot_alec/bot_bits.ex | 0.609873 | 0.580887 | bot_bits.ex | starcoder |
defmodule CoronaWHO do
def example(countries \\ ["Italy", "Germany", "United States of America"]) do
cases_by_country()
|> (fn {:ok, list} -> list end).()
|> Enum.flat_map(fn res = %{name: name} ->
if name in countries do
[res]
else
[]
end
end)
|> Enum.map(fn %{co... | lib/corona_who.ex | 0.513181 | 0.407245 | corona_who.ex | starcoder |
defmodule Xfighter.Account do
alias Xfighter.AccountStatus
alias Xfighter.Exception.ConnectionError
alias Xfighter.Exception.InvalidJSON
alias Xfighter.Exception.RequestError
import Xfighter.API, only: [decode_response: 2, request: 2]
@doc """
Get the status of all orders sent for a given account on a v... | lib/xfighter/account.ex | 0.786049 | 0.429071 | account.ex | starcoder |
defmodule AWS.RDSData do
@moduledoc """
Amazon RDS Data Service
Amazon RDS provides an HTTP endpoint to run SQL statements on an Amazon
Aurora Serverless DB cluster. To run these statements, you work with the
Data Service API.
For more information about the Data Service API, see [Using the Data API
for... | lib/aws/generated/rds_data.ex | 0.775222 | 0.556219 | rds_data.ex | starcoder |
defmodule Helper.Converter.EditorToHTML.Validator.EditorSchema do
@moduledoc false
# header
@valid_header_level [1, 2, 3]
# quote
@valid_quote_mode ["short", "long"]
# list
@valid_list_mode ["checklist", "order_list", "unordered_list"]
@valid_list_label_type ["green", "red", "warn", "default", nil]
... | lib/helper/converter/editor_to_html/validator/editor_schema.ex | 0.520496 | 0.412027 | editor_schema.ex | starcoder |
defmodule Uploadex.Files do
@moduledoc """
Functions to store and delete files.
Note that all functions in this module require the Uploader as an argument. You are free to call them like that:
iex> Uploadex.Files.store_files(user, MyUploader)
{:ok, %User{}}
However, by doing `use Uploadex` in you... | lib/files.ex | 0.786541 | 0.411761 | files.ex | starcoder |
defmodule TimeZoneInfo.IanaParser do
@moduledoc """
The IANA-Parser builds the data structure for `TimeZoneInfo`.
The format of the IANA data explains the article [How to Read the tz Database
Source Files](https://data.iana.org/time-zones/tz-how-to.html)
"""
import NimbleParsec
import TimeZoneInfo.IanaP... | lib/time_zone_info/iana_parser.ex | 0.9036 | 0.609146 | iana_parser.ex | starcoder |
defmodule Utils.Math do
alias :math, as: Math
@shapes_indexes %{
rectangle: 0,
circle: 1
}
def shape_index(shape_atom) do
@shapes_indexes[shape_atom]
end
def collision?(
rect1_x,
rect1_y,
{:rectangle, rect1_width},
rect2_x,
rect2_y,
{:rectangle,... | lib/utils/math.ex | 0.628521 | 0.491456 | math.ex | starcoder |
defmodule ExtendedTypes.Types do
@moduledoc """
This module lists all the types availables in `ExtendedTypes`.
"""
Module.register_attribute(__MODULE__, :types, accumulate: true)
@types {:non_pos_integer, 0,
quote do
@typedoc """
A non-positive integer.
That is... | lib/extended_types/types.ex | 0.905055 | 0.525491 | types.ex | starcoder |
defmodule Poker.Hand.Evaluator.FiveCards do
use Poker.Hand.Evaluator
alias __MODULE__
def eval(cards) do
FiveCards.ByFeature.eval(cards)
end
defmodule ByMatching do
use Poker.Hand.Evaluator
alias Poker.Hand
alias Poker.Card
def eval(cards) do
cards |> Card.sort_by_rank |> do_ev... | lib/poker/hand/evaluator/five_cards.ex | 0.658637 | 0.67389 | five_cards.ex | starcoder |
defmodule ExTorch.Utils.Types do
@moduledoc """
General type hierarchy comparison utils
"""
@doc """
Given two basic types, compare them and return the type that subsumes the other one.
"""
@spec compare_types(ExTorch.DType.base_type(), ExTorch.DType.base_type()) :: ExTorch.DType.base_type()
def compar... | lib/extorch/utils/types.ex | 0.833866 | 0.842604 | types.ex | starcoder |
defmodule Absinthe.Type.Field do
alias Absinthe.Type
@moduledoc """
Used to define a field.
Usually these are defined using `Absinthe.Schema.Notation.field/4`
See the `t` type below for details and examples of how to define a field.
"""
alias Absinthe.Type
alias Absinthe.Type.Deprecation
alias Abs... | deps/absinthe/lib/absinthe/type/field.ex | 0.944957 | 0.826677 | field.ex | starcoder |
defmodule Mix.Tasks.Licenses.Lint do
@moduledoc """
Check the current project's licenses.
The Hex administrators recommend setting a package's `:licenses` value to SPDX license identifiers.
However, this is only a recommendation, and is not enforced in any way.
This task will enforce the use of SPDX identif... | lib/mix/tasks/licenses/lint.ex | 0.792544 | 0.493287 | lint.ex | starcoder |
defmodule Pigeon.ADM do
@moduledoc """
`Pigeon.Adapter` for ADM (Amazon Android) push notifications.
## Getting Started
1. Create an ADM dispatcher.
```
# lib/adm.ex
defmodule YourApp.ADM do
use Pigeon.Dispatcher, otp_app: :your_app
end
```
2. (Optional) Add configuration to your `config.exs... | lib/pigeon/adm.ex | 0.917024 | 0.685397 | adm.ex | starcoder |
defmodule Sanbase.Clickhouse.MarkExchanges do
@moduledoc ~s"""
Used to transform a list of transactions in the form of `input_transaction` type
to `output_transaction` type.
"""
@type input_transaction :: %{
from_address: String.t(),
to_address: String.t(),
trx_value: float,
... | lib/sanbase/clickhouse/mark_exchanges.ex | 0.854748 | 0.457197 | mark_exchanges.ex | starcoder |
defmodule SecretAgent do
@moduledoc """
This module provides the possibility to manage secrets and to watch for directory changes.
It's aimed at managing secrets rotation (typically credentials written by Vault). Thus,
it wraps secrets in closures to avoid leaking and use a constant-time comparison function
... | lib/secret_agent.ex | 0.94611 | 0.45423 | secret_agent.ex | starcoder |
defmodule Dispenser.Server.BatchingBufferServer do
@moduledoc """
A `BatchingBufferServer` is an example `GenServer` that uses `Dispenser.Buffer`.
It can receive events and send them to subscriber processes.
The `BatchingBufferServer` works like `BufferServer`, but tries to minimize the number of messages
se... | lib/dispenser/server/batching_buffer_server.ex | 0.902114 | 0.523542 | batching_buffer_server.ex | starcoder |
defmodule Crux.Structs.VoiceState do
@moduledoc """
Represents a Discord [Voice State Object](https://discord.com/developers/docs/resources/voice#voice-state-object)
"""
@moduledoc since: "0.1.0"
@behaviour Crux.Structs
alias Crux.Structs
alias Crux.Structs.{Member, Snowflake, User, Util}
defstruct [... | lib/structs/voice_state.ex | 0.857902 | 0.446193 | voice_state.ex | starcoder |
defmodule Sanity do
@moduledoc """
Client library for Sanity CMS. See the [README](readme.html) for examples.
"""
alias Sanity.{Request, Response}
@asset_options_schema [
asset_type: [
default: :image,
type: {:in, [:image, :file]},
doc: "Either `:image` or `:file`."
],
content_... | lib/sanity.ex | 0.908445 | 0.607139 | sanity.ex | starcoder |
defmodule Bcrypt do
@moduledoc """
Bcrypt password hashing library main module.
This library can be used on its own, or it can be used together with
[Comeonin](https://hexdocs.pm/comeonin/api-reference.html), which
provides a higher-level api.
For a lower-level API, see Bcrypt.Base.
## Bcrypt
Bcrypt... | deps/bcrypt_elixir/lib/bcrypt.ex | 0.875028 | 0.650675 | bcrypt.ex | starcoder |
defmodule Conform.Utils do
@moduledoc false
@doc """
Recursively merges two keyword lists. Values themselves are also merged (depending on type),
such that the resulting keyword list is a true merge of the second keyword list over the first.
## Examples
iex> old = [one: [one_sub: [a: 1, b: 2]], two: ... | lib/conform/utils/utils.ex | 0.614625 | 0.609234 | utils.ex | starcoder |
defmodule AutoApi.PropCheckFixtures do
@moduledoc false
use PropCheck
alias AutoApi.{GetAvailabilityCommand, GetCommand, SetCommand}
def command() do
let [
command_type <- oneof([GetAvailabilityCommand, GetCommand, SetCommand]),
capability <- capability(),
property_or_state <- property_... | test/support/propcheck_fixtures.ex | 0.681197 | 0.48182 | propcheck_fixtures.ex | starcoder |
defmodule Example do
@moduledoc """
Example of `Enum.reduce/3` vs. list comprehensions when pushing
maps to a list.
"""
@doc """
Build given number of activities and append to a list.
## Examples
iex> Example.build_activities([], 2)
[%{state: :ok}, %{state: :ok}]
iex> Example.build_a... | lib/append_to_list.ex | 0.901303 | 0.627752 | append_to_list.ex | starcoder |
defmodule Tds.Ecto do
@moduledoc """
Adapter module for MSSQL.
It uses `tds` for communicating to the database
and manages a connection pool with `poolboy`.
## Features
* Full query support (including joins, preloads and associations)
* Support for transactions
* Support for data migrations
... | lib/tds_ecto.ex | 0.791015 | 0.582729 | tds_ecto.ex | starcoder |
defmodule Day19 do
@moduledoc """
AoC 2019, Day 19 - Tractor Beam
"""
@doc """
Number of points affected by the tractor beam
"""
def part1 do
Util.priv_file(:day19, "day19_input.txt")
|> count_points(49, 49)
end
@doc """
Find the closest 100x100 area within the beam
"""
def part2 do
... | apps/day19/lib/day19.ex | 0.628635 | 0.637962 | day19.ex | starcoder |
defmodule Riptide.Mutation do
@behaviour Access
@moduledoc """
A mutation represents a set of changes that can be applied to a `Riptide.Store`. This module contains functions that make it easy to compose complex mutations and combine them together.
Mutations contains two types of operations:
- `:merge` - A m... | packages/elixir/lib/riptide/store/mutation.ex | 0.907028 | 0.89214 | mutation.ex | starcoder |
defmodule Exchange.Adapters.InMemoryTimeSeries do
@moduledoc """
Public API to use the adapter of `Exchange.TimeSeries`, the InMemoryTimeSeries.
This adapter is an approach of an in memory time series database and it keeps state about orders, prices and trades.
"""
use GenServer
use Exchange.TimeSeries, req... | lib/exchange/adapters/in_memory_time_series.ex | 0.843186 | 0.549943 | in_memory_time_series.ex | starcoder |
defmodule Stripe.Capability do
@moduledoc """
Work with [Stripe Connect `capability` objects](https://stripe.com/docs/api/capabilities).
You can:
- [Retrieve an Account Capability](https://stripe.com/docs/api/capabilities/retrieve)
- [Update an Account Capability](https://stripe.com/docs/api/capabilities/upd... | lib/stripe/connect/capability.ex | 0.769903 | 0.406243 | capability.ex | starcoder |
defmodule Ekv do
@moduledoc """
Ekv is a simple key-value store providing optional persistence to the local file
system.
Under the hood, Ekv uses [ETS](https://erlang.org/doc/man/ets.html) and
[GenServer](https://hexdocs.pm/elixir/GenServer.html) to plainly manage state.
### Usage
1. Set up a new modul... | lib/ekv.ex | 0.671471 | 0.840193 | ekv.ex | starcoder |
defmodule EdgeDB.Set do
@moduledoc """
A representation of an immutable set of values returned by a query.
Nested sets in the result are also returned as `EdgeDB.Set` objects.
`EdgeDB.Set` implements `Enumerable` protocol for iterating over set values.
```elixir
iex(1)> {:ok, pid} = EdgeDB.start_link()
... | lib/edgedb/types/set.ex | 0.883525 | 0.708629 | set.ex | starcoder |
defmodule Calixir.Holidays do
@moduledoc """
This module provides the holiday data contained in the sample
data file `holiday-list.csv` of calendrica-4.0 as Elixir data.
The data consist of a list of holiday lists with the holiday dates
ranging from 2000 to 2103.
Each holiday list has the following struct... | lib/calixir/holidays.ex | 0.832441 | 0.961642 | holidays.ex | starcoder |
defmodule CaseStyle.PascalCase do
@moduledoc """
Module for converting from and to PascalCase
"""
defstruct tokens: []
@behaviour CaseStyle
alias CaseStyle.Tokens
alias CaseStyle.Tokens.{
AfterSpacingChar,
AfterSpacingDigit,
Char,
Digit,
End,
FirstLetter,
Literal,
Spacin... | lib/case_style/pascal_case.ex | 0.62498 | 0.466846 | pascal_case.ex | starcoder |
defmodule FutureMadeConcerts.Spotify.Session do
@moduledoc """
Defines a behaviour that can be used to model an active user session against the Spotify API.
Implementations should be stateful: given an initial session id and
authentication credentials, the implementation should perform authentication
in `c:s... | lib/future_made_concerts/spotify/session.ex | 0.767211 | 0.445349 | session.ex | starcoder |
defmodule OpenTelemetry do
@moduledoc """
An [OpenTelemetry](https://opentelemetry.io) Trace consists of 1 or more Spans that either have a
parent/child relationship or are linked together through a Link. Each Span has a TraceId (`t:trace_id/0`),
SpanId (`t:span_id/0`), and a start and end time in nanoseconds.
... | apps/opentelemetry_api/lib/open_telemetry.ex | 0.944969 | 0.653707 | open_telemetry.ex | starcoder |
defmodule Nookal.Patient do
import Nookal.Utils
@type t() :: %__MODULE__{
id: integer(),
title: String.t(),
first_name: String.t(),
middle_name: String.t(),
last_name: String.t(),
nickname: String.t(),
dob: Date.t(),
gender: String.t()... | lib/nookal/patient.ex | 0.604632 | 0.477432 | patient.ex | starcoder |
defmodule ExUnit.Callbacks do
@moduledoc %S"""
Defines ExUnit Callbacks.
This module defines four callbacks: `setup_all`, `teardown_all`,
`setup` and `teardown`.
These callbacks are defined via macros and each one can optionally receive a
keyword list with metadata, usually referred to as `context`. The c... | lib/ex_unit/lib/ex_unit/callbacks.ex | 0.846546 | 0.628607 | callbacks.ex | starcoder |
defmodule Timestamp.Converter do
@moduledoc """
Timestamp converter module
"""
alias Timestamp.Converter.Data.{WeekDays, DateTimeStruct, Month}
def now() do
case DateTime.now("Etc/UTC") do
{:ok, dt} -> dt |> DateTime.to_unix(:millisecond) |> timestamp_to_datetime()
_ -> timestamp_to_datetime(... | lib/timestamp/converter/core/converter.ex | 0.683736 | 0.478712 | converter.ex | starcoder |
defmodule AWS.PI do
@moduledoc """
Amazon RDS Performance Insights
Amazon RDS Performance Insights enables you to monitor and explore different
dimensions of database load based on data captured from a running DB instance.
The guide provides detailed information about Performance Insights data types,
par... | lib/aws/generated/pi.ex | 0.892899 | 0.693655 | pi.ex | starcoder |
defmodule ExSDP.Serializer do
@moduledoc """
Module providing helper functions for serialization.
"""
@doc """
Serializes both sdp lines (<type>=<value>) and sdp parameters (<parameter>=<value>)
"""
@spec maybe_serialize(type :: binary(), value :: term()) :: binary()
def maybe_serialize(_type, nil), do... | lib/ex_sdp/serializer.ex | 0.611962 | 0.401512 | serializer.ex | starcoder |
defmodule Opencensus.Logger do
@moduledoc """
Updates Elixir's Logger metadata to match Erlang's logger metadata.
`set_logger_metadata/0` and `set_logger_metadata/1` update the following attributes in
`Logger.metadata/0`:
* `trace_id`
* `span_id`
* `trace_options`
You won't need to use this module if... | lib/opencensus/logger.ex | 0.815416 | 0.683235 | logger.ex | starcoder |
defmodule Niffler do
@moduledoc """
Just-In-Time nif generator, FFI generator, C-compiler based on TinyCC.
For Linux, MacOS, Windows (msys2)
# Using Niffler
Once installed, you can use the Niffler to define new nif modules using embedded C fragments:
```
defmodule Example do
use Niffler
defnif... | lib/niffler.ex | 0.874118 | 0.845433 | niffler.ex | starcoder |
defmodule Resources.Monitor do
@moduledoc ~S"""
Simple monitor of the system resources that gathers updated system information
at regular interval.
Also, this currently must monitor all known resources. Should be able to specify
resources to monitor
## Examples
iex> Resources.Monitor.start(call... | lib/resources/monitor.ex | 0.827619 | 0.454109 | monitor.ex | starcoder |
defmodule AWS.SageMakerA2IRuntime do
@moduledoc """
Amazon Augmented AI is in preview release and is subject to change.
We do not recommend using this product in production environments.
Amazon Augmented AI (Amazon A2I) adds the benefit of human judgment to any
machine learning application. When an AI appl... | lib/aws/generated/sage_maker_a2i_runtime.ex | 0.809314 | 0.625467 | sage_maker_a2i_runtime.ex | starcoder |
defmodule Google.Protobuf.DoubleValue do
@moduledoc false
use Protobuf, syntax: :proto3
@type t :: %__MODULE__{
value: float | :infinity | :negative_infinity | :nan
}
defstruct [:value]
field :value, 1, type: :double
def transform_module(), do: nil
end
defmodule Google.Protobuf.FloatV... | lib/google_protos/wrappers.pb.ex | 0.821975 | 0.582224 | wrappers.pb.ex | starcoder |
defmodule GeoPotion.Angle do
alias __MODULE__
@type units :: :degrees | :radians
@type t :: %__MODULE__{value: number, units: units}
defstruct value: 0.0, units: :degrees
@moduledoc """
Implements structure for holding a decimal angle value in degrees or radians
"""
@o... | lib/geopotion/angle.ex | 0.930829 | 0.771564 | angle.ex | starcoder |
defmodule AdminAPI.V1.TransactionCalculationController do
@moduledoc """
The controller to serve transaction calculations.
"""
use AdminAPI, :controller
import AdminAPI.V1.ErrorHandler
alias EWallet.{Exchange, Helper}
alias EWalletDB.Token
@doc """
Calculates transaction amounts.
"""
def calculat... | apps/admin_api/lib/admin_api/v1/controllers/transaction_calculation_controller.ex | 0.704567 | 0.475484 | transaction_calculation_controller.ex | starcoder |
defmodule RDF.Statement do
@moduledoc """
Helper functions for RDF statements.
An RDF statement is either a `RDF.Triple` or a `RDF.Quad`.
"""
alias RDF.{Resource, BlankNode, IRI, Literal, Quad, Term, Triple, PropertyMap}
import RDF.Guards
@type subject :: Resource.t()
@type predicate :: Resource.t()
... | lib/rdf/statement.ex | 0.867612 | 0.599778 | statement.ex | starcoder |
defmodule Nx.Tensor do
@moduledoc """
The tensor struct and the behaviour for backends.
`Nx.Tensor` is a generic container for multidimensional data structures.
It contains the tensor type, shape, and names. The data itself is a
struct that points to a backend responsible for controlling the data.
The back... | lib/nx/tensor.ex | 0.922987 | 0.885977 | tensor.ex | starcoder |
defmodule CurrencyConversion do
@moduledoc """
Module to Convert Currencies.
"""
alias CurrencyConversion.Rates
alias CurrencyConversion.UpdateWorker
@doc """
Convert from currency A to B.
### Example
iex> CurrencyConversion.convert(Money.new(7_00, :CHF), :USD, %CurrencyConversion.Rates{base: ... | lib/currency_conversion.ex | 0.892796 | 0.525004 | currency_conversion.ex | starcoder |
defmodule D07.Challenge do
@moduledoc false
require Logger
def run(1) do
crap_positions =
Utils.read_input(7) |> hd |> String.split(",") |> Enum.map(&String.to_integer/1)
minimal_fuel_average =
average(crap_positions) |> total_distance_from_minimum(crap_positions, :constant)
Logger.inf... | lib/d07/challenge.ex | 0.669313 | 0.469034 | challenge.ex | starcoder |
defmodule Day1.Citywalk do
use GenServer
defmodule State do
defstruct x: 0, y: 0, direction: :north, visited_points: [[0,0]]
end
def start_link do
GenServer.start_link(__MODULE__, [])
end
# -- status
def position(pid) do
GenServer.call(pid, :position)
end
def direction(pid) do
Gen... | elixir/day1/GenServer/lib/day1/citywalk.ex | 0.576184 | 0.618795 | citywalk.ex | starcoder |
defmodule Drab.Coder do
@moduledoc """
Provides various encoders/decoders to store values in the string.
Example:
<% {:ok, encoded_value} = Drab.Coder.encode(%{question: "foo", answer: 42}) %>
<button drab='click:check_answer("<%= encoded_value %>")'>Check answer</button>
defhandler check_an... | lib/drab/coder.ex | 0.894784 | 0.420153 | coder.ex | starcoder |
defmodule Tox.Time do
@moduledoc """
A set of functions to work with `Time`.
"""
alias Tox.IsoDays
@doc """
Adds `durations` to the given `naive_datetime`.
The `durations` is a keyword list of one or more durations of the type
`Tox.duration` e.g. `[hour: 1, minute: 5, second: 500]`.
## Examples
... | lib/tox/time.ex | 0.942784 | 0.610047 | time.ex | starcoder |
defmodule RemoteIp do
@moduledoc """
A plug to overwrite the `Plug.Conn`'s `remote_ip` based on headers such as
`X-Forwarded-For`.
To use, add the `RemoteIp` plug to your app's plug pipeline:
```elixir
defmodule MyApp do
use Plug.Builder
plug RemoteIp
end
```
There are 2 options that can b... | lib/remote_ip.ex | 0.868255 | 0.901271 | remote_ip.ex | starcoder |
defmodule Currency do
@moduledoc """
`Currency` represents a monetary value, stored in its smallest unit possible
in a given currency, i.e., cents.
See `Currency.Ecto` for a custom type implementation that can be used in a
schema.
In order to use the `~M` sigil, import the module:
import Currency
... | lib/currency.ex | 0.904815 | 0.642243 | currency.ex | starcoder |
defmodule Helper.Country do
@moduledoc false
defmacro __using__(_) do
quote do
import Helper.Country
def regex, do: ""
def country, do: ""
def a2, do: ""
def a3, do: ""
defoverridable regex: 0, country: 0, a2: 0, a3: 0
def builder(number) do
[[_, code, area, ... | lib/helpers/country.ex | 0.70304 | 0.444022 | country.ex | starcoder |
defmodule BSV.Contract.VarIntHelpers do
@moduledoc """
Helper module for working with `t:BSV.VarInt.t/0` in `BSV.Contract` modules.
VarInts are commonly used in Bitcoin scripts to encode variable length bits of
data. This module provides a number of functions for extracting the data from
VarInts.
"""
ali... | lib/bsv/contract/var_int_helpers.ex | 0.794305 | 0.521227 | var_int_helpers.ex | starcoder |
defmodule Rustic.Result do
@moduledoc """
Documentation for `RusticResult`.
"""
defmodule UnhandledError do
@moduledoc "Error raised when trying to unwrap an Err result"
defexception [:reason]
@doc "Convert error to string"
@spec message(%__MODULE__{}) :: String.t()
def message(e) do
... | lib/rustic_result.ex | 0.884202 | 0.436742 | rustic_result.ex | starcoder |
defmodule FuzzyCompare.SubstringComparison do
@moduledoc """
This module offers the functionality of comparing strings of different
lengths.
iex> FuzzyCompare.SubstringComparison.similarity("DEUTSCHLAND", "BUNDESREPUBLIK DEUTSCHLAND")
0.9090909090909092
iex> String.jaro_distance("DEUTSCHLAND",... | lib/fuzzy_compare/substring_comparison.ex | 0.840259 | 0.470737 | substring_comparison.ex | starcoder |
defmodule PelemaySample do
import Pelemay
require Pelemay
@moduledoc """
```elixir
defpelemay do
def cal(list) do
list
|> Enum.map(& &1 + 2)
|> Enum.map(fn x -> x * 2 end)
end
#=>
def cal(list) do
list
|> PelemayNif.map_mult
|> PelemayNif.map_plus
end
```
"""
de... | lib/pelemay_sample.ex | 0.509276 | 0.419678 | pelemay_sample.ex | starcoder |
defmodule Flect.Timer do
@moduledoc """
Provides convenience functions for timing various passes in the compiler.
"""
@opaque session() :: {String.t(), non_neg_integer(), [{atom(), :erlang.timestamp() | non_neg_integer()}]}
@opaque finished_session() :: {String.t(), [{atom(), {non_neg_integer(), no... | lib/timer.ex | 0.860677 | 0.558568 | timer.ex | starcoder |
defmodule Telemetria do
use Boundary, exports: [Hooks]
@moduledoc """
`Telemetriฬa` is the opinionated wrapper for [`:telemetry`](https://hexdocs.pm/telemetry)
providing handy macros to attach telemetry events to any function, private function,
anonymous functions (on per-clause basis) and just random set of... | lib/telemetria.ex | 0.895457 | 0.880746 | telemetria.ex | starcoder |
defmodule Hanyutils do
@moduledoc """
Utilities for dealing with Chinese characters (Hanzi) and Pinyin.
This module contains several functions which deal with strings containing Han characters or
Pinyin. Specifically, the following functionality is present:
iex> Hanyutils.to_marked_pinyin("ไฝ ๅฅฝ")
"n... | lib/hanyutils.ex | 0.733929 | 0.717136 | hanyutils.ex | starcoder |
defmodule Say do
@number_words %{
1 => "one",
2 => "two",
3 => "three",
4 => "four",
5 => "five",
6 => "six",
7 => "seven",
8 => "eight",
9 => "nine",
10 => "ten",
11 => "eleven",
12 => "twelve",
13 => "thirteen",
14 => "fourteen",
15 => "fifteen",
16 =>... | elixir/say/lib/say.ex | 0.558086 | 0.414928 | say.ex | starcoder |
defmodule Adventofcode.Day02BathroomCode do
# Position as a grid
# 1 2 3 {0,0} {1,0} {2,0}
# 4 5 6 {0,1} {1,1} {2,1}
# 7 8 9 {0,2} {1,2} {2,2}
# Thus the starting position "5" is...
@start_pos {1, 1}
@grid_width 3
@grid_height 3
@max_x @grid_width - 1
@max_y @grid_height - 1
def bathroom... | lib/day_02_bathroom_code.ex | 0.572603 | 0.726911 | day_02_bathroom_code.ex | starcoder |
defmodule Specter.TrackLocalStaticSample do
@moduledoc """
A representation of webrtc.rs `TrackLocalStaticSample`.
In general, a track in WebRTC represents a single audio or video
and its main purpose is to provide user with API for
sending and receiving media data/packets.
Therefore, webrtc.rs has multip... | lib/specter/track.ex | 0.895367 | 0.526525 | track.ex | starcoder |
defmodule Rbt.Conn do
@moduledoc """
This module implements a state machine that starts
and monitors a named connection which gets automatically
re-estabilished in case of issues.
Reconnection attempts implement a backoff logic.
"""
@behaviour :gen_statem
alias Rbt.Conn.URI, as: ConnURI
alias Rbt.B... | lib/rbt/conn.ex | 0.793586 | 0.510435 | conn.ex | starcoder |
defmodule SpadesGame.Deck do
@moduledoc """
Represents a list of playing cards.
"""
alias SpadesGame.{Deck, Card}
@type t :: [Card.t()]
@spec new_shuffled() :: Deck.t()
@doc """
new_shuffled/0: Returns a new deck with 52 cards, shuffled.
"""
def new_shuffled do
for rank <- Card.ranks(), suit <... | backend/lib/spades_game/deck.ex | 0.804713 | 0.404919 | deck.ex | starcoder |
defmodule OMG.EthereumEventListener.Core do
@moduledoc """
Logic module for the `OMG.EthereumEventListener`
Responsible for:
- deciding what ranges of Ethereum events should be fetched from the Ethereum node
- deciding the right size of event batches to read (too little means many RPC requests, too big ... | apps/omg/lib/omg/ethereum_event_listener/core.ex | 0.873181 | 0.410845 | core.ex | starcoder |
defmodule Plaid.Institutions do
@moduledoc """
[Plaid Institutions API](https://plaid.com/docs/api/institutions/) calls and schema.
"""
defmodule GetResponse do
@moduledoc """
[Plaid API /institutions/get response schema.](https://plaid.com/docs/api/institutions/#institutionsget)
"""
@behaviou... | lib/plaid/institutions.ex | 0.870487 | 0.463626 | institutions.ex | starcoder |
defmodule Aoc.Year2018.Day03 do
@moduledoc """
Solution to Day 03 of 2018: No Matter How You Slice It
## --- Day 3: No Matter How You Slice It ---
The Elves managed to locate the chimney-squeeze prototype fabric for Santa's
suit (thanks to someone who helpfully wrote its box IDs on the wall of the
warehou... | lib/aoc/year_2018/day_03.ex | 0.88333 | 0.987876 | day_03.ex | starcoder |
defmodule HL7.Composite.Default.PL do
@moduledoc """
2.9.29 PL - person location
Components:
- `point_of_care` (IS)
- `room` (IS)
- `bed` (IS)
- `facility` (HD)
- `location_status` (IS )
- `person_location_type` (IS)
- `building` (IS )
- `floor` (IS)
- `location_description` ... | lib/ex_hl7/composite/default/pl.ex | 0.881366 | 0.672752 | pl.ex | starcoder |
defmodule AWS.SES do
@moduledoc """
Amazon Simple Email Service
This document contains reference information for the [Amazon Simple Email
Service](https://aws.amazon.com/ses/) (Amazon SES) API, version 2010-12-01.
This document is best used in conjunction with the [Amazon SES Developer
Guide](https://docs... | lib/aws/ses.ex | 0.792143 | 0.523177 | ses.ex | starcoder |
defmodule Cog.Pipeline.ExecutionStage do
alias Experimental.GenStage
alias Carrier.Messaging.Connection
alias Cog.Config
alias Cog.Events.PipelineEvent
alias Cog.Pipeline.{Binder, OptionParser, PermissionEnforcer}
alias Cog.Messages.{Command, CommandResponse}
alias Cog.Pipeline.{AbortSignal, DataSignal, ... | lib/cog/pipeline/execution_stage.ex | 0.882428 | 0.487002 | execution_stage.ex | starcoder |
defmodule Mix.Tasks.Yuki.Testcase.Download do
@shortdoc "Downloads a list of testcases"
@moduledoc """
Downloads a list of the specified problem.
From mix task:
mix yuki.testcase.download NO [--problem-id]
From escript:
yuki testcase.download NO [--problem-id]
> Note: If the specified file ... | lib/mix/tasks/yuki.testcase.download.ex | 0.769687 | 0.4575 | yuki.testcase.download.ex | starcoder |
defmodule Automaton.Composite.Sequence do
@moduledoc """
Behavior for user-defined sequence actions. When the execution of a sequence
node starts, then the nodeโs children are executed in succession from left
to right, returning to its parent a status failure (or running) as soon as a
child that retur... | lib/automata/core/composites/sequence.ex | 0.521715 | 0.555978 | sequence.ex | starcoder |
defmodule Ecto.Type do
@moduledoc """
Defines functions and the `Ecto.Type` behaviour for implementing
custom types.
A custom type expects 5 functions to be implemented, all documented
and described below. We also provide two examples of how custom
types can be used in Ecto to augment existing types or pro... | lib/ecto/type.ex | 0.905354 | 0.786602 | type.ex | starcoder |
defmodule ExPolygon.Financial do
@type t :: %ExPolygon.Financial{}
defstruct ~w(
ticker
period
calendar_date
report_period
updated
accumulated_other_comprehensive_income
assets
assets_average
assets_current
asset_turnover
assets_non_current
book_value_per_share
c... | lib/ex_polygon/financial.ex | 0.606265 | 0.498535 | financial.ex | starcoder |
defmodule ArtemisWeb.ViewHelper.Print do
use Phoenix.HTML
@doc """
Convert `\n` new lines to <br/> tags
"""
def new_line_to_line_break(values) when is_list(values) do
values
|> Enum.map(&new_line_to_line_break/1)
|> Enum.join()
end
def new_line_to_line_break(value) when is_bitstring(value) d... | apps/artemis_web/lib/artemis_web/view_helpers/print.ex | 0.769254 | 0.487612 | print.ex | starcoder |
defmodule BSV.Sig do
@moduledoc """
Module for signing and verifying Bitcoin transactions.
Signing a transaction in Bitcoin first involves computing a transaction
preimage. A `t:BSV.Sig.sighash_flag/0` is used to indicate which parts of the
transaction are included in the preimage.
| Flag ... | lib/bsv/sig.ex | 0.843122 | 0.593197 | sig.ex | starcoder |
defmodule ANN.Test.Values.Network do
alias ANN.{Network, Math, Neuron, Layer, Signal}
def initial do
%Network{
activation_fn: Math.Sigmoid,
layers: [
%Layer{
neurons: [
%Neuron{signals: [], sum: 0},
%Neuron{signals: [], sum: 0}
],
bias: ... | test/ann/values/network.ex | 0.564339 | 0.760006 | network.ex | starcoder |
defmodule X.Transformer do
@moduledoc """
Contains a set of functions to transform compiled Elixir AST
into more performance optimized AST.
Also, it contains functions to transform Elixir AST for inline components.
"""
@spec compact_ast(Macro.t()) :: Macro.t()
def compact_ast(tree) when is_list(tree) do
... | lib/x/transformer.ex | 0.872728 | 0.651417 | transformer.ex | starcoder |
defmodule Zipper do
defstruct [:focus, genealogy: []]
@type t :: %Zipper{
focus: BinTree.t(),
genealogy: [{:left, any, BinTree.t()} | {:right, any, BinTree.t()}]
}
@doc """
Get a zipper focused on the root node.
"""
@spec from_tree(BinTree.t()) :: Zipper.t()
def from_tree(%Bi... | elixir/zipper/lib/zipper.ex | 0.861786 | 0.776242 | zipper.ex | starcoder |
defmodule Syts do
@moduledoc """
This is the Syts module.
It provides functions for sending a YouTube search query (via youtube-dl), offering
a selection of results to the user, and then playing a selected result in MPV.
"""
@doc """
Run the entire search - select - play operation.
Returns `:ok`.
... | lib/syts.ex | 0.830113 | 0.624623 | syts.ex | starcoder |
defmodule Adventofcode.Day21FractalArt do
@enforce_keys [:enhancement_rules, :iteration]
defstruct grid: ~w(.#. ..# ###),
size: 3,
enhancement_rules: nil,
iteration: nil
def pixels_left_on_count(input, iterations) do
input
|> new(iterations)
|> iterate()
|> do_... | lib/day_21_fractal_art.ex | 0.605799 | 0.654115 | day_21_fractal_art.ex | starcoder |
defmodule Galena.ProducerConsumer do
@moduledoc """
**Galena.ProducerConsumer** is a customized `GenStage` consumer-producer which is able to receive _some_ messages
from _some_ producers or producers-consumers and send them to the consumers or
producer-consumers that are subscribed. The producer-consumer will ... | lib/galena/producer_consumer.ex | 0.750187 | 0.815159 | producer_consumer.ex | starcoder |
defmodule ImgCf do
@moduledoc """
This module provides a Phoenix Component which provides CDN and on-the-fly image resizing
through Cloudflares (CF) Image Resize (IR) service.
Modify your view_helpers function to always import it the img_cf Component:
lib/myapp_web/myapp_web.ex:
defp view_hel... | lib/img_cf.ex | 0.721154 | 0.497986 | img_cf.ex | starcoder |
defprotocol Paddle.Class do
@moduledoc ~S"""
Protocol used to allow some objects (mainly structs) to represent an LDAP
entry.
Implementing this protocol for your specific classes will enable you to
manipulate LDAP entries in an easier way than using DNs (hopefully).
If the class you want to implement is s... | lib/paddle/class.ex | 0.922783 | 0.663069 | class.ex | starcoder |
defmodule Metalove do
@moduledoc """
The main application interface.
"""
@doc ~S"""
Convenience entry point.
Args:
* `url` - URL of a podcast feed or webpage (e.g. "atp.fm" or "https://freakshow.fm/feed/m4a/")
Return values:
* `Metalove.Podcast.t()` if a podcast could be deduced and fetched fro... | lib/metalove.ex | 0.897438 | 0.428831 | metalove.ex | starcoder |
defmodule Kitt.Message.SRM do
@moduledoc """
Defines the structure and instantiation function
for creating a J2735-compliant SignalRequestMessage
An `SRM` defines the interchange of a DSRC-capable
vehicle with the infrastructure regarding signal and
timing information pertaining to an intersection
"""
... | lib/kitt/message/srm.ex | 0.865437 | 0.575827 | srm.ex | starcoder |
defmodule Ffaker.KoKr.PhoneNumer do
@moduledoc"""
ํ๊ตญ ์ ํ๋ฒํธ ๋ฐ์ดํฐ์ ๊ด๋ จ๋ ํจ์๊ฐ ๋ค์ด์๋ ๋ชจ๋
"""
import Ffaker, only: [numerify: 1]
@home_phone_prefixes ~w(02 031 032 033 041 042 043 044 049
051 052 053 054 055 061 062 063 064)
@mobile_phone_prefixes ~w(010 011 016 019)
@doc"""
์ ํ ๋ฒํธ๋ฅผ ๋ฐํ
... | lib/ffaker/ko_kr/phone_number.ex | 0.524882 | 0.451568 | phone_number.ex | starcoder |
defmodule Harald.HCI.Event.LEMeta.ConnectionComplete do
@moduledoc """
The HCI_LE_Connection_Complete event indicates to both of the Hosts forming
the connection that a new connection has been created.
Upon the creation of the connection a Connection_Handle shall be assigned by
the Controller, and passed to ... | lib/harald/hci/event/le_meta/connection_complete.ex | 0.742702 | 0.445349 | connection_complete.ex | starcoder |
defmodule Zaryn.TransactionChain.Transaction.ValidationStamp.LedgerOperations do
@moduledoc """
Represents the ledger operations defined during the transaction mining regarding the network movements:
- transaction movements
- node rewards
- unspent outputs
- transaction fee
"""
@storage_node_rate 0.5
... | lib/zaryn/transaction_chain/transaction/validation_stamp/ledger_operations.ex | 0.911249 | 0.582966 | ledger_operations.ex | starcoder |
defmodule OpentelemetryLiveView do
@moduledoc """
OpentelemetryLiveView uses [telemetry](https://hexdocs.pm/telemetry/) handlers to create
`OpenTelemetry` spans for LiveView *mount*, *handle_params*, and *handle_event*. The LiveView
telemetry events that are used are documented [here](https://hexdocs.pm/phoenix... | lib/opentelemetry_liveview.ex | 0.775435 | 0.50769 | opentelemetry_liveview.ex | starcoder |
defmodule Cldr.Calendar.Formatter.Options do
@moduledoc """
Defines and validates the options
for a calendar formatter.
These options are passed to the formatter
callbacks defined in `Cldr.Calendar.Formatter`.
The valid options are:
* `:calendar` is an calendar module defined with
`use Cldr.Calenda... | lib/formatter/options.ex | 0.879949 | 0.685213 | options.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.