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 Finitomata.Mermaid do
@moduledoc false
import NimbleParsec
alias Finitomata.Transition
use Boundary, deps: [Finitomata], exports: []
@alphanumeric [?a..?z, ?A..?Z, ?0..?9, ?_]
blankspace = ignore(ascii_string([?\s], min: 1))
semicolon = ignore(string(";"))
transition_op = string("-->")
... | lib/finitomata/parsers/mermaid.ex | 0.743168 | 0.471345 | mermaid.ex | starcoder |
defmodule Membrane.RTP.VP8.Frame do
@moduledoc """
Module resposible for accumulating data from RTP packets into VP8 frames
Implements loosely algorithm described here: https://tools.ietf.org/html/rfc7741#section-4.5
"""
alias Membrane.Buffer
alias Membrane.RTP.VP8.PayloadDescriptor
alias Membrane.RTP.VP... | lib/frame.ex | 0.765944 | 0.403302 | frame.ex | starcoder |
defmodule Cased.Event do
@moduledoc """
Data modeling a Cased audit event.
"""
import Norm
defstruct [:audit_trail, :id, :url, :data, :published_at, :processed_at]
@type t :: %__MODULE__{
audit_trail: Cased.AuditTrail.t(),
id: String.t(),
url: String.t(),
published_... | lib/cased/event.ex | 0.864968 | 0.447762 | event.ex | starcoder |
defmodule Earmark do
if Version.compare(System.version, "1.12.0") == :lt do
IO.puts(:stderr, "DEPRECATION WARNING: versions < 1.12.0 of Elixir are not tested anymore and will not be supported in Earmark v1.5")
end
@type ast_meta :: map()
@type ast_tag :: binary()
@type ast_attribute_name :: binary()
@... | lib/earmark.ex | 0.724675 | 0.574395 | earmark.ex | starcoder |
defmodule TextDelta.Iterator do
@moduledoc """
Iterator iterates over two sets of operations at the same time, ensuring next
elements in the resulting stream are of equal length.
"""
alias TextDelta.Operation
@typedoc """
Individual set of operations.
"""
@type set :: [Operation.t()]
@typedoc """... | lib/text_delta/iterator.ex | 0.885226 | 0.625281 | iterator.ex | starcoder |
defmodule AttributeRepository.Resource do
@moduledoc """
Convenience macro to create resource module that makes it fancier to use an
attribute repository
## Usage
Create a module that uses this module:
```elixir
defmodule Asteroid.Subject do
use AttributeRepository.Resource, otp_app: :asteroid
en... | lib/attribute_repository/resource.ex | 0.916236 | 0.573858 | resource.ex | starcoder |
defmodule Crutches.List do
@moduledoc ~s"""
Convenience functions for lists.
This module provides several convenience functions operating on lists.
Simply call any function (with any options if applicable) to make use of it.
"""
@doc ~S"""
Returns the tail of the `collection` from `position`.
## Exam... | lib/crutches/list.ex | 0.846133 | 0.606848 | list.ex | starcoder |
defmodule Stripe.Token do
@moduledoc """
Work with Stripe token objects.
You can:
- Create a token for a Connect customer with a card
- Create a token with all options - Only for Unit Tests with Stripe
- Retrieve a token
Does not yet render lists or take options.
Stripe API reference: https://stripe... | lib/stripe/token.ex | 0.802517 | 0.520984 | token.ex | starcoder |
defmodule Timex.Format.Time.Formatters.Humanized do
@moduledoc """
Handles formatting timestamp values as human readable strings.
For formatting timestamps as points in time rather than intervals,
use `DateFormat`
"""
use Timex.Format.Time.Formatter
@minute 60
@hour @minute * 60
@day @hour * 24
... | lib/format/time/formatters/humanized.ex | 0.933688 | 0.441372 | humanized.ex | starcoder |
defmodule Guardian.Token.Jwt do
@moduledoc """
Deals with things JWT
This module should not be used directly.
It is intended to be used by Guardian on behalf of your implementation
as it's token module.
Token types are encoded in the `typ` field.
### Configuration
Configuration should be added to the... | lib/guardian/token/jwt.ex | 0.869063 | 0.820937 | jwt.ex | starcoder |
defmodule Drab.Live do
@moduledoc """
Drab Module to provide a live access and update of assigns of the template, which is currently rendered and displayed
in the browser.
The idea is to reuse your Phoenix templates and let them live, to make a possibility to update assigns
on the living page, from the Elixi... | lib/drab/live.ex | 0.817028 | 0.741323 | live.ex | starcoder |
defmodule Exqlite.Pragma do
@moduledoc """
Handles parsing extra options for the SQLite connection
"""
def journal_mode(nil), do: journal_mode([])
def journal_mode(options) do
case Keyword.get(options, :journal_mode, :delete) do
:delete -> "DELETE"
:memory -> "MEMORY"
:off -> "OFF"
... | lib/exqlite/pragma.ex | 0.590425 | 0.438545 | pragma.ex | starcoder |
defmodule TelemetryMetricsStatsd do
@moduledoc """
`Telemetry.Metrics` reporter for StatsD-compatible metric servers.
To use it, start the reporter with the `start_link/1` function, providing it a list of
`Telemetry.Metrics` metric definitions:
import Telemetry.Metrics
TelemetryMetricsStatsd.star... | lib/telemetry_metrics_statsd.ex | 0.940285 | 0.689613 | telemetry_metrics_statsd.ex | starcoder |
defmodule Mix.Tasks.SyncGmailInbox do
use Mix.Task
@shortdoc "Script to test the upcoming Gmail inbox sync feature"
@moduledoc """
Example:
```
$ mix sync_gmail_inbox [ACCOUNT_ID]
$ mix sync_gmail_inbox [ACCOUNT_ID] [HISTORY_ID]
$ mix sync_gmail_inbox [ACCOUNT_ID] [HISTORY_ID] [LABEL_ID]
```
"""
... | lib/mix/tasks/sync_gmail_inbox.ex | 0.519278 | 0.603143 | sync_gmail_inbox.ex | starcoder |
defmodule Nebulex.Adapter.Persistence do
@moduledoc ~S"""
Specifies the adapter persistence API.
## Default implementation
This module provides a default implementation that uses `File` and `Stream`
under-the-hood. For dumping a cache to a file, the entries are streamed from
the cache and written in chunk... | lib/nebulex/adapter/persistence.ex | 0.819785 | 0.609321 | persistence.ex | starcoder |
defmodule Bureaucrat.SwaggerSlateMarkdownWriter do
@moduledoc """
This markdown writer integrates swagger information and outputs in a slate-friendly markdown format.
It requires that the decoded swagger data be available via Application.get_env(:bureaucrat, :swagger),
eg by passing it as an option to the Burea... | lib/bureaucrat/swagger_slate_markdown_writer.ex | 0.677154 | 0.475544 | swagger_slate_markdown_writer.ex | starcoder |
defmodule ApaDiv do
@moduledoc """
APA : Arbitrary Precision Arithmetic - Division - ApaDiv.
"""
# used in division to prevent the infinite loop
@precision_default Application.get_env(:apa, :precision_default, -1)
@precision_limit if @precision_default == -1, do: 28, else: @precision_default
# nearly cor... | lib/apa_div.ex | 0.753104 | 0.418222 | apa_div.ex | starcoder |
defmodule CanvasAPI.CanvasController do
use CanvasAPI.Web, :controller
alias CanvasAPI.CanvasService
plug CanvasAPI.CurrentAccountPlug when not action in [:show]
plug CanvasAPI.CurrentAccountPlug, [permit_none: true] when action in [:show]
plug :ensure_team when not action in [:show]
plug :ensure_user whe... | web/controllers/canvas_controller.ex | 0.675444 | 0.432123 | canvas_controller.ex | starcoder |
defmodule Protox.Message do
@moduledoc """
This module provides functions to work with messages.
"""
@doc """
Singular fields of `msg` will be overwritten, if specified in `from`, except for
embedded messages which will be merged. Repeated fields will be concatenated.
Note that "specified" has a differe... | lib/protox/message.ex | 0.867204 | 0.650842 | message.ex | starcoder |
defmodule Sanbase.Signal.SqlQuery do
@table "signals"
@metadata_table "signal_metadata"
@moduledoc ~s"""
Define the SQL queries to access the signals in Clickhouse
The signals are stored in the '#{@table}' Clickhouse table
"""
use Ecto.Schema
import Sanbase.DateTimeUtils, only: [str_to_sec: 1]
imp... | lib/sanbase/signal/sql_query/signal_sql_query.ex | 0.594787 | 0.450541 | signal_sql_query.ex | starcoder |
defmodule VintageNet.Connectivity.Inspector do
@moduledoc """
This module looks at the network activity of all TCP socket connections known
to Erlang/OTP to deduce whether the internet is working.
To use it, call `check_internet/2`, save the returned cache, and then call it
again a minute later (or so). If a... | lib/vintage_net/connectivity/inspector.ex | 0.792825 | 0.455199 | inspector.ex | starcoder |
defmodule HPAX.Types do
@moduledoc false
import Bitwise, only: [<<<: 2]
alias HPAX.Huffman
# This is used as a macro and not an inlined function because we want to be able to use it in
# guards.
defmacrop power_of_two(n) do
quote do: 1 <<< unquote(n)
end
## Encoding
@spec encode_integer(non_n... | lib/hpax/types.ex | 0.633297 | 0.421165 | types.ex | starcoder |
defmodule Gettext.Fuzzy do
@moduledoc false
alias Gettext.PO
alias Gettext.PO.Translation
alias Gettext.PO.PluralTranslation
@type translation_key :: binary | {binary, binary}
@doc """
Returns a matcher function that takes two translation keys and checks if they
match.
`String.jaro_distance/2` (wh... | deps/gettext/lib/gettext/fuzzy.ex | 0.853501 | 0.525978 | fuzzy.ex | starcoder |
defmodule Nanoid do
@moduledoc """
Elixir port of NanoID ([https://github.com/ai/nanoid](https://github.com/ai/nanoid)), a tiny, secure URL-friendly unique string ID generator.
**Safe.** It uses cryptographically strong random APIs and guarantees a proper distribution of symbols.
**Small.** Only 179 bytes (mi... | lib/nanoid.ex | 0.865622 | 0.776835 | nanoid.ex | starcoder |
defmodule Cldr.Rfc5646.Parser do
@moduledoc """
Implements parsing for [RFC5646](https://datatracker.ietf.org/doc/html/rfc5646) language
tags with [BCP47](https://tools.ietf.org/search/bcp47) extensions.
The primary interface to this module is the function
`Cldr.LanguageTag.parse/1`.
"""
alias Cldr.La... | lib/cldr/language_tag/rfc5646_parser.ex | 0.873404 | 0.542863 | rfc5646_parser.ex | starcoder |
defmodule NewRelicAddons.Decorators do
@moduledoc """
Provides easy-to-use stackable decorators for the official New Relic library.
## Features
- decorators are stackable with others e.g. from other libraries
- allows to hide args in event tracer via `hide_args` option
- includes transaction tracer with p... | lib/new_relic_addons/decorators.ex | 0.813016 | 0.430566 | decorators.ex | starcoder |
defmodule Ecto.LoggerJSON do
@moduledoc """
Keep in sync with https://github.com/elixir-ecto/ecto/blob/master/lib/ecto/log_entry.ex
Struct used for logging entries.
It is composed of the following fields:
* query - the query as string or a function that when invoked resolves to string;
* source - the q... | lib/ecto/logger_json.ex | 0.903502 | 0.504333 | logger_json.ex | starcoder |
defmodule PolicrMini.StatisticBusiness do
@moduledoc """
用户业务功能的实现。
"""
use PolicrMini, business: PolicrMini.Schema.Statistic
import Ecto.Query, only: [from: 2]
@type status :: :passed | :timeout | :wronged | :other
@spec create(map) :: written_returns
def create(params) do
%Statistic{} |> Stati... | lib/policr_mini/businesses/statistic_business.ex | 0.508788 | 0.425247 | statistic_business.ex | starcoder |
defmodule BlockBox.LayoutBlocks do
@moduledoc """
Defines generator functions for all [layout blocks](https://api.slack.com/reference/block-kit/blocks).
"""
alias BlockBox.CompositionObjects, as: CO
alias BlockBox.Utils, as: Utils
@doc """
Creates a [section block](https://api.slack.com/reference/block-... | lib/layout_blocks.ex | 0.864996 | 0.506164 | layout_blocks.ex | starcoder |
defmodule QuantumStorageMnesia.Impl do
@moduledoc false
alias QuantumStorageMnesia.{Mnesia, State}
require Mnesia
@spec init(module) :: State.t()
def init(name) do
nodes = [node()]
Mnesia.create_module(name)
Mnesia.Table.create!(name, nodes)
State.new(name)
end
@spec jobs(State.t()) ... | lib/quantum_storage_mnesia/impl.ex | 0.762247 | 0.483892 | impl.ex | starcoder |
defmodule TicTacToeBoard do
@moduledoc """
Board logic for TicTacToe game
"""
defguard allowed_position_number?(value) when is_integer(value) and value >= 1 and value <= 9
@max_positions 9
@typedoc "Board position value type"
@type position_value :: nil | :x | :o
@typedoc "Board mapping type"
@typ... | lib/tic_tac_toe_board.ex | 0.903294 | 0.698495 | tic_tac_toe_board.ex | starcoder |
defmodule Day18 do
@moduledoc """
AoC 2019, Day 18 - Many-Worlds Interpretation
"""
defmodule Maze do
defstruct map: %{}, start: []
end
@doc """
Shortest path that collects all the keys
"""
def part1 do
Util.priv_file(:day18, "day18_input.txt")
|> File.read!()
|> shortest_path()
en... | apps/day18/lib/day18.ex | 0.721253 | 0.486514 | day18.ex | starcoder |
defmodule Axon.Training do
@moduledoc """
Abstractions for training machine learning models.
"""
require Axon
require Axon.Updates
@doc """
Represents a single training step.
It expects a pair of 2-element tuples:
* The first pair contains the model initialization function
and the objectiv... | lib/axon/training.ex | 0.935317 | 0.835685 | training.ex | starcoder |
defmodule StepFlow.Jobs.Status do
use Ecto.Schema
import Ecto.Changeset
import EctoEnum
alias StepFlow.Jobs.Job
alias StepFlow.Jobs.Status
alias StepFlow.Repo
@moduledoc false
defenum(StateEnum, [
"queued",
"skipped",
"processing",
"retrying",
"error",
"completed",
"ready_... | lib/step_flow/jobs/status.ex | 0.536313 | 0.452778 | status.ex | starcoder |
defmodule Xema.Behaviour do
@moduledoc """
A behaviour module for implementing a schema validator. This behaviour is
just for `Xema` and `JsonXema`.
"""
alias Xema.{
JsonSchema,
Loader,
Ref,
Schema,
SchemaError,
Utils,
ValidationError,
Validator
}
@typedoc """
The schem... | lib/xema/behaviour.ex | 0.905823 | 0.482856 | behaviour.ex | starcoder |
defmodule AWS.Connect do
@moduledoc """
Amazon Connect is a cloud-based contact center solution that makes it easy
to set up and manage a customer contact center and provide reliable
customer engagement at any scale.
Amazon Connect provides rich metrics and real-time reporting that allow you
to optimize c... | lib/aws/generated/connect.ex | 0.770551 | 0.512144 | connect.ex | starcoder |
defmodule ParallelStream.Filter do
alias ParallelStream.FilterExecutor
alias ParallelStream.Producer
@moduledoc ~S"""
The filter iterator implementation
"""
defmodule Consumer do
@moduledoc ~S"""
The filter consumer - filters according to direction passed
"""
def build!(stream, direction)... | data/web/deps/parallel_stream/lib/parallel_stream/filter.ex | 0.892627 | 0.501099 | filter.ex | starcoder |
defmodule ShouldI do
@moduledoc """
ShouldI is a testing DSL around ExUnit.
ShouldI supports having blocks for nested contexts,
convenience apis for behavioral naming.
## Examples
defmodule MyFatTest do
having "necessary_key" do
setup context do
assign context,
... | lib/shouldi.ex | 0.834238 | 0.548492 | shouldi.ex | starcoder |
defmodule Dashwallet.Parser do
require Logger
@doc """
Maps a trailwallet data row into a `Map`.
Returns a parsed `Map`.
"""
def map_csv([
trip, date, local_currency, local_amount, home_currency,
home_amount, category, notes, tags, image
]) do
%{
trip: trip,
date: date,
loc... | lib/dashwallet/parser/parser.ex | 0.83622 | 0.519887 | parser.ex | starcoder |
defmodule Instruments.Probe.Definitions do
@moduledoc false
use GenServer
alias Instruments.Probe
alias Instruments.Probe.Errors
@type definition_errors :: {:error, {:probe_names_taken, [String.t()]}}
@type definition_response :: {:ok, [String.t()]} | definition_errors
@probe_prefix Application.get_env... | lib/probe/definitions.ex | 0.803752 | 0.425456 | definitions.ex | starcoder |
defmodule Ecto.Validator.Predicates do
@moduledoc """
A handful of predicates to be used in validations.
The examples in this module use the syntax made
available via `Ecto.Model.Validations` in your
model.
"""
@type maybe_error :: [] | Keyword.t
@blank [nil, "", []]
@doc """
Validates the attrib... | lib/ecto/validator/predicates.ex | 0.893391 | 0.53868 | predicates.ex | starcoder |
defmodule Nebulex.Adapters.Partitioned do
@moduledoc ~S"""
Built-in adapter for partitioned cache topology.
A partitioned cache is a clustered, fault-tolerant cache that has linear
scalability. Data is partitioned among all the machines of the cluster.
For fault-tolerance, partitioned caches can be configure... | lib/nebulex/adapters/partitioned.ex | 0.890223 | 0.729207 | partitioned.ex | starcoder |
defmodule Braintree.TransactionLineItem do
@moduledoc """
For fetching line items for a given transaction.
https://developers.braintreepayments.com/reference/response/transaction-line-item/ruby
"""
use Braintree.Construction
alias Braintree.HTTP
alias Braintree.ErrorResponse, as: Error
@type t :: %_... | lib/transaction_line_item.ex | 0.915157 | 0.441191 | transaction_line_item.ex | starcoder |
defmodule Sushi.Schemas.Boat do
import Ecto.Changeset
use Ecto.Schema
@type t :: %__MODULE__{
x: Integer.t(),
y: Integer.t(),
length: Integer.t(),
rot: String.t(),
sunk: boolean()
}
@primary_key false
embedded_schema do
field(:x, :integer)
field(:y, :integer)
field(:length... | pancake/lib/sushi/schemas/boat.ex | 0.675015 | 0.474266 | boat.ex | starcoder |
defmodule WechatPay.Utils.Signature do
@moduledoc """
Module to sign data
"""
alias WechatPay.Error
alias WechatPay.JSON
require JSON
@doc """
Generate the signature of data with API key
## Example
```elixir
iex> WechatPay.Utils.Signature.sign(%{...}, "wx9999")
...> "02696FC7E3E19F852A0335F... | lib/wechat_pay/utils/signature.ex | 0.843863 | 0.779993 | signature.ex | starcoder |
defmodule Searchex.Command.Search.Bm25 do
@moduledoc false
@num_docs 100
@avg_doc_token_len 100
@doc_token_len 100
@term_freq_tuning_factor 1.2
@doc_len_tuning_param 0.72
@doc """
Document Scores
terms looks like:
["term1", "term2"]
doc_matches looks like:
[{"term1", %{"doc... | lib/searchex/command/search/bm25.ex | 0.654122 | 0.529568 | bm25.ex | starcoder |
defmodule Univrse.Alg.AES_GCM do
@moduledoc """
AES_GCM algorithm module.
Sign and encrypt messages using AES-GCM symetric encryption.
"""
alias Univrse.Key
@doc """
Decrypts the cyphertext with the key using the specified algorithm.
Accepted options:
* `aad` - Ephemeral public key
* `iv` - Agr... | lib/univrse/alg/aes_gcm.ex | 0.755366 | 0.451992 | aes_gcm.ex | starcoder |
defmodule AWS.CodeBuild do
@moduledoc """
AWS CodeBuild
AWS CodeBuild is a fully managed build service in the cloud. AWS CodeBuild
compiles your source code, runs unit tests, and produces artifacts that are
ready to deploy. AWS CodeBuild eliminates the need to provision, manage,
and scale your own build s... | lib/aws/code_build.ex | 0.765199 | 0.579847 | code_build.ex | starcoder |
defmodule Semver do
@moduledoc """
Utilities for working with [semver.org](http://semver.org)-compliant version strings.
"""
@vsn File.read!("VERSION") |> String.strip
@pattern ~r"""
^v?
(?<major>0|[1-9]\d*)\.
(?<minor>0|[1-9]\d*)\.
(?<patch>0|[1-9]\d*)
... | lib/semver.ex | 0.817356 | 0.528533 | semver.ex | starcoder |
defmodule Forma.Typespecs do
def compile(module) do
module
|> Code.Typespec.fetch_types()
|> case do
{:ok, types} ->
types
# coveralls-ignore-start
:error ->
raise "Code.Typespec.fetch_types(#{module}) error"
# coveralls-ignore-end
end
|> rewrite(module)
... | lib/forma/typespecs.ex | 0.611266 | 0.432363 | typespecs.ex | starcoder |
defmodule Aecore.Channel.ChannelOffChainUpdate do
@moduledoc """
Behaviour that states all the necessary functions that every update of the offchain state should implement.
This module implements helpers for applying updates to an offchain chainstate
"""
alias Aecore.Chain.Chainstate
alias Aecore.Channel.... | apps/aecore/lib/aecore/channel/channel_off_chain_update.ex | 0.885012 | 0.496765 | channel_off_chain_update.ex | starcoder |
defmodule Type.Function.Var do
@moduledoc """
a special container type indicating that the function has a type dependency.
### Example:
The following typespec:
```elixir
@spec identity(x) :: x when x: var
```
generates the following typespec:
```elixir
%Type.Function{
params: [%Type.Functio... | lib/type/function.var.ex | 0.928466 | 0.924756 | function.var.ex | starcoder |
defmodule Cassandra.Ecto.Migration do
@moduledoc """
Implements `Ecto.Adapter.Migration` behaviour.
## Defining Cassandra migrations
Your migration module should use `Cassandra.Ecto.Migration` instead of
`Ecto.Migration` to be able to use additional features.
Any table must have option `primary_key: fals... | lib/cassandra_ecto/migration.ex | 0.845672 | 0.528959 | migration.ex | starcoder |
defmodule EctoIPRange.IP6R do
@moduledoc """
Struct for PostgreSQL `:ip6r`.
## Usage
When used during a changeset cast the following values are accepted:
- `:inet.ip6_address()`: an IP6 tuple, e.g. `{8193, 3512, 34211, 0, 0, 35374, 880, 29492}` (single address only)
- `binary`
- `"2001:0db8:85a3:0000... | lib/ecto_ip_range/ip6r.ex | 0.879199 | 0.539347 | ip6r.ex | starcoder |
defmodule Zigler.Parser.Nif do
@moduledoc """
This datastructure represents structured information about a single nif
inside of a `Zigler.sigil_Z/2` block. This is used to generate the
`exported_nifs` variable which is an array of `ErlNifFunc` structs. The
following keys are implemented:
- name: (`t:ato... | lib/zigler/parser/nif.ex | 0.716516 | 0.539408 | nif.ex | starcoder |
defmodule SimpleBayes.Tokenizer do
@doc """
Converts a string into a list of words.
## Examples
iex> SimpleBayes.Tokenizer.tokenize("foobar")
["foobar"]
iex> SimpleBayes.Tokenizer.tokenize("foo bar")
["foo", "bar"]
iex> SimpleBayes.Tokenizer.tokenize(",foo bar .")
["foo",... | lib/simple_bayes/tokenizer.ex | 0.83752 | 0.459804 | tokenizer.ex | starcoder |
defmodule Maru.Params.Types.DateTime do
@moduledoc """
Buildin Type: DateTime
## Parser Arguments
* `:format` - how to parse a datetime value
* `:iso8601` - parse by `DateTime.from_iso8601/2` or `NaiveDateTime.from_iso8601/2`
* `{:unix, unit}` - parse by `DateTime.from_unix/2`
* `:u... | lib/maru/params/types/datetime.ex | 0.902313 | 0.67848 | datetime.ex | starcoder |
defmodule Expublish do
@moduledoc """
Main module putting everything together:
```
def major do
Tests.run!()
:major
|> Project.get_version!()
|> Semver.increase!()
|> Project.update_version!()
|> Changelog.write_entry!()
|> Git.commit_and_tag()
|> Git.push()
|> Hex.publish(... | lib/expublish.ex | 0.697609 | 0.52275 | expublish.ex | starcoder |
defmodule Benchmark do
@moduledoc """
Benchmarks the CPU and Memory consumption for struct operations
with type checking comparing to native ones.
"""
alias Benchmark.{Inputs, Samples, Tweet}
def run do
count = 10_000
puts_title("Generate #{count} inputs, may take a while.")
list = Enum.take(... | benchmark/lib/benchmark.ex | 0.784732 | 0.464416 | benchmark.ex | starcoder |
defmodule Slack.Channel do
@moduledoc """
A publicly listed communication channel in a team
"""
@base "channels"
use Slack.Request
@doc """
Archive a channel.
https://api.slack.com/methods/channels.archive
## Examples
Slack.client(token)
|> Slack.Channel.archive(channel: "C123456... | lib/slack/channel.ex | 0.802323 | 0.493775 | channel.ex | starcoder |
defmodule ExWikipedia do
@moduledoc """
`ExWikipedia` is an Elixir client for the [Wikipedia API](https://en.wikipedia.org/w/api.php).
"""
alias ExWikipedia.Page
@callback fetch(input :: integer(), opts :: keyword()) :: {:ok, map()} | {:error, any()}
@doc """
Accepts an integer (or a binary representati... | lib/ex_wikipedia.ex | 0.841696 | 0.453201 | ex_wikipedia.ex | starcoder |
defmodule Cog.Commands.Tee do
use Cog.Command.GenCommand.Base,
bundle: Cog.Util.Misc.embedded_bundle
require Logger
alias Cog.Command.Service.MemoryClient
alias Cog.Command.Service.DataStore
@data_namespace [ "commands", "tee" ]
@description "Save and pass through pipeline data"
@long_description... | lib/cog/commands/tee.ex | 0.748812 | 0.445107 | tee.ex | starcoder |
defmodule AOC.Day4 do
@moduledoc """
https://adventofcode.com/2018/day/4
"""
@doc """
iex> AOC.Day4.part_1([
...> %{
...> action: ["Guard", "#10", "begins", "shift"],
...> time: ~N[1518-11-01 00:00:00.000]
...> },
...> %{action: ["falls", "asleep"], time: ~N[1518-11-01 00:05:00.000]},
..... | lib/day_4.ex | 0.551815 | 0.52074 | day_4.ex | starcoder |
defmodule Exi.ConnectServer do
@moduledoc """
Nerves起動時に `Node.connect()` を受け入れるための準備をする。
## 使い方
application.exに以下を記載する。
```
{Exi.ConnectServer, [node_name, cookie]}
```
- node_name: 自分のノード名
- cookie: クッキー(共通鍵)
## 例
```
{Exi.ConnectServer, ["my_node_name", "comecomeeverybody"]}
```
""... | dio/exibee/lib/exi/exi_connect_server.ex | 0.706494 | 0.687964 | exi_connect_server.ex | starcoder |
defmodule Xalsa do
@moduledoc """
Elixir ALSA connector. The Xalsa module implements the API.
The client may send any number of frames as a binary array of 32 bit floats and may
optionally receive back a notification in form of a :ready4more message 5-10 ms
before all frames are consumed by the ALSA driver.
... | lib/xalsa.ex | 0.90704 | 0.451024 | xalsa.ex | starcoder |
defmodule TimeDiscountRate.Host do
alias TimeDiscountRate.Main
defp ensure_integer(integer) when is_integer(integer), do: integer
defp ensure_integer(str), do: Integer.parse(str) |> elem(0)
defp ensure_float(float) when is_float(float), do: float
defp ensure_float(str), do: Float.parse(str) |> elem(0)
def... | lib/host.ex | 0.553505 | 0.428174 | host.ex | starcoder |
defmodule I18n2Elm.Types do
@moduledoc ~S"""
Specifies the main Elixir types used for describing the
intermediate representations of i18n resources.
"""
defmodule Translation do
@moduledoc ~S"""
Represents a parsed translation file.
JSON:
# da_DK.json
{
"Yes": "Ja",
... | lib/types.ex | 0.750095 | 0.424859 | types.ex | starcoder |
defmodule ISO8583.Bitmap do
alias ISO8583.Utils
@moduledoc """
This module is for building the bitmaps. It supports both Primary, Secondary and Tertiary bitmaps for fields `0-127`. You can also
use the same module to build bitamps for extended fields like `127.0-39` and `127.25.0-33`
"""
@doc """
Funct... | lib/iso_8583/bitmap/bitmap.ex | 0.865807 | 0.42662 | bitmap.ex | starcoder |
defmodule ExUnitAssertMatch do
@moduledoc """
Provedes functionality to assert that given data structure is as expected.
The usage is on [README](./readme.html#usage).
"""
alias ExUnitAssertMatch.{Type, Types, Option, InternalState}
@doc """
Assert that given `data` match `type` specification.
a... | lib/ex_unit_assert_match.ex | 0.873276 | 0.8398 | ex_unit_assert_match.ex | starcoder |
defmodule Mailroom.IMAP.BodyStructure do
defmodule Part do
defstruct section: nil,
params: %{},
multipart: false,
type: nil,
id: nil,
description: nil,
encoding: nil,
encoded_size: nil,
disposition: nil... | lib/mailroom/imap/body_structure.ex | 0.508788 | 0.40539 | body_structure.ex | starcoder |
defmodule StrawHat.Review.Review do
@moduledoc """
Represents a Review Ecto Schema.
"""
use StrawHat.Review.Schema
alias StrawHat.Review.{Comment, Media, ReviewAspect, ReviewReaction}
@typedoc """
- `reviewee_id`: The object or user that receive the review.
- `reviewer_id`: The user that make the comm... | lib/straw_hat_review/reviews/review.ex | 0.796213 | 0.462291 | review.ex | starcoder |
defmodule SteamEx.IEconService do
@moduledoc """
Additional Steam Economy methods that provide access to Steam Trading.
**NOTE:** This is a Service interface, methods in this interface should be called with the `input_json` parameter.
For more info on how to use the Steamworks Web API please see the [Web API ... | lib/interfaces/i_econ_service.ex | 0.712932 | 0.537163 | i_econ_service.ex | starcoder |
defmodule AdventOfCode2019.FlawedFrequencyTransmission do
@moduledoc """
Day 16 — https://adventofcode.com/2019/day/16
"""
@base_pattern [0, 1, 0, -1]
@spec part1(Enumerable.t()) :: binary
def part1(in_stream) do
in_stream
|> read_input_signal()
|> repeat_phases(100)
|> Stream.take(8)
... | lib/advent_of_code_2019/day16.ex | 0.823115 | 0.470676 | day16.ex | starcoder |
defmodule Geo.Turf.Math do
@moduledoc """
All sorts of mathematical functions
"""
@type si_length_uk :: :meters | :kilometers | :centimeters | :millimeters
@type si_length_us :: :metres | :kilometres | :centimetres | :millimetres
@type imperial_length :: :miles | :nauticalmiles | :inches | :yards | :feet
... | lib/geo/turf/math.ex | 0.867233 | 0.809803 | math.ex | starcoder |
defmodule Membrane.RTP.VAD do
@moduledoc """
Simple vad based on audio level sent in RTP header.
To make this module work appropriate RTP header extension has to be set in SDP offer/answer.
If avg of audio level in packets in `time_window` exceeds `vad_threshold` it emits
notification `t:speech_notification... | lib/membrane/rtp/vad.ex | 0.833968 | 0.505737 | vad.ex | starcoder |
defmodule Traverse.Fn do
use Traverse.Types
@moduledoc """
Implements convenience functions, and function wrappers to complete
partial functions.
The latter is done by catching `FunctionClauseError`.
iex> partial = fn x when is_atom(x) -> to_string(x) end
...> complete = Traverse.Fn.... | lib/traverse/fn.ex | 0.723505 | 0.706558 | fn.ex | starcoder |
defmodule Toml.Test.JsonConverter do
@moduledoc false
def parse_toml_file!(path) do
case Toml.decode_file(path) do
{:ok, map} ->
Jason.encode!(to_typed_map(map), pretty: true)
{:error, _} = err ->
err
end
end
def parse_json_file!(path) do
Jason.decode!(File.read!(path)... | test/support/converter.ex | 0.577257 | 0.515986 | converter.ex | starcoder |
defmodule Geo.WKB.Encoder do
@moduledoc false
@point 0x00_00_00_01
@point_m 0x40_00_00_01
@point_z 0x80_00_00_01
@point_zm 0xC0_00_00_01
@line_string 0x00_00_00_02
@line_string_z 0x80_00_00_02
@polygon 0x00_00_00_03
@polygon_z 0x80_00_00_03
@multi_point 0x00_00_00_04
@multi_point_z 0x80_00_00_04
... | lib/geo/wkb/encoder.ex | 0.531453 | 0.700396 | encoder.ex | starcoder |
defmodule Stream do
@moduledoc """
Functions for creating and composing streams.
Streams are composable, lazy enumerables (for an introduction on
enumerables, see the `Enum` module). Any enumerable that generates
elements one by one during enumeration is called a stream. For example,
Elixir's `Range` is a ... | lib/elixir/lib/stream.ex | 0.88856 | 0.775562 | stream.ex | starcoder |
defmodule Stellar.Base.StrKey do
@moduledoc false
# Logic copied from https://github.com/stellar/js-stellar-base/blob/master/src/strkey.js
import Bitwise
@version_bytes %{
# G
ed25519PublicKey: 6 <<< 3,
# S
ed25519SecretSeed: 18 <<< 3,
# T
preAuthTx: 19 <<< 3,
# X
sha256Hash: ... | lib/stellar/base/str_key.ex | 0.832849 | 0.502075 | str_key.ex | starcoder |
defmodule Azalea.Zipper do
@moduledoc """
A zipper is an omni-directionally traversable wrapper around a tree that focuses on a single node, but stores enough data
to be able to reconstruct the entire tree from that point.
`Azalea.Zipper` provides such a wrapper around `Azalea.Tree`, using a stack of `Azal... | lib/azalea/zipper.ex | 0.914434 | 0.728833 | zipper.ex | starcoder |
defmodule Easypost.Client do
@moduledoc """
Access the Easypost API from Elixir using maps and returning structs
##Usage:
First, add test key to config/test.exs and config/dev.exs like this:
config :myapp, easypost_endpoint: "https://api.easypost.com/v2/",
easypost_key: "your test ... | lib/client.ex | 0.698741 | 0.501404 | client.ex | starcoder |
defmodule Pair2.Matcher do
@moduledoc """
Rules-based matcher for finding optimal 1:1 matches between two lists of maps.
"""
alias Pair2.{
Comparer,
Index
}
@doc """
Performs 1:1 match of two lists of maps, list_l and list_r, by applying
rules from a list of rule structs. For two maps to match... | lib/matcher.ex | 0.84966 | 0.580471 | matcher.ex | starcoder |
defmodule Artificery.Console.Table do
@moduledoc """
A printer for tabular data.
"""
@doc """
Given a title, header, and rows, prints the data as a table.
Takes the same options as `format/4`.
"""
def print(title, header, rows, opts \\ []) do
IO.write(format(title, header, rows, opts))
end
@d... | lib/console/table.ex | 0.756807 | 0.599895 | table.ex | starcoder |
defmodule Boundary.Classifier do
@moduledoc false
@type t :: %{boundaries: %{Boundary.name() => Boundary.t()}, modules: %{module() => Boundary.name()}}
@spec new :: t
def new, do: %{boundaries: %{}, modules: %{}}
@spec delete(t, atom) :: t
def delete(classifier, app) do
boundaries_to_delete =
c... | lib/boundary/classifier.ex | 0.806167 | 0.4206 | classifier.ex | starcoder |
defmodule Phoenix.Router.Route do
# This module defines the Route struct that is used
# throughout Phoenix's router. This struct is private
# as it contains internal routing information.
@moduledoc false
alias Phoenix.Router.Route
@doc """
The `Phoenix.Router.Route` struct. It stores:
* :verb - the... | lib/phoenix/router/route.ex | 0.790207 | 0.478224 | route.ex | starcoder |
defmodule Mix.Triplex do
@moduledoc """
Useful functions for any triplex mix task.
Here is the list of tasks we have for now:
- [`mix triplex.gen.migration`](./Mix.Tasks.Triplex.Gen.Migration.html) -
generates a tenant migration for the repo
- [`mix triplex.migrate`](./Mix.Tasks.Triplex.Migrate.html) -
... | lib/mix/triplex.ex | 0.859147 | 0.55097 | triplex.ex | starcoder |
defmodule Matrex.IDX do
@moduledoc false
# IDX format data types
@unsigned_byte 0x08
@signed_byte 0x09
@short 0x0B
@integer 0x0C
@float 0x0D
@double 0x0E
@spec load(binary) :: binary
def load(data) when is_binary(data) do
<<0, 0, data_type, dimensions_count>> = binary_part(data, 0, 4)
dime... | lib/matrex/idx.ex | 0.584034 | 0.420957 | idx.ex | starcoder |
defmodule AWS.KinesisAnalyticsV2 do
@moduledoc """
Amazon Kinesis Data Analytics is a fully managed service that you can use to
process and analyze streaming data using Java, SQL, or Scala.
The service enables you to quickly author and run Java, SQL, or Scala code
against streaming sources to perform time s... | lib/aws/generated/kinesis_analytics_v2.ex | 0.895154 | 0.57344 | kinesis_analytics_v2.ex | starcoder |
defexception Dynamo.Router.InvalidSpecError, message: "invalid route specification"
defmodule Dynamo.Router.Utils do
@moduledoc false
@doc """
Convert a given verb to its connection representation.
"""
def normalize_verb(verb) do
String.upcase(to_string(verb))
end
@doc """
Generates a representat... | lib/dynamo/router/utils.ex | 0.845544 | 0.531088 | utils.ex | starcoder |
defmodule Numerix.Tensor do
@moduledoc """
Defines a data structure for a tensor and its operations.
You can construct a `Tensor` by calling `Tensor.new/1` and passing it a list, or a list of lists, or a list of lists of...you get the idea.
Example
use Numerix.Tensor
x = Tensor.new([[1, 2, 3], [... | lib/tensor.ex | 0.949389 | 0.880026 | tensor.ex | starcoder |
defmodule StateMachine.Ecto do
@moduledoc """
This addition makes StateMachine fully compatible with Ecto.
State setter and getter are abstracted in order to provide a way to update a state
in the middle of transition for a various types of models. With Ecto, we call `change() |> Repo.update`.
We also wrap e... | lib/state_machine/ecto.ex | 0.81637 | 0.545588 | ecto.ex | starcoder |
defmodule OpcUA.NodeId do
use IsEnumerable
use IsAccessible
@moduledoc """
An identifier for a node in the address space of an OPC UA Server.
An OPC UA information model is made up of nodes and references between nodes.
Every node has a unique NodeId. NodeIds refer to a namespace with an additional
iden... | lib/opc_ua/nodestore/node_id.ex | 0.619932 | 0.433862 | node_id.ex | starcoder |
defmodule Cog.Queries.User do
import Ecto.Query, only: [from: 2, where: 3]
alias Cog.Models.Permission
alias Cog.Models.User
@doc """
Given a `token`, find the User it belongs to. `ttl_in_seconds` is
the current amount of time that a token can be considered valid; if
it was inserted more than `ttl_in_s... | lib/cog/queries/user.ex | 0.604983 | 0.438304 | user.ex | starcoder |
defmodule Graphmath.Mat44 do
@moduledoc """
This is the 3D mathematics library for graphmath.
This submodule handles 4x4 matrices using tuples of floats.
"""
@type mat44 ::
{float, float, float, float, float, float, float, float, float, float, float, float,
float, float, float, float}
... | lib/graphmath/Mat44.ex | 0.956022 | 0.902481 | Mat44.ex | starcoder |
defmodule AWS.OpsWorksCM do
@moduledoc """
AWS OpsWorks CM
AWS OpsWorks for configuration management (CM) is a service that runs and
manages configuration management servers.
You can use AWS OpsWorks CM to create and manage AWS OpsWorks for Chef Automate
and AWS OpsWorks for Puppet Enterprise servers, an... | lib/aws/generated/ops_works_cm.ex | 0.892363 | 0.435541 | ops_works_cm.ex | starcoder |
defmodule Segment.Analytics.Sender do
@moduledoc """
The `Segment.Analytics.Sender` service implementation is an alternative to the default Batcher to send every event as it is called.
The HTTP call is made with an async `Task` to not block the GenServer. This will not guarantee ordering.
The `Segment.An... | lib/segment/sender.ex | 0.823754 | 0.433802 | sender.ex | starcoder |
defmodule Esperanto.Walker do
@moduledoc """
Walker is used to go through input couting line and columns.
Every parser is responsible to walk and leave the walker in the state he can continue
"""
alias Esperanto.Barriers.NeverMatchBarrier
require Logger
defstruct [:input, rest: "", line: 1, column: 1, b... | apps/esperanto/lib/trybe/esperanto/walker.ex | 0.826362 | 0.569523 | walker.ex | starcoder |
defmodule Openstex.Keystone.V2.Helpers do
@moduledoc ~s"""
A module that provides helper functions for executing more complex multi-step queries
for Keystone authentication.
See the `ExOvh` library for an example usage of the helpers module.
"""
alias Openstex.Request
alias Openstex.Keystone.V2
alias O... | lib/openstex/keystone/v2/helpers.ex | 0.941005 | 0.729631 | helpers.ex | starcoder |
defprotocol Timex.Protocol do
@moduledoc """
This protocol defines the API for functions which take a `Date`,
`NaiveDateTime`, or `DateTime` as input.
"""
@doc """
Convert a date/time value to a Julian calendar date number
"""
def to_julian(datetime)
@doc """
Convert a date/time value to gregorian... | elixir/codes-from-books/little-elixir/cap8/blitzy/deps/timex/lib/protocol.ex | 0.908911 | 0.746139 | protocol.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.