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 Want.List do
@moduledoc """
Manages conversions to and from lists.
"""
use Want.Type
@type element :: any()
@type result :: {:ok, list(element())} | {:error, binary()}
@default_separator ","
@doc """
Cast an input into a list. By default this function will simply break up the input into ... | lib/want/list.ex | 0.909048 | 0.692174 | list.ex | starcoder |
defmodule ParallelStream do
alias ParallelStream.Mapper
alias ParallelStream.Each
alias ParallelStream.Filter
@moduledoc ~S"""
Parallel stream implementation for Elixir.
"""
@doc """
Creates a stream that will apply the given function on enumeration in
parallel and return the functions return value.... | lib/parallel_stream.ex | 0.914444 | 0.670283 | parallel_stream.ex | starcoder |
defmodule AWS.ACM do
@moduledoc """
AWS Certificate Manager
Welcome to the AWS Certificate Manager (ACM) API documentation.
You can use ACM to manage SSL/TLS certificates for your AWS-based websites
and applications. For general information about using ACM, see the [ *AWS
Certificate Manager User Guide*
... | lib/aws/acm.ex | 0.870377 | 0.673178 | acm.ex | starcoder |
defmodule Txbox do
@moduledoc """


Txbox is a Bitcoin transaction storage schema. It lets you store Bitcoin
transactions in your ... | lib/txbox.ex | 0.895643 | 0.868882 | txbox.ex | starcoder |
defmodule Ockam.Hub.Service.Discovery do
@moduledoc """
Discovery service storing information about other services
Options:
storage: storage module to use, default is `Ockam.Hub.Service.Discovery.Storage.Memory`
storage_options: options to call storage.init/1 with
"""
use Ockam.Worker
alias Ockam.Bar... | implementations/elixir/ockam/ockam_hub/lib/hub/service/discovery.ex | 0.630685 | 0.41653 | discovery.ex | starcoder |
defmodule MerklePatriciaTree.Trie.Node do
@moduledoc """
This module encodes and decodes nodes from a
trie encoding back into RLP form. We effectively implement
`c(I, i)` from the Yellow Paper.
TODO: Add richer set of tests, esp. in re: storage and branch values.
"""
alias MerklePatriciaTree.Trie
alia... | lib/trie/node.ex | 0.65202 | 0.49585 | node.ex | starcoder |
defmodule MerklePatriciaTree.Trie.Builder do
@moduledoc """
Builder is responsible for adding keys to an
existing merkle trie. To add a key, we need to
make a delta to our trie that ends up as the canonical
form of the given tree as defined in http://gavwood.com/Paper.pdf.
Note: this algorithm is non-obvio... | lib/trie/builder.ex | 0.652906 | 0.577555 | builder.ex | starcoder |
elixir_doc = """
Top level module providing convenience access to needed functions as well
as the very high level `Benchee.run` API.
Intended Elixir interface.
"""
erlang_doc = """
High-Level interface for more convenient usage from Erlang. Same as `Benchee`.
"""
for {module, moduledoc} <- [{Benchee, elixir_doc}, {... | lib/benchee.ex | 0.899734 | 0.467696 | benchee.ex | starcoder |
defmodule BSV.PrivKey do
@moduledoc """
A PrivKey is a data structure representing a Bitcoin private key.
Internally, a private key is a secret 256-bit integer within the range of the
ECDSA `secp256k1` parmaeters. Each private key corresponds to a public key
which is a coordinate on the `secp256k1` curve.
... | lib/bsv/priv_key.ex | 0.879587 | 0.602793 | priv_key.ex | starcoder |
defmodule Dotenvy.Transformer do
@moduledoc """
This module provides functionality for converting string values to specific Elixir data types.
These conversions were designed to operate on system environment variables, which
_always_ store string binaries.
"""
defmodule Error do
@moduledoc false
d... | lib/dotenvy/transformer.ex | 0.918959 | 0.836488 | transformer.ex | starcoder |
defmodule Noizu.Scaffolding.EntityBehaviour do
@moduledoc """
This Behaviour provides some callbacks needed for the Noizu.ERP (EntityReferenceProtocol) to work smoothly.
Note the following naming conventions (where Path.To.Entity is the same path in each following case)
- Entities MyApp.(Path.To.Entity).MyF... | lib/scaffolding/behaviours/entity_behaviour.ex | 0.88056 | 0.712848 | entity_behaviour.ex | starcoder |
defmodule AdventOfCode.Y2020.Day18 do
@numbers 0..9 |> Enum.map(&Integer.to_string/1)
def test_data() do
"5 + (8 * 3 + 9 + 3 * 4 * 3)"
# "2 * 3 + (4 * 5)"
end
def run() do
AdventOfCode.Helpers.Data.read_from_file("2020/day18.txt")
|> Enum.map(&calculate/1)
|> Enum.sum()
end
def cal... | lib/2020/day18.ex | 0.5144 | 0.559049 | day18.ex | starcoder |
defmodule Redix do
@moduledoc """
This module provides the main API to interface with Redis.
## Overview
`start_link/2` starts a process that connects to Redis. Each Elixir process
started with this function maps to a client TCP connection to the specified
Redis server.
The architecture is very simple:... | lib/redix.ex | 0.91331 | 0.69035 | redix.ex | starcoder |
defmodule Gobstopper.API.Auth.Email do
@moduledoc """
Handles the management of email authorization credentials.
"""
@service Gobstopper.Service.Auth
@credential_type :email
alias Gobstopper.API.Auth
@doc """
Create a new identity initially associated with the given email credenti... | apps/gobstopper_api/lib/gobstopper.api/auth/email.ex | 0.881239 | 0.428233 | email.ex | starcoder |
defmodule RenrakuWeb.Plugs.VerifyToken do
@behaviour Plug
@moduledoc """
Plug middleware to verify JWT tokens passed with the request and deny access if
no JWT was given.
The JWT needs to be issued by another application, signed with the valid RS256 key
and attached to the request in the `Authorization` h... | lib/renraku_web/plugs/verify_token.ex | 0.762336 | 0.474875 | verify_token.ex | starcoder |
defmodule LdGraph2.Agent do
@moduledoc """
An agent that manages a graph, allowing key-value databases to be used
instead of a purposefully-built graph database.
Note that a few special graph operations like searching are not implemented
yet.
"""
use Agent
require Logger
# Increment when adding back... | apps/ld_graph2/lib/ld_graph2/agent.ex | 0.887064 | 0.637623 | agent.ex | starcoder |
defmodule Tracex do
@moduledoc """
Tracex is a tool for static analysis of mix projects
It builds upon compiler tracing introduced in Elixir 1.10, simplifying
collection of traces and turning them into valuable insights.
Tracex collects traces emitted by Elixir compiler and performs some basic data
extrac... | lib/tracex.ex | 0.788909 | 0.526647 | tracex.ex | starcoder |
defmodule Plaid.Accounts do
@moduledoc """
Functions for Plaid `accounts` endpoint.
"""
import Plaid, only: [make_request_with_cred: 4, get_cred: 0]
alias Plaid.Utils
defstruct accounts: [], item: nil, request_id: nil
@type t :: %__MODULE__{accounts: [Plaid.Accounts.Account.t],
... | lib/plaid/accounts.ex | 0.785267 | 0.597989 | accounts.ex | starcoder |
defmodule Ockam.Wire.Binary.V1 do
@moduledoc false
@behaviour Ockam.Wire
alias Ockam.Address
alias Ockam.Message
@version 1
# TODO: refactor this.
def bare_spec(:address) do
{:struct, [type: :uint, value: :data]}
end
def bare_spec(:route) do
{:array, bare_spec(:address)}
end
def bare... | implementations/elixir/ockam/ockam/lib/ockam/wire/binary/v1.ex | 0.644001 | 0.419172 | v1.ex | starcoder |
defmodule Grizzly.ZWave.CommandClasses.DoorLock do
@moduledoc """
DoorLock Command Class
This command class provides commands that are used to operate and configure
door lock devices
"""
@behaviour Grizzly.ZWave.CommandClass
alias Grizzly.ZWave.DecodeError
@type mode ::
:unsecured
... | lib/grizzly/zwave/command_classes/door_lock.ex | 0.797911 | 0.400192 | door_lock.ex | starcoder |
defmodule ExUnitFixtures.Teardown do
@moduledoc false
def start_link do
Agent.start_link(fn -> %{pids: %{}, teardowns: %{}} end, name: __MODULE__)
end
@doc """
Runs teardown for the module registered as `module_ref`.
"""
@spec run(reference) :: :ok
def run(module_ref) when is_reference(module_ref)... | lib/ex_unit_fixtures/teardown.ex | 0.696991 | 0.421046 | teardown.ex | starcoder |
defmodule Snowpack.Telemetry do
@moduledoc """
Telemetry integration.
Unless specified, all time's are in `:native` units.
Snowpack executes the following events:
* `[:snowpack, :query, :start]` - Executed at the start of each query sent to Snowflake.
#### Measurements
* `:system_time` - The time t... | lib/snowpack/telemetry.ex | 0.88806 | 0.649481 | telemetry.ex | starcoder |
defmodule Blunt.Message.Options.Parser do
alias Blunt.Message.{Changeset, Metadata}
def parse_message_opts(message_module, opts) do
message_opts = Metadata.get(message_module, :options, [])
%{parsed: parsed, unparsed: unparsed} =
Enum.reduce(
message_opts,
%{parsed: [], unparsed: opt... | apps/blunt/lib/blunt/message/options/parser.ex | 0.510008 | 0.404155 | parser.ex | starcoder |
defmodule Grizzly.SmartStart.MetaExtension.LocationInformation do
@moduledoc """
This extension is used to advertise the location assigned to the supporting node
The location string cannot contain underscores and cannot end with a dash.
The location string can contain a period (.) but a sublocation cannot end... | lib/grizzly/smart_start/meta_extension/location_information.ex | 0.913058 | 0.83868 | location_information.ex | starcoder |
defmodule Functor do
@moduledoc """
An implementation of functor-style error handling of `:ok`/`:error` tuples.
"""
@type result() :: {:ok, any()} | {:error, any()} | :error
@doc """
map implementation for functor for :ok, :error
## Examples
iex> Functor.f_map({:ok, [1, 2, 3]}, &hd/1)
{:ok... | lib/functor.ex | 0.90567 | 0.417984 | functor.ex | starcoder |
defmodule Kitt.Util do
@moduledoc """
Utility functions for interacting with data frames and elements
for cleaner readability across modules.
"""
alias Kitt.Message.{BSM, CSR, EVA, ICA, MAP, PSM, RSA, SPAT, SRM, SSM, TIM}
@doc """
Converts an integer to its 4-byte binary representation
for compatibili... | lib/kitt/util.ex | 0.867387 | 0.651698 | util.ex | starcoder |
defmodule RandomAccessList do
@moduledoc """
A random access list is a persistent list data structure that has O(log n) time lookups and updates,
while maintaining a constant time for cons, tail and head operations.
This compares to a standard list that has a O(i) time for lookups and updates, with i being the... | lib/random_access_list.ex | 0.752831 | 0.421046 | random_access_list.ex | starcoder |
defmodule OneDHCPD.IPCalculator do
@moduledoc """
This module handles IP address calculations.
The most involved of the calculations is the determination of a good IP
subnet to use. OneDHCPD subnet tries for the following:
* Subnets should be the same across reboots (convenience and no surprise conflicts)
... | lib/one_dhcpd/ip_calculator.ex | 0.804675 | 0.626196 | ip_calculator.ex | starcoder |
import Croma.Defun
alias Croma.Result, as: R
defmodule Croma.TypeGen do
@moduledoc """
Module that defines macros for ad-hoc (in other words "in-line") module definitions.
"""
@doc """
Creates a new module that represents a nilable type, based on the given type module `module`.
Using the given type modul... | lib/croma/type_gen.ex | 0.823648 | 0.455501 | type_gen.ex | starcoder |
defmodule Contentful.Delivery do
@moduledoc """
The `Contentful.Delivery` module offers functions to interact with the [Contentful Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/) (CDA).
The API is _read only_. If you wish to manipulate data, have a look at the Managemen... | lib/contentful_delivery/delivery.ex | 0.875521 | 0.53048 | delivery.ex | starcoder |
defmodule Fiet.RSS2 do
@moduledoc """
RSS 2.0 parser, comply with [RSS 2.0 at Harvard Law](http://cyber.harvard.edu/rss/rss.html).
"""
use Fiet.RSS2.Engine
@doc """
Parses RSS 2.0 XML document.
## Example
iex> rss2 = File.read!("/path/to/rss2.xml")
iex> Fiet.RSS2.parse(rss2)
{:ok,
... | lib/fiet/rss2.ex | 0.720663 | 0.420659 | rss2.ex | starcoder |
defmodule Sidewalk do
@moduledoc ~S"""
Sidewalk is an Elixir client which is compatible with Sidekiq, the Β»efficient background processing library for RubyΒ«.
It can be used to enqueue jobs for later processing alongside e.g. with an already existing Ruby application.
For more information about Sidekiq please re... | lib/sidewalk.ex | 0.604399 | 0.409486 | sidewalk.ex | starcoder |
defmodule Explorer.DataFrame do
@moduledoc """
The DataFrame struct and API.
"""
alias __MODULE__, as: DataFrame
alias Explorer.Series
import Explorer.Shared, only: [impl!: 1]
import Nx.Defn.Kernel, only: [keyword!: 2]
@type data :: Explorer.Backend.DataFrame.t()
@type t :: %DataFrame{data: data}
... | lib/explorer/data_frame.ex | 0.904904 | 0.711894 | data_frame.ex | starcoder |
defmodule Dnsimple.Registrar do
@moduledoc """
Provides functions to interact with the
[registrar endpoints](https://developer.dnsimple.com/v2/registrar/).
See:
- https://developer.dnsimple.com/v2/registrar/
- https://developer.dnsimple.com/v2/registrar/auto-renewal/
- https://developer.dnsimple.com/v2/r... | lib/dnsimple/registrar.ex | 0.627951 | 0.465327 | registrar.ex | starcoder |
defmodule PhantomChain.Client.Logger do
@moduledoc """
This is a wrapper for the standard Logger module. It contains convenience
methods for logging exceptions and objects in addition to strings.
"""
require Logger
# Contextual
@doc """
Converts a rescued error and stacktrace into a pretty error outpu... | lib/phantomchain/client/logger.ex | 0.847337 | 0.533033 | logger.ex | starcoder |
defmodule Beiin.Record do
defstruct metric: "name", tags: %{"default" => "value"}, timestamp: 0, value: 0
end
defmodule Beiin.RecordServer do
use GenServer
alias Beiin.Record
alias Beiin.TimestampGenerator, as: TSG
## Client API
def start_link(metrics, tag_maps, opts \\ []) do
{ins_tsg, opts} = Keyw... | lib/record_server.ex | 0.647798 | 0.421909 | record_server.ex | starcoder |
defmodule Mnemo do
@moduledoc """
Implementation of [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki)
"""
@valid_strenghts [128, 160, 192, 224, 256]
@default_strength 256
@valid_mnemonic_word_count [12, 15, 18, 21, 24]
@pbkdf2_opts rounds: 2048, digest: :sha512, length: 64, format: ... | lib/mnemo.ex | 0.854126 | 0.585279 | mnemo.ex | starcoder |
defmodule Phoenix.LiveView.Diff do
# The diff engine is responsible for tracking the rendering state.
# Given that components are part of said state, they are also
# handled here.
@moduledoc false
alias Phoenix.LiveView.{View, Rendered, Comprehension, Component}
@components :c
@static :s
@dynamics :d
... | lib/phoenix_live_view/diff.ex | 0.839767 | 0.622631 | diff.ex | starcoder |
defmodule Chunkr.Opts do
@moduledoc """
Options for paginating.
## Fields
* `:repo` β The `Ecto.Repo` for the query.
* `:planner` β The module implementing the pagination strategy.
* `:query` β The non-paginated query to be extended for pagination purposes.
* `:strategy` β The name of the pagina... | lib/chunkr/opts.ex | 0.882098 | 0.70638 | opts.ex | starcoder |
defmodule Membrane.Element.Pad do
@moduledoc """
Pads are units defined by each element, allowing it to be linked with another
elements. This module consists of pads typespecs and utils.
Each pad is described by its name, direction, availability, mode and possible caps.
For pads to be linkable, these propert... | lib/membrane/element/pad.ex | 0.889021 | 0.732137 | pad.ex | starcoder |
defmodule JaSerializer.DSL do
@moduledoc """
A DSL for defining JSON-API.org spec compliant payloads.
Built on top of the `JaSerializer.Serializer` behaviour.
The following macros are available:
* `location/1` - Define the url of a single serialized object.
* `attributes/1` - Define the attributes to... | lib/ja_serializer/dsl.ex | 0.908236 | 0.520374 | dsl.ex | starcoder |
defmodule Quark.Partial do
@moduledoc ~S"""
Provide curried functions, that can also be partially bound without
dot notation. Partially applying a function will always return a
fully-curried function.
Please note that these will use all of the arities up to the defined function.
For instance:
defpa... | lib/quark/partial.ex | 0.675658 | 0.540863 | partial.ex | starcoder |
defmodule ILI9486 do
@moduledoc """
ILI9486 Elixir driver
"""
use GenServer
use Bitwise
@enforce_keys [:gpio, :opts, :lcd_spi, :data_bus, :display_mode, :chunk_size]
defstruct [
:gpio,
:opts,
:lcd_spi,
:touch_spi,
:touch_pid,
:pix_fmt,
:rotation,
:mad_mode,
:data_bus,... | lib/ili9486_elixir.ex | 0.889775 | 0.818809 | ili9486_elixir.ex | starcoder |
defmodule Membrane.RTP.SessionBin do
@moduledoc """
Bin handling one RTP session, that may consist of multiple incoming and outgoing RTP streams.
## Incoming streams
Incoming RTP streams can be connected via `:rtp_input` pads. As each pad can provide multiple RTP streams,
they are distinguished basing on SSR... | lib/membrane/rtp/session_bin.ex | 0.830422 | 0.515681 | session_bin.ex | starcoder |
defmodule Exdis.CommandParsers.Util do
## ------------------------------------------------------------------
## RESP Type Coercion - To String
## ------------------------------------------------------------------
def maybe_coerce_into_string({:string, string}) do
{:ok, string}
end
def maybe_coerce_int... | lib/exdis/command_parsers/util.ex | 0.533884 | 0.519582 | util.ex | starcoder |
defmodule WechatPay do
@moduledoc """
WechatPay provide toolkit for Wechat Payment Platform.
### Setup
You need to define you own pay module, then `use` WechatPay:
```elixir
defmodule MyPay do
use WechatPay, otp_app: :my_app
end
```
Then config your app in `config/config.exs`:
```elixir
c... | lib/wechat_pay.ex | 0.752649 | 0.624694 | wechat_pay.ex | starcoder |
defmodule AWS.Cognito.Sync do
@moduledoc """
Amazon Cognito Sync
Amazon Cognito Sync provides an AWS service and client library that enable
cross-device syncing of application-related user data. High-level client
libraries are available for both iOS and Android. You can use these
libraries to persist data... | lib/aws/cognito_sync.ex | 0.798462 | 0.530601 | cognito_sync.ex | starcoder |
defmodule FastSanitize.Fragment do
@moduledoc "Processing of HTML fragment trees."
import Plug.HTML, only: [html_escape_to_iodata: 1]
def to_tree(bin) do
with {:ok, fragment} <-
:fast_html.decode_fragment(bin,
format: [:nil_self_closing, :comment_tuple3, :html_atoms]
) do
... | lib/fast_sanitize/fragment.ex | 0.66454 | 0.433502 | fragment.ex | starcoder |
defmodule Stream.Reducers do
# Collection of reducers shared by Enum and Stream.
@moduledoc false
defmacro chunk(amount, step, limit, fun \\ nil) do
quote do
fn entry, acc(head, {buffer, count}, tail) ->
buffer = [entry | buffer]
count = count + 1
new_state =
if count... | lib/elixir/lib/stream/reducers.ex | 0.62601 | 0.487429 | reducers.ex | starcoder |
defmodule Grizzly.ZWave.Commands.ScheduleEntryLockYearDaySet do
@moduledoc """
This command sets or erases a schedule slot for a identified user who already has valid user access code
Params:
* `:set_action` - Indicates whether to erase or modify
* `:user_identifier` - The User Identifier is used to re... | lib/grizzly/zwave/commands/schedule_entry_lock_year_day_set.ex | 0.864982 | 0.660518 | schedule_entry_lock_year_day_set.ex | starcoder |
defmodule OMG.Eth.RootChain.Abi do
@moduledoc """
Functions that provide ethereum log decoding
"""
alias ExPlasma.Crypto
alias OMG.Eth.Encoding
alias OMG.Eth.RootChain.AbiEventSelector
alias OMG.Eth.RootChain.AbiFunctionSelector
alias OMG.Eth.RootChain.Fields
def decode_function(enriched_data, signat... | apps/omg_eth/lib/omg_eth/root_chain/abi.ex | 0.690559 | 0.415373 | abi.ex | starcoder |
defmodule OptionParser do
@moduledoc """
This module contains functions to parse command line arguments.
"""
@doc """
Parses `argv` and returns a tuple with the parsed options, its
arguments, and a list options that couldn't be parsed.
## Examples
iex> OptionParser.parse(["--debug"])
{ [deb... | lib/elixir/lib/option_parser.ex | 0.851922 | 0.495239 | option_parser.ex | starcoder |
defmodule HomeBot.DataStore.EnergyPostgresStore do
@moduledoc "Data store for energy data"
import HomeBot.DataStore.PostgresStore
def get_latest_measurement do
query("SELECT * FROM energy ORDER BY time DESC limit 1")
|> List.first()
end
def get_measurements_since(datetime) do
query("SELECT * FR... | lib/home_bot/data_store/energy_postgres_store.ex | 0.779616 | 0.457924 | energy_postgres_store.ex | starcoder |
defmodule WebDriver.Keys do
@moduledoc """
This provides symbols to represent various non-printable keystrokes that
can be sent to a web browser.
The codes are defined in: https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value
"""
@non_text_keys [
{ :key_n... | lib/webdriver/keys.ex | 0.754373 | 0.745167 | keys.ex | starcoder |
defmodule Exq.Redis.JobStat do
@moduledoc """
The JobStat module encapsulates storing system-wide stats on top of Redis
It aims to be compatible with the Sidekiq stats format.
"""
require Logger
alias Exq.Support.{Binary, Process, Job, Time, Node}
alias Exq.Redis.{Connection, JobQueue}
def record_proc... | lib/exq/redis/job_stat.ex | 0.592902 | 0.475666 | job_stat.ex | starcoder |
defmodule Personnummer do
@moduledoc """
A module to make the usage of Swedish social security numbers easier.
"""
defp valid_date_part?(year, month, day) do
{social_security_success, _} = Date.new(year, month, day)
{coordination_success, _} = Date.new(year, month, day - 60)
social_security_success ... | lib/personnummer.ex | 0.646906 | 0.493836 | personnummer.ex | starcoder |
defmodule Cldr.Territory do
@moduledoc """
Supports the CLDR Territories definitions which provide the localization of many
territories.
"""
alias Cldr.LanguageTag
@type as_options :: [as: :atom | :binary | :charlist]
@type atom_binary_charlist :: atom() | binary() | charlist()
@... | lib/cldr/territory.ex | 0.908448 | 0.468183 | territory.ex | starcoder |
defmodule Absinthe.Relay.Connection.Notation do
@moduledoc """
Macros used to define Connection-related schema entities
See `Absinthe.Relay.Connection` for more information.
If you wish to use this module on its own without `use Absinthe.Relay` you
need to include
```
@pipeline_modifier Absinthe.Relay.S... | lib/absinthe/relay/connection/notation.ex | 0.885291 | 0.673514 | notation.ex | starcoder |
defmodule Tirexs.Mapping do
@moduledoc """
Provides DSL-like macros for indices definition.
The mapping could be defined alongside with `settings` or just only `mappings`.
Mappings and Settings definition:
index = [index: "articles", type: "article"]
settings do
analysis do
ana... | lib/tirexs/mapping.ex | 0.682997 | 0.510741 | mapping.ex | starcoder |
defmodule Runlet.Cmd.Query do
require Logger
@moduledoc "Query a riemann server"
defstruct url: "",
host: "",
port: 80,
query: "",
retry: 3_000,
conn: nil,
ref: nil,
m: nil
@type t :: %__MODULE__{
url: String.t(),
... | lib/runlet/cmd/query.ex | 0.730194 | 0.427456 | query.ex | starcoder |
defmodule Blockchain.Blocktree do
@moduledoc """
Blocktree provides functions for adding blocks to the
overall blocktree and forming a consistent blockchain.
"""
defmodule InvalidBlockError do
defexception [:message]
end
alias Blockchain.Block
alias Blockchain.Chain
alias Blockchain.Genesis
ali... | apps/blockchain/lib/blockchain/blocktree.ex | 0.869077 | 0.63576 | blocktree.ex | starcoder |
defmodule Greetings do
@moduledoc """
This is a Greeting library
For this contrived example we have
- hello() which just returns :world
- hello(atom) which just returns atom
- hello(string) which just returns "Hello {string}"
- greet(name) which returns a "Hello $name!" (english is default language)
- ... | 03_greetings/lib/greetings.ex | 0.708414 | 0.46035 | greetings.ex | starcoder |
defmodule Commanded.EventStore.Adapter do
@moduledoc """
Defines the behaviour to be implemented by an event store adapter to be used by Commanded.
"""
alias Commanded.EventStore.{EventData, RecordedEvent, SnapshotData}
@type adapter_meta :: map
@type application :: Commanded.Application.t()
@type confi... | lib/commanded/event_store/adapter.ex | 0.86592 | 0.415936 | adapter.ex | starcoder |
defmodule VistaClient.Transformations.Serializer do
@moduledoc ~S"""
Convert VistaClient's tuple-based internal data structures of
- "films in a cinema on a day with their sessions" and
- "films in a cinema in a week with their sessions by day"
into Jason-digestible maps.
## Examples
iex> alias... | lib/transformations/serializer.ex | 0.523177 | 0.425844 | serializer.ex | starcoder |
defmodule Semaphore do
alias :ets, as: ETS
@table :semaphore
@call_safe_table :semaphore_call_safe
## Application Callbacks
use GenServer
def start(_type, _args) do
import Supervisor.Spec, warn: false
Supervisor.start_link([worker(__MODULE__, [])], strategy: :one_for_one)
end
def start_link(... | lib/semaphore.ex | 0.621426 | 0.411466 | semaphore.ex | starcoder |
defmodule ExWire.Packet.Protocol.Hello do
@moduledoc """
This packet establishes capabilities and etc between two peer to peer
clients. This is generally required to be the first signed packet communicated
after the handshake is complete.
```
**Hello** `0x00` [`p2pVersion`: `P`, `clientId`: `B`, [[`cap1`: ... | apps/ex_wire/lib/ex_wire/packet/protocol/hello.ex | 0.845321 | 0.842539 | hello.ex | starcoder |
defmodule Chess.Moves.Piece do
@moduledoc false
alias Chess.Board
alias Chess.Moves.Generator
alias Chess.Moves.Pieces.Knight
alias Chess.Moves.Pieces.Pawn
def attacked?(board, {file, rank}) do
attacked_by_rook_or_queen?(board, {file, rank}) ||
attacked_by_bishop_or_queen?(board, {file, rank}) |... | lib/chess/moves/piece.ex | 0.666822 | 0.514522 | piece.ex | starcoder |
defmodule Dicer.Lexer do
alias Dicer.Tokens
def tokenize({:ok, input}) when is_binary(input) do
_tokenize(input)
end
def tokenize(input = {:error, _}) do
input
end
defp _tokenize(input, result \\ [])
defp _tokenize("", result) do
{:ok, Enum.reverse([%Tokens.End{}] ++ result)}
end
defp ... | lib/dicer/lexer.ex | 0.564098 | 0.489564 | lexer.ex | starcoder |
defmodule Makeup.Styles.HTML.StyleMap do
@moduledoc """
This module contains all styles, and facilities to map style names (binaries or atoms) to styles.
Style names are of the form `<name>_style`.
"""
alias Makeup.Styles.HTML
# %% Start Pygments %%
@doc """
The *abap* style. Example [he... | deps/makeup/lib/makeup/styles/html/style_map.ex | 0.731538 | 0.565839 | style_map.ex | starcoder |
defmodule Alchemy.Guild do
alias Alchemy.{Channel, User, Voice, VoiceState}
alias Alchemy.Guild.{Emoji, GuildMember, Integration, Presence, Role}
import Alchemy.Structs
@moduledoc """
Guilds represent a collection of users in a "server". This module contains
information about the types, and subtypes related... | lib/Structs/Guild/guild.ex | 0.864053 | 0.474327 | guild.ex | starcoder |
defmodule Plug.Builder do
alias Plug.Conn
@moduledoc """
Conveniences for building plugs.
This module can be used into a module in order to build
a plug pipeline:
defmodule MyApp do
use Plug.Builder
plug Plug.Logger
plug :hello, upper: true
def hello(conn, opts) do
... | lib/plug/builder.ex | 0.835886 | 0.425456 | builder.ex | starcoder |
defmodule SanbaseWeb.Graphql.DocumentProvider do
@moduledoc ~s"""
Custom Absinthe DocumentProvider for more effective caching.
Absinthe phases have one main difference compared to plugs - all phases must run
and cannot be halted. But phases can be jumped over by returning
`{:jump, result, destination_phase}`... | lib/sanbase_web/graphql/document/document_provider.ex | 0.891256 | 0.510619 | document_provider.ex | starcoder |
defmodule Day04 do
# https://adventofcode.com/2018/day/4
def hello() do
:hello
end
def parse_datetime(rec) do
t = rec |> String.trim() |> String.split("]") |> List.first() |> String.trim("[")
(t <> ":00+0000") |> DateTime.from_iso8601() |> elem(1)
end
def compare(rec1, rec2) do
DateTime.co... | lib/day04.ex | 0.623148 | 0.474266 | day04.ex | starcoder |
defmodule HTMLParser.HTMLNodeTree do
@moduledoc """
Represents a tree of HTML nodes
"""
alias HTMLParser.HTMLTextNode
@enforce_keys [:tag]
defstruct [:tag, :next, children: [], attrs: %{}, empty: false]
@type t :: %__MODULE__{}
@type tag :: atom()
@doc """
Builds a new `HTMLNodeTree`
"""
@sp... | lib/html_parser/html_node_tree.ex | 0.843831 | 0.421284 | html_node_tree.ex | starcoder |
defmodule UniLoggerBackend do
@moduledoc """
A logger backend that forwards log messages to a process.
## Usage
First add the logger to the backends:
```
# config/config.exs
config :logger, :backends, [{UniLoggerBackend, :console}]
config :logger, level: :info
```
Then configure the `pid` of t... | lib/uni_logger_backend.ex | 0.861465 | 0.785473 | uni_logger_backend.ex | starcoder |
defmodule Pinterex.Api.Base do
@moduledoc """
The module contains all the logic that does the actual calls to
the Pinterest API
"""
use Tesla
plug Tesla.Middleware.BaseUrl, "https://api.pinterest.com/v1/"
plug Tesla.Middleware.Query, [access_token: key]
plug Tesla.Middleware.JSON
#plug Tesla.Middlewa... | lib/api/base.ex | 0.682362 | 0.400163 | base.ex | starcoder |
defmodule Kino.Utils.Table do
@moduledoc false
# Common functions for handling various Elixir terms
# as table records.
@type record :: map() | list({term(), term()}) | tuple() | term()
@doc """
Computes table column specifications that accommodate
the given records.
Note that the columns are comput... | lib/kino/utils/table.ex | 0.714528 | 0.607489 | table.ex | starcoder |
defmodule Kiq do
@moduledoc ~S"""
Kiq is a robust and extensible job processing queue that aims for
compatibility with Sidekiq Enterprise.
Job queuing, processing and reporting are all built on GenStage. That means
maximum parallelism with the safety of backpressure as jobs are processed.
## Usage
Kiq ... | lib/kiq.ex | 0.912463 | 0.567098 | kiq.ex | starcoder |
defmodule Bitcoinex.Utils do
@moduledoc """
Contains useful utility functions used in Bitcoinex.
"""
@spec sha256(iodata()) :: binary
def sha256(str) do
:crypto.hash(:sha256, str)
end
@spec replicate(term(), integer()) :: list(term())
def replicate(_num, 0) do
[]
end
def replicate(x, num)... | lib/utils.ex | 0.860266 | 0.506347 | utils.ex | starcoder |
defmodule Apq.DocumentProvider do
@moduledoc """
Apq document provider or Absinthe plug.
### Example
Define a new module and `use Apq.DocumentProvider`:
```elixir
defmodule ApqExample.Apq do
use Apq.DocumentProvider,
cache_provider: ApqExample.Cache,
max_query_size: 16384 # default
end... | lib/apq/document_provider.ex | 0.804214 | 0.762601 | document_provider.ex | starcoder |
defmodule RaceConditionBank do
@doc """
## Example 1 Manual Way:
iex[1]> alias RaceConditionBank, as: RCB
RaceConditionBank
iex[2]> RCB.new_account(1, 100)
{:ok, #PID<0.157.0>}
iex[3]> RCB.credit(1, 50)
:ok
iex[4]> :sys.get_state(1 |> Integer.to_string |> String.to_atom)
150
i... | 2020/otp/race_condition_bank/lib/race_condition_bank.ex | 0.544196 | 0.407687 | race_condition_bank.ex | starcoder |
defmodule Iodized.DefinitionJson do
defprotocol Json do
def to_json(definition)
end
def from_json(nil) do
nil
end
def from_json(definition) do
operand = Dict.fetch!(definition, :operand)
from_json(operand, definition)
end
defp from_json("any", definition) do
%Iodized.Definition.Any{... | lib/iodized/definition_json.ex | 0.688049 | 0.408955 | definition_json.ex | starcoder |
defmodule GatherSubmissions.Submission.Utils do
@moduledoc """
Contains some utility functions to work with DOMjudge submissions.
"""
alias GatherSubmissions.Submission
alias GatherSubmissions.Submission.File, as: SubFile
alias GatherSubmissions.Student
@doc """
Given a list of submissions, removes th... | lib/submissions/utils.ex | 0.802323 | 0.456531 | utils.ex | starcoder |
defmodule Elixium.BlockEncoder do
alias Elixium.Block
@moduledoc """
Provides functionality for encoding and decoding blocks
"""
@encoding_order [
:index, :hash, :previous_hash,
:merkle_root, :timestamp, :nonce,
:difficulty, :version, :transactions
]
@doc """
Encode a block to a binar... | lib/encoding/block_encoder.ex | 0.813609 | 0.434161 | block_encoder.ex | starcoder |
defmodule Stein.Storage do
@moduledoc """
`Stein.Storage` covers uploading, downloading, and deleting remote files
## Available backends
### FileBackend
The `Stein.Storage.FileBackend` is available for development purposes.
For the file backend, you can configure the folder Stein should use. This
shou... | lib/stein/storage.ex | 0.778355 | 0.487978 | storage.ex | starcoder |
defmodule Lullabeam.InputDevices.JellyCombKeypad do
@moduledoc """
Interpret keystrokes coming from a Jelly Comb CP001878, described on Amazon
as "USB Numeric Keypad, Jelly Comb N001 Portable Slim Mini Number Pad for
Laptop Desktop Computer PC, Full Size 19 Key, Big Print Letters - Black"
Layout:
βββββ ββ... | lib/lullabeam/input_devices/jelly_comb_keypad.ex | 0.538255 | 0.666893 | jelly_comb_keypad.ex | starcoder |
defmodule Singyeong.Utils do
@moduledoc """
Some utility functions that don't really belong in any one place.
"""
@spec fast_list_concat(list(), list()) :: list()
def fast_list_concat(a, b) do
# See #72 for why this check is needed
cond do
a == nil ->
b
b == nil ->
a
... | lib/singyeong/utils.ex | 0.763836 | 0.414425 | utils.ex | starcoder |
defmodule Plug.Crypto do
@moduledoc """
Namespace and module for crypto-related functionality.
Please see `Plug.Crypto.KeyGenerator`, `Plug.Crypto.MessageEncryptor`,
and `Plug.Crypto.MessageVerifier` for more functionality.
"""
use Bitwise
@doc """
Prunes the stacktrace to remove any argument trace.
... | lib/plug/crypto.ex | 0.818592 | 0.612339 | crypto.ex | starcoder |
defmodule CircuitsLED do
@moduledoc """
Control LEDs
This module provides a consistent way of controlling LEDs on devices
running Nerves or Linux.
Use cases I'm thinking about:
1. Control `/sys/class` LEDs and GPIO LEDs using functions to make
things easier on users who don't know about Linux's LED ... | lib/circuits_led.ex | 0.743634 | 0.457076 | circuits_led.ex | starcoder |
defmodule RDF.Literal.Generic do
@moduledoc """
A generic `RDF.Literal.Datatype` for literals of an unknown datatype.
"""
defstruct [:value, :datatype]
use RDF.Literal.Datatype,
name: "generic",
id: nil
alias RDF.Literal.Datatype
alias RDF.{Literal, IRI}
import RDF.Guards
@type t :: %__MOD... | lib/rdf/literal/datatypes/generic.ex | 0.902863 | 0.647791 | generic.ex | starcoder |
defmodule Elastic.Scroll do
@moduledoc ~S"""
Provides Elixir functions for ElasticSearch's scroll endpoint](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/search-request-scroll.html#search-request-scroll).
You should probably be using `Elastic.Scroller` instead.
"""
alias Elastic.HTTP
ali... | lib/elastic/scroll.ex | 0.921592 | 0.659838 | scroll.ex | starcoder |
defmodule Tablespoon.Communicator.Modem do
@moduledoc """
Communication with a modem at an intersection.
The communication is line-based.
When we first connect, we expect an "OK" line, unless passed the "expect_ok?: false" option is passed
To request priority at an intersection, we set one of the relays to... | lib/tablespoon/communicator/modem.ex | 0.812086 | 0.487856 | modem.ex | starcoder |
defmodule Waffle.Storage.Google.CloudStorage do
@moduledoc """
The main storage integration for Waffle, this acts primarily as a wrapper
around `Google.Api.Storage.V1`. To use this module with Waffle, simply set
your `:storage` config appropriately:
```elixir
config :waffle, storage: Waffle.Storage.Google.... | lib/waffle/storage/google/cloud_storage.ex | 0.846704 | 0.71889 | cloud_storage.ex | starcoder |
defmodule EctoEnum do
@moduledoc """
Provides `defenum/2` macro for defining an Enum Ecto type.
"""
@doc """
Defines an enum custom `Ecto.Type`.
It can be used like any other `Ecto.Type` by passing it to a field in your model's
schema block. For example:
import EctoEnum
defenum StatusEnum, ... | lib/ecto_enum.ex | 0.81841 | 0.475423 | ecto_enum.ex | starcoder |
import Kernel, except: [inspect: 1]
import Inspect.Algebra
alias Code.Identifier
defprotocol Inspect do
@moduledoc """
The `Inspect` protocol is responsible for converting any Elixir
data structure into an algebra document. This document is then
formatted, either in pretty printing format or a regular one.
... | lib/elixir/lib/inspect.ex | 0.747339 | 0.659172 | inspect.ex | starcoder |
defmodule ExAdmin.ErrorsHelper do
@moduledoc """
The primary purpose of this module is to take nested changeset errors created
by many_to_many and has many through relationships and change them into a format
that the forms can use to get the error message from the field name.
Changes sets such as:
... | web/ex_admin/errors_helper.ex | 0.649023 | 0.456834 | errors_helper.ex | starcoder |
defmodule Surface.Compiler do
@moduledoc """
Defines a behaviour that must be implemented by all HTML/Surface node translators.
This module also contains the main logic to translate Surface code.
"""
alias Surface.Compiler.Parser
alias Surface.IOHelper
alias Surface.AST
alias Surface.Compiler.Helpers
... | lib/surface/compiler.ex | 0.777088 | 0.453564 | compiler.ex | starcoder |
defmodule MarsRoverKata.Instruction do
@moduledoc """
Apply instructions to robot position.
"""
alias MarsRoverKata.Planet
alias MarsRoverKata.Point
alias MarsRoverKata.Position
@spec perform_next(Planet.t(), Position.t(), atom) :: Position.t()
def perform_next(
%Planet{} = planet,
%Po... | lib/mars_rover_kata/instruction.ex | 0.903084 | 0.730242 | instruction.ex | starcoder |
defmodule Tournament do
@header "Team | MP | W | D | L | P"
@doc """
Given `input` lines representing two teams and whether the first of them won,
lost, or reached a draw, separated by semicolons, calculate the statistics
for each team's number of games played, won, drawn, lost,... | exercism/tournament/tournament.ex | 0.87444 | 0.542924 | tournament.ex | starcoder |
defmodule IdenticonGenerator.Identicon do
@doc """
Hashes a string input and returns the hash within the Image struct as hex
## Examples
iex> hash = IdenticonGenerator.Identicon.hash_input("banana")
iex> Map.get(hash, :hex)
[114, 179, 2, 191, 41, 122, 34, 138, 117, 115, 1, 35, 239, 239, 124, ... | lib/identicon_generator/identicon.ex | 0.90495 | 0.401512 | identicon.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.