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 Cog.Repository.PipelineHistory do
@moduledoc """
Behavioral API for interacting with pipeline history
records.
"""
import Ecto.Query, only: [from: 2]
alias Cog.Repo
alias Cog.Models.PipelineHistory
@allowed_states ["running", "waiting", "finished"]
@doc """
Updates any pipelines in "ru... | lib/cog/repository/pipeline_history.ex | 0.682679 | 0.412175 | pipeline_history.ex | starcoder |
defmodule Sqlitex do
@type connection :: {:connection, reference, String.t}
@type string_or_charlist :: String.t | char_list
@type sqlite_error :: {:error, {:sqlite_error, char_list}}
@moduledoc """
Sqlitex gives you a way to create and query sqlite databases.
## Basic Example
```
iex> {:ok, db} = Sq... | deps/sqlitex/lib/sqlitex.ex | 0.838515 | 0.546617 | sqlitex.ex | starcoder |
defmodule Membrane.Element.Base.Mixin.CommonBehaviour do
@moduledoc """
Module defining behaviour common to all elements.
When used declares behaviour implementation, provides default callback definitions
and imports macros.
For more information on implementing elements, see `Membrane.Element.Base`.
"""
... | lib/membrane/element/base/mixin/common_behaviour.ex | 0.919208 | 0.403714 | common_behaviour.ex | starcoder |
defmodule BetterParams do
@behaviour Plug
@moduledoc """
Implementation of the `BetterParams` plug and its core logic.
See the [`README`](https://github.com/sheharyarn/better_params) for
installation and usage instructions.
"""
@doc """
Initializes the Plug.
"""
@impl Plug
def init(opts) do
... | lib/better_params.ex | 0.834103 | 0.904355 | better_params.ex | starcoder |
defmodule Finitomata do
@moduledoc "README.md" |> File.read!() |> String.split("\n---") |> Enum.at(1)
require Logger
use Boundary, top_level?: true, deps: [], exports: [Supervisor, Transition]
alias Finitomata.Transition
defmodule State do
@moduledoc """
Carries the state of the FSM.
"""
al... | lib/finitomata.ex | 0.871721 | 0.64699 | finitomata.ex | starcoder |
defmodule WMS.Placement do
@moduledoc """
`WMS.Placement` is a process that handles cart delivery placement from acquiring to cells.
"""
require KVS
require ERP
require BPE
require Record
Record.defrecord(:placement, [:path, :item])
def auth(_), do: true
def clear(proc) do
feed = '/wms/in/' ++... | lib/actors/placement.ex | 0.53777 | 0.433262 | placement.ex | starcoder |
defmodule Nile do
@doc """
Expand each item into 0..n items
iex> Nile.expand(0..10, &([&1, &1])) |> Enum.take(12)
[0,0,1,1,2,2,3,3,4,4,5,5]
"""
def expand(stream, fun) do
Stream.resource(
fn -> {stream, fun} end,
fn ({stream, fun} = s) ->
case Nile.Utils.next(stream) do
... | lib/nile.ex | 0.709221 | 0.452657 | nile.ex | starcoder |
defmodule Satchel do
@moduledoc """
Satchel is a library for serializing and de-serializing values. Currently,
only little endian is supported (for my own convenience). The following
types are supported:
* `bool` (unsigned 8-bit int)
* `int8`
* `uint8`
* `int16`
* `uint16`
* `int32`
* `uint32`
... | lib/satchel.ex | 0.733738 | 0.533944 | satchel.ex | starcoder |
defmodule Tzdata.PeriodBuilder do
@moduledoc false
alias Tzdata.Util, as: Util
# the last year to use when precalcuating rules that go into the future
# indefinitely
@years_in_the_future_where_precompiled_periods_are_used 40
@extra_years_to_precompile 4
@future_years_in_seconds (@years_in_the_future_wher... | deps/tzdata/lib/tzdata/period_builder.ex | 0.742515 | 0.564098 | period_builder.ex | starcoder |
defmodule Support.Harness.Validation do
import ExUnit.Assertions
alias Absinthe.{Blueprint, Schema, Phase, Pipeline, Language}
@type error_checker_t :: ([{Blueprint.t, Blueprint.Error.t}] -> boolean)
defmacro __using__(_) do
quote do
import unquote(__MODULE__)
def bad_value(node_kind, message... | test/support/harness/validation.ex | 0.70304 | 0.446796 | validation.ex | starcoder |
defmodule ExAws.Boto.Util do
@doc """
Converts a service ID and shape name into an Elixir module
## Examples
iex> ExAws.Boto.Util.module_name("SomeService", "TestObject")
ExAws.SomeService.TestObject
"""
def module_name(service_id, shape \\ nil)
def module_name(service_id, nil) do
["Elixir... | lib/ex_aws/boto/util.ex | 0.685318 | 0.497925 | util.ex | starcoder |
defmodule Aecore.Account.Tx.SpendTx do
@moduledoc """
Module defining the Spend transaction
"""
@behaviour Aecore.Tx.Transaction
alias Aecore.Account.{Account, AccountStateTree}
alias Aecore.Account.Tx.SpendTx
alias Aecore.Chain.{Identifier, Chainstate}
alias Aecore.Keys
alias Aecore.Tx.{DataTx, Sig... | apps/aecore/lib/aecore/account/tx/spend_tx.ex | 0.868088 | 0.481515 | spend_tx.ex | starcoder |
defmodule Unicode.Property do
@moduledoc """
Functions to introspect Unicode properties for binaries
(Strings) and codepoints.
"""
@behaviour Unicode.Property.Behaviour
@type string_or_codepoint :: String.t() | non_neg_integer
alias Unicode.{Utils, GeneralCategory, Emoji}
@derived_properties Utils.d... | lib/unicode/property.ex | 0.938717 | 0.45538 | property.ex | starcoder |
defmodule Nostrum.Cache.ChannelCache do
@moduledoc """
Cache for channels.
The ETS table name associated with the Channel Cache is `:channels`. Besides the
methods provided below you can call any other ETS methods on the table.
## Example
```elixir
info = :ets.info(:channels)
[..., heir: :none, name: ... | lib/nostrum/cache/channel_cache.ex | 0.932691 | 0.807499 | channel_cache.ex | starcoder |
defmodule Vector do
@moduledoc """
Functions that work on vectors.
This datastructure wraps Erlang's `array` type for fast random
lookup and update to large collections.
The point of this module is not meant to be a 1:1 wrapper, but to be
a useful set of higher-level API operations.
Note that this modu... | lib/vector.ex | 0.951919 | 0.756268 | vector.ex | starcoder |
defmodule ResxDropbox.Utility do
@moduledoc """
General helpers.
### Dropbox Content Hash
This module provides an implementation of the [Dropbox Content Hash](https://www.dropbox.com/developers/reference/content-hash).
For use externally or with `Resx.Resource`.
"""
@type algos ::... | lib/resx_dropbox/utility.ex | 0.89077 | 0.551453 | utility.ex | starcoder |
defmodule Snitch.Data.Schema.Card do
@moduledoc """
Models Credit and Debit cards.
A `User` can save cards by setting the `:card_name`, even if the card is not
saved, it is associated with the user.
"""
use Snitch.Data.Schema
alias Snitch.Data.Schema.{CardPayment, User}
@typedoc """
## `:is_disabl... | apps/snitch_core/lib/core/data/schema/card.ex | 0.885885 | 0.593285 | card.ex | starcoder |
alias Maru.Entity.Utils
alias Maru.Entity.Struct.{Batch, Serializer, Exposure}
alias Maru.Entity.Struct.Exposure.{Runtime, Information}
defmodule Maru.Entity do
@moduledoc ~S"""
## Defining Entities
### Basic Exposure
expose :id
expose with `Map.get(instance, :id)`
`%{id: 1}` => `%{id: 1}`
### ... | lib/maru/entity.ex | 0.848612 | 0.455622 | entity.ex | starcoder |
defmodule PhxComponentHelpers do
@moduledoc """
`PhxComponentHelpers` are helper functions meant to be used within Phoenix
LiveView live_components to make your components more configurable and extensible
from your templates.
It provides following features:
* set HTML or data attributes from component ass... | lib/phx_component_helpers.ex | 0.918893 | 0.853547 | phx_component_helpers.ex | starcoder |
defmodule LexibombServer.Board.Grid do
@moduledoc """
Acts as the glue between the high-level board interface and the low-level
square states.
The grid module is responsible for establishing and manipulating the
underlying data structure of a board's coordinate system. The squares within
a grid are referre... | apps/lexibomb_server/lib/lexibomb_server/board/grid.ex | 0.949553 | 0.834609 | grid.ex | starcoder |
defmodule Cashtrail.Contacts.Contact do
@moduledoc """
This is an `Ecto.Schema` struct that represents a contact of the entity.
## Definition
According to the [BusinessDictionary.com](http://www.businessdictionary.com/definition/contact.html),
this term can be used to describe reaching out to or being in to... | apps/cashtrail/lib/cashtrail/contacts/contact.ex | 0.81648 | 0.66993 | contact.ex | starcoder |
defmodule Protobuf.TypeUtil do
require Record
Record.defrecord(
:proto_type,
code: 0,
label: :DEFAULT_TYPE,
type: :default,
elixir_type: "any()"
)
@type t :: record(
:proto_type,
code: non_neg_integer(),
label: atom(),
type: atom(),
elixir_type: String.t() | :dynamic
... | lib/protobuf/type_util.ex | 0.612657 | 0.472014 | type_util.ex | starcoder |
defmodule Day12 do
def part1(path) do
solve(path, &move/2, {1, 0})
end
def part2(path) do
solve(path, &move_waypoint/2, {10, 1})
end
def solve(path, move, start) do
path
|> File.stream!()
|> Enum.map(&parse/1)
|> Enum.reduce({{0, 0}, start}, move)
|> elem(0)
|> manhattan({0, ... | lib/day_12.ex | 0.722625 | 0.732927 | day_12.ex | starcoder |
defmodule Curvy.Point do
@moduledoc """
Module used for manipulating ECDSA point coordinates.
"""
use Bitwise, only_operators: true
import Curvy.Util, only: [mod: 2, inv: 2, ipow: 2]
alias Curvy.{Curve, Key, Signature}
defstruct [:x, :y]
@typedoc "Point Coordinates"
@type t :: %__MODULE__{
x: in... | lib/curvy/point.ex | 0.90546 | 0.668759 | point.ex | starcoder |
if Version.match?(System.version(), ">= 1.3.0") do
defmodule Faker.Date do
@moduledoc """
Functions for generating dates
"""
@seconds_per_day 86400
@doc """
Returns a random date of birth for a person with an age specified by a number or range
## Examples
date_of_birth #=> ~D[1... | lib/faker/date.ex | 0.804367 | 0.451387 | date.ex | starcoder |
defmodule Parques.Core.Game do
@moduledoc """
A Game is the primary piece of data, representing a match of ParquΓ©s.
"""
use TypedStruct
import Parques.Core.Color, only: [is_color: 1]
alias Parques.Core.Color
alias Parques.Core.Player
@max_players Color.count()
@type id :: String.t()
@type state ... | lib/parques/core/game.ex | 0.817137 | 0.439086 | game.ex | starcoder |
defimpl String.Chars, for: ExPcap.MagicNumber do
@doc """
Returns a human readable representation of the magic number.
"""
@spec to_string(ExPcap.MagicNumber.t()) :: String.t()
def to_string(magic_number) do
"""
magic number: 0x#{magic_number.magic |> Integer.to_string(16) |> String.downcase()... | lib/expcap/magic_number.ex | 0.831656 | 0.574335 | magic_number.ex | starcoder |
defmodule PlugCacheControl do
@moduledoc """
A plug + helpers for overwriting the default `cache-control` header. The plug
supports all the response header directives defined in [RFC7234, section
5.2.2](https://datatracker.ietf.org/doc/html/rfc7234#section-5.2.2).
## Header directives
The `PlugCacheContro... | lib/plug_cache_control.ex | 0.867787 | 0.670706 | plug_cache_control.ex | starcoder |
defmodule ExSieve.Builder.Where do
@moduledoc false
alias Ecto.Query.Builder.Filter
alias ExSieve.Node.{Attribute, Grouping, Condition}
@true_values [1, '1', 'T', 't', true, 'true', 'TRUE', "1", "T", "t", "true",
"TRUE"]
@spec build(Ecto.Queryable.t, Grouping.t, Macro.t) :: Ecto.Query.t
de... | lib/ex_sieve/builder/where.ex | 0.635336 | 0.550909 | where.ex | starcoder |
defmodule Hunter do
@moduledoc """
A Elixir client for Mastodon, a GNU Social compatible micro-blogging service
"""
@hunter_version Mix.Project.config()[:version]
@doc """
Retrieve account of authenticated user
## Parameters
* `conn` - connection credentials
"""
@spec verify_credentials(Hunt... | lib/hunter.ex | 0.903661 | 0.534916 | hunter.ex | starcoder |
defmodule GeoDistance do
@moduledoc """
Using the [Haversine
formula](http://rosettacode.org/wiki/Haversine_formula#Erlang)
calculate the distance between two point of latitude/longititude.
To and From parameters may be specified as
(from_lat, from_long, to_lat, to_long)
or
({from_la... | lib/geo_distance.ex | 0.954616 | 0.920576 | geo_distance.ex | starcoder |
defmodule VexValidators.Number do
@moduledoc """
Ensure a value is a number.
## Options
The `options` can be a keyword list with any of the following keys:
* `:is`: A boolean value whether the value must be or not a number.
* `:==`: A number where must be equal to the value.
* `:>`: A number where must... | lib/vex_validators/number.ex | 0.911972 | 0.714728 | number.ex | starcoder |
defmodule Arfficionado do
@moduledoc """
Reader for [ARFF (Attribute Relation File Format)](https://waikato.github.io/weka-wiki/arff/) data.
Adaptable to application-specific needs through custom handler behaviour implementations.
```
{:ok, instances} =
File.stream!("data.arff")
|> Arfficionado.read(... | lib/arfficionado.ex | 0.838812 | 0.827793 | arfficionado.ex | starcoder |
defmodule Maze.Server do
@moduledoc """
Provides an API to create one or more mazes.
"""
require Logger
use GenServer
alias Maze.{Path}
defstruct mazes: []
def canvas_options(maze, paint_mode \\ :solve, paint_interval \\ 100) do
[
title: 'Elixir Maze #{maze.rows} x #{maze.columns}',
... | lib/maze/server.ex | 0.778439 | 0.461259 | server.ex | starcoder |
defmodule Stops.Nearby do
@moduledoc "Functions for retrieving and organizing stops relative to a location."
import Util.Distance
alias Routes.Route
alias Stops.Stop
alias Util.{Distance, Position}
@default_timeout 10_000
@mile_in_degrees 0.02
@total 12
@type route_with_direction :: %{direction_id: ... | apps/stops/lib/nearby.ex | 0.866641 | 0.400163 | nearby.ex | starcoder |
defmodule Kino.DataTable do
@moduledoc """
A widget for interactively viewing enumerable data.
The data must be an enumerable of records, where each
record is either map, struct, keyword list or tuple.
## Examples
data = [
%{id: 1, name: "Elixir", website: "https://elixir-lang.org"},
... | lib/kino/data_table.ex | 0.768168 | 0.625266 | data_table.ex | starcoder |
defmodule ExCoveralls.Local do
@moduledoc """
Locally displays the result to screen.
"""
defmodule Count do
@moduledoc """
Stores count information for calculating coverage values.
"""
defstruct lines: 0, relevant: 0, covered: 0
end
@doc """
Provides an entry point for the module.
"""... | lib/excoveralls/local.ex | 0.655667 | 0.49707 | local.ex | starcoder |
defmodule Zaryn.Mining.StandaloneWorkflow do
@moduledoc """
Transaction validation is performed in a single node processing.
This workflow should be executed only when the network is bootstrapping (only 1 validation node)
The single node will auto validate the transaction
"""
use Task
alias Zaryn.Crypto... | lib/zaryn/mining/standalone_workflow.ex | 0.798423 | 0.432303 | standalone_workflow.ex | starcoder |
defmodule TimeZoneInfo.Transformer.Rule do
@moduledoc """
This module handles and transforms the IANA rules.
"""
alias TimeZoneInfo.{
IanaDateTime,
IanaParser,
Transformer.RuleSet,
UtcDateTime
}
@doc """
Returns a map of rule-set for the given map of `rules`.
"""
@spec to_rule_sets(%... | lib/time_zone_info/transformer/rule.ex | 0.905909 | 0.531513 | rule.ex | starcoder |
defmodule Crew.Periods do
@moduledoc """
The Periods context.
"""
import Ecto.Query, warn: false
import Ecto.Changeset
alias Crew.Repo
alias Crew.Periods.Period
def period_query(site_id), do: from(p in Period, where: p.site_id == ^site_id)
@doc """
Returns the list of periods.
## Examples
... | lib/crew/periods.ex | 0.906965 | 0.572155 | periods.ex | starcoder |
defmodule Sanbase.MapUtils do
@doc ~s"""
Return a subset of `left` map that has only the keys that are also present in `right`.
#### Examples:
iex> Sanbase.MapUtils.drop_diff_keys(%{}, %{})
%{}
iex> Sanbase.MapUtils.drop_diff_keys(%{a: 1}, %{a: 1})
%{a: 1}
iex> Sanbase.MapUtils.drop_diff_ke... | lib/map_utils.ex | 0.858481 | 0.597872 | map_utils.ex | starcoder |
defmodule Oban.Plugins.Stager do
@moduledoc """
Transition jobs to the `available` state when they reach their scheduled time.
This module is necessary for the execution of scheduled and retryable jobs.
## Options
* `:interval` - the number of milliseconds between database updates. This is directly tied to... | lib/oban/plugins/stager.ex | 0.84691 | 0.622961 | stager.ex | starcoder |
defmodule Queutils.BlockingQueue do
use GenServer
@moduledoc """
A queue with a fixed length that blocks on `Queutils.BlockingQueue.push/2` if the queue is full.
## Usage
Add it to your application supervisor's `start/2` function, like this:
def start(_type, _args) do
children = [
... | lib/queutils/blocking_queue.ex | 0.835651 | 0.449755 | blocking_queue.ex | starcoder |
defmodule Exco do
@moduledoc ~S"""
Concurrent versions of some of the functions in the `Enum` module.
See further discussion in the [readme section](readme.html).
## Options
* `max_concurrency` - the maximum number of items to run at the same time. Set it to an integer or one of the following:
* `:sch... | lib/exco.ex | 0.88136 | 0.815637 | exco.ex | starcoder |
defmodule AWS.Neptune do
@moduledoc """
Amazon Neptune
Amazon Neptune is a fast, reliable, fully-managed graph database service that
makes it easy to build and run applications that work with highly connected
datasets.
The core of Amazon Neptune is a purpose-built, high-performance graph database
engin... | lib/aws/generated/neptune.ex | 0.868353 | 0.678094 | neptune.ex | starcoder |
defmodule Unicode.GeneralCategory do
@moduledoc """
Functions to introspect Unicode
general categories for binaries
(Strings) and codepoints.
"""
@behaviour Unicode.Property.Behaviour
alias Unicode.Utils
alias Unicode.GeneralCategory.Derived
@categories Utils.categories()
|> Utils.re... | lib/unicode/category.ex | 0.91384 | 0.459076 | category.ex | starcoder |
defmodule Exexif.Data.Gps do
@moduledoc """
Internal representation of GPS tag in the EXIF.
"""
@type t :: %Exexif.Data.Gps{
gps_version_id: any(),
gps_latitude_ref: any(),
gps_latitude: any(),
gps_longitude_ref: any(),
gps_longitude: any(),
gps_altit... | lib/exexif/data/gps.ex | 0.765023 | 0.50061 | gps.ex | starcoder |
defmodule Temp do
@type options :: nil | Path.t | map
@doc """
Returns `:ok` when the tracking server used to track temporary files started properly.
"""
@pdict_key :"$__temp_tracker__"
@spec track :: Agent.on_start
def track() do
case Process.get(@pdict_key) do
nil ->
start_tracker()... | lib/temp.ex | 0.79653 | 0.451266 | temp.ex | starcoder |
defmodule Cldr.AcceptLanguage do
@moduledoc """
Tokenizer and parser for HTTP `Accept-Language` header values as defined in
[rfc2616](https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4).
The Accept-Language request-header field is similar to Accept, but restricts
the set of natural languages tha... | lib/cldr/accept_language.ex | 0.905022 | 0.464659 | accept_language.ex | starcoder |
defmodule Alchemetrics.Annotation do
alias Alchemetrics.Annotation.InstrumentedFunctionList
alias Alchemetrics.Annotation.Function
@moduledoc """
Annotations allow you to automatically report the amount of calls and time spent on a particular function.
They work with multiple clauses, guard clauses, recursi... | lib/alchemetrics/annotation/annotation.ex | 0.881825 | 0.926835 | annotation.ex | starcoder |
defmodule Bodyguard do
@moduledoc """
Authorize actions at the boundary of a context
Please see the [README](readme.html).
"""
@type opts :: keyword | %{optional(atom) => any}
@doc """
Authorize a user's action.
Returns `:ok` on success, and `{:error, reason}` on failure.
If `params` is a keyword... | lib/bodyguard.ex | 0.878164 | 0.516778 | bodyguard.ex | starcoder |
defmodule Issues.TableFormatter do
import Enum, only: [ each: 2, map: 2, map_join: 3, max: 1 ]
@doc """
Takes a list of row data, where each row is a HashDict, and a list of
headers. Prints a table to STDOUT of the data from each row
identified by each header. That is, each header identifies a column,
and ... | programming_elixir/issues/lib/issues/table_formatter.ex | 0.870198 | 0.811452 | table_formatter.ex | starcoder |
defmodule BoardingStatus do
@moduledoc """
Structure to represent the status of a single train
"""
require Logger
import ConfigHelpers
defstruct scheduled_time: :unknown,
predicted_time: :unknown,
route_id: :unknown,
trip_id: :unknown,
direction_id: :unknown,... | apps/commuter_rail_boarding/lib/boarding_status.ex | 0.833121 | 0.513485 | boarding_status.ex | starcoder |
defmodule Hammox do
@moduledoc """
Hammox is a library for rigorous unit testing using mocks, explicit
behaviours and contract tests.
See the [README](readme.html) page for usage guide and examples.
Most of the functions in this module come from
[Mox](https://hexdocs.pm/mox/Mox.html) for backwards compati... | lib/hammox.ex | 0.859295 | 0.893913 | hammox.ex | starcoder |
defmodule SanbaseWeb.Graphql.Complexity do
require Logger
@compile inline: [
calculate_complexity: 3,
interval_seconds: 1,
years_difference_weighted: 2,
get_metric_name: 1
]
@doc ~S"""
Returns the complexity as a real number.
For basic authoriza... | lib/sanbase_web/graphql/complexity/complexity.ex | 0.910002 | 0.672202 | complexity.ex | starcoder |
defmodule ScrapyCloudEx.Endpoints.Storage.Requests do
@moduledoc """
Wraps the [Requests](https://doc.scrapinghub.com/api/requests.html) endpoint.
The requests API allows you to work with request and response data from your crawls.
"""
import ScrapyCloudEx.Endpoints.Guards
alias ScrapyCloudEx.Endpoints.H... | lib/endpoints/storage/requests.ex | 0.807878 | 0.681217 | requests.ex | starcoder |
defmodule Phoenix.LiveView.Router do
@moduledoc """
Provides LiveView routing for Phoenix routers.
"""
@cookie_key "__phoenix_flash__"
@doc """
Defines a LiveView route.
A LiveView can be routed to by using the `live` macro with a path and
the name of the LiveView:
live "/thermostat", Thermost... | lib/phoenix_live_view/router.ex | 0.909849 | 0.587884 | router.ex | starcoder |
defmodule Akin do
@moduledoc """
Akin
=======
Functions for comparing two strings for similarity using a collection of string comparison algorithms for Elixir. Algorithms can be called independently or in total to return a map of metrics.
## Options
Options accepted in a keyword list (i.e. [ngram_size: 3... | lib/akin.ex | 0.911974 | 0.718446 | akin.ex | starcoder |
defmodule Nostrum.Cache.PresenceCache do
@default_cache_implementation Nostrum.Cache.PresenceCache.ETS
@moduledoc """
Cache behaviour & dispatcher for Discord presences.
By default, `#{@default_cache_implementation}` will be use for caching
presences. You can override this in the `:caches` option of the `no... | lib/nostrum/cache/presence_cache.ex | 0.827689 | 0.624508 | presence_cache.ex | starcoder |
defmodule Fixate do
@moduledoc """
Insert fixtures into your ExUnit context in a clean manner.
## Usage
Start Fixate by adding `Fixate.start()` to your `test/test_helper.exs` file.
```elixir
ExUnit.start()
Fixate.start()
```
Then inside your test files add `use Fixate.Case` to allow the fixtur... | lib/fixate.ex | 0.910304 | 0.78374 | fixate.ex | starcoder |
defmodule Ecto.Adapter.Queryable do
@moduledoc """
Specifies the query API required from adapters.
"""
@typedoc "Proxy type to the adapter meta"
@type adapter_meta :: Ecto.Adapter.adapter_meta()
@typedoc "Ecto.Query metadata fields (stored in cache)"
@type query_meta :: %{sources: tuple, preloads: term,... | lib/ecto/adapter/queryable.ex | 0.898541 | 0.417954 | queryable.ex | starcoder |
defmodule Protobuf do
@moduledoc """
`protoc` should always be used to generate code instead of writing the code by hand.
By `use` this module, macros defined in `Protobuf.DSL` will be injected. Most of thee macros
are equal to definition in .proto files.
defmodule Foo do
use Protobuf, syntax: :... | lib/protobuf.ex | 0.924108 | 0.481759 | protobuf.ex | starcoder |
defmodule Highlander do
@moduledoc """
Highlander allows you to run a single globally unique process in a cluster.
Highlander uses erlang's `:global` module to ensure uniqueness, and uses `child_spec.id` as the uniqueness key.
Highlander will start its child process just once in a cluster. The first Highlande... | lib/highlander.ex | 0.824885 | 0.926901 | highlander.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.
"""
alias MerklePatriciaTree.Trie.Storage
alias MerklePatriciaTree.{HexPrefix, Trie}
@type trie_node ::
... | apps/merkle_patricia_tree/lib/merkle_patricia_tree/trie/node.ex | 0.859649 | 0.521349 | node.ex | starcoder |
defmodule AWS.ApplicationAutoScaling do
@moduledoc """
With Application Auto Scaling, you can configure automatic scaling for the
following resources:
<ul> <li> Amazon ECS services
</li> <li> Amazon EC2 Spot Fleet requests
</li> <li> Amazon EMR clusters
</li> <li> Amazon AppStream 2.0 fleets
</li>... | lib/aws/application_auto_scaling.ex | 0.930789 | 0.605799 | application_auto_scaling.ex | starcoder |
defmodule Scenic.Math.Matrix.Utils do
@moduledoc """
Helper functions for working with matrices.
The matrix format for the main Scenic.Math.Matrix functions is a 64 byte binary
blob containing 16 4-byte floats. This is great for doing the math in code,
but not so great for reading or understanding the value... | lib/scenic/math/matrix_utils.ex | 0.867556 | 0.480052 | matrix_utils.ex | starcoder |
defmodule D3 do
def p1(input) do
list_of_numbers = String.split(input)
frequencies = calc_frequencies(list_of_numbers)
gamma = rate_value(Enum.reverse(frequencies), {0, 0}, :gamma)
epsilon = rate_value(Enum.reverse(frequencies), {0, 0}, :epsilon)
gamma * epsilon
end
def p2(input) do
oxyg... | d03/lib/d3.ex | 0.544075 | 0.540378 | d3.ex | starcoder |
defmodule Lumberjack do
@moduledoc """
Documentation for `Lumberjack`.
"""
@doc """
Hello world.
## Examples
iex> Lumberjack.hello()
:world
"""
def hello do
:world
end
def split(seq) do split(seq, 0, [], []) end
def split([], l, left, right) do
[{left, right, l}]
... | lumberjack/lib/lumberjack.ex | 0.728362 | 0.652982 | lumberjack.ex | starcoder |
defmodule Textwrap do
@moduledoc """
`Textwrap` provides a set of functions for wrapping, indenting, and dedenting text. It wraps the Rust [`textwrap`](https://lib.rs/textwrap) crate.
## Wrapping
Use `wrap/2` to turn a `String` into a list of `String`s each no more
than `width` characters long.
iex> ... | lib/textwrap.ex | 0.936901 | 0.521959 | textwrap.ex | starcoder |
defmodule Ockam.Services.Kafka.Provider do
@moduledoc """
Implementation for Ockam.Services.Provider
providing kafka stream services, :stream_kafka and :stream_kafka_index
Services arguments:
stream_kafka:
address_prefix: optional<string>, worker address prefix
stream_prefix: optional<string>, kafka ... | implementations/elixir/ockam/ockam_kafka/lib/services/provider.ex | 0.830353 | 0.407864 | provider.ex | starcoder |
defmodule Bolt.Sips.Response do
@moduledoc """
Support for transforming a Bolt response to a list of Bolt.Sips.Types or arbitrary values.
A Bolt.Sips.Response is used for mapping any response received from a Neo4j server into a an Elixir struct.
You'll interact with this module every time you're needing to get... | lib/bolt_sips/response.ex | 0.730386 | 0.557243 | response.ex | starcoder |
defmodule WhereTZ do
@moduledoc """
**WhereTZ** is Elixir version of Ruby gem for lookup of timezone by georgraphic coordinates.
## Example
iex(1)> WhereTZ.lookup(50.004444, 36.231389)
"Europe/Kiev"
iex(2)> WhereTZ.get(50.004444, 36.231389)
#<TimezoneInfo(Europe/Kiev - EET (+02:00:... | lib/wheretz.ex | 0.913305 | 0.482002 | wheretz.ex | starcoder |
defmodule Eml.Query.Helper do
@moduledoc false
alias Eml.Element
def do_transform(_node, :node, value) do
value
end
def do_transform(%Element{attrs: attrs} = node, { :attrs, key }, value) do
%Element{node|attrs: Map.put(attrs, key, value)}
end
def do_transform(%Element{} = node, key, value) do
... | lib/eml/query.ex | 0.747892 | 0.478346 | query.ex | starcoder |
defmodule ExRabbitMQ.RPC.Server do
@moduledoc """
*A behavior module for implementing a RabbitMQ RPC server with a `GenServer`.*
It uses the `ExRabbitMQ.Consumer`, which in-turn uses the `AMQP` library to configure and consume messages.
Additionally this module offers a way to receive requests and send back re... | lib/ex_rabbitmq/rpc/server.ex | 0.896026 | 0.824144 | server.ex | starcoder |
defmodule Weaver do
@moduledoc """
Root module and main API of Weaver.
Entry point for weaving queries based on `Absinthe.Pipeline`.
Use `run/3` for initial execution, returning a `Weaver.Step.Result`.
Subsequent steps (the result's `dispatched` and `next` steps) can be executed via `resolve/3`.
"""
de... | lib/weaver.ex | 0.898801 | 0.62651 | weaver.ex | starcoder |
defmodule Vex.Validators.Confirmation do
@moduledoc """
Ensure a value, if provided, is equivalent to a second value.
Generally used to check, eg, a password and password
confirmation.
Note: This validator is treated differently by Vex, in that
two values are passed to it.
## Options
* `:message`: ... | lib/vex/validators/confirmation.ex | 0.837935 | 0.489564 | confirmation.ex | starcoder |
defmodule SMWCBot.MessageServer do
@moduledoc """
A GenServer for Sending messages at a specified rate.
## Options
- `:rate` (integer) - The rate at which to send the messages. (one message
per `rate`). Optional. Defaults to `1500` ms.
### Twitch command and message rate limits:
If command and me... | lib/smwc_bot/message_server.ex | 0.851984 | 0.530419 | message_server.ex | starcoder |
defmodule Crutches.String do
alias Crutches.Option
import String,
only: [
replace: 3,
slice: 2,
trim: 1
]
@moduledoc ~s"""
Convenience functions for strings.
This module provides several convenience functions operating on strings.
Simply call any function (with any options if ap... | lib/crutches/string.ex | 0.868465 | 0.438124 | string.ex | starcoder |
defmodule SqlValue do
@moduledoc """
Implementations of SQL operators and functions (where they differ from Elixir).
SQL is pretty weird, around `NULL` at least; we have to implement the weirdness
somewhere.
"""
@doc """
True if `v` is a null value.
Because the CSV files don't include any information... | jorendorff+elixir/lib/SqlValue.ex | 0.901463 | 0.586819 | SqlValue.ex | starcoder |
defmodule ShEx.ShExC.Decoder do
@moduledoc false
import ShEx.Utils
alias RDF.{IRI, BlankNode, Literal, XSD}
alias ShEx.NodeConstraint.{StringFacets, NumericFacets}
import RDF.Serialization.ParseHelper, only: [error_description: 1]
defmodule State do
@moduledoc false
defstruct base_iri: nil, nam... | lib/shex/shexc/decoder.ex | 0.627495 | 0.500671 | decoder.ex | starcoder |
defmodule Ratatouille.Renderer.Element.Panel do
@moduledoc false
@behaviour Ratatouille.Renderer
alias ExTermbox.Position
alias Ratatouille.Renderer.{Border, Box, Canvas, Element, Text}
@padding 2
@title_offset_x 2
@impl true
def render(
%Canvas{render_box: box} = canvas,
%Element{att... | lib/ratatouille/renderer/element/panel.ex | 0.856392 | 0.42051 | panel.ex | starcoder |
defmodule Advent.Y2021.D09 do
@moduledoc """
https://adventofcode.com/2021/day/9
"""
@typep point :: {non_neg_integer(), non_neg_integer()}
@typep grid :: %{point() => non_neg_integer()}
@doc """
Find all of the low points on your heightmap. What is the sum of the risk
levels of all low points on your... | lib/advent/y2021/d09.ex | 0.767559 | 0.589066 | d09.ex | starcoder |
defmodule Omise.Recipient do
@moduledoc ~S"""
Provides Recipient API interfaces.
<https://www.omise.co/recipients-api>
"""
use Omise.HTTPClient, endpoint: "recipients"
defstruct object: "recipient",
id: nil,
livemode: nil,
location: nil,
verified: nil,
... | lib/omise/recipient.ex | 0.913416 | 0.529993 | recipient.ex | starcoder |
defmodule Stripe.Util do
def datetime_from_timestamp(ts) when is_binary ts do
ts = case Integer.parse ts do
:error -> 0
{i, _r} -> i
end
datetime_from_timestamp ts
end
def datetime_from_timestamp(ts) when is_number ts do
{{year, month, day}, {hour, minutes, seconds}} = :calendar.grego... | lib/stripe/util.ex | 0.656438 | 0.460168 | util.ex | starcoder |
defmodule ColonelKurtz.BlockTypeContent do
@moduledoc """
`BlockTypeContent` is used to model the inner `content` field for a given block
type. Each block type has a unique schema represented by an Ecto.Schema that
defines an `embedded_schema` for the expected fields (corresponding with the
JS implementation ... | lib/colonel_kurtz/block_type_content.ex | 0.823506 | 0.441553 | block_type_content.ex | starcoder |
defmodule Membrane.RawAudio do
@moduledoc """
This module contains a definition and related functions for struct `t:#{inspect(__MODULE__)}.t/0`,
describing a format of raw audio stream with interleaved channels.
"""
alias __MODULE__.SampleFormat
alias Membrane.Time
@compile {:inline,
[
... | lib/membrane_raw_audio.ex | 0.909942 | 0.687525 | membrane_raw_audio.ex | starcoder |
defmodule Vivaldi.Peer.PingClient do
@moduledoc """
Periodically Pings peers in a random order, and measures RTT on response.
When 8(configurable) responses are received from another peer `x_j`, the median RTT and latest coordinate of `x_j` is chosen, and sent to the Coordinate process
so that it can update o... | vivaldi/lib/peer/ping_client.ex | 0.782746 | 0.448306 | ping_client.ex | starcoder |
defmodule Ockam.Stream.Index.Shard do
@moduledoc """
Stream index management shard.
This module performs storage operations and keeping state per client_id/stream_name pair
"""
use Ockam.Worker
require Logger
def get_index(shard, partition) do
GenServer.call(shard, {:get_index, partition})
end
... | implementations/elixir/ockam/ockam/lib/ockam/stream/index/shard.ex | 0.754418 | 0.405331 | shard.ex | starcoder |
defmodule MixUnused.Filter do
@moduledoc false
import Kernel, except: [match?: 2]
alias MixUnused.Exports
@type module_pattern() :: module() | Regex.t() | :_
@type function_pattern() :: atom() | Regex.t() | :_
@type arity_pattern() :: arity() | Range.t(arity(), arity()) | :_
@type pattern() ::
... | lib/mix_unused/filter.ex | 0.851305 | 0.86771 | filter.ex | starcoder |
defexception IO.StreamError, reason: nil do
def message(exception) do
formatted = iolist_to_binary(:file.format_error(reason exception))
"error during streaming: #{formatted}"
end
end
defmodule IO do
@moduledoc """
Module responsible for doing IO. Many functions in this
module expects an IO device an... | lib/elixir/lib/io.ex | 0.87584 | 0.677444 | io.ex | starcoder |
defmodule Logi.Layout do
@moduledoc """
Log Message Layout Behaviour.
This module defines the standard interface to format log messages issued by the functions in `Logi` module.
(e.g., `Logi.info/3`, `Logi.warning/3`, etc)
A layout instance may be installed into a channel along with an associated sink.
#... | lib/logi/layout.ex | 0.894397 | 0.76934 | layout.ex | starcoder |
defmodule Refraction.Neuron do
alias Refraction.Neuron
alias Refraction.Neuron.{Activation, Connection}
@type t :: %__MODULE__{
pid: pid(),
input: integer,
output: integer | float,
incoming: [integer],
outgoing: [integer | float],
bias?: boolean,
... | lib/refraction/neuron.ex | 0.825027 | 0.424173 | neuron.ex | starcoder |
defmodule RGBMatrix.Animation.HueWave do
@moduledoc """
Creates a wave of shifting hue that moves across the matrix.
"""
use RGBMatrix.Animation
alias Chameleon.HSV
alias KeyboardLayout.LED
import RGBMatrix.Utils, only: [mod: 2]
field(:speed, :integer,
default: 4,
min: 0,
max: 32,
do... | lib/rgb_matrix/animation/hue_wave.ex | 0.922961 | 0.597667 | hue_wave.ex | starcoder |
defmodule Strsim do
@moduledoc """
Documentation for `Strsim`.
"""
@doc """
Like optimal string alignment, but substrings can be edited an unlimited number of times, and the triangle inequality holds.
iex> Strsim.damerau_levenshtein("ab", "bca")
{:ok, 2}
"""
defdelegate damerau_levenshtein(a... | lib/strsim.ex | 0.911441 | 0.625724 | strsim.ex | starcoder |
defmodule Atomex.Feed do
@moduledoc """
Represent an Atom feed. Embed many `Atomex.Entry`
"""
@type t :: list()
import XmlBuilder
alias Atomex.Types.{Person, Link, Text, Category}
@doc """
Create a new feed
"""
@spec new(binary(), DateTime.t(), binary(), binary()) :: Atomex.Feed.t()
def new(id,... | lib/atomex/feed.ex | 0.899048 | 0.401277 | feed.ex | starcoder |
defmodule Mailapi.SmtpHandler do
@behaviour :gen_smtp_server_session
require Logger
alias Mailapi.Database
defmodule State do
defstruct options: []
end
@type error_message :: {:error, String.t, State.t}
# SMTP error codes
@smtp_too_busy 421
@smtp_requested_action_okay 250
@smtp_mail_action_a... | lib/mailapi/smtp_handler.ex | 0.539226 | 0.623635 | smtp_handler.ex | starcoder |
defmodule Towwwer.Tools.WPScan do
@moduledoc """
Contains functions used to interact with the separately installed
WPScan tool.
"""
@doc """
Run WPScan against the given `url` with default settings.
TODO: Check if System.cmd actually runs properly.
"""
@spec run(map(), String.t()) :: {:ok, any()} | {... | lib/towwwer/tools/wpscan.ex | 0.600188 | 0.4165 | wpscan.ex | starcoder |
require Logger
defmodule Notifications.Data.Migrator do
@moduledoc """
This applies any migrations provided by Data.Migrations.all that have not been applied
in order, with transactional context. While the changes are not written to be idempotent,
the transaction around each migration ensures that we can't be ... | components/notifications-service/server/lib/data/migrator.ex | 0.785473 | 0.416856 | migrator.ex | starcoder |
defmodule Adap.Joiner do
@doc """
Make a stream wich reduces input elements joining them according to specified key pattern.
The principle is to keep a fixed length queue of elements waiting to
receive joined elements.
This is for stream of elements where order is unknown, but elements to join
are suppose... | lib/joiner.ex | 0.685529 | 0.544438 | joiner.ex | starcoder |
defmodule Day10 do
def part1(input, chip_list \\ [17, 61]) do
solve(input, chip_list)
|> Map.fetch!(:result)
|> elem(1)
end
def part2(input) do
solve(input, nil)
|> result_part2
end
defp solve(input, chip_list) do
instructions = Parser.parse(input)
state = init_state(instruction... | day10/lib/day10.ex | 0.537527 | 0.558809 | day10.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.