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 ExSpec do
@moduledoc """
ExSpec is a simple wrapper around ExUnit that adds Rspec-style macros. Specifically, it adds `context` and `it`.
While it takes inspiration from Rspec, ExSpec is significantly simplier. The `context` macro has only two functions:
1. Aid test organization
2. Prepend to the ... | lib/ex_spec.ex | 0.867401 | 0.717952 | ex_spec.ex | starcoder |
defmodule DataDaemon.Decorators do
@moduledoc ~S"""
Decorators.
"""
@doc false
@spec enable :: term
def enable do
quote do
@doc unquote(@moduledoc)
defmacro __using__(opts \\ []) do
tags = Keyword.put(opts[:tags] || [], :module, inspect(__CALLER__.module))
quote location: :... | lib/data_daemon/decorators.ex | 0.842976 | 0.464962 | decorators.ex | starcoder |
defmodule CachexMemoize do
@moduledoc """
## CachexMemoize
CachexMemoize provides straightforward memoization macros using Cachex as a backend.
## How to memoize
If you want to cache a function, `use CachexMemoize` on the module and change `def` to `defmemo` and specify a cache.
IMPORTANT! If your cache ... | lib/cachex_memoize.ex | 0.858036 | 0.892281 | cachex_memoize.ex | starcoder |
defprotocol Kalevala.Brain.Node do
@moduledoc """
Process a node in the behavior tree
"""
def run(node, conn, event)
end
defmodule Kalevala.Brain.NullNode do
@moduledoc """
A no-op node
"""
defstruct []
defimpl Kalevala.Brain.Node do
def run(_node, conn, _event), do: conn
end
end
defmodule ... | lib/kalevala/brain.ex | 0.821008 | 0.639455 | brain.ex | starcoder |
defmodule Meta.Intro do
@moduledoc """
## AST
Types that are preserved as is in the AST:
atoms, integers, floats, lists, strings,
and any two-element tuples containing the former types
## Useful functions
- `Code.eval_quoted` - evalutes quoted expression
- `Macro.expand_once/2` - expands macros once
... | lib/meta/intro.ex | 0.780035 | 0.437583 | intro.ex | starcoder |
defmodule ChatApi.Intercom do
@moduledoc """
The Intercom context.
"""
import Ecto.Query, warn: false
alias ChatApi.Repo
alias ChatApi.Intercom.IntercomAuthorization
@spec list_intercom_authorizations() :: [IntercomAuthorization.t()]
def list_intercom_authorizations() do
Repo.all(IntercomAuthoriza... | lib/chat_api/intercom.ex | 0.73678 | 0.441191 | intercom.ex | starcoder |
defmodule Timex.DateFormat.Formats do
@moduledoc """
This module defines all known (by timex) common date/time formats, in macro form.
Each format is returned as the following structure:
[tokenizer: <module this format string will be tokenized with (expects a tokenize/1 def)>,
format: <format as a (... | lib/dateformat/formats.ex | 0.907204 | 0.593668 | formats.ex | starcoder |
defmodule Raft.Server do
@moduledoc """
Implementation for the raft server
"""
alias Raft.PG
alias Raft.State
require Logger
@key :raft
@cluster_size Application.get_env(:ex_venture, :cluster)[:size]
@winner_subscriptions [Game.World.Master, Raft.Server]
@check_election_timeout 1500
def debug(... | lib/raft/server.ex | 0.729327 | 0.519521 | server.ex | starcoder |
defmodule Mix.Tasks.Ggity.Visual.Geom.Point do
@shortdoc "Launch a browser and draw sample point geom plots."
@moduledoc @shortdoc
use Mix.Task
alias GGity.{Examples, Plot}
@default_browser "firefox"
@doc false
@spec run(list(any)) :: any()
def run([]), do: run([@default_browser])
def run(argv) d... | lib/mix/tasks/ggity_visual_geom_point.ex | 0.868339 | 0.487246 | ggity_visual_geom_point.ex | starcoder |
defmodule Zaryn.Election.StorageConstraints do
@moduledoc """
Represents the constraints for the storage nodes election
"""
defstruct [
:min_geo_patch,
:min_geo_patch_average_availability,
:number_replicas
]
alias Zaryn.Election.HypergeometricDistribution
alias Zaryn.P2P.Node
@default_mi... | lib/zaryn/election/constraints/storage.ex | 0.858392 | 0.534795 | storage.ex | starcoder |
defmodule Flop.Cursor do
@moduledoc """
Functions for encoding, decoding and extracting cursor values.
"""
@doc """
Encodes a cursor value.
iex> Flop.Cursor.encode(%{name: "Peter", email: "<EMAIL>"})
"g3QAAAACZAAFZW1haWxtAAAACnBldGVyQG1haWxkAARuYW1lbQAAAAVQZXRlcg=="
"""
@doc since: "0.8.0"
... | lib/flop/cursor.ex | 0.858214 | 0.412767 | cursor.ex | starcoder |
defmodule ExOauth2Provider.Authorization.Code do
@moduledoc """
Methods for authorization code flow.
The flow consists of three method calls:
1. `preauthorize(resource_owner, request)`
This validates the request. If a resource owner already have been
authenticated previously it'll respond with a redirect... | lib/ex_oauth2_provider/oauth2/authorization/strategy/code.ex | 0.868632 | 0.643161 | code.ex | starcoder |
defmodule Membrane.Dashboard.Charts do
@moduledoc """
Utility types for charts.
"""
@typedoc """
A type representing a single chart.
## Note
The first series must be named `time` and the first row of data must
consist of timestamps instead of proper values.
"""
@type chart_data_t :: %{
s... | lib/membrane_dashboard/charts.ex | 0.900522 | 0.728314 | charts.ex | starcoder |
defmodule Conqueuer do
@moduledoc ~S"""
Conqueuer (pronounced like conquer) is a non-persistent Elixir work queue.
## Architecture
In conqueuer, there are 3 collaborators involved in the work off process. The
work is initially queued to a [queue](Conqueuer.Queue.html) executing as a
registered (or named) ... | lib/conqueuer.ex | 0.822688 | 0.571079 | conqueuer.ex | starcoder |
defmodule Cortex do
@moduledoc """
Documentation for Cortex.
## Features
Cortex runs along side your elixir application.
### Reload
Once added to your dependencies, it will startup automatically
when you run `iex -S mix`.
```
$ iex -S mix
```
A file-watcher will keep an eye on any chan... | lib/cortex.ex | 0.800302 | 0.797517 | cortex.ex | starcoder |
defmodule Hypex.Util do
@moduledoc false
# Provides internal tooling which doesn't fit into the main Hypex module. This
# module shall remain undocumented as the specifics of this module should not
# be relied upon and may change at any time.
# our hash size in bits
@hash_length 32
# the maximum uniques... | lib/hypex/util.ex | 0.84481 | 0.730097 | util.ex | starcoder |
defmodule Mazes.RectangularMazeWithMask do
@behaviour Mazes.Maze
alias Mazes.{Maze, RectangularMaze, Mask}
@doc "Returns a rectangular maze with given size, either with all walls or no walls"
@impl true
def new(opts) do
file = Keyword.get(opts, :file)
if file do
new_from_file(file, Keyword.del... | lib/mazes/rectangular_maze_with_mask.ex | 0.814754 | 0.494812 | rectangular_maze_with_mask.ex | starcoder |
defmodule Scenic.Primitive.Style.Paint.Color do
@moduledoc """
Fill a primitive with a single color
The color paint is used as the data for the [`:fill`](Scenic.Primitive.Style.Fill.html) style.
## Full Format
`{:color, valid_color}`
The full format is a tuple with two parameters. The first is the :col... | lib/scenic/primitive/style/paint/color.ex | 0.932099 | 0.86988 | color.ex | starcoder |
defmodule ForthVM.Words.Logic do
@moduledoc """
Comparison, logic and bitwise words
"""
import ForthVM.Utils
alias ForthVM.Process
@c_true true
@c_false false
# ---------------------------------------------
# Comparison operations
# ---------------------------------------------
@doc """
=: ... | lib/forthvm/words/logic.ex | 0.786828 | 0.822118 | logic.ex | starcoder |
defmodule Day19 do
@moduledoc """
Somehow, a network packet got lost and ended up here. It's trying to follow a routing diagram (your puzzle input),
but it's confused about where to go.
Its starting point is just off the top of the diagram. Lines (drawn with |, -, and +) show the path it needs to take,
start... | lib/day19.ex | 0.52342 | 0.777722 | day19.ex | starcoder |
defmodule FiveHundred.Bid do
@derive Jason.Encoder
defstruct [:name, :suit, :tricks, :points]
alias FiveHundred.{Bid, Card}
@type t :: %Bid{
name: String.t(),
suit: Card.suit(),
tricks: integer,
points: 40..1000
}
@type special_bid :: %Bid{
name: Str... | lib/five_hundred/bid.ex | 0.802323 | 0.589214 | bid.ex | starcoder |
defmodule Pair2.Comparer do
@moduledoc """
Core functions for comparing two values or maps and returning a similarity value between 0.0 and 1.0.
"""
@doc """
Scores the similarity of two maps based on a list of rules.
Returns score that is >= 0.0.
"""
def compare_maps(map_l, map_r, rules) do
Enum.r... | lib/comparer.ex | 0.838498 | 0.777511 | comparer.ex | starcoder |
defmodule Venomq.Transport.Data do
require Logger
def encode_long_string(string) do
<<byte_size(string)::32>> <> string
end
def encode_short_string(string) do
<<byte_size(string)>> <> string
end
@doc"""
Utility function to decode a map from field-table byte stream.
returns: {value, length, e... | lib/venomq/transport/data.ex | 0.715424 | 0.489686 | data.ex | starcoder |
defmodule ExTweet do
@moduledoc """
Public interface of ExTweet
"""
alias ExTweet.{Scraper, Proxies}
alias ExTweet.Parser.Tweet
alias ExTweet.Query
defguard is_proxy(value)
when value in [:no_proxy, :random_proxy] or
(is_binary(elem(value, 0)) and is_binary(elem(value, 1)))
... | lib/ex_tweet.ex | 0.874212 | 0.448245 | ex_tweet.ex | starcoder |
defmodule Haex.Data.DataConstructorBuilder do
@moduledoc """
generates AST representation of `Haex.Data.DataConstructor` to return from
`Haex.data/1` macro
"""
alias Haex.Ast
alias Haex.Data
alias Haex.Data.DataConstructor
alias Haex.Data.TypeConstructor
@spec build(DataConstructor.t()) :: Macro.outp... | lib/haex/data/data_constructor_builder.ex | 0.783988 | 0.441914 | data_constructor_builder.ex | starcoder |
defmodule Vantagex.HttpClient do
@moduledoc """
Module that deals with the requests to the API.
Uses HTTPoison.Base
"""
use HTTPoison.Base
alias Vantagex.Config
@endpoint Config.api_url
@doc """
From HTTPoison.Base. Processes the given params.
Adds the required api_key to the params.
Args:
... | lib/vantagex/http_client.ex | 0.842151 | 0.468061 | http_client.ex | starcoder |
defmodule Membrane.FFmpeg.VideoFilter.TextOverlay do
@moduledoc """
Element adding text overlay to raw video frames - using 'drawtext' video filter from FFmpeg Library.
(https://ffmpeg.org/ffmpeg-filters.html#drawtext-1).
Element allows for specifying most commonly used 'drawtext' settings (such as fontsize, fo... | lib/membrane_ffmpeg_video_filter/text_overlay.ex | 0.877634 | 0.472257 | text_overlay.ex | starcoder |
defmodule SanbaseWeb.Graphql.Schema.KafkaTypes do
use Absinthe.Schema.Notation
enum(:side_enum, values: [:buy, :sell])
object :exchange_market_depth do
field(:exchange, :string)
field(:ticker_pair, :string)
field(:datetime, :datetime)
field(:ask, :float)
field(:asks025_percent_depth, :float)... | lib/sanbase_web/graphql/schema/types/kafka_types.ex | 0.645679 | 0.687092 | kafka_types.ex | starcoder |
defmodule Day13 do
def part1 lines do
chart = make_chart lines
{carts, chart} = remove_carts chart
{_, [collision | _]} = find_collisions carts, chart
collision
end
def part2 lines do
chart = make_chart lines
{carts, chart} = remove_carts chart
{remaining_cart, _} = find_collisions c... | day13/lib/day13.ex | 0.526099 | 0.46873 | day13.ex | starcoder |
defmodule Imagineer.Image.PNG.Pixels.Adam7 do
alias Imagineer.Image.PNG
alias PNG.Interlace.Adam7
import PNG.Helpers, only: [channels_per_pixel: 1]
def extract(%PNG{unfiltered_rows: passes} = image) do
extract_pixels_from_passes(passes, image)
|> Adam7.merge({image.width, image.height})
end
def se... | lib/imagineer/image/png/pixels/adam7.ex | 0.752013 | 0.480052 | adam7.ex | starcoder |
defmodule EctoTestDSL.Nouns.FieldCalculator do
use EctoTestDSL.Drink.Me
use T.Drink.Assertively
use T.Drink.AndRun
@moduledoc """
A description of how a field's value can be calculated in terms of
other fields (and constants).
"""
defstruct [:calculation, :args, :from]
def new(calculation, args, fr... | lib/00_nouns/field_calculator.ex | 0.738103 | 0.685121 | field_calculator.ex | starcoder |
defmodule ScrapyCloudEx.Endpoints.Storage.Activity do
@moduledoc """
Wraps the [Activity](https://doc.scrapinghub.com/api/activity.html) endpoint.
Scrapinghub keeps track of certain project events such as when spiders
are run or new spiders are deployed. This activity log can be accessed
in the dashboard by ... | lib/endpoints/storage/activity.ex | 0.830972 | 0.757794 | activity.ex | starcoder |
defmodule Tesla.Middleware.Replay do
@behaviour Tesla.Middleware
@moduledoc """
Simple middleware for saving/replaying response data.
This middleware intercepts requests and either returns locally stored
data or performs the request and saves the result to disk (to replay
for future requests).
### Exam... | lib/tesla_replay.ex | 0.895862 | 0.726668 | tesla_replay.ex | starcoder |
defmodule ServerSentEventStage do
@moduledoc """
A GenStage producer which parses the ServerSentEvent (SSE) protocol.
SSEs are used in browsers via the EventSource API, but they can be used for
any kind of one-directional streaming.
For more information, see the [W3C](https://html.spec.whatwg.org/multipage/... | lib/server_sent_event_stage.ex | 0.755366 | 0.465448 | server_sent_event_stage.ex | starcoder |
defmodule Translecto.Migration do
import Ecto.Migration
@moduledoc """
Provides convenient functionality for creating tables that support translatable
data.
"""
@doc """
Setup the table as a translation lookup. All fields in this table will now be
translatable.
Translatio... | lib/translecto/migration.ex | 0.824179 | 0.484807 | migration.ex | starcoder |
defmodule Versioning.Change do
@moduledoc """
Defines a versioning change.
A versioning change is used to make small changes to data of a certain type.
They are used within a `Versioning.Schema`. Changes should attempt to be as
focused as possible to ensure complexity is kept to a minimum.
## Example
... | lib/versioning/change.ex | 0.906413 | 0.510008 | change.ex | starcoder |
defmodule Ratatouille.Renderer.Element do
@moduledoc false
alias __MODULE__, as: Element
alias Ratatouille.Renderer.Element.{
Bar,
Chart,
Column,
Label,
Overlay,
Panel,
Row,
Sparkline,
Table,
Tree,
View
}
@type t :: %Element{tag: atom()}
@enforce_keys [:tag]
... | lib/ratatouille/renderer/element.ex | 0.869188 | 0.561335 | element.ex | starcoder |
defmodule IO.ANSI.Sequence do
@moduledoc false
defmacro defsequence(name, code, terminator \\ "m") do
quote bind_quoted: [name: name, code: code, terminator: terminator] do
def unquote(name)() do
"\e[#{unquote(code)}#{unquote(terminator)}"
end
defp format_sequence(unquote(name)) do
... | lib/elixir/lib/io/ansi.ex | 0.809991 | 0.500916 | ansi.ex | starcoder |
defmodule Phoenix do
@moduledoc """
This is the documentation for the Phoenix project.
By default, Phoenix applications depend on the following packages
across these categories.
## General
* [Ecto](https://hexdocs.pm/ecto) - a language integrated query and
database wrapper
* [ExUnit](https:/... | lib/phoenix.ex | 0.751739 | 0.723358 | phoenix.ex | starcoder |
defmodule Membrane.Caps.Audio.Raw do
@moduledoc """
This module implements struct for caps representing raw audio stream with
interleaved channels.
"""
alias __MODULE__.Format
alias Membrane.Time
@compile {:inline,
[
sample_size: 1,
frame_size: 1,
sa... | lib/membrane_caps_audio_raw.ex | 0.897578 | 0.526647 | membrane_caps_audio_raw.ex | starcoder |
defmodule Concentrate.Parser.GTFSRealtime do
@moduledoc """
Parser for [GTFS-Realtime](https://developers.google.com/transit/gtfs-realtime/) ProtoBuf files.
"""
@behaviour Concentrate.Parser
alias Concentrate.Parser.Helpers
require Logger
alias Concentrate.{Alert, Alert.InformedEntity, StopTimeUpdate, Tr... | lib/concentrate/parser/gtfs_realtime.ex | 0.771972 | 0.437223 | gtfs_realtime.ex | starcoder |
defmodule Mix.Tasks.PromEx.Gen.Config do
@moduledoc """
This Mix Task generates a PromEx config module in your project. This config
file acts as a starting point with instructions on how to set up PromEx
in your application, some default PromEx metrics plugins, and their
accompanying dashboards.
The follow... | lib/mix/tasks/prom_ex.gen.config.ex | 0.790692 | 0.596227 | prom_ex.gen.config.ex | starcoder |
defmodule Exq.Scheduler.Server do
@moduledoc """
The Scheduler is responsible for monitoring the `schedule` and `retry` queues.
These queues use a Redis sorted set (term?) to schedule and pick off due jobs.
Once a job is at or past it's execution date, the Scheduler moves the job into the
live execution queue... | lib/exq/scheduler/server.ex | 0.713631 | 0.58602 | server.ex | starcoder |
defmodule AMQP.Queue do
@moduledoc """
Functions to operate on Queues.
"""
import AMQP.Core
alias AMQP.{Basic, Channel, Utils, BasicError}
@doc """
Declares a queue. The optional `queue` parameter is used to set the name.
If set to an empty string (default), the server will assign a name.
Besides ... | lib/amqp/queue.ex | 0.882415 | 0.545165 | queue.ex | starcoder |
defmodule Manticoresearch.Api.Index do
@moduledoc """
API calls for all endpoints tagged `Index`.
"""
alias Manticoresearch.Connection
import Manticoresearch.RequestBuilder
@doc """
Bulk index operations
Sends multiple operatons like inserts, updates, replaces or deletes. For each operation it's ob... | out/manticoresearch-elixir/lib/manticoresearch/api/index.ex | 0.856407 | 0.639356 | index.ex | starcoder |
defmodule Ecto.Migration do
@moduledoc """
Migrations are used to modify your database schema over time.
This module provides many helpers for migrating the database,
allowing developers to use Elixir to alter their storage in
a way it is database independent.
Here is an example:
defmodule MyRepo.M... | lib/ecto/migration.ex | 0.832951 | 0.5425 | migration.ex | starcoder |
defmodule AOC do
@moduledoc """
Advent of Code solution module macro and helpers.
This module contains the `aoc/3` macro, which should be used to write a solution module for a
given advent of code challenge. The intended use is to write your solution for day `<day>`, year
`<year>` as follows:
```
import... | lib/aoc.ex | 0.924509 | 0.951369 | aoc.ex | starcoder |
defmodule Stack do
@moduledoc """
Module for working with the VM's internal stack
"""
@maximum_stack_length 1024
@spec push(any(), map()) :: :ok | {:error, String.t(), list()}
def push(arg, state) do
stack = State.stack(state)
if length(stack) < @maximum_stack_length do
State.set_stack([arg... | apps/aevm/lib/stack.ex | 0.801664 | 0.542136 | stack.ex | starcoder |
defmodule Mix.Compilers.Erlang do
@moduledoc false
@manifest_vsn 1
@doc """
Compiles the files in `mappings` with given extensions into
the destination, automatically invoking the callback for each
stale input and output pair (or for all if `force` is `true`) and
removing files that no longer have a sou... | lib/mix/lib/mix/compilers/erlang.ex | 0.786008 | 0.616445 | erlang.ex | starcoder |
defmodule EctoTestDSL.Run.RunningExample do
use EctoTestDSL.Drink.Me
use EctoTestDSL.Drink.AndRun
use EctoTestDSL.Drink.Assertively
import MockeryExtras.Getters
@enforce_keys [:example, :history]
defstruct [:example, :history,
script: :none_just_testing,
tracer: :none]
getters ... | lib/20_run/running_example.ex | 0.664758 | 0.412619 | running_example.ex | starcoder |
defmodule Mix.Tasks.Gringotts.New do
@shortdoc """
Generates a barebones implementation for a gateway.
"""
@moduledoc """
Generates a barebones implementation for a gateway.
It expects the (brand) name of the gateway as argument and we recommend that
it be capitalized. *This will not necessarily be the ... | lib/mix/new.ex | 0.781914 | 0.773131 | new.ex | starcoder |
defmodule Ecto do
@moduledoc ~S"""
Ecto is split into 4 main components:
* `Ecto.Repo` - repositories are wrappers around the database.
Via the repository, we can create, update, destroy and query existing entries.
A repository needs an adapter and a URL to communicate to the database
* `Ecto.... | lib/ecto.ex | 0.86378 | 0.656534 | ecto.ex | starcoder |
defmodule Ockam.SecureChannel.EncryptedTransportProtocol.AeadAesGcm do
@moduledoc false
alias Ockam.Message
alias Ockam.Router
alias Ockam.Vault
alias Ockam.Wire
def setup(_options, initial_state, data) do
{:ok, initial_state, data}
end
def handle_message(message, {:encrypted_transport, :ready} =... | implementations/elixir/ockam/ockam/lib/ockam/secure_channel/encrypted_transport_protocol/aead_aes_gcm.ex | 0.831143 | 0.439687 | aead_aes_gcm.ex | starcoder |
defmodule Makeup.Lexer.Postprocess do
@moduledoc """
Often you'll want to run the token list through a postprocessing stage before
running the formatter.
Most of what we can do in a post-processing stage can be done with more parsing rules,
but doing it in a post-processing stage is often easier and faster.
... | lib/makeup/lexer/postprocess.ex | 0.911301 | 0.906818 | postprocess.ex | starcoder |
defmodule StateMachine.Callback do
@moduledoc """
Callback defines a captured function, that can be called
in a various points of a State Machine's lifecycle.
Depending on return type (shape) of the callback,
it can update the context or the model, stop the transition with error, or be ignored.
"""
alias... | lib/state_machine/callback.ex | 0.882719 | 0.667016 | callback.ex | starcoder |
defmodule Adminable do
@moduledoc """
Behaviour to capture how to build admin interfaces and which fields to allow to edit
## Configuration
- Add `use Adminable` to your Ecto Schema. Optionally
```elixir
defmodule MyApp.User do
use Ecto.Schema
import Ecto.{Query, Changeset}, warn: false
use A... | lib/adminable.ex | 0.856797 | 0.689985 | adminable.ex | starcoder |
defmodule InputParser do
@shortdoc "Convert Module.function/arity -> {Module, function, arity}"
@moduledoc """
Parse input from a string definition of a function, into a tuple with
{Module, function, arity}, so that it can be used for documentation
lookup.
"""
@doc """
Parse input from a string defin... | lib/input_parser.ex | 0.711932 | 0.514644 | input_parser.ex | starcoder |
defmodule ETS.KeyValueSet do
@moduledoc """
The Key Value Set is an extension of `ETS.Set` which abstracts the concept of tuple records
away, replacing it with the standard concept of key/value. Behind the scenes, the set stores
its records as {key, value}.
## Examples
iex> {:ok, kvset} = KeyValueSet.... | lib/ets/key_value_set.ex | 0.905033 | 0.472318 | key_value_set.ex | starcoder |
defmodule Faker.Name.Es do
import Faker, only: [sampler: 2]
@moduledoc """
Functions for name data in Spanish
"""
@doc """
Returns a complete name (may include a suffix/prefix or both)
## Examples
iex> Faker.Name.Es.name()
"<NAME> MD"
iex> Faker.Name.Es.name()
"<NAME>"
ie... | lib/faker/name/es.ex | 0.632162 | 0.401424 | es.ex | starcoder |
defmodule RF24.SimplePingPair do
@moduledoc """
Sample receiver process that will log
all received packets via Elixir's Logger.
This can be considered a complement to
[this arduino example](https://github.com/nRF24/RF24/blob/master/examples/pingpair_irq_simple/pingpair_irq_simple.ino)
"""
use GenServer
... | lib/rf24/simple_ping_pair.ex | 0.793546 | 0.409191 | simple_ping_pair.ex | starcoder |
defmodule CargueroTaskBunny.Publisher do
@moduledoc """
Conviniences for publishing messages to a queue.
It's a semi private module and provides lower level functions.
You should use Job.enqueue to enqueue a job from your application.
"""
require Logger
alias CargueroTaskBunny.{Publisher.PublishError, Co... | lib/carguero_task_bunny/publisher.ex | 0.81899 | 0.456955 | publisher.ex | starcoder |
defmodule Prime.Fermat do
@moduledoc """
Implementation of Fermat-test.
This module provides the primality test based on
Fermat's Little Theorem.
The methodology is essentially probablistic, which means
even if the result says the number given is a prime,
there is no strong guarantee that it actually is... | lib/prime/fermat.ex | 0.739234 | 0.871966 | fermat.ex | starcoder |
defmodule Tds.Error do
@moduledoc """
Defines the `Tds.Error` struct.
The struct has two fields:
* `:message`: expected to be a string
* `:mssql`: expected to be a keyword list with the fields `line_number`,
`number` and `msg_text`
## Usage
iex> raise Tds.Error
** (Tds.Error) A... | lib/tds/error.ex | 0.872497 | 0.533094 | error.ex | starcoder |
defmodule ExUnit.CaptureIO do
@moduledoc %S"""
This module provides functionality to capture IO to test it.
## Examples
defmodule AssertionTest do
use ExUnit.Case
import ExUnit.CaptureIO
test :example do
assert capture_io(fn ->
IO.puts "a"
end) == ... | lib/ex_unit/lib/ex_unit/capture_io.ex | 0.776708 | 0.613294 | capture_io.ex | starcoder |
defmodule Domo.Changeset do
@moduledoc """
Validation functions for [Echo.Changeset](https://hexdocs.pm/ecto/Ecto.Changeset.html#module-validations-and-constraints).
The `Ecto` schema changes can be validated to conform to types in `t()`
and to fulfill appropriate preconditions.
defmodule User do
... | lib/domo/changeset.ex | 0.872252 | 0.523116 | changeset.ex | starcoder |
defmodule ExMagick do
@moduledoc """
NIF bindings to the GraphicsMagick API with optional support for
dirty scheduling.
## Examples
*Transform a PNG image to JPEG*
```
ExMagick.init!()
|> ExMagick.image_load!(Path.join(__DIR__, "../test/images/elixir.png"))
|> ExMagick.image_dump!("/tmp/elixir.jpg"... | lib/exmagick.ex | 0.909901 | 0.834576 | exmagick.ex | starcoder |
defmodule Serum.Build.Pass2.PageBuilder do
@moduledoc """
During pass 2, PageBuilder does the following:
1. Reads each page source file and produces HTML code according to the format:
* If the source format is markdown, converts the soruce into HTML using
Earmark.
* If the source format is HT... | lib/serum/build/pass_2/page_builder.ex | 0.767646 | 0.431764 | page_builder.ex | starcoder |
defmodule Membrane.MP4.Container.SerializeHelper do
@moduledoc false
use Bunch
alias Membrane.MP4.Container
alias Membrane.MP4.Container.Schema
@box_name_size 4
@box_size_size 4
@box_header_size @box_name_size + @box_size_size
@spec serialize_boxes(Container.t(), Schema.t()) ::
{:error, Co... | lib/membrane_mp4/container/serialize_helper.ex | 0.712932 | 0.442335 | serialize_helper.ex | starcoder |
defmodule Xandra.Cluster.ControlConnection do
@moduledoc false
@behaviour :gen_statem
alias Xandra.{Frame, Simple, Cluster, Connection.Utils}
require Logger
@default_backoff 5_000
@default_timeout 5_000
@forced_transport_options [packet: :raw, mode: :binary, active: false]
# Internal NimbleOptions ... | lib/xandra/cluster/control_connection.ex | 0.827967 | 0.438725 | control_connection.ex | starcoder |
defmodule Mantis do
@moduledoc """
Mantis provides an eventually consistent, ephemeral KV store. It relies on
distributed erlang and uses LWW-registers and Hybrid-logical clocks
to ensure maximum availability. Mantis utilizes ETS for efficient reading.
## Usage
```elixir
# Changes are propogated to othe... | lib/mantis.ex | 0.902263 | 0.893356 | mantis.ex | starcoder |
defmodule MlDHT do
use Application
require Logger
alias MlDHT.Server.Utils, as: Utils
@moduledoc ~S"""
MlDHT is an Elixir package that provides a Kademlia Distributed Hash Table
(DHT) implementation according to [BitTorrent Enhancement Proposals (BEP)
05](http://www.bittorrent.org/beps/bep_0005.html). ... | lib/mldht.ex | 0.626353 | 0.413714 | mldht.ex | starcoder |
defmodule Day12 do
def from_file(path) do
File.stream!(path)
|> Enum.to_list
|> Enum.map(&parse_row/1)
end
def parse_row(row) do
[x, y, z] = Regex.run(~r{<x=(.*), y=(.*), z=(.*)>}, row, capture: :all_but_first)
{String.to_integer(x), String.to_integer(y), String.to_integer(z)}
end
def i... | lib/day12.ex | 0.610802 | 0.592048 | day12.ex | starcoder |
defmodule Mariaex.Query do
@moduledoc """
Query struct returned from a successfully prepared query. Its fields are:
* `name` - The name of the prepared statement;
* `statement` - The prepared statement;
* `num_params` - The number of parameters;
* `ref` - Reference that uniquely identifies when the... | deps/mariaex/lib/mariaex/query.ex | 0.842475 | 0.501038 | query.ex | starcoder |
if Cldr.Code.ensure_compiled?(Cldr.LocaleDisplay) do
defmodule Cldr.HTML.Locale do
@moduledoc """
Implements `Phoenix.HTML.Form.select/4` specifically for
localised locale display.
"""
alias Cldr.Locale
@type select_options :: [
{:locales, [atom() | binary(), ...]}
|... | lib/cldr_html_locale.ex | 0.88258 | 0.444746 | cldr_html_locale.ex | starcoder |
defmodule MT940.Parser do
@moduledoc ~S"""
This module contains functions to parse SWIFT's MT940 messages.
## API
The `parse` function in this module returns `{:ok, result}`
in case of success, `{:error, reason}` otherwise. It is also
followed by a variant that ends with `!` which returns the
result (wi... | lib/parser.ex | 0.698432 | 0.494995 | parser.ex | starcoder |
defmodule Absinthe.Type.Directive do
@moduledoc """
Used by the GraphQL runtime as a way of modifying execution
behavior.
Type system creators will usually not create these directly.
"""
alias Absinthe.Type
alias Absinthe.Language
use Absinthe.Introspection.Kind
@typedoc """
A defined directive.
... | lib/absinthe/type/directive.ex | 0.762557 | 0.447702 | directive.ex | starcoder |
defmodule Day06.Orbits do
def parse(lines), do: parse(lines, %{})
defp parse([], orbits), do: orbits
defp parse([orbit | rest], orbits) do
[from, to] = String.split(orbit, ")")
orbits = Map.update(orbits, from, %{to: [to]}, fn(m) -> Map.update(m, :to, [to], fn(a) -> [to | a] end) end)
orbits = Map.upd... | year_2019/lib/day_06/orbits.ex | 0.62498 | 0.698047 | orbits.ex | starcoder |
defmodule ExUnitAssertions do
@doc """
Matches pattern in list:
> match_in?(1, [1, 2, 3])
1
> match_in?(%{a: 1}, [%{a: 1, b: 2}, %{a: 2, b: 3}])
%{a: 1, b: 2}
> match_in?(%{a: 1}, [%{a: 2, b: 2}, %{a: 2, b: 3}])
raised error
> a = 1
> match_in?(%{a: ^a}, [%{a: 1, ... | lib/ex_unit_assertions.ex | 0.693265 | 0.675229 | ex_unit_assertions.ex | starcoder |
defmodule Tune.Link do
@moduledoc """
Provides functions to generate integration links from tracks, artists and albums.
Implementations are extremely naive and rely on building URLs from metadata,
but there are times when they simply don't work, particularly with titles
that have suffixes like "2017 remaster... | lib/tune/link.ex | 0.750553 | 0.404008 | link.ex | starcoder |
defmodule ExFuzzywuzzy do
@external_resource readme = "README.md"
@moduledoc """
ex_fuzzywuzzy is a fuzzy string matching library that uses a customizable measure
to calculate a distance ratio
#{
readme
|> File.read!()
|> String.split("<!--MDOC !-->")
|> Enum.fetch!(1)
}
"""
alias ExFu... | lib/ex_fuzzywuzzy.ex | 0.916904 | 0.806967 | ex_fuzzywuzzy.ex | starcoder |
defmodule ErrorLogger do
require Logger
@type message :: binary | [message]
@type kind :: :error | :exit
@type error :: any
@doc """
Formats and logs the given error using `Exception.format/3` and `Logger.error/1`.
Depending on from where this macro is called, it will also include
the stacktrace that... | lib/easy_error_logger.ex | 0.732879 | 0.448185 | easy_error_logger.ex | starcoder |
defmodule Reactivity.Processing.CombineVarWithGuarantees do
@moduledoc false
use Observables.GenObservable
alias Observables.Obs
alias Reactivity.Processing.Matching
require Logger
def init([qmap, gmap, type, imap, hosp]) do
Logger.debug("CombineVarWithGuarantee: #{inspect(self())}")
# Define the ... | lib/reactivity/processing/combine_var_with_guarantees.ex | 0.641871 | 0.415017 | combine_var_with_guarantees.ex | starcoder |
defmodule Xlsxir.SaxParser do
@moduledoc """
Provides SAX (Simple API for XML) parsing functionality of the `.xlsx` file via the [Erlsom](https://github.com/willemdj/erlsom) Erlang library. SAX (Simple API for XML) is an event-driven
parsing algorithm for parsing large XML files in chunks, preventing the need to ... | lib/xlsxir/sax_parser.ex | 0.82755 | 0.555013 | sax_parser.ex | starcoder |
defmodule Anise do
@moduledoc """
Anis is a set of helpers/assertions for Absinthe
"""
@doc """
Creates `graphql` functions that performs request.
```elixir
graphql(conn, "/api", @mutation, %{email: "<EMAIL>", name: "Boris"})
```
"""
defmacro __using__(_opts) do
import Phoenix.ConnTest, o... | lib/anise.ex | 0.794505 | 0.731514 | anise.ex | starcoder |
defmodule Samly.Assertion do
@moduledoc """
SAML assertion returned from IDP upon successful user authentication.
The assertion attributes returned by the IdP are available in `attributes` field
as a map. Any computed attributes (using a Plug Pipeline by way of configuration)
are available in `computed` fiel... | lib/samly/assertion.ex | 0.867976 | 0.51818 | assertion.ex | starcoder |
defmodule XGen.Properties do
@moduledoc ~S"""
Helpers to create domain-specific behaviours with properties to set.
*Properties* are defined as pure functions returning either a constant or a
dynamic value built from assigns. A module using `XGen.Properties` can define
property callbacks and helper macros to ... | lib/xgen/properties.ex | 0.887156 | 0.547162 | properties.ex | starcoder |
defmodule TimeHelper do
@moduledoc """
Collection of functions for handling time-based conversions.
"""
@minute 60
@hour @minute * 60
@day @hour * 24
@week @day * 7
@divisor [@week, @day, @hour, @minute, 1]
@doc """
sec_to_str/1: returns a string breakdown of total seconds into weeks, days,
hou... | lib/time_helper.ex | 0.906927 | 0.814016 | time_helper.ex | starcoder |
defmodule Example_Li do
def start do
[1, "two", :three, 4]
end
def start2 do
[1, true, 3, 4, false] -- [true, false]
end
def start3 do
new = 0
list = [1, 2, 3, 4]
[new | list]
end
def start4 do
[head | tail] = [1, 2, 3, 4, 5]
end
def start5 do
list = [1, 2, 3]
list ... | lib/beam/list/list.ex | 0.549157 | 0.748697 | list.ex | starcoder |
defmodule AWS.WorkDocs do
@moduledoc """
The WorkDocs API is designed for the following use cases:
* File Migration: File migration applications are supported for
users who want to migrate their files from an on-premises or off-premises file
system or service.
Users can insert files into a user directo... | lib/aws/generated/work_docs.ex | 0.763307 | 0.408336 | work_docs.ex | starcoder |
defmodule Still.Compiler.CompilationStage do
@moduledoc """
Almost every compilation request goes through `CompilationStage`. This
process is responsible for keeping track of subscriptions (e.g: a browser
subscribing to changes) and notifying all the subscribers of the end of the
compilation cycle.
Subscri... | lib/still/compiler/compilation_stage.ex | 0.747708 | 0.401688 | compilation_stage.ex | starcoder |
defmodule Genex.Visualizer do
alias Genex.Types.{Chromosome, Population}
@moduledoc """
Behaviour for implementing visualizations.
A visualizer provides robust visualization for your genetic algorithms. A complete visualizer behaviour implements two functions: `init/1` and `display/2`.
The visualizer behav... | lib/genex/visualizer.ex | 0.930316 | 0.95803 | visualizer.ex | starcoder |
defmodule OsrsEx.Hiscores do
@moduledoc """
For working with the Jagex Hiscores API.
It is **EXTREMELY** important to note that this module transforms the data
it recieves from the Jagex Hiscores API. The Jagex Hiscores API will
randomly return either `-1` or the true level/xp/score when a player is... | lib/hiscores/hiscores.ex | 0.838283 | 0.632276 | hiscores.ex | starcoder |
defmodule OnFlow.Crypto do
use Bitwise
@doc """
Generates a key pair.
"""
@spec generate_keys() :: %{public_key: String.t(), private_key: String.t()}
def generate_keys do
{<<4>> <> public_key, private_key} = :crypto.generate_key(:ecdh, :secp256r1)
public_key = Base.encode16(public_key, case: :lower... | lib/on_flow/crypto.ex | 0.823648 | 0.474875 | crypto.ex | starcoder |
defmodule Matcha do
@readme "README.md"
@external_resource @readme
@moduledoc_blurb @readme
|> File.read!()
|> String.split("<!-- MODULEDOC BLURB -->")
|> Enum.fetch!(1)
@moduledoc_snippet @readme
|> File.read!()
... | lib/matcha.ex | 0.828766 | 0.488527 | matcha.ex | starcoder |
defmodule Playwright.JSHandle do
@moduledoc """
`Playwright.JSHandle` represents an in-page JavaScript object. `JSHandles`
can be created with `Playwright.Page.evaluate_handle/3`.
## Example
handle = Page.evaluate_handle(page, "() => window")
`JSHandle` prevents the referenced JavaScript object from ... | lib/playwright/js_handle.ex | 0.935751 | 0.624437 | js_handle.ex | starcoder |
defmodule Zaryn.Governance.Pools do
@moduledoc """
Governance pool management.
The Zaryn governance is spread across several pool of voters with different power or area of expertise.
The pools are:
- Foundation
- Technical council
- Ethical council
- Zaryn
- Miners
- Users
For instance, every c... | lib/zaryn/governance/pools.ex | 0.551936 | 0.641472 | pools.ex | starcoder |
defmodule Weebo do
@moduledoc ~S"""
Weebo is an [XML-RPC](http://wikipedia.org/wiki/XML-RPC) parser/formatter for
Elixir, with full data-type support.
Weebo can be combined with GenServer, Phoenix, HTTPoison (and others!) to create
fully-featured XML-RPC clients & servers.
request = Weebo.parse("<?xml... | lib/weebo.ex | 0.80784 | 0.486088 | weebo.ex | starcoder |
defmodule AWS.IoTThingsGraph do
@moduledoc """
AWS IoT Things Graph
AWS IoT Things Graph provides an integrated set of tools that enable developers
to connect devices and services that use different standards, such as units of
measure and communication protocols.
AWS IoT Things Graph makes it possible to... | lib/aws/generated/iot_things_graph.ex | 0.878158 | 0.447581 | iot_things_graph.ex | starcoder |
defmodule AWS.CertificateManager 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 Manag... | lib/aws/certificate_manager.ex | 0.913152 | 0.609757 | certificate_manager.ex | starcoder |
defmodule Record.Extractor do
@moduledoc false
def extract(name, opts) do
extract_record(name, from_or_from_lib_file(opts))
end
def extract_all(opts) do
extract_all_records(from_or_from_lib_file(opts))
end
defp from_or_from_lib_file(opts) do
cond do
file = opts[:from] ->
{from_f... | lib/elixir/lib/record/extractor.ex | 0.675872 | 0.506103 | extractor.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.