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 AWS.SMS do
@moduledoc """
AWS Server Migration Service
AWS Server Migration Service (AWS SMS) makes it easier and faster for you to
migrate your on-premises workloads to AWS.
To learn more about AWS SMS, see the following resources:
* [AWS Server Migration Service product page](http://aws.am... | lib/aws/generated/sms.ex | 0.841826 | 0.452052 | sms.ex | starcoder |
defmodule Conform.Schema do
@moduledoc """
A schema is a keyword list which represents how to map, transform, and validate
configuration values parsed from the .conf file. The following is an explanation of
each key in the schema definition in order of appearance, and how to use them.
## Import
A list of ... | lib/conform/schema.ex | 0.921203 | 0.651258 | schema.ex | starcoder |
defmodule ApiWeb.ScheduleController do
@moduledoc """
Controller for Schedules. Filterable by:
* stop
* route
* direction ID
* service date
* trip
* stop sequence
"""
use ApiWeb.Web, :api_controller
alias State.Schedule
plug(ApiWeb.Plugs.ValidateDate)
plug(:date)
@filters ~w(date directi... | apps/api_web/lib/api_web/controllers/schedule_controller.ex | 0.817902 | 0.411584 | schedule_controller.ex | starcoder |
defmodule Expo.Mo do
@moduledoc """
`.mo` file handler
"""
alias Expo.Mo.InvalidFileError
alias Expo.Mo.Parser
alias Expo.Mo.UnsupportedVersionError
alias Expo.Translations
@type compose_options :: [
{:endianness, :little | :big},
{:use_fuzzy, boolean()},
{:statistics, bo... | lib/expo/mo.ex | 0.850717 | 0.46478 | mo.ex | starcoder |
defmodule PhoenixMDBootstrapForm do
@moduledoc """
Documentation for `PhoenixMDBootstrapForm` which provides helper methods for creating beautiful looking Material Design Bootstrap forms in Phoenix.
## Installation
This package can be installed by adding `rrpproxy` to your list of dependencies in `mix.exs`:
... | lib/phoenix_mdbootstrap_form.ex | 0.874252 | 0.807233 | phoenix_mdbootstrap_form.ex | starcoder |
defmodule Infer.Ecto.Query do
@moduledoc """
Functions to dynamically generate Ecto query parts.
"""
alias Infer.Util
alias Infer.Evaluation, as: Eval
alias __MODULE__.Builder
import Ecto.Query, only: [dynamic: 1, dynamic: 2, from: 2]
defguard is_simple(val)
when is_integer(val) or is_floa... | lib/infer/ecto/query.ex | 0.855444 | 0.505798 | query.ex | starcoder |
defmodule Expo.PluralForms.Evaluator do
@moduledoc false
alias Expo.PluralForms
@boolean_operators [:!=, :>, :<, :==, :>=, :<=, :&&, :||]
defmodule IntegerOperators do
@moduledoc false
# credo:disable-for-lines:28 Credo.Check.Readability.Specs
# credo:disable-for-lines:27 Credo.Check.Readability... | lib/expo/plural_forms/evaluator.ex | 0.639511 | 0.623864 | evaluator.ex | starcoder |
defmodule Axon.Metrics do
@moduledoc """
Metric functions.
Metrics are used to measure the performance and compare
performance of models in easy-to-understand terms. Often
times, neural networks use surrogate loss functions such
as negative log-likelihood to indirectly optimize a certain
performance metr... | lib/axon/metrics.ex | 0.937232 | 0.920504 | metrics.ex | starcoder |
defmodule Nebulex.Adapters.Replicated do
@moduledoc ~S"""
Built-in adapter for replicated cache topology.
The replicated cache excels in its ability to handle data replication,
concurrency control and failover in a cluster, all while delivering
in-memory data access speeds. A clustered replicated cache is ex... | lib/nebulex/adapters/replicated.ex | 0.856347 | 0.684183 | replicated.ex | starcoder |
defmodule Aecore.Chain.ChainState do
@moduledoc """
Module used for calculating the block and chain states.
The chain state is a map, telling us what amount of tokens each account has.
"""
require Logger
@doc """
Calculates the balance of each account mentioned
in the transactions a single block, retu... | apps/aecore/lib/aecore/chain/chain_state.ex | 0.775435 | 0.618608 | chain_state.ex | starcoder |
use Croma
defmodule Antikythera.Xml do
el = inspect(__MODULE__.Element)
@moduledoc """
Convenient XML parser module wrapping [fast_xml](https://github.com/processone/fast_xml).
`decode/2` can parse XML into `#{el}.t`, and `encode/2` can serialize `#{el}.t` back to XML string.
`#{el}.t` is XML element data... | lib/type/xml.ex | 0.844985 | 0.409162 | xml.ex | starcoder |
defmodule Numerix.Correlation do
@moduledoc """
Statistical correlation functions between two vectors.
"""
use Numerix.Tensor
import Numerix.LinearAlgebra
alias Numerix.{Common, Statistics}
@doc """
Calculates the Pearson correlation coefficient between two vectors.
"""
@spec pearson(Common.vect... | lib/correlation.ex | 0.886282 | 0.743378 | correlation.ex | starcoder |
defmodule Datix.NaiveDateTime do
@moduledoc """
A `NaiveDateTime` parser using `Calendar.strftime` format-string.
"""
@doc """
Parses a datetime string according to the given `format`.
See the `Calendar.strftime` documentation for how to specify a format-string.
The `:ok` tuple contains always an UTC d... | lib/datix/naive_date_time.ex | 0.926835 | 0.926037 | naive_date_time.ex | starcoder |
defmodule Bs.Game do
alias Bs.Game.PubSub
alias Bs.Game.Registry
alias Bs.Game.Supervisor
alias Bs.Game.Server
use GenServer
import GenServer, only: [call: 2]
defdelegate(handle_call(request, from, state), to: Server)
defdelegate(handle_cast(request, state), to: Server)
defdelegate(handle_info(requ... | lib/bs/game.ex | 0.51562 | 0.429669 | game.ex | starcoder |
defmodule AWS.EKS do
@moduledoc """
Amazon Elastic Kubernetes Service (Amazon EKS) is a managed service that makes
it easy for you to run Kubernetes on AWS without needing to stand up or maintain
your own Kubernetes control plane.
Kubernetes is an open-source system for automating the deployment, scaling, a... | lib/aws/generated/eks.ex | 0.911895 | 0.41401 | eks.ex | starcoder |
defmodule Bounds.Chunked do
@moduledoc false
defstruct [:bounds, :step]
def new(%Bounds{lower: lower, upper: upper} = bounds, step, partial_strategy) when is_integer(step) and step >= 1 do
case {rem(upper - lower, step), partial_strategy} do
{0, _} ->
%Bounds.Chunked{bounds: bounds, step: step... | lib/bounds/chunked.ex | 0.812235 | 0.642397 | chunked.ex | starcoder |
defmodule ProperCase do
@moduledoc """
An Elixir library that converts keys in maps between `snake_case` and `camel_case`
"""
import String, only: [first: 1, replace: 4, downcase: 1, upcase: 1]
@doc """
Converts all the keys in a map to `camelCase` if mode is :lower or `CamleCase` if mode is :upper.
If ... | lib/proper_case.ex | 0.658857 | 0.604282 | proper_case.ex | starcoder |
defmodule CubDB.Btree.KeyRange do
@moduledoc false
# `CubDB.Btree.KeyRange` is a module implementing the `Enumerable` protocol to
# iterate through a range of entries on a Btree bounded by a minimum and
# maximum key. The bounds can be exclusive or inclusive: bounds are either
# `nil` or tuples of `{key, boo... | lib/cubdb/btree/key_range.ex | 0.896639 | 0.480844 | key_range.ex | starcoder |
defmodule Phoenix.Socket do
@moduledoc ~S"""
Holds state for every channel, pointing to its transport,
pubsub server and more.
## Socket Fields
* `id` - The string id of the socket
* `assigns` - The map of socket assigns, default: `%{}`
* `channel` - The channel module where this socket originated
* `... | lib/phoenix/socket.ex | 0.890169 | 0.426859 | socket.ex | starcoder |
defprotocol Vow.Conformable do
@moduledoc """
TODO
"""
alias Vow.ConformError
@fallback_to_any true
@type conformed :: term
@type result :: {:ok, conformed} | {:error, [ConformError.Problem.t()]}
@doc """
Given a vow and a value, return an error if the value does not match
the vow, otherwise re... | lib/vow/conformable.ex | 0.735642 | 0.409516 | conformable.ex | starcoder |
defmodule HTS221.CTRLReg1 do
@moduledoc """
Control the power state, data rate, and update strategy of the HTS221
"""
import Bitwise
@power_mode_active 0x80
@wait_for_reading 0x04
@one_Hz 0x01
@seven_Hz 0x02
@twelve_point_five_Hz 0x03
@type power_mode() :: :down | :active
@type block_data_upda... | lib/hts221/ctrl_reg1.ex | 0.757346 | 0.69416 | ctrl_reg1.ex | starcoder |
defmodule JWT.Jwa do
@moduledoc """
Choose a cryptographic algorithm to be used for a JSON Web Signature (JWS)
see http://tools.ietf.org/html/rfc7518
"""
alias JWT.Algorithm.Ecdsa
alias JWT.Algorithm.Hmac
alias JWT.Algorithm.Rsa
@algorithms ~r/(HS|RS|ES)(256|384|512)?/i
@doc """
Return a Message... | lib/jwt/jwa.ex | 0.873073 | 0.446193 | jwa.ex | starcoder |
defmodule UnblockMeSolver.Generator do
@moduledoc false
@doc """
Generates a 5 by 5 problem with 1 block.
Idealy used as a test case, the solution block is unobstructed
## Examples
iex> UnblockMeSolver.Generator.trivial()
[
[nil, nil, nil, nil, nil],
[nil, nil, nil, nil, nil],
... | lib/unblock_me_solver/generator.ex | 0.704262 | 0.582105 | generator.ex | starcoder |
defmodule Robotica.Plugins.Lifx.Animate do
@moduledoc """
Lifx animation
"""
alias Robotica.Devices.Lifx, as: RLifx
require Logger
alias Robotica.Devices.Lifx.HSBKA
@type hsbkas :: {integer(), list(HSBKA.t()), integer()}
@spec animate(map(), integer()) :: list(hsbkas)
defp animate(animation, number... | robotica/lib/robotica/plugins/lifx/animate.ex | 0.777384 | 0.4206 | animate.ex | starcoder |
defmodule News.Util.RandomColor do
# Quick and dirty port of https://github.com/davidmerfield/randomColor
@color_bounds [
{:monochrome, [0,360], [[0,0],[100,0]]},
{:red, [-26,18], [[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]},
{:orange, [19,46], [[20,100],[30,93],[40,88... | lib/news/util/random_color.ex | 0.53437 | 0.572006 | random_color.ex | starcoder |
defmodule ConciergeSite.TimeHelper do
@moduledoc """
Time functions for subscription views
"""
import Phoenix.HTML.Form, only: [select: 4, time_select: 3]
import Phoenix.HTML.Tag, only: [content_tag: 2, content_tag: 3]
alias Calendar.Strftime
@doc """
Takes a time struct and returns HH:MM AM/PM
"""
... | apps/concierge_site/lib/views/time_helper.ex | 0.74872 | 0.439747 | time_helper.ex | starcoder |
defmodule CSSEx.Helpers.EEX do
@moduledoc false
import CSSEx.Parser, only: [open_current: 2, close_current: 1, add_error: 2]
import CSSEx.Helpers.Shared,
only: [
inc_col: 1,
inc_col: 2,
inc_line: 1,
inc_line: 2,
inc_no_count: 1,
file_and_line_opts: 1
]
import CSSEx... | lib/helpers/eex.ex | 0.636579 | 0.415996 | eex.ex | starcoder |
defmodule ElixirCardDealer do
@moduledoc """
Provides methods for creating and handling a deck of cards.
"""
@doc """
Greets user.
"""
def hello do
"Hello there, Player."
end
@doc """
Creates and returns a new deck of 52 cards.
"""
def create_deck do
values = ["Ace", "Two", "Three", "F... | lib/elixir_card_dealer.ex | 0.845799 | 0.572424 | elixir_card_dealer.ex | starcoder |
defmodule Bitcoinex.Transaction do
@moduledoc """
Bitcoin on-chain transaction structure.
Supports serialization of transactions.
"""
alias Bitcoinex.Transaction
alias Bitcoinex.Transaction.In
alias Bitcoinex.Transaction.Out
alias Bitcoinex.Transaction.Witness
alias Bitcoinex.Utils
alias Bitcoinex.T... | server/bitcoinex/lib/transaction.ex | 0.839734 | 0.407628 | transaction.ex | starcoder |
defmodule Retry.DelayStreams do
@moduledoc """
This module provide a set of helper functions that produce delay streams for
use with `retry`.
"""
@doc """
Returns a stream of delays that increase exponentially.
Example
retry with: exponential_backoff do
# ...
end
"""
@spec e... | lib/retry/delay_streams.ex | 0.939872 | 0.652131 | delay_streams.ex | starcoder |
defmodule ElixirMock do
@moduledoc """
This module contains functions and macros for creating mocks from real modules. It also contains utilities for
verifying that calls were made to functions in the mocks.
"""
# TODO: This module has too many public functions and macros that should really be private
req... | lib/elixir_mock.ex | 0.61855 | 0.847527 | elixir_mock.ex | starcoder |
defmodule NatsEx.Connection do
@moduledoc """
A GenServer implementing a connection to Natsd server.
You can set options for Nats in your config.exs. For example
```elixir
config :nats_ex, host: "localhost", port: 4222
```
Supported options are:
- `username`: Username, if auth is required
- `passwo... | lib/nats_ex/connection.ex | 0.869742 | 0.592401 | connection.ex | starcoder |
defmodule IdleAnimations.Ant do
use GenServer, restart: :temporary
@moduledoc "A langton's ant idle animation"
@fps 20
@max_steps 10_000
@min_changed_between_interesting_inspection 5
@steps_between_interesting_inspection 16
defmodule State do
use TypedStruct
typedstruct enforce: true do
... | web/lib/infolab_light_games/idle_animations/langtons_ant.ex | 0.777596 | 0.459015 | langtons_ant.ex | starcoder |
defmodule Scidata.IMDBReviews do
@moduledoc """
Module for downloading the [Large Movie Review Dataset](https://ai.stanford.edu/~amaas/data/sentiment/).
"""
@base_url "http://ai.stanford.edu/~amaas/data/sentiment/"
@dataset_file "aclImdb_v1.tar.gz"
alias Scidata.Utils
@type train_sentiment :: :pos | :n... | lib/scidata/imdb_reviews.ex | 0.870267 | 0.799286 | imdb_reviews.ex | starcoder |
defmodule VintageNetMobile.Modem.TelitLE910 do
@behaviour VintageNetMobile.Modem
@moduledoc """
Telit LE910 support
```elixir
VintageNet.configure(
"ppp0",
%{
type: VintageNetMobile,
vintage_net_mobile: %{
modem: VintageNetMobile.Modem.TelitLE910,
service_providers: [%{ap... | lib/vintage_net_mobile/modem/telit_LE910.ex | 0.787278 | 0.57821 | telit_LE910.ex | starcoder |
defmodule ResultEx do
@moduledoc """
ResultEx is a module for handling functions returning a `t:ResultEx.t/0`.
This module is inspired by the f# Result module, and [Railway Oriented Programming](https://fsharpforfunandprofit.com/rop/) as explained by <NAME>.
A result can be either the tuple {:ok, term} where t... | lib/result_ex.ex | 0.909987 | 0.755141 | result_ex.ex | starcoder |
defmodule LaFamiglia.Mechanics.Buildings do
@moduledoc """
All build times are specified in microseconds.
"""
alias LaFamiglia.Building
def buildings do
[
%Building{
id: 1,
key: :building_1,
build_time: fn level ->
((200 + 500 * level + :math.pow(level, 1.8)) |> r... | lib/mechanics/buildings.ex | 0.61231 | 0.513729 | buildings.ex | starcoder |
defmodule GenRegex.Generator do
@moduledoc """
Regex generator module and struct. This will be the intermediate step between interpreting parsed ASTs and generating strings.
For expressions that match an indefinite maximum number of repetitions (e.g a+, a*), the default maximum of 100 will be used
In the... | lib/grammar/generator.ex | 0.601711 | 0.492493 | generator.ex | starcoder |
defmodule Commanded.Command do
@moduledoc ~S"""
Creates an `Ecto.Schema.embedded_schema` that supplies a command with all the validation power of the `Ecto.Changeset` data structure.
defmodule CreateAccount do
use Commanded.Command,
username: :string,
email: :string,
age: :integer... | lib/commanded/command.ex | 0.803559 | 0.460289 | command.ex | starcoder |
defmodule BoatServer.Prometheus do
use Prometheus.Metric
require Logger
def setup do
Gauge.new(
name: :wind_speed_apparent,
labels: [:boat, :source],
help: "Apparent wind speed"
)
Gauge.new(
name: :wind_angle_apparent,
labels: [:boat, :source],
help: "Apparent win... | lib/boat_server/prometheus.ex | 0.629319 | 0.409634 | prometheus.ex | starcoder |
defmodule GraphQL.QueryBuilder do
@moduledoc """
Functions to simplify the creation of GraphQL queries.
The easiest way to use these functions is to `import` this module directly,
this way you'll have all you need to build a query.
## Helper functions
- `query/4` - creates a new "query" operation
- `mu... | lib/graphql/query_builder.ex | 0.905241 | 0.941223 | query_builder.ex | starcoder |
defmodule Lilictocat.Github do
@github_api Application.get_env(:lilictocat, :github_api, Lilictocat.Github.API)
@moduledoc """
this module consumes the github API, and makes the necessary transformations to use the data
"""
@doc """
returns a list of organiztions.
## Examples
iex> Lilictocat.G... | lib/lilictocat/github.ex | 0.536799 | 0.437763 | github.ex | starcoder |
defmodule Membrane.H264 do
@moduledoc """
This module provides format definition for H264 video stream
"""
@typedoc """
Width of single frame in pixels.
Allowed values may be restricted by used encoding parameters, for example, when using
4:2:0 chroma subsampling dimensions must be divisible by 2.
"""... | lib/membrane_h264_format/h264.ex | 0.926078 | 0.684073 | h264.ex | starcoder |
defmodule Gamenect.Lobby do
use Gamenect.Web, :model
schema "lobbies" do
field :title, :string
field :finished_at, Ecto.DateTime
field :status, :integer, default: 1
field :password, :string
field :max_players, :integer
belongs_to :game, Gamenect.Game
belongs_to :host, Gamenect.User
... | project/gamenect/web/models/lobby.ex | 0.717705 | 0.556219 | lobby.ex | starcoder |
defmodule Dovetail.Deliver do
@moduledoc """
Use dovecot's LDA [deliver] to deliver mail.
"""
alias Dovetail.Config
require Logger
require EEx
@timeout 5000
@default_exec_path Path.join(Config.dovecot_path(),
"libexec/dovecot/deliver")
@doc """
Deliver the email to... | lib/dovetail/deliver.ex | 0.639398 | 0.480418 | deliver.ex | starcoder |
defmodule Kitt.Message.ICA do
@moduledoc """
Defines the structure and instantiation function
for creating a J2735-compliant Intersection Collision Alert message
An ICA defines the alert message type that is emitted to DSRC-capable
vehicles entering the vicinity of an intersection in which a collision
has ... | lib/kitt/message/ica.ex | 0.83545 | 0.603231 | ica.ex | starcoder |
defmodule MeshxRpc.Client do
@moduledoc """
Convenience module on top of `MeshxRpc.Client.Pool`.
Module leverages `Kernel.use/2` macro to simplify user interaction with `MeshxRpc.Client.Pool` module:
* current module name is used as pool id,
* pool options can be specified with `use/2` clause.
Please ... | lib/client/client.ex | 0.89607 | 0.562417 | client.ex | starcoder |
defmodule Data.GeoJSON do
def to_feature_lists(%Map.Parsed{} = map) do
%{
routes: as_feat_collection(routes(map) ++ routeless_ways(map)),
articles: as_feat_collection(articles(map)),
markers: as_feat_collection(markers(map))
}
end
defp markers(map) do
map.nodes()
|> Map.Element.... | lib/data/geojson.ex | 0.649467 | 0.428233 | geojson.ex | starcoder |
defmodule ExAws.Vocabulary do
@moduledoc """
Operations for AWS Transcribe Vocabulary Endpoints
"""
import ExAws.Utils, only: [camelize_keys: 2]
@version "2017-10-26"
@doc """
Creates a vocabulary
Doc: <https://docs.aws.amazon.com/transcribe/latest/dg/API_CreateVocabulary.html>
Example:
... | lib/ex_aws/vocabulary.ex | 0.878647 | 0.736543 | vocabulary.ex | starcoder |
defmodule AntlUtilsEcto.Queryable do
@moduledoc """
Superpower your schemas.
"""
@callback queryable() :: Ecto.Queryable.t()
@callback include(Ecto.Queryable.t(), list) :: Ecto.Queryable.t()
@callback filter(Ecto.Queryable.t(), keyword) :: Ecto.Queryable.t()
@callback order_by(Ecto.Queryable.t(), list |... | lib/queryable.ex | 0.705176 | 0.403361 | queryable.ex | starcoder |
defmodule Cryppo.Rsa4096 do
@moduledoc """
Encryption strategy RSA with 4096-bit keys and some RSA-specific functions
For encryption and decryption please use functions in module `Cryppo`.
This module also contains logic for PEMs, singing and verification.
"""
# Key length 4096
# Exponents: 65537
# P... | lib/cryppo/rsa4096.ex | 0.865494 | 0.542863 | rsa4096.ex | starcoder |
defmodule Delugex.MessageStore.Postgres do
@moduledoc """
This is the real implementation of MessageStore. It will execute the needed
queries on Postgres through Postgrex by calling the functions provided in
[ESP](https://github.com/Carburetor/ESP/tree/master/app/config/functions/stream). You should be able to ... | lib/delugex/message_store/postgres.ex | 0.770853 | 0.493592 | postgres.ex | starcoder |
defmodule MotleyHue do
@moduledoc """
An Elixir utility for calculating the following color combinations:
* Complimentary - Two colors that are on opposite sides of the color wheel
* Analagous - Three colors that are side by side on the color wheel
* Monochromatic - A spectrum of shades, tones and tints of on... | lib/motley_hue.ex | 0.95374 | 0.666307 | motley_hue.ex | starcoder |
defmodule BitcoinPriceScraper.RateLimiter do
use GenStage
alias BitcoinPriceScraper.Upbit
alias __MODULE__.Producer
defmodule Producer do
defstruct [:limits_per_second, :pending]
def new(limits_per_second) do
%__MODULE__{
limits_per_second: limits_per_second,
# candle 조회에 실패한 이벤... | lib/bitcoin_price_scraper/rate_limiter.ex | 0.568296 | 0.444685 | rate_limiter.ex | starcoder |
defmodule JSON.Parser.Unicode do
@moduledoc """
Implements a JSON Unicode Parser for Bitstring values
"""
use Bitwise
@doc """
parses a valid chain of escaped unicode and returns the string representation,
plus the remainder of the string
## Examples
iex> JSON.Parser.parse ""
{:error, :u... | node_modules/@snyk/snyk-hex-plugin/elixirsrc/deps/json/lib/json/parser/unicode.ex | 0.81309 | 0.418103 | unicode.ex | starcoder |
defmodule Akd.Publish.Release do
@moduledoc """
A native Hook module that comes shipped with Akd.
This module uses `Akd.Hook`.
Provides a set of operations to evaluate some elixir code after publishing the release
# Options:
* `run_ensure`: `boolean`. Specifies whether to a run a command or not.
* `ig... | lib/akd/base/publish/release.ex | 0.860237 | 0.482246 | release.ex | starcoder |
defmodule Yum.Ingredient do
@moduledoc """
A struct that contains all the data about an ingredient.
"""
defstruct [
ref: nil,
translation: %{},
exclude_diet: [],
exclude_allergen: [],
nutrition: %{}
]
@type t :: %Yum.Ingredient{ ref: String.t, translat... | lib/yum/ingredient.ex | 0.762114 | 0.569224 | ingredient.ex | starcoder |
defmodule Multihash do
@moduledoc """
A [multihash](https://github.com/jbenet/multihash) implementation.
"""
defstruct algorithm: :sha512, size: 0, digest: <<>>
@type algorithm :: :sha1 | :sha256 | :sha512 | :sha3 | :blake2b | :blake2s
@type t :: %Multihash{algorithm: algorithm,
si... | lib/multihash.ex | 0.876032 | 0.74911 | multihash.ex | starcoder |
defmodule Flawless do
@moduledoc """
Flawless is a library meant for validating Elixir data structures. The validation
is done by providing the `validate` function with a value and a schema.
"""
alias Flawless.Error
alias Flawless.Helpers
alias Flawless.Types
alias Flawless.Rule
alias Flawless.Spec
... | lib/flawless.ex | 0.925129 | 0.583975 | flawless.ex | starcoder |
defmodule Mix.Releases.Shell do
@moduledoc """
This module provides conveniences for writing output to the shell.
"""
use Mix.Releases.Shell.Macros
@type verbosity :: :silent | :quiet | :normal | :verbose
# The order of these levels is from least important to most important
# When comparing log levels wi... | lib/mix/lib/releases/shell.ex | 0.819857 | 0.482673 | shell.ex | starcoder |
defmodule Map do
@moduledoc """
A set of functions for working with maps.
Maps are the "go to" key-value data structure in Elixir. Maps can be created
with the `%{}` syntax, and key-value pairs can be expressed as `key => value`:
iex> %{}
%{}
iex> %{"one" => :two, 3 => "four"}
%{3 => "... | lib/elixir/lib/map.ex | 0.924637 | 0.730794 | map.ex | starcoder |
defmodule Plug.Parsers do
defmodule RequestTooLargeError do
@moduledoc """
Error raised when the request is too large.
"""
defexception message: "the request is too large. If you are willing to process " <>
"larger requests, please give a :length to Plug.Parsers",
... | lib/plug/parsers.ex | 0.851274 | 0.414958 | parsers.ex | starcoder |
defmodule Speakeasy.LoadResource do
@moduledoc """
Loads a resource into the speakeasy context:
```
%Absinthe.Resolution{context: %{speakeasy: %Speakeasy.Context{resource: your_resource}}}
```
See the [README](readme.html) for a complete example in a Absinthe Schema.
"""
@behaviour Absinthe.Middlewar... | lib/speakeasy/load_resource.ex | 0.843622 | 0.727443 | load_resource.ex | starcoder |
defmodule ExEntropy do
@doc """
Compute the Shannon entropy of a binary value.
reference:
- <http://stackoverflow.com/questions/990477/how-to-calculate-the-entropy-of-a-file>
- <https://en.wikipedia.org/wiki/Entropy_(information_theory)>
"""
@spec shannon_entropy(binary, integer) :: float
def shannon_... | lib/ex_crypto/ex_entropy.ex | 0.802865 | 0.692642 | ex_entropy.ex | starcoder |
defmodule ResxJSON.Encoder do
@moduledoc """
Encode data resources into strings of JSON.
### Media Types
Only `x.erlang.native` types are valid. This can either be a subtype or suffix.
Valid: `application/x.erlang.native`, `application/geo+x.erlang.native`.
If an error is being retu... | lib/resx_json/encoder.ex | 0.895247 | 0.744052 | encoder.ex | starcoder |
defmodule Base do
import Bitwise
@moduledoc """
This module provides data encoding and decoding functions
according to [RFC 4648](http://tools.ietf.org/html/rfc4648).
This document defines the commonly used base 16, base 32, and base
64 encoding schemes.
## Base 16 alphabet
| Value | Encoding | ... | lib/elixir/lib/base.ex | 0.663996 | 0.668366 | base.ex | starcoder |
defmodule Cldr.Normalize.Territories do
@moduledoc false
alias Cldr.Locale
def normalize(content) do
content
|> normalize_territory_info
end
def normalize_territory_info(content) do
content
|> Cldr.Map.remove_leading_underscores()
|> Cldr.Map.underscore_keys()
|> Cldr.Map.integerize... | mix/support/normalize/normalize_territory_info.ex | 0.69946 | 0.42674 | normalize_territory_info.ex | starcoder |
defmodule Memcache do
@moduledoc """
This module provides a user friendly API to interact with the
memcached server.
## Example
{:ok, pid} = Memcache.start_link()
{:ok} = Memcache.set(pid, "hello", "world")
{:ok, "world"} = Memcache.get(pid, "hello")
## Coder
`Memcache.Coder` allows yo... | lib/memcache.ex | 0.929103 | 0.610279 | memcache.ex | starcoder |
defmodule ExIntercom.User do
@moduledoc """
Users are the primary way of interacting with the ExIntercom API. If you know a
user's ID you can easily fetch their data.
```elixir
{:ok, %ExIntercom.User{} = user} = ExIntercom.User.get("530370b477ad7120001d")
```
You can also look them up using the `user_i... | lib/intercom/user.ex | 0.809012 | 0.737229 | user.ex | starcoder |
defmodule Tesla.Multipart do
@moduledoc """
Multipart functionality.
## Example
```
mp =
Multipart.new()
|> Multipart.add_content_type_param("charset=utf-8")
|> Multipart.add_field("field1", "foo")
|> Multipart.add_field("field2", "bar",
headers: [{"content-id", "1"}, {"content-type", ... | lib/tesla/multipart.ex | 0.890509 | 0.571079 | multipart.ex | starcoder |
defmodule Jamdb.Oracle do
@vsn "0.3.7"
@moduledoc """
Adapter module for Oracle. `DBConnection` behaviour implementation.
It uses `jamdb_oracle` for communicating to the database.
"""
use DBConnection
defstruct [:pid, :mode, :cursors]
@doc """
Starts and links to a database connection process.
... | lib/jamdb_oracle.ex | 0.799168 | 0.430088 | jamdb_oracle.ex | starcoder |
defmodule Engine.Ethereum.Event.Listener do
@moduledoc """
GenServer running the listener.
Periodically fetches events made on dynamically changing block range
from the root chain contract and feeds them to a callback.
It is **not** responsible for figuring out which ranges of Ethereum blocks are eligible t... | apps/engine/lib/engine/ethereum/event/listener.ex | 0.85405 | 0.468365 | listener.ex | starcoder |
defmodule Zaryn.Mining.TransactionContext do
@moduledoc """
Gathering of the necessary information for the transaction validation:
- previous transaction
- unspent outputs
"""
alias Zaryn.Crypto
alias Zaryn.P2P
alias Zaryn.P2P.Node
alias __MODULE__.DataFetcher
alias __MODULE__.NodeDistribution
... | lib/zaryn/mining/transaction_context.ex | 0.803135 | 0.481515 | transaction_context.ex | starcoder |
defmodule ExHashRing.HashRing do
@compile :native
@type t :: __MODULE__
@type override_map :: %{atom => [binary]}
use Bitwise
alias ExHashRing.HashRing.Utils
defstruct num_replicas: 0, nodes: [], overrides: %{}, items: {}
@spec new :: t
def new, do: new([])
@spec new([binary], override_map, integ... | lib/hash_ring.ex | 0.821295 | 0.42471 | hash_ring.ex | starcoder |
defmodule GSS.Client.Limiter do
@moduledoc """
Model of Limiter request subscribed to Client with partition :write or :read
This process is a ProducerConsumer for this GenStage pipeline.
"""
use GenStage
require Logger
@type state :: %__MODULE__{
max_demand: pos_integer(),
max_inter... | lib/elixir_google_spreadsheets/client/limiter.ex | 0.918485 | 0.478651 | limiter.ex | starcoder |
if Code.ensure_loaded?(Plug) do
defmodule Guardian.Plug.VerifyHeader do
@moduledoc """
Looks for and validates a token found in the `Authorization` header.
In the case where:
1. The session is not loaded
2. A token is already found for `:key`
This plug will not do anything.
This, like... | lib/guardian/plug/verify_header.ex | 0.788054 | 0.919859 | verify_header.ex | starcoder |
defmodule DeadLetter do
@moduledoc """
Structure around errors in the data processing pipeline. `DeadLetter`
objects should be written to the dead-letter-queue through `dlq`.
## Configuration
* `dataset_id` - Required.
* `subset_id` - Required.
* `app_name` - Required. Atom or string name for applicatio... | apps/definition_deadletter/lib/dead_letter.ex | 0.823825 | 0.519887 | dead_letter.ex | starcoder |
defmodule Sanbase.Clickhouse.Label do
@moduledoc """
Labeling addresses
"""
@type label :: %{
name: String.t(),
metadata: String.t()
}
def list_all(:all = _blockchain) do
query = """
SELECT DISTINCT(label) FROM blockchain_address_labels
"""
Sanbase.ClickhouseRepo... | lib/sanbase/clickhouse/labels.ex | 0.749087 | 0.455562 | labels.ex | starcoder |
defmodule Plausible.Stats.Query do
defstruct date_range: nil,
interval: nil,
period: nil,
filters: %{},
sample_threshold: 20_000_000,
include_imported: false
@default_sample_threshold 20_000_000
def shift_back(%__MODULE__{period: "year"} = query, site)... | lib/plausible/stats/query.ex | 0.784402 | 0.573798 | query.ex | starcoder |
defmodule Identicon do
alias IO.ANSI, as: Ansi
@moduledoc """
Identicon generator written in Elixir
Resources:
* https://en.wikipedia.org/wiki/Identicon
* https://github.com/mauricius/identicon
"""
@doc """
Exports a string into an Identicon PNG image.
## Parameters
- input: The input string... | lib/identicon.ex | 0.801548 | 0.405979 | identicon.ex | starcoder |
defmodule Stripe.Request do
@moduledoc """
A module for working with requests to the Stripe API.
Requests are composed in a functional manner. The request does not happen
until it is configured and passed to `make_request/1`.
Currently encompasses only requests to the normal Stripe API. The OAuth
endpoint... | lib/stripe/request.ex | 0.910349 | 0.575349 | request.ex | starcoder |
defmodule Nabo.Parser do
@moduledoc """
The behaviour to implement a parser in Nabo. It requires a `parse/2` callback to be implemented.
There are three kinds of parser for accordingly three components in a post: a front parser for metadata,
an excerpt parser and finally a post body parser.
By default Nabo ... | lib/nabo/parser.ex | 0.909292 | 0.922273 | parser.ex | starcoder |
defmodule Contex.GanttChart do
@moduledoc """
Generates a Gantt Chart.
Bars are drawn for each task covering the start and end time for each task. In addition, tasks can be grouped
into categories which have a different coloured background - this is useful for showing projects that are
in major phases.
Th... | lib/chart/gantt.ex | 0.926179 | 0.941493 | gantt.ex | starcoder |
defmodule Numerix.Statistics do
@moduledoc """
Common statistical functions.
"""
use Numerix.Tensor
alias Numerix.Common
@doc """
The average of a list of numbers.
"""
@spec mean(Common.vector()) :: Common.maybe_float()
def mean(%Tensor{items: []}), do: nil
def mean(x = %Tensor{}) do
sum(x... | lib/statistics.ex | 0.942566 | 0.713045 | statistics.ex | starcoder |
defmodule Nerves.NetworkInterface do
@moduledoc """
This module exposes a simplified view of Linux network configuration to
applications.
## Overview
This module should be added to a supervision tree or started via the
`start_link/0` call. Once running, the module provides functions to
list network int... | lib/nerves_network_interface.ex | 0.877221 | 0.540621 | nerves_network_interface.ex | starcoder |
defmodule Plymio.Vekil.Forom.List do
@moduledoc ~S"""
The module implements the `Plymio.Vekil.Forom` protocol and manages a list of other *forom*
See `Plymio.Vekil.Forom` for the definitions of the protocol functions.
See `Plymio.Vekil` for an explanation of the test environment.
## Module State
See `Pl... | lib/vekil/concrete/forom/list.ex | 0.836755 | 0.615521 | list.ex | starcoder |
defmodule AWS.Glacier do
@moduledoc """
Amazon S3 Glacier (Glacier) is a storage solution for "cold data."
Glacier is an extremely low-cost storage service that provides secure, durable,
and easy-to-use storage for data backup and archival.
With Glacier, customers can store their data cost effectively for ... | lib/aws/generated/glacier.ex | 0.871898 | 0.623119 | glacier.ex | starcoder |
defmodule Scenic.Primitive.Triangle do
use Scenic.Primitive
alias Scenic.Math
# alias Scenic.Primitive
# alias Scenic.Primitive.Style
@styles [:hidden, :fill, :stroke]
# ===========================================================================
# data verification and serialization
# ------------... | lib/scenic/primitive/triangle.ex | 0.695441 | 0.48054 | triangle.ex | starcoder |
defmodule Day08.Redo do
def part1(file_name \\ "test1.txt") do
file_name
|> parse()
|> count_1_4_7_8()
end
def part2(file_name \\ "test1.txt") do
file_name
|> parse()
|> sum_output()
end
def sum_output(lines) do
Enum.reduce(lines, 0, fn %{input: input, output: output}, total ->
... | jpcarver+elixir/day08/lib/day08.redo.ex | 0.536556 | 0.443841 | day08.redo.ex | starcoder |
defmodule RMap.Ruby do
@moduledoc """
Summarized all of Ruby's Hash functions.
Functions corresponding to the following patterns are not implemented
- When a function with the same name already exists in Elixir.
- When a method name includes `!`.
- <, <=, ==, >, >=, [], []=, default_*
"""
@spec __usi... | lib/r_map/ruby.ex | 0.704465 | 0.57687 | ruby.ex | starcoder |
defmodule Aoc2019.Day12 do
@behaviour DaySolution
def solve_part1() do
positions = get_moons()
velocities = List.duplicate({0, 0, 0}, length(positions))
{positions, velocities} |> iterate(1000) |> total_energy()
end
def solve_part2() do
positions = get_moons()
velocities = List.duplicate({... | lib/aoc2019/day12.ex | 0.773388 | 0.585397 | day12.ex | starcoder |
defmodule Rubber.Index do
@moduledoc """
The indices APIs are used to manage individual indices, index settings, aliases, mappings, and index templates.
[Elastic documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices.html)
"""
import Rubber.HTTP, only: [prepare_url: 2]
alias... | lib/rubber/index.ex | 0.863291 | 0.402891 | index.ex | starcoder |
defmodule Divo.Compose do
@moduledoc """
Implements the basic docker-compose commands for running from
your mix tasks. Run, stop, and kill container services.
These operations only apply to services managed by Divo, i.e. defined in
your Mix.env file under the `:myapp, :divo` key.
"""
require Logger
al... | lib/divo/compose.ex | 0.689515 | 0.440048 | compose.ex | starcoder |
defmodule Processes do
use Koans
@intro "Processes"
koan "You are a process" do
assert Process.alive?(self()) == true
end
koan "You can ask a process to introduce itself" do
information = Process.info(self())
assert information[:status] == :running
end
koan "Processes are referenced by th... | lib/koans/15_processes.ex | 0.613005 | 0.591163 | 15_processes.ex | starcoder |
defmodule CensysEx.Hosts do
@moduledoc """
CensysEx wrapper for the search.censys.io v2 API for the "hosts" resource
"""
alias CensysEx.{Paginate, Search, Util}
@typedoc """
Values that determine how to query Virtual Hosts. `:exclude` will ignore any virtual hosts
entries, `:include` virtual hosts will b... | lib/collections/hosts.ex | 0.915318 | 0.754892 | hosts.ex | starcoder |
defmodule LetterLinesElixir.BoardWord do
@moduledoc """
Module for working with a BoardWord. Each BoardWord is aware of the x/y coordinates of the start of its word,
whether the word is presented horizontal or vertical, the string value of hte word, whether it has been revealed,
and the length of the word
"""... | lib/letter_lines_elixir/board_word.ex | 0.833968 | 0.619975 | board_word.ex | starcoder |
defmodule HTTPEventServer.Endpoint do
@moduledoc """
Forward requests to this router by `forward "/message", to: Messenger.Router`. This will capture
POST requests on the `/message/:task` route calling the task specified. In your config, you will need
to add the following options:
```
config :http_event_... | lib/endpoint.ex | 0.714927 | 0.623663 | endpoint.ex | starcoder |
defmodule Astarte.Flow.Blocks.Container do
@moduledoc """
This is a producer_consumer block that sends messages to a Docker container.
Messages are sent and received via AMQP.
The block will manage the creation of the Container in a Kubernetes cluster using
the Astarte Kubernetes Operator.
"""
use Gen... | lib/astarte_flow/blocks/container.ex | 0.744285 | 0.433142 | container.ex | starcoder |
defmodule Liquor.Transformer do
@moduledoc """
Transformer takes a list of search items and tries to
"""
@type spec_item ::
{:apply, module, atom, list} |
{:mod, module} |
{:type, atom} |
atom |
((atom, atom, term) -> {:ok, {atom, atom, term}} | :error)
@type type_spec :: %{ atom => spec_... | lib/liquor/transformer.ex | 0.786049 | 0.682686 | transformer.ex | starcoder |
defmodule D08.Challenge do
@moduledoc """
Solution sketch:
As described in part 1 we can identify 1, 4, 7 and 8 by counting their string length. We now have a map of
1 => cf
4 => bcdf
7 => acf
8 => abcdefg
(these are ideal values - they can change but have the same meaning!)
We can use the values of ... | lib/d08/challenge.ex | 0.6508 | 0.607489 | challenge.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.