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 NervesKey.Data do
@moduledoc """
This module handles Data Zone data stored in the Nerves Key.
"""
@doc """
Create a public/private key pair
The public key is returned on success. This can only be called on devices that
have their configuration locked, but not their data.
"""
@spec genkey(A... | lib/nerves_key/data.ex | 0.780286 | 0.437103 | data.ex | starcoder |
defmodule Adventofcode.Day10SyntaxScoring do
use Adventofcode
alias __MODULE__.{Autocompleter, Parser, Part1, Part2, SyntaxChecker}
def part_1(input) do
input
|> Parser.parse()
|> Part1.solve()
end
def part_2(input) do
input
|> Parser.parse()
|> Part2.solve()
end
defmodule Synt... | lib/day_10_syntax_scoring.ex | 0.606498 | 0.484624 | day_10_syntax_scoring.ex | starcoder |
defmodule Churn.Processor.CyclomaticComplexity do
@moduledoc """
Cyclomatic Complexity calulator, source code based (stolen?) from:
https://github.com/rrrene/credo/blob/master/lib/credo/check/refactor/cyclomatic_complexity.ex
"""
alias Churn.File, as: ChurnFile
@spec calculate(ChurnFile.t()) :: pos_intege... | lib/churn/processor/cyclomatic_complexity.ex | 0.761804 | 0.610947 | cyclomatic_complexity.ex | starcoder |
defmodule Utils.Graph do
def big_o_notation do
size = 600
widget =
VegaLite.new(width: size, height: size)
|> VegaLite.mark(:line)
|> VegaLite.encode_field(:x, "x", type: :quantitative)
|> VegaLite.encode_field(:y, "y", type: :quantitative)
|> VegaLite.transform(groupby: ["color... | utils/lib/graph.ex | 0.741768 | 0.413536 | graph.ex | starcoder |
defmodule Phoenix.PubSub.EventStore do
@moduledoc """
Phoenix PubSub adapter backed by EventStore.
An example usage (add this to your supervision tree):
```elixir
{Phoenix.PubSub,
[name: MyApp.PubSub,
adapter: Phoenix.PubSub.EventStore,
eventstore: MyApp.EventStore]
}
```
where `MyApp.Eve... | lib/phoenix/pub_sub/event_store.ex | 0.863348 | 0.715275 | event_store.ex | starcoder |
defmodule ExampleFiles do
@moduledoc """
A `GenServer` that provides access to the `ExampleFiles.File` processes for a
project.
"""
defmodule State do
@moduledoc """
A struct encapsulating the state of an `ExampleFiles` process.
"""
@enforce_keys [:options]
defstruct [:all, :options]
e... | lib/example_files.ex | 0.728459 | 0.545528 | example_files.ex | starcoder |
defmodule Velocity do
@moduledoc """
A simple `Elixir.Agent` for registering occurrences of different events and reporting event counts for the given time period.
Configuration can be passed to `start_link/1` as a keyword list. Supported parameters are:
- `:ttl` - the duration, in seconds, that events should b... | lib/velocity.ex | 0.919877 | 0.710829 | velocity.ex | starcoder |
defmodule Nebulex.Adapters.Local do
@moduledoc ~S"""
Adapter module for Local Generational Cache; inspired by
[epocxy](https://github.com/duomark/epocxy).
Generational caching using an ets table (or multiple ones when used with
`:shards`) for each generation of cached data. Accesses hit the newer
generatio... | lib/nebulex/adapters/local.ex | 0.898349 | 0.789538 | local.ex | starcoder |
defmodule Flix do
@moduledoc ~S"""
Flix is an Elixir client for the [Flic](https://flic.io/) smart button.
Flic buttons don't connect directly to `Flix` nor the other way around. Flic buttons connect
to a `flicd` via bluetooth. `Flix` applications also connect to `flicd` but via a TCP. See
the diagram below.... | lib/flix.ex | 0.897986 | 0.775669 | flix.ex | starcoder |
defmodule Membrane.HTTPAdaptiveStream.Manifest.Track do
@moduledoc """
Struct representing a state of a single manifest track and functions to operate
on it.
"""
alias Membrane.HTTPAdaptiveStream.Manifest
require Manifest.SegmentAttribute
defmodule Config do
@moduledoc """
Track configuration.
... | lib/membrane_http_adaptive_stream/manifest/track.ex | 0.95803 | 0.49707 | track.ex | starcoder |
defmodule Spotify.Users do
@moduledoc """
For manipulating users.
[Spotify Docs](https://beta.developer.spotify.com/documentation/web-api/reference/users-profile/)
"""
alias Spotify.{ExternalUrls, Followers, Image, Timestamp, Context}
alias Spotify.Tracks.TrackSimple
@typedoc """
The user’s dat... | lib/spotify/models/users/users.ex | 0.756268 | 0.469459 | users.ex | starcoder |
defmodule Erlex do
@moduledoc """
Convert Erlang style structs and error messages to equivalent Elixir.
Lexes and parses the Erlang output, then runs through pretty
printer.
## Usage
Invoke `Erlex.pretty_print/1` wuth the input string.
```elixir
iex> str = ~S"('Elixir.Plug.Conn':t(),binary() | atom(... | lib/erlex.ex | 0.804021 | 0.752729 | erlex.ex | starcoder |
defmodule DistLimiter do
@scope __MODULE__
@doc """
Consume a count of resources if available.
If succeeds, `{:ok, remaining_count}`.
If falied, `{:error, :overflow}`.
```
iex> DistLimiter.consume({:ip, "a.b.c.d", :password_challenge}, {60000, 1}, 1)
{:ok, 0}
iex> DistLimiter.consume({:ip,... | lib/dist_limiter.ex | 0.832237 | 0.735214 | dist_limiter.ex | starcoder |
defmodule Telegex.Marked.BlockParser do
@moduledoc """
Parsing implementation of block nodes.
"""
use Telegex.Marked.Parser
alias Telegex.Marked.BlockCodeRule
alias Telegex.Marked.{Line, InlineParser}
@rule_modules [BlockCodeRule]
@doc """
Parse Markdown text, including inline elements.
Note: T... | lib/telegex/marked/parsers/block_parser.ex | 0.645679 | 0.51562 | block_parser.ex | starcoder |
defmodule PortAudio.Device do
alias PortAudio.Device
defstruct [
:index,
:name,
:host_api_index,
:max_input_channels,
:max_output_channels,
:default_input_latency,
:default_output_latency,
:default_sample_rate
]
@type t :: %Device{}
@doc """
Fetch a device with the given d... | lib/portaudio/device.ex | 0.63443 | 0.434161 | device.ex | starcoder |
defmodule StarkInfra.Event.Attempt do
alias __MODULE__, as: Attempt
alias StarkInfra.Utils.Rest
alias StarkInfra.Utils.Check
alias StarkInfra.User.Project
alias StarkInfra.User.Organization
alias StarkInfra.Error
@moduledoc """
Groups Event.Attempt related functions
"""
@doc """
When an Event de... | lib/event/event_attempt.ex | 0.875121 | 0.462109 | event_attempt.ex | starcoder |
defmodule Content.Audio.TrainIsBoarding do
@moduledoc """
The next train to [destination] is now boarding.
"""
require Logger
@enforce_keys [:destination, :route_id, :track_number]
defstruct @enforce_keys ++ [:trip_id]
@type t :: %__MODULE__{
destination: PaEss.destination(),
trip_i... | lib/content/audio/train_is_boarding.ex | 0.684159 | 0.417093 | train_is_boarding.ex | starcoder |
defmodule AWS.Kendra do
@moduledoc """
Amazon Kendra is a service for indexing large document sets.
"""
@doc """
Removes one or more documents from an index.
The documents must have been added with the `BatchPutDocument` operation.
The documents are deleted asynchronously. You can see the progress of ... | lib/aws/generated/kendra.ex | 0.89268 | 0.668082 | kendra.ex | starcoder |
defmodule Athel.ModelCase do
@moduledoc """
This module defines the test case to be used by
model tests.
You may define functions here to be used as helpers in
your model tests. See `errors_on/2`'s definition as reference.
Finally, if the test case interacts with the database,
it cannot be async. For th... | test/support/model_case.ex | 0.806319 | 0.40536 | model_case.ex | starcoder |
defmodule QbBackend.Posts do
@moduledoc """
This module takes the id of a manual and proceeds to find the associated Manual
"""
alias QbBackend.{
Repo,
Posts.Manual,
Posts.Comment,
Accounts.Profile,
Posts.Image
}
@doc """
This function takes the manual identification and proceeds to... | lib/qb_backend/posts/posts.ex | 0.620622 | 0.589037 | posts.ex | starcoder |
defmodule CrossedWires do
@moduledoc """
Day 3 — https://adventofcode.com/2019/day/3
"""
@doc """
iex> ["R8,U5,L5,D3", "U7,R6,D4,L4"] |> CrossedWires.part1()
6
iex> ["R75,D30,R83,U83,L12,D49,R71,U7,L72", "U62,R66,U55,R34,D71,R55,D58,R83"]
iex> |> CrossedWires.part1()
159
iex> ["R98,U47,R26,D63,R3... | lib/advent_of_code_2019/day03.ex | 0.782579 | 0.625753 | day03.ex | starcoder |
defmodule Cldr.Number.Parser do
@moduledoc """
Functions for parsing numbers and currencies from
a string.
"""
@number_format "[-+]?[0-9][0-9,_]*\\.?[0-9_]+([eE][-+]?[0-9]+)?"
@doc """
Scans a string locale-aware manner and returns
a list of strings and numbers.
## Arguments
* `string` is any `... | lib/cldr/number/parse.ex | 0.905134 | 0.647826 | parse.ex | starcoder |
defmodule Beamchmark do
@moduledoc """
Top level module providing `Beamchmark.run/2` API.
`#{inspect(__MODULE__)}` measures EVM performance while it is running user `#{inspect(__MODULE__)}.Scenario`.
# Metrics being measured
## Scheduler Utilization
At the moment, the main interest of `#{inspect(__MODUL... | lib/beamchmark.ex | 0.892237 | 0.632928 | beamchmark.ex | starcoder |
defmodule JSONRPC2.Clients.TCP do
@moduledoc """
A client for JSON-RPC 2.0 using a line-based TCP transport.
"""
alias JSONRPC2.Clients.TCP.Protocol
@default_timeout 5_000
@type host :: binary | :inet.socket_address() | :inet.hostname()
@type request_id :: any
@type call_option ::
{:strin... | lib/jsonrpc2/clients/tcp.ex | 0.909219 | 0.420153 | tcp.ex | starcoder |
defmodule Clickhousex.Codec.RowBinary do
@moduledoc """
A codec that speaks Clickhouse's RowBinary format
To use this codec, set the application `:clickhousex` `:codec` application variable:
config :clickhousex, codec: Clickhousex.Codec.RowBinary
"""
alias Clickhousex.{Codec, Codec.Binary.Extractor,... | lib/clickhousex/codec/row_binary.ex | 0.733643 | 0.517449 | row_binary.ex | starcoder |
defmodule Relay.Certs do
@moduledoc """
Utilities for working with PEM-encoded certificates.
"""
@typep pem_entry :: :public_key.pem_entry()
# This is a somewhat loose regex designed to exclude things that obviously
# aren't hostnames. It will allow some non-hostnames, because full validation
# would be... | lib/relay/certs.ex | 0.745861 | 0.444083 | certs.ex | starcoder |
defmodule Recurly.Coupon do
@moduledoc """
Module for handling coupons in Recurly.
See the [developer docs on coupons](https://dev.recurly.com/docs/list-active-coupons)
for more details
"""
use Recurly.Resource
alias Recurly.{Resource,Coupon,Money}
@endpoint "/coupons"
schema :coupon do
field :a... | lib/recurly/coupon.ex | 0.838217 | 0.725454 | coupon.ex | starcoder |
defmodule Robotica.Scheduler.Schedule do
@moduledoc """
Process a schedule entry
"""
alias Robotica.Config.Loader
@timezone Application.compile_env(:robotica, :timezone)
if Application.compile_env(:robotica_common, :compile_config_files) do
@filename Application.compile_env(:robotica, :schedule_file)... | robotica/lib/robotica/scheduler/schedule.ex | 0.727201 | 0.438785 | schedule.ex | starcoder |
defmodule BridgeEx.Graphql.LanguageConventions do
@moduledoc """
This defines an adapter that supports GraphQL query documents in their
conventional (in JS) camelcase notation, while allowing the schema to be
defined using conventional (in Elixir) underscore (snakecase) notation, and
tranforming the names as ... | lib/graphql/language_conventions.ex | 0.857604 | 0.869991 | language_conventions.ex | starcoder |
defmodule Gradient.ExprData do
require Gradient.Debug
import Gradient.Debug, only: [elixir_to_ast: 1]
def all_basic_pp_test_data() do
[
value_test_data(),
list_test_data(),
call_test_data(),
variable_test_data(),
exception_test_data(),
block_test_data(),
binary_test_... | test/support/expr_data.ex | 0.623835 | 0.474631 | expr_data.ex | starcoder |
defmodule BroadwaySQS.Producer do
@moduledoc """
A GenStage producer that continuously polls messages from a SQS queue and
acknowledge them after being successfully processed.
By default this producer uses `BroadwaySQS.ExAwsClient` to talk to S3 but
you can provide your client by implemneting the `BroadwaySQ... | lib/broadway_sqs/producer.ex | 0.903189 | 0.522689 | producer.ex | starcoder |
defmodule AWS.PI do
@moduledoc """
AWS Performance Insights enables you to monitor and explore different
dimensions of database load based on data captured from a running RDS
instance. The guide provides detailed information about Performance
Insights data types, parameters and errors. For more information a... | lib/aws/pi.ex | 0.825414 | 0.608478 | pi.ex | starcoder |
defmodule Lin.Ldf do
require Logger
@moduledoc """
# LIN .ldf file parser.
## Output
A map containing all fields from a `.ldf` file.
Top lever fields are:
* `global`
* `section`
"""
# Structure representing data in .ldf-file
defstruct [
master: [],
slaves: [],
signals: [],
f... | apps/app_lin/lib/ldf.ex | 0.587115 | 0.543106 | ldf.ex | starcoder |
defmodule WeChat.Work do
@moduledoc """
企业微信
```elixir
use WeChat.Work,
corp_id: "corp_id",
agents: [
contacts_agent(secret: "your_contacts_secret"),
%WeChat.Work.Agent{name: :agent_name, id: 10000, secret: "your_secret"},
...
]
```
"""
import WeChat.Utils, only: [work_doc_l... | lib/wechat/work/work.ex | 0.52342 | 0.573559 | work.ex | starcoder |
defmodule Plug.Adapters.Cowboy2 do
@moduledoc """
Adapter interface to the Cowboy2 webserver.
## Options
* `:ip` - the ip to bind the server to.
Must be either a tuple in the format `{a, b, c, d}` with each value in `0..255` for IPv4
or a tuple in the format `{a, b, c, d, e, f, g, h}` with each ... | lib/plug/adapters/cowboy2.ex | 0.881806 | 0.547041 | cowboy2.ex | starcoder |
defmodule Backoff do
@moduledoc """
Functions to decrease the rate of some process.
A **Backoff** algorithm is commonly used to space out repeated retransmissions
of the same block of data, avoiding congestion.
This module provides a data structure, [Backoff](#t:t/0), that holds the state
and the configur... | lib/backoff.ex | 0.908176 | 0.843444 | backoff.ex | starcoder |
defmodule FishermanServer.Sorts do
@moduledoc """
Provides handy algorithm helpers
"""
@doc """
Sort shell records by relative time interval. This is accomplished
by the following process:
1. Separate each shell record into two bounds (start and end)
2. Sort all bounds by timestamp and record their so... | fisherman_server/lib/fisherman_server/sorts.ex | 0.844297 | 0.557183 | sorts.ex | starcoder |
defmodule Translecto.Query do
@moduledoc """
Provides convenient functionality for querying translatable models.
"""
defmacro __using__(_options) do
quote do
import Translecto.Query
import Ecto.Query, except: [from: 1, from: 2]
end
end
defp get_table({ ... | lib/translecto/query.ex | 0.604282 | 0.478712 | query.ex | starcoder |
defmodule Membrane.Core.Element.DemandController do
@moduledoc false
# Module handling demands incoming through output pads.
alias Membrane.{Core, Element}
alias Core.CallbackHandler
alias Element.{CallbackContext, Pad}
alias Core.Element.{ActionHandler, PadModel, State}
require CallbackContext.Demand
... | lib/membrane/core/element/demand_controller.ex | 0.788624 | 0.416025 | demand_controller.ex | starcoder |
defmodule AOC.Day5 do
@moduledoc """
Solution to Day 5 of the Advent of code 2021
https://adventofcode.com/2021/day/5
"""
@doc """
Read the input file
"""
@spec get_inputs(File) :: [String.t()]
def get_inputs(f \\ "lib/inputs/day5.txt") do
File.read!(f)
|> String.trim()
|> String.split("\... | elixir/advent_of_code/lib/2021/day5.ex | 0.802594 | 0.548915 | day5.ex | starcoder |
defmodule ExJsonSchema.Validator.Type do
@moduledoc """
`ExJsonSchema.Validator` implementation for `"type"` attributes.
See:
https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.2
https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.25
https://tools.ietf.org/... | lib/ex_json_schema/validator/type.ex | 0.707607 | 0.502991 | type.ex | starcoder |
defmodule Nx.Defn.Compiler do
@moduledoc """
The specification and helper functions for custom `defn` compilers.
"""
@aot_version 1
@doc """
Callback for async execution (on top of JIT compilation).
It receives the same arguments as `c:__jit__/4` but must return
a struct that implements the `Nx.Async... | lib/nx/defn/compiler.ex | 0.754644 | 0.539226 | compiler.ex | starcoder |
defmodule Example_Ke do
def start do
Keyword.delete([a: 1, b: 2], :a)
end
def start2 do
Keyword.drop([a: 1, b: 2, b: 3, c: 3, a: 5], [:b, :d])
end
def start3 do
Keyword.equal?([a: 1, b: 2, a: 3], [b: 2, a: 3, a: 1])
end
def start4 do
Keyword.from_keys([:foo, :bar, :baz], :atom)
end
... | lib/beam/keyword/keyword.ex | 0.667256 | 0.852383 | keyword.ex | starcoder |
defmodule Elixirdo.Instance.MonadTrans.State do
alias Elixirdo.Instance.MonadTrans.State, as: StateT
use Elixirdo.Base
use Elixirdo.Typeclass.Monad.Trans, import_typeclasses: true
use Elixirdo.Typeclass.Monad.State, import_monad_state: true
defstruct [:data]
defmodule State do
defstruct [:input, :pos... | lib/elixirdo/instance/monad_trans/state.ex | 0.528777 | 0.565089 | state.ex | starcoder |
defmodule ApiWeb.Params do
@moduledoc """
Parses request params into domain datastructures.
"""
## Defaults
@max_limit 100
@default_params ~w(include sort page filter fields api_key)
@doc """
Returns a Keyword list of options from JSONAPI query params.
Supported options:
* `:offset` - a `"pag... | apps/api_web/lib/api_web/params.ex | 0.887296 | 0.403802 | params.ex | starcoder |
defmodule WebDriver do
use Application
@moduledoc """
Version: #{ WebDriver.Mixfile.project[:version] }
This is the Elixir WebDriver application. It can be used to drive a
WebDriver enabled browser via Elixir code.
The current version supports PhantomJS, ChromeDriver, FireFox and remote
Web D... | lib/webdriver.ex | 0.79854 | 0.659609 | webdriver.ex | starcoder |
defmodule Salemove.HttpClient.Middleware.Logger do
@behaviour Tesla.Middleware
@moduledoc """
Log requests as single line.
Logs request method, url, response status and time taken in milliseconds.
### Example usage
```
defmodule MyClient do
use Tesla
plug Salemove.HttpClient.Middleware.Logger,... | lib/salemove/http_client/middleware/logger.ex | 0.809765 | 0.646767 | logger.ex | starcoder |
defmodule RigCloudEvents.Parser.PartialParser do
@moduledoc """
Error-tolerant reader for JSON encoded CloudEvents.
Interprets the passed data structure as little as possible. The idea comes from the
CloudEvents spec that states that JSON payloads ("data") are encoded along with the
envelope ("context attrib... | apps/rig_cloud_events/lib/rig_cloud_events/parser/partial_parser.ex | 0.858199 | 0.489626 | partial_parser.ex | starcoder |
defmodule ForgeAbi.AccountState do
@moduledoc false
use Protobuf, syntax: :proto3
@type t :: %__MODULE__{
balance: ForgeAbi.BigUint.t() | nil,
nonce: non_neg_integer,
num_txs: non_neg_integer,
address: String.t(),
pk: binary,
type: ForgeAbi.WalletType.t... | lib/protobuf/gen/state.pb.ex | 0.714329 | 0.660857 | state.pb.ex | starcoder |
defmodule LocalLedger.CachedBalance do
@moduledoc """
This module is an interface to the abstract balances stored in DB. It is responsible for caching
wallets and serves as an interface to retrieve the current balances (which will either be
loaded from a cached balance or computed - or both).
"""
alias Loca... | apps/local_ledger/lib/local_ledger/cached_balance.ex | 0.796332 | 0.529385 | cached_balance.ex | starcoder |
defmodule Day7 do
def read_file(path) do
File.stream!(path)
|> parse_input
end
def parse_input(input) do
input
|> Stream.map(&String.split/1)
|> Stream.filter(fn x -> !Enum.empty? x end)
|> Enum.to_list
|> Enum.map(&row/1)
|> Map.new(fn item -> {item[:name], item} end)
end
de... | lib/day7.ex | 0.541894 | 0.458894 | day7.ex | starcoder |
defmodule Graphvix.HTMLRecord do
@moduledoc """
Models a graph vertex that uses HTML to generate a table-shaped record.
# Table structure
The Graphviz API allows the basic table-related HTML elements:
* `<table>`
* `<tr>`
* `<th>`
and the `Graphvix` API provides the parallel functions:
* `new/2`
... | lib/graphvix/html_record.ex | 0.895377 | 0.733422 | html_record.ex | starcoder |
defmodule Sourceror.LinesCorrector do
@moduledoc false
import Sourceror, only: [get_line: 1, correct_lines: 2]
@doc """
Corrects the line numbers of AST nodes such that they are correctly ordered.
* If a node has no line number, it's assumed to be in the same line as the previous one.
* If a node has a l... | lib/sourceror/lines_corrector.ex | 0.658637 | 0.567937 | lines_corrector.ex | starcoder |
defmodule Tensorflow.Eager.Operation.Input do
@moduledoc false
use Protobuf, syntax: :proto3
@type t :: %__MODULE__{
item: {atom, any}
}
defstruct [:item]
oneof(:item, 0)
field(:remote_handle, 1, type: Tensorflow.Eager.RemoteTensorHandle, oneof: 0)
field(:tensor, 2, type: Tensorflow.... | lib/tensorflow/core/protobuf/eager_service.pb.ex | 0.818374 | 0.678533 | eager_service.pb.ex | starcoder |
defmodule Configure.Persist do
@moduledoc """
Persist and broadcast changes to settings.
Implemented as a simple GenServer that reads and caches state. For the purposes of
this, it does not really matter that this is a bottleneck - highly concurrent access is not
needed in the same way as if this was on an i... | apps/configure/lib/configure/persist.ex | 0.63307 | 0.435001 | persist.ex | starcoder |
defmodule Plymio.Vekil.Form do
@moduledoc ~S"""
This module implements the `Plymio.Vekil` protocol using a `Map` where the
*proxies* (`keys`) are atoms and the *foroms* (`values`) hold quoted forms.
The default when creating a **form** *vekil* is to create
`Plymio.Vekil.Forom.Form` *forom* but any *vekil* c... | lib/vekil/concrete/vekil/form.ex | 0.870803 | 0.705075 | form.ex | starcoder |
defmodule AWS.CloudFront do
@moduledoc """
Amazon CloudFront
This is the *Amazon CloudFront API Reference*. This guide is for developers
who need detailed information about CloudFront API actions, data types, and
errors. For detailed information about CloudFront features, see the *Amazon
CloudFront Develo... | lib/aws/cloud_front.ex | 0.884389 | 0.512449 | cloud_front.ex | starcoder |
defmodule Combinatorics do
@moduledoc """
Utility for generating combinatorics.
Extracted from the [implementation in CouchDB](https://github.com/apache/couchdb/blob/master/src/couch_tests/src/couch_tests_combinatorics.erl).
"""
@doc """
Generate a powerset for a given list.
Returns a list.
## Exampl... | lib/combinatorics.ex | 0.893366 | 0.648383 | combinatorics.ex | starcoder |
defmodule Cloak.Cipher do
@moduledoc """
A behaviour for encryption/decryption modules. You can rely on this behaviour
to create your own Cloak-compatible cipher modules.
## Example
We will create a cipher that simply prepends `"Hello, "` to any given
plaintext on encryption, and removes the prefix on dec... | lib/cloak/cipher.ex | 0.905573 | 0.465752 | cipher.ex | starcoder |
defmodule Yggdrasil.Adapter.Icon do
@moduledoc """
This module defines an `Yggdrasil` adapter for ICON 2.0.
## Overview
With this adapter we can subscribe to the ICON 2.0 websocket to get either or
both block and event log updates in real time. It leverages `Yggdrasil` (built
over `Phoenix.PubSub`) for ha... | lib/yggdrasil/adapter/icon.ex | 0.876588 | 0.949482 | icon.ex | starcoder |
defmodule Nosedrum.ApplicationCommand do
@moduledoc """
The application command behaviour specifies the interface that a slash, user,
or message command module should implement.
Like regular commands, application command modules are stateless on their own. Implementations of the callbacks
defined by this beh... | lib/nosedrum/application_command.ex | 0.939927 | 0.691953 | application_command.ex | starcoder |
defmodule Logi.Filter do
@moduledoc """
Log Message Filter Behaviour.
A filter decides whether to allow a message be sent to the target channel.
## Note
A filter should not raise exceptions when it's `c:filter/2` is called.
If any exception is raised, the invocation of the log function will be aborted a... | lib/logi/filter.ex | 0.846038 | 0.751671 | filter.ex | starcoder |
defmodule JSONAPI.View do
@moduledoc """
A View is simply a module that defines certain callbacks to configure proper
rendering of your JSONAPI documents.
defmodule PostView do
use JSONAPI.View
def fields, do: [:id, :text, :body]
def type, do: "post"
def relationships do
... | lib/jsonapi/view.ex | 0.839306 | 0.500366 | view.ex | starcoder |
defmodule Finch.Request do
@moduledoc """
A request struct.
"""
@enforce_keys [:scheme, :host, :port, :method, :path, :headers, :body, :query]
defstruct [:scheme, :host, :port, :method, :path, :headers, :body, :query]
@atom_methods [
:get,
:post,
:put,
:patch,
:delete,
:head,
:... | lib/finch/request.ex | 0.883949 | 0.447762 | request.ex | starcoder |
defmodule DateTimeParser.Formatters do
@moduledoc false
def format_token(tokens, :hour) do
case {find_token(tokens, :hour), tokens |> find_token(:am_pm) |> format()} do
{{:hour, 0}, _} ->
0
{{:hour, 12}, "AM"} ->
0
{{:hour, hour}, "PM"} when hour < 12 ->
hour + 12
... | lib/formatters.ex | 0.745213 | 0.619788 | formatters.ex | starcoder |
defmodule RDF.IRI.InvalidError do
defexception [:message]
end
defmodule RDF.Literal.InvalidError do
defexception [:message]
end
defmodule RDF.Triple.InvalidSubjectError do
defexception [:subject]
def message(%{subject: subject}) do
"'#{inspect(subject)}' is not a valid subject of a RDF.Triple"
end
end
... | lib/rdf/exceptions.ex | 0.625896 | 0.515681 | exceptions.ex | starcoder |
defmodule Streamex.Activities do
@moduledoc """
The `Streamex.Activities` module defines functions
for working with feed activities.
"""
import Streamex.Request
alias Streamex.{Request, Client, Feed, Activity}
@doc """
Lists the given feed's activities.
Returns `{:ok, activities}`, or `{:error, mess... | lib/streamex/activities.ex | 0.883989 | 0.525491 | activities.ex | starcoder |
defmodule Paginator.Ecto.Query do
@moduledoc false
import Ecto.Query
alias Paginator.Config
def paginate(queryable, config \\ [])
def paginate(queryable, %Config{} = config) do
queryable
|> maybe_where(config)
|> limit(^query_limit(config))
end
def paginate(queryable, opts) do
paginat... | lib/paginator/ecto/query.ex | 0.651466 | 0.441011 | query.ex | starcoder |
defmodule Snowflex do
@moduledoc """
The client interface for connecting to the Snowflake data warehouse.
The main entry point to this module is `Snowflex.sql_query`. This function takes a string containing
a SQL query and returns a list of maps (one per row). NOTE: due to the way the Erlang ODBC works, all va... | lib/snowflex.ex | 0.785309 | 0.408513 | snowflex.ex | starcoder |
defmodule Nacha.Batch do
@moduledoc """
A struct that represents a batch, containing the Batch Header, Batch Control,
and Entry Detail records.
Also includes utility functions for building and managing batches.
"""
import Kernel, except: [to_string: 1]
alias Nacha.Entry
alias Nacha.Records.BatchHeade... | lib/nacha/batch.ex | 0.825379 | 0.53868 | batch.ex | starcoder |
defmodule Surface.Components.Utils do
@moduledoc false
import Surface, only: [event_to_opts: 2]
@valid_uri_schemes [
"http:",
"https:",
"ftp:",
"ftps:",
"mailto:",
"news:",
"irc:",
"gopher:",
"nntp:",
"feed:",
"telnet:",
"mms:",
"rtsp:",
"svn:",
"tel:",... | lib/surface/components/utils.ex | 0.565659 | 0.500732 | utils.ex | starcoder |
defmodule Ecto.Adapters.SQL.Sandbox do
@moduledoc ~S"""
A pool for concurrent transactional tests.
The sandbox pool is implemented on top of an ownership mechanism.
When started, the pool is in automatic mode, which means the
repository will automatically check connections out as with any
other pool.
Th... | lib/ecto/adapters/sql/sandbox.ex | 0.911389 | 0.615261 | sandbox.ex | starcoder |
defmodule Geocoder.Store do
use GenServer
use Towel
# Public API
def geocode(opts) do
GenServer.call(name(), {:geocode, opts[:address]})
end
def reverse_geocode(opts) do
GenServer.call(name(), {:reverse_geocode, opts[:latlng]})
end
def update(location) do
GenServer.call(name(), {:update, ... | lib/geocoder/store.ex | 0.721449 | 0.420391 | store.ex | starcoder |
defmodule RethinkDB.Pseudotypes do
@moduledoc false
defmodule Binary do
@moduledoc false
defstruct data: nil
def parse(%{"$reql_type$" => "BINARY", "data" => data}, opts) do
case Keyword.get(opts, :binary_format) do
:raw ->
%__MODULE__{data: data}
_ ->
:base64... | lib/rethinkdb/pseudotypes.ex | 0.632049 | 0.562357 | pseudotypes.ex | starcoder |
defmodule Commanded.Scheduler do
@moduledoc """
One-off command scheduler for [Commanded][1] CQRS/ES applications.
[1]: https://hex.pm/packages/commanded
- [Getting started](getting-started.html)
- [Usage](usage.html)
- [Testing](testing.html)
"""
alias Commanded.Scheduler.{
ScheduleBatch,
C... | lib/commanded/scheduler.ex | 0.881768 | 0.46563 | scheduler.ex | starcoder |
defmodule Module.ParallelChecker do
@moduledoc false
@type cache() :: {pid(), :ets.tid()}
@type warning() :: term()
@type kind() :: :def | :defmacro
@doc """
Receives pairs of module maps and BEAM binaries. In parallel it verifies
the modules and adds the ExCk chunk to the binaries. Returns the updated
... | lib/elixir/lib/module/parallel_checker.ex | 0.808899 | 0.444143 | parallel_checker.ex | starcoder |
defmodule Broadway.Topology.RateLimiter do
@moduledoc false
use GenServer
@atomics_index 1
def start_link(opts) do
case Keyword.fetch!(opts, :rate_limiting) do
# If we don't have rate limiting options, we don't even need to start this rate
# limiter process.
nil ->
:ignore
... | lib/broadway/topology/rate_limiter.ex | 0.789518 | 0.582283 | rate_limiter.ex | starcoder |
defmodule MeshxRpc.Protocol.Default do
@moduledoc """
RPC protocol default functions.
"""
require Logger
@int32_max round(:math.pow(2, 32) - 1)
@ser_flag_bin 0
@ser_flag_ser 1
@doc """
Calculates checksum for given `data` with `:erlang.crc32/1`.
Function returns checksum as 4 bytes binary big en... | lib/protocol/default.ex | 0.854521 | 0.728265 | default.ex | starcoder |
defmodule CadetWeb.ViewHelper do
@moduledoc """
Helper functions shared throughout views
"""
defp build_staff(user) do
transform_map_for_view(user, [:name, :id])
end
def unsubmitted_by_builder(nil), do: nil
def unsubmitted_by_builder(staff) do
build_staff(staff)
end
def grader_builder(nil)... | lib/cadet_web/helpers/view_helper.ex | 0.87168 | 0.866246 | view_helper.ex | starcoder |
defmodule NaturalSetDemo do
@moduledoc """
Tests to demonstrate `NaturalSet`
## Bit vector demonstration
iex> NaturalSet.new()
#NaturalSet<[]>
iex> NaturalSet.new().bits
0
iex> NaturalSet.new([0]).bits
1
iex> NaturalSet.new([1]).bits
2
iex> NaturalSet.new([1... | natural_set_demo/lib/natural_set_demo.ex | 0.729231 | 0.420332 | natural_set_demo.ex | starcoder |
defmodule TelemetryMetricsTelegraf.Telegraf.ConfigTemplates do
@moduledoc "Telegraf toml configuration templates."
@type opts :: keyword({:period, String.t()})
@type basicstats_opts :: keyword({:period, String.t()} | {:stats, [atom | String.t()]})
@type hisogram_opts ::
keyword(
{:period,... | lib/telemetry_metrics_telegraf/telegraf/config_templates.ex | 0.696371 | 0.409368 | config_templates.ex | starcoder |
defmodule LcdDisplay.HD44780.MCP23008 do
@moduledoc """
Knows how to commuticate with HD44780 type display through the 8-bit I/O expander
[MCP23008](https://ww1.microchip.com/downloads/en/DeviceDoc/MCP23008-MCP23S08-Data-Sheet-20001919F.pdf).
You can turn on/off the backlight.
## Usage
```
iex(2)> Circ... | lib/lcd_display/driver/hd44780_mcp23008.ex | 0.786746 | 0.797872 | hd44780_mcp23008.ex | starcoder |
defmodule Grizzly.ZWave.Commands.NodeAddDSKSet do
@moduledoc """
Command to set the DSK for a including node
Params:
* `:seq_number` - the sequence number for the command (required)
* `:accept` - the including controller accepts the inclusion process
and should proceed with adding the including n... | lib/grizzly/zwave/commands/node_add_dsk_set.ex | 0.678753 | 0.438845 | node_add_dsk_set.ex | starcoder |
defmodule AgeGuard do
@moduledoc """
Verifies if a person born at a given date meets provided age requirements.
It checks given DOB (date of birth) against given age.
Useful when registering users.
Acceptable formats of DOB (mix of integers and strings):
```
1, 12, 2020
01, 03, 2010
"01", "12"... | lib/age_guard.ex | 0.824956 | 0.919317 | age_guard.ex | starcoder |
defmodule Expline.Matrix do
@moduledoc false
@enforce_keys [:n_rows, :m_cols, :internal]
defstruct [:n_rows, :m_cols, :internal]
@type t() :: %__MODULE__{n_rows: pos_integer(), m_cols: pos_integer(), internal: internal()}
@type vector() :: Expline.Vector.t()
@typep internal() :: tuple()
@typep binary_... | lib/expline/matrix.ex | 0.839898 | 0.561275 | matrix.ex | starcoder |
defmodule AWS.ECR do
@moduledoc """
Amazon Elastic Container Registry
Amazon Elastic Container Registry (Amazon ECR) is a managed container image
registry service. Customers can use the familiar Docker CLI, or their
preferred client, to push, pull, and manage images. Amazon ECR provides a
secure, scalable... | lib/aws/generated/ecr.ex | 0.915479 | 0.525734 | ecr.ex | starcoder |
defmodule K8s.Operation do
@moduledoc "Encapsulates Kubernetes REST API operations."
alias K8s.Operation
@derive {Jason.Encoder, except: [:path_params]}
@allow_http_body [:put, :patch, :post]
@verb_map %{
list_all_namespaces: :get,
list: :get,
deletecollection: :delete,
create: :post,
up... | lib/k8s/operation.ex | 0.918462 | 0.690403 | operation.ex | starcoder |
defmodule ExVmstats do
use GenServer
defstruct [:backend, :use_histogram, :interval, :sched_time, :prev_sched, :timer_ref, :namespace, :prev_io, :prev_gc]
@timer_msg :interval_elapsed
def start_link do
GenServer.start_link(__MODULE__, [])
end
def init(_args) do
interval = Application.get_env(:ex... | lib/ex_vmstats.ex | 0.708112 | 0.412323 | ex_vmstats.ex | starcoder |
defmodule Nebulex.Hook do
@moduledoc """
This module specifies the behaviour for pre/post hooks callbacks.
These functions are defined in order to intercept any cache operation
and be able to execute a set of actions before and/or after the operation
takes place.
## Execution modes
It is possible to set... | lib/nebulex/hook.ex | 0.9064 | 0.625424 | hook.ex | starcoder |
defmodule Raygun.Format do
@moduledoc """
This module builds payloads of error messages that Raygun will understand.
These functions return maps of data which will be encoding as JSON prior
to submission to Raygun.
"""
@raygun_version Mix.Project.config()[:version]
@doc """
Builds an error payload tha... | lib/raygun/format.ex | 0.773687 | 0.413832 | format.ex | starcoder |
defmodule SieveOfAtkin do
@moduledoc """
Documentation for `SieveOfAtkin`.
"""
@doc """
Generates prime numbers up to a given maximum.
## Examples
iex> SieveOfAtkin.generate_primes(30) |> Enum.sort()
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
"""
def generate_primes(n)
def generate_primes(n)... | lib/sieve_of_atkin.ex | 0.847905 | 0.560253 | sieve_of_atkin.ex | starcoder |
defmodule Bandit.HTTP2.Frame.Data do
@moduledoc false
import Bandit.HTTP2.Frame.Flags
alias Bandit.HTTP2.{Connection, Errors, Frame, Stream}
defstruct stream_id: nil,
end_stream: false,
data: nil
@typedoc "An HTTP/2 DATA frame"
@type t :: %__MODULE__{
stream_id: Stream.... | lib/bandit/http2/frame/data.ex | 0.752104 | 0.405831 | data.ex | starcoder |
defmodule Contex.OrdinalScale do
@moduledoc """
An ordinal scale to map discrete values (text or numeric) to a plotting coordinate system.
An ordinal scale is commonly used for the category axis in barcharts. It has to be able
to generate the centre-point of the bar (e.g. for tick annotations) as well as the
... | lib/chart/scale/ordinal_scale.ex | 0.899481 | 0.774626 | ordinal_scale.ex | starcoder |
defmodule NcsaHmac.EndpointPlug do
import Plug.Conn
@moduledoc """
The EndpointPlug module provides functions to authenticate a web request at the Endpoint level.
This allows the user to removal all auth configuration from the Controller level.
"""
@doc """
Set default opts values.
"""
def init(opts... | lib/ncsa_hmac/endpoint_plug.ex | 0.513668 | 0.441914 | endpoint_plug.ex | starcoder |
use Bitwise
defmodule Zeam do
@moduledoc """
Zeam is a module of ZEAM. ZEAM is ZACKY's Elixir Abstract Machine, which is aimed at being BEAM compatible.
Zeam now provides bytecode analyzing functions.
"""
@tags [
SMALL: 15,
BIG: 11,
FLOAT: 9,
ATOM: 7,
REFER: 6,
PORT: 5,
PID: 3,
... | lib/zeam.ex | 0.824815 | 0.502747 | zeam.ex | starcoder |
defmodule OddJob.Utils do
@moduledoc """
Internal utilities for working with OddJob processes.
To avoid unexpected behavior, it's recommended that developers do not interact
directly with OddJob processes. See `OddJob` for the public API.
"""
@moduledoc since: "0.4.0"
import OddJob.Registry, only: [via:... | lib/odd_job/utils.ex | 0.892176 | 0.416678 | utils.ex | starcoder |
defmodule AWS.Sdb do
@moduledoc """
Amazon SimpleDB is a web service providing the core database functions of
data indexing and querying in the cloud. By offloading the time and effort
associated with building and operating a web-scale database, SimpleDB
provides developers the freedom to focus on applicatio... | lib/aws/sdb.ex | 0.913508 | 0.709447 | sdb.ex | starcoder |
defmodule Sneex.Ops.ProcessorStatus do
@moduledoc """
This represents the op codes for interacting with the processor status bits.
This includes the following commands:
CLC, SEC, CLD, SED, REP, SEP, SEI, CLI, CLV, NOP, XBA, and XCE
One thing to note about this opcode is that since it doesn't do a lot of memo... | lib/sneex/ops/processor_status.ex | 0.738292 | 0.644603 | processor_status.ex | starcoder |
defmodule Robot do
defstruct direction: :north, position: {0,0}
end
defmodule RobotSimulator do
@doc """
Create a Robot Simulator given an initial direction and position.
Valid directions are: `:north`, `:east`, `:south`, `:west`
"""
@valid_directions [:north, :east, :south, :west]
@valid_instructions [... | robot-simulator/lib/robot_simulator.ex | 0.851398 | 0.790207 | robot_simulator.ex | starcoder |
defmodule Filtrex.Condition.DateTime do
use Filtrex.Condition
use Timex
@format "{ISO:Extended}"
@comparators ["equals", "does not equal", "after", "on or after", "before", "on or before"]
@moduledoc """
`Filtrex.Condition.DateTime` is a specific condition type for handling datetime filters with various c... | lib/filtrex/conditions/datetime.ex | 0.86923 | 0.497986 | datetime.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.