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 Adventofcode.Day10KnotHash do
require Bitwise
defstruct current: 0, skip: 0, size: 255, lengths: [], values: {}
def first_two_sum(input, list_size \\ 256) do
input
|> build_lengths
|> new(list_size)
|> process_recursively
|> sum_of_first_two
end
def knot_hash(input) do
inp... | lib/day_10_knot_hash.ex | 0.707506 | 0.627552 | day_10_knot_hash.ex | starcoder |
defmodule Aja.OrdMap do
base_doc = ~S"""
A map preserving key insertion order, with efficient lookups, updates and enumeration.
It works like regular maps, except that the insertion order is preserved:
iex> %{"one" => 1, "two" => 2, "three" => 3}
%{"one" => 1, "three" => 3, "two" => 2}
iex> Aj... | lib/ord_map.ex | 0.85183 | 0.553566 | ord_map.ex | starcoder |
defmodule AMQP.Basic.Async do
@moduledoc false
import AMQP.Core
alias AMQP.Utils
alias AMQP.Channel
@doc """
Publishes a message to an Exchange.
This method publishes a message to a specific exchange. The message will be routed
to queues as defined by the exchange configuration and distributed to any... | lib/amqp/basic/async.ex | 0.922661 | 0.617311 | async.ex | starcoder |
defmodule PhoenixBricks.Query do
@moduledoc ~S"""
Defines a common interface for adding scopes to a Schema
## Examples
```elixir
defmodule RecordQuery do
use PhoenixBricks.Query, schema: Record
end
```
It provides you a method `scope` that improve the empty scope of provided schema
with addition... | lib/phoenix_bricks/query.ex | 0.902298 | 0.904524 | query.ex | starcoder |
defmodule Day16.Part2 do
def part2(notes_filename, tickets_filename) do
{notes, my_ticket, nearby_tickets} = parse_input(notes_filename, tickets_filename)
valid_values = notes_to_mapset(notes)
valid_tickets =
Enum.filter(nearby_tickets, &([] == ticket_to_invalid_values(&1, valid_values)))
mapp... | lib/day16/part2.ex | 0.507324 | 0.602851 | part2.ex | starcoder |
defmodule ProxerEx.Api.List do
@moduledoc """
Contains helper methods to build requests for the list api.
"""
use ProxerEx.Api.Base, api_class: "list"
# Processing methods
@doc false
def to_plus_separated_string(%ProxerEx.Request{get_args: get_args} = request, name, value)
when is_list(value) do
... | lib/api_classes/list_api.ex | 0.855791 | 0.691224 | list_api.ex | starcoder |
defmodule Day10 do
def from_file(path) do
Helper.read_file(path)
|> Enum.to_list
|> List.flatten
end
def new_map(input) do
input
|> Enum.map(&String.graphemes/1)
|> Enum.with_index
|> Enum.map(fn {row, ix} -> row |> to_coordinates(ix) end)
|> List.flatten
end
def to_coordina... | lib/day10.ex | 0.692122 | 0.629177 | day10.ex | starcoder |
defmodule Eiga.Store do
import Ecto.Query
@moduledoc """
Functions for interacting with the database.
"""
alias Eiga.Repo
alias Eiga.Movie
alias Eiga.Review
@doc "Get a list of all movies watched."
def all_movies do
Movie
|> select([movie], %{id: movie.id, title: movie.title, year: movie.ye... | maru_sqlite/lib/eiga/store.ex | 0.672762 | 0.47457 | store.ex | starcoder |
defmodule AdventOfCode.Y2020.Day23.Ring do
defstruct current: nil, content: %{}, size: 0, min: nil, max: nil
alias AdventOfCode.Y2020.Day23.Ring
def new(content) do
first = Enum.take(content, 1) |> hd
size = Enum.count(content)
content
|> Stream.chunk_every(2, 1)
|> Enum.reduce(%{}, fn pair... | lib/2020/day23.ex | 0.802362 | 0.520557 | day23.ex | starcoder |
defmodule Glock do
@moduledoc """
Glock is a simple websocket client application based on the Gun
HTTP/HTTP2/Websocket Erlang library.
Glock aims to simplify the specific task of starting and configuring
a websocket client connection to a remote server, providing common
default values for all connection se... | lib/glock.ex | 0.862648 | 0.469642 | glock.ex | starcoder |
defmodule Clover do
@moduledoc """
The Clover application
"""
use Application
alias Clover.{
Adapter,
Conversation,
Robot
}
@registry Clover.Registry
@robot_supervisor Clover.Robots
@doc false
def start(_type, _args) do
Clover.Supervisor.start_link(@robot_supervisor, name: Clover... | lib/clover.ex | 0.806091 | 0.549943 | clover.ex | starcoder |
defmodule Blanket do
@moduledoc """
This is the facade of the Blanket application. Handles starting/stopping the
application and defines the client API.
"""
alias Blanket.Heir
alias Blanket.Metatable
# -- Application API --------------------------------------------------------
use Application
@doc ... | lib/blanket.ex | 0.76999 | 0.514156 | blanket.ex | starcoder |
defmodule Day13.Game do
defstruct pid: nil, paddle: {0, 0}, ball: {0, 0}
def output do
machine = 13 |> InputFile.contents_of() |> Intcode.build
my_pid = self()
spawn(fn -> Intcode.execute(machine, {:mailbox, my_pid}) end)
retrieve_output([])
|> Enum.chunk_every(3)
|> build_screen(%{})
|... | year_2019/lib/day_13/game.ex | 0.507324 | 0.451508 | game.ex | starcoder |
defmodule BigchaindbEx.Condition.Ed25519Sha256 do
@moduledoc """
ED25519: Ed25519 signature condition.
This condition implements Ed25519 signatures.
ED25519 is assigned the type ID 4. It relies only on the ED25519 feature suite
which corresponds to a bitmask of 0x20.
"""
alias BigchaindbEx.... | lib/bigchaindb_ex/condition/ed25519Sha256.ex | 0.848188 | 0.403214 | ed25519Sha256.ex | starcoder |
defmodule AntlUtilsElixir.DateTime.Period do
@moduledoc """
Period
"""
alias AntlUtilsElixir.DateTime.Comparison
@type t :: %{start_at: nil | DateTime.t(), end_at: nil | DateTime.t()}
@spec included?(map, map, atom, atom) :: boolean
def included?(a, b, start_at_key, end_at_key)
when is_map(a) and ... | lib/datetime/period.ex | 0.854126 | 0.46873 | period.ex | starcoder |
defmodule FIQLEx.QueryBuilder do
@moduledoc """
`QueryBuilder` module has to be used to build queries from FIQL.
You have at least to use this module and define the functions `init` and `build`.
Here is the minimal code:
```
defmodule MyQueryBuilder do
use FIQLEx.QueryBuilder
@impl true
def ... | lib/query_builder.ex | 0.94256 | 0.846578 | query_builder.ex | starcoder |
defmodule Tammes do
# helper function
def call(args, fun) do
apply(fun, args)
end
def call(args, fun, module) do
apply(module, fun, args)
end
def vector_fun(e1, e2, fun) do
Enum.zip(e1, e2)
|> Enum.map(&Tuple.to_list(&1))
|> Enum.map(&call(&1, fun))
end
def dot_product(c1, c2) d... | tammes.ex | 0.5083 | 0.664778 | tammes.ex | starcoder |
defmodule Bolt.Cogs.Clean do
@moduledoc false
@behaviour Nosedrum.Command
alias Bolt.Converters
alias Bolt.ErrorFormatters
alias Bolt.Humanizer
alias Bolt.ModLog
alias Bolt.Parsers
alias Nosedrum.Predicates
alias Nostrum.Api
alias Nostrum.Cache.Mapping.ChannelGuild
alias Nostrum.Struct.Message
... | lib/bolt/cogs/clean.ex | 0.867962 | 0.515376 | clean.ex | starcoder |
defmodule Oban.Config do
@moduledoc """
The Config struct validates and encapsulates Oban instance state.
Typically, you won't use the Config module directly. Oban automatically creates a Config struct
on initialization and passes it through to all supervised children with the `:conf` key.
To fetch a runnin... | lib/oban/config.ex | 0.919163 | 0.46952 | config.ex | starcoder |
defmodule ChangelogWeb.TimeView do
alias Timex.Duration
def closest_monday_to(date) do
offset = case Timex.weekday(date) do
1 -> 0
2 -> -1
3 -> -2
4 -> -3
5 -> 3
6 -> 2
7 -> 1
end
Timex.shift(date, days: offset)
end
def duration(seconds) when is_nil(... | lib/changelog_web/views/time_view.ex | 0.606498 | 0.525125 | time_view.ex | starcoder |
defmodule Mint.HTTP2 do
@moduledoc """
Processless HTTP client with support for HTTP/2.
This module provides a data structure that represents an HTTP/2 connection to
a given server. The connection is represented as an opaque struct `%Mint.HTTP2{}`.
The connection is a data structure and is not backed by a pr... | lib/mint/http2.ex | 0.897933 | 0.563438 | http2.ex | starcoder |
defmodule AWS.SageMaker do
@moduledoc """
Provides APIs for creating and managing Amazon SageMaker resources.
Other Resources:
* [Amazon SageMaker Developer Guide](https://docs.aws.amazon.com/sagemaker/latest/dg/whatis.html#first-time-user)
* [Amazon Augmented AI Runtime API Reference](https://docs.aw... | lib/aws/generated/sage_maker.ex | 0.901977 | 0.461563 | sage_maker.ex | starcoder |
defmodule Phoenix.Socket.Transport do
@moduledoc """
Outlines the Socket <-> Transport communication.
This module specifies a behaviour that all sockets must implement.
`Phoenix.Socket` is just one possible implementation of a socket
that multiplexes events over multiple channels. Developers can
implement ... | lib/phoenix/socket/transport.ex | 0.912185 | 0.566498 | transport.ex | starcoder |
defmodule ExZample do
@moduledoc """
ExZample is a factory library based on Elixir behaviours.
"""
alias ExZample.{Sequence, SequenceSupervisor}
import ExZample.Since
@doc """
Invoked every time you build your data using `ExZample` module.
You need to return a struct with example values.
This cal... | lib/ex_zample/ex_zample.ex | 0.91854 | 0.5425 | ex_zample.ex | starcoder |
defmodule Application do
@moduledoc """
A module for working with applications and defining application callbacks.
In Elixir (actually, in Erlang/OTP), an application is a component
implementing some specific functionality, that can be started and stopped
as a unit, and which can be re-used in other systems ... | lib/elixir/lib/application.ex | 0.832747 | 0.621914 | application.ex | starcoder |
defmodule AWS.CloudWatch do
@moduledoc """
Amazon CloudWatch monitors your Amazon Web Services (AWS) resources and the
applications you run on AWS in real time. You can use CloudWatch to collect
and track metrics, which are the variables you want to measure for your
resources and applications.
CloudWatch ... | lib/aws/generated/cloud_watch.ex | 0.929748 | 0.641605 | cloud_watch.ex | starcoder |
defmodule Handkit do
@moduledoc """


Handkit is an Elixir client for the [Handcash Connect API](https://handcash.dev).
Handkit offers 100% coverage o... | lib/handkit.ex | 0.820073 | 0.519826 | handkit.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.909293 | 0.555315 | router.ex | starcoder |
defmodule Services.Service do
@moduledoc "Processes Services, including dates and notes"
alias JsonApi.Item
defstruct added_dates: [],
added_dates_notes: [],
description: "",
end_date: nil,
name: "",
id: nil,
removed_dates: [],
r... | apps/services/lib/service.ex | 0.732974 | 0.466542 | service.ex | starcoder |
use Croma
defmodule RaftKV.Config do
@default_stats_collection_interval (if Mix.env() == :test, do: 2_000, else: 60_000)
@default_workflow_execution_interval (if Mix.env() == :test, do: 2_000, else: 60_000)
@default_workflow_lock_period (if Mix.env() ==... | lib/raft_kv/config.ex | 0.774796 | 0.584983 | config.ex | starcoder |
defmodule ContentSecurityPolicy.Plug.AddNonce do
@moduledoc """
Plug which adds a random nonce to the content security policy. Sets this
nonce in `Plug.assigns` under the `csp_nonce` key.
This plug must be run after the `ContentSecurityPolicy.Setup` plug, or it
will raise an exception.
## Example Usage
... | lib/content_security_policy/plug/add_nonce.ex | 0.840783 | 0.482856 | add_nonce.ex | starcoder |
defmodule Benchee.Benchmark do
@moduledoc """
Functions related to building and running benchmarking scenarios.
Exposes `benchmark/4` and `measure/3` functions.
"""
alias Benchee.Benchmark.{Runner, Scenario, ScenarioContext}
alias Benchee.Output.BenchmarkPrinter, as: Printer
alias Benchee.Suite
alias B... | lib/benchee/benchmark.ex | 0.816443 | 0.553686 | benchmark.ex | starcoder |
defmodule Plug.Static do
@moduledoc """
A plug for serving static assets.
It expects two options on initialization:
* `:at` - the request path to reach for static assets.
It must be a binary.
* `:from` - the filesystem path to read static assets from.
It must be a binary, containing a file ... | lib/plug/static.ex | 0.866019 | 0.591251 | static.ex | starcoder |
defmodule Authex.Token do
@moduledoc """
A struct wrapper for token claims.
Typically, we shouldnt need to directly interact with this module. Rather, we
should use the `Authex.token/3` function.
"""
alias Authex.Token
defstruct nbf: nil,
exp: nil,
iat: nil,
jti: nil... | lib/authex/token.ex | 0.881704 | 0.418133 | token.ex | starcoder |
defmodule LiveSup.PromEx do
@moduledoc """
Be sure to add the following to finish setting up PromEx:
1. Update your configuration (config.exs, dev.exs, prod.exs, releases.exs, etc) to
configure the necessary bit of PromEx. Be sure to check out `PromEx.Config` for
more details regarding configuring Prom... | lib/live_sup/prom_ex.ex | 0.825941 | 0.675791 | prom_ex.ex | starcoder |
defmodule PhoenixToggl.TimeBoundries.TimeEntry do
use Ecto.Schema
use Timex
import Ecto.{ Query, Changeset }
alias PhoenixToggl.{ TimeBoundries.TimeEntry, Accounts.User, Workspace.Board }
@derive {Poison.Encoder, only: [
:id, :description, :started_at, :stopped_at, :restarted_at, :duration,
:updated_... | lib/phoenix_toggl/time_boundries/time_entry.ex | 0.765856 | 0.477615 | time_entry.ex | starcoder |
defmodule Grizzly.Inclusions.InclusionRunner.Inclusion do
@moduledoc false
# This module is useful for moving an inclusion process through
# the various states
alias Grizzly.ZWave.Command
alias Grizzly.ZWave.Commands.{NodeAdd, NodeRemove, NodeAddKeysSet, NodeAddDSKSet, LearnModeSet}
@type state ::
... | lib/grizzly/inclusions/inclusion_runner/inclusion.ex | 0.860384 | 0.512022 | inclusion.ex | starcoder |
defmodule Appsignal.Span do
alias Appsignal.{Config, Nif, Span}
defstruct [:reference, :pid]
@nif Application.get_env(:appsignal, :appsignal_tracer_nif, Appsignal.Nif)
@type t() :: %__MODULE__{
reference: reference(),
pid: pid()
}
@spec create_root(String.t(), pid()) :: t() | nil... | lib/appsignal/span.ex | 0.873754 | 0.510313 | span.ex | starcoder |
defmodule Recurly.APIError do
@moduledoc """
Module represents a generic APIError with a `symbol` and `description`.
"""
defstruct ~w(status_code symbol description)a
defimpl Recurly.XML.Parser do
import SweetXml
def parse(_error, xml_doc, false) do
parsed =
xpath(
xml_doc,
... | lib/recurly/errors.ex | 0.900283 | 0.711631 | errors.ex | starcoder |
defmodule Playground.Scenario.ETS do
use Playground.Scenario
def scenario_type do
{:iterations, Stream.map(10..20, &round(:math.pow(2, &1)))}
end
def scenario_banner do
"""
Scenario: use an ETS table.
Data: {integer}
Tasks:
- Bulk Load of <count> items (in one go)
- Concurrent... | lib/playground/scenario/ets.ex | 0.758958 | 0.609669 | ets.ex | starcoder |
defmodule DeltaCrdt.AWLWWMap do
defstruct keys: MapSet.new(),
dots: MapSet.new(),
value: %{}
require Logger
@doc false
def new(), do: %__MODULE__{}
defmodule Dots do
@moduledoc false
def compress(dots = %MapSet{}) do
Enum.reduce(dots, %{}, fn {c, i}, dots_map ->
... | lib/delta_crdt/aw_lww_map.ex | 0.677581 | 0.442998 | aw_lww_map.ex | starcoder |
defmodule Broadway.Acknowledger do
@moduledoc """
A behaviour used to acknowledge that the received messages
were successfully processed or failed.
When implementing a new connector for Broadway, you should
implement this behaviour and consider how the technology
you're working with handles message acknowl... | lib/broadway/acknowledger.ex | 0.847732 | 0.58673 | acknowledger.ex | starcoder |
defmodule EnvHelper do
@moduledoc """
Helpers for enviroment and application variables.
"""
@doc """
creates a method `name/0` which returns either `alt` or the environment variable set for the upcase version `name`.
## Paramenters
* `name` :: atom
The name of a system environment variable, downca... | lib/env_helper.ex | 0.869535 | 0.430985 | env_helper.ex | starcoder |
defmodule Dwolla.WebhookSubscription do
@moduledoc """
Functions for `webhook-subscriptions` endpoint.
"""
alias Dwolla.Utils
defstruct id: nil, created: nil, url: nil, paused: false
@type t :: %__MODULE__{id: String.t(), created: String.t(), url: String.t(), paused: boolean}
@type token :: String.t()
... | lib/dwolla/webhook_subscription.ex | 0.811974 | 0.447581 | webhook_subscription.ex | starcoder |
defprotocol Gringotts.Money do
@moduledoc """
Money protocol used by the Gringotts API.
The `amount` argument required for some of Gringotts' API methods must
implement this protocol.
If your application is already using a supported Money library, just pass in
the Money struct and things will work out of ... | lib/gringotts/money.ex | 0.920361 | 0.640959 | money.ex | starcoder |
defmodule AOC.IEx do
@moduledoc """
IEx helpers for advent of code.
This module contains various helpers that make it easy to call procedures in your solution
modules. This is particularly useful when you are testing your solutions from within iex.
In order to avoid prefixing all calls with `AOC.IEx`, we re... | lib/aoc/iex.ex | 0.864925 | 0.89765 | iex.ex | starcoder |
defmodule Ancestry do
@moduledoc """
Documentation for Ancestry.
"""
defmacro __using__(opts) do
quote do
import unquote(__MODULE__)
@ancestry_opts unquote(opts)
@before_compile unquote(__MODULE__)
end
end
defmacro __before_compile__(%{module: module}) do
ancestry_opts = Modu... | lib/ancestry.ex | 0.797911 | 0.414662 | ancestry.ex | starcoder |
defmodule Cldr.Locale do
@moduledoc """
Functions to parse and normalize locale names into a structure
locale represented by a `Cldr.LanguageTag`.
CLDR represents localisation data organized into locales, with
each locale being identified by a locale name that is formatted
according to [RFC5646](https://to... | lib/cldr/locale.ex | 0.926416 | 0.739322 | locale.ex | starcoder |
defmodule Borsh do
@moduledoc """
BORSH, binary serializer for security-critical projects.
Borsh stands for `Binary` `Object` `Representation` `Serializer` for `Hashing`.
It is meant to be used in security-critical projects as it prioritizes consistency, safety, speed;
and comes with a strict specification.
... | lib/borsh.ex | 0.852383 | 0.925903 | borsh.ex | starcoder |
defmodule Interp.SubprogramInterp do
alias Interp.Stack
alias Interp.Interpreter
alias Interp.Globals
alias Commands.ListCommands
alias Commands.GeneralCommands
import Interp.Functions
use Bitwise
def interp_step(op, subcommands, stack, environment) do
case op do
... | lib/interp/commands/subprogram_interp.ex | 0.601242 | 0.464234 | subprogram_interp.ex | starcoder |
defmodule Jobbit do
# get the absolute path to via the relative path of this file to the README.
@readme_path Path.join(__DIR__, "../README.md")
# ensure the module recompiles if the README changes
# NOTE: @external_resource requires an absolute path.
@external_resource @readme_path
# read the README into... | lib/jobbit.ex | 0.861203 | 0.474631 | jobbit.ex | starcoder |
defmodule ReWeb.Types.Interest do
@moduledoc """
GraphQL types for interests
"""
use Absinthe.Schema.Notation
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
alias ReWeb.Resolvers.Interests, as: InterestsResolver
object :interest do
field :id, :id
field :uuid, :uuid
field :name, :... | apps/re_web/lib/graphql/types/interest.ex | 0.593138 | 0.526647 | interest.ex | starcoder |
defmodule Murmur do
@moduledoc ~S"""
This module implements the x86_32, x86_128 and x64_128 variants of the
non-cryptographic hash Murmur3.
## Examples
iex> Murmur.hash_x86_32("b2622f5e1310a0aa14b7f957fe4246fa", 2147368987)
3297211900
iex> Murmur.hash_x86_128("some random data")
55866... | lib/murmur.ex | 0.862598 | 0.53279 | murmur.ex | starcoder |
defmodule Fluex do
@moduledoc """
The `Fluex` module provides a localization system for natural-sounding translations using [fluent-rs](https://github.com/projectfluent/fluent-rs).
Fluex uses [NIFs](https://github.com/rusterlium/rustler) to make calls to fluent-rs.
## Installation
Add `Fluex` to your list o... | lib/fluex.ex | 0.843154 | 0.534916 | fluex.ex | starcoder |
defmodule Exdn do
@moduledoc """
Exdn is a two-way translator between Elixir data structures and data
following the [edn specification](https://github.com/edn-format/edn);
it wraps the [erldn edn parser](https://github.com/marianoguerra/erldn)
for Erlang, with some changes in the data formats.
## Examples
... | lib/exdn.ex | 0.913295 | 0.531088 | exdn.ex | starcoder |
defmodule EV.ChangesetHelper do
@moduledoc """
Helper meant for retrieving normalised changes from Ecto.Changeset.
"""
@doc """
Gets changes from a given changeset, recursively normalised.
## Options
* `:carry_fields` - full_path [`:changeset_helper_opts`, :carry_fields]; optional; atom or list of at... | lib/helpers/changeset_helper.ex | 0.894091 | 0.586878 | changeset_helper.ex | starcoder |
defmodule HTMLAssertion.Matcher do
@moduledoc false
alias HTMLAssertion
alias HTMLAssertion.{Selector}
@compile {:inline, raise_match: 3}
@typep assert_or_refute :: :assert | :refute
@spec selector(assert_or_refute, binary, binary()) :: nil | HTMLAssertion.html()
def selector(matcher, html, selector) ... | lib/html_assertion/matcher.ex | 0.801004 | 0.566648 | matcher.ex | starcoder |
defmodule ScrapyCloudEx.Endpoints do
@moduledoc """
Documents commonalities between all endpoint-related functions.
## Options
The last argument provided to most endpoint functions is a keyword list
of options. These options are made available to the HttpAdapter during the
API request.
- `:decoder` - s... | lib/endpoints.ex | 0.870961 | 0.607459 | endpoints.ex | starcoder |
defmodule Routemaster.Drains.Siphon do
@moduledoc """
Allows to pluck events for one or more topics and remove them
from the current payload. The removed -- siphoned -- events
are sent to a siphon module that must implement the `call/1`
function, that will be invoked with a list of `Routemaster.Drain.Event`
... | lib/routemaster/drain/drains/siphon.ex | 0.792665 | 0.779909 | siphon.ex | starcoder |
defmodule Populate do
@moduledoc """
The `Populate` module provides helpers for creating a builder
interface which can be used with population specs.
## Usage
defmodule Builder do
use Populate
def create(:frog, _opts), do: :frog
def create(:lizard, _opts), do: :lizard
en... | lib/populate.ex | 0.798344 | 0.494568 | populate.ex | starcoder |
defmodule BrainWall.Solvers.MarksSolver do
alias BrainWall.Solution
@moduledoc """
this is what I think the logic is for placing a point:
1) of the edges that this point has, which edges are fixed on the other end?
2) for each of those edges, compute the possible places where the unfixed endpoint
c... | brain_wall/lib/brain_wall/solvers/marks_solver.ex | 0.720368 | 0.665566 | marks_solver.ex | starcoder |
defmodule Liaison.Strategy.Epmd do
@moduledoc """
Strategy for node connections via EPMD
```elixir
config :liaison,
strategy: [
[
strategy: #{__MODULE__},
reconnect_period: 10,
nodes: []
]
]
```
## Staying Connected
Staying conencted via the Ep... | lib/strategy/empd.ex | 0.620392 | 0.546496 | empd.ex | starcoder |
defmodule Flex.EngineAdapter.Mamdani do
@moduledoc """
Mamdani fuzzy inference was first introduced as a method to create a control system by synthesizing a set of linguistic control rules obtained from experienced human operators.
In a Mamdani system, the output of each rule is a fuzzy set. Since Mamdani systems... | lib/engine_adapters/mamdani.ex | 0.846974 | 0.585753 | mamdani.ex | starcoder |
defmodule Kalevala.World.Room.Private do
@moduledoc """
Store private information for a room, e.g. characters in the room
"""
defstruct characters: [], item_instances: []
end
defmodule Kalevala.World.Room.Feature do
@moduledoc """
A room feature is a highlighted part of a room
"""
defstruct [:id, :ke... | lib/kalevala/world/room.ex | 0.794943 | 0.451206 | room.ex | starcoder |
defmodule ArbejdQ.Job do
@moduledoc """
Job queued or running within ArbejdQ.
When a job is `:running` it is taken by a worker node, and the job
may not be executed by other nodes.
`:status_updated` is to be updated at regular intervals. If `:status_update` has not
been updated for too long, other nodes a... | lib/arbejd_q/job.ex | 0.820397 | 0.403802 | job.ex | starcoder |
defmodule Proj do
@moduledoc """
Provides functions to transform coordinates between given coordinate systems.
iex> {:ok, bng} = Proj.from_epsg(27700) # British National Grid CRS is EPSG:27700
{:ok, #Proj<+init=epsg:27700 ...>}
iex> Proj.to_lat_lng!({529155, 179699}, bng)
{51.50147938477216... | lib/proj.ex | 0.899636 | 0.581719 | proj.ex | starcoder |
defmodule Lens do
use Lens.Macros
@opaque t :: (:get, any, function -> list(any)) | (:get_and_update, any, function -> {list(any), any})
@doc ~S"""
Returns a lens that does not focus on any part of the data.
iex> Lens.empty |> Lens.to_list(:anything)
[]
iex> Lens.empty |> Lens.map(1, &(&1 +... | lib/lens.ex | 0.836921 | 0.572484 | lens.ex | starcoder |
defmodule Phoenix.LiveDashboard.PageBuilder do
defstruct info: nil,
module: nil,
node: nil,
params: nil,
route: nil,
tick: 0
@opaque component :: {module, map}
@type session :: map
@type requirements :: [{:application | :process | :module, atom()}]
... | lib/phoenix/live_dashboard/page_builder.ex | 0.856512 | 0.547041 | page_builder.ex | starcoder |
defmodule StaffNotesApi.TokenAuthentication do
@moduledoc """
A module `Plug` for validating the API token in the authorization request header.
Looks for the token in the request `Authorization` header in the format
`token [big-long-token-thing]`. When found, it verifies the token (using
`Phoenix.Token.verif... | lib/staff_notes_api/plugs/token_authentication.ex | 0.850717 | 0.70791 | token_authentication.ex | starcoder |
defmodule Crux.Structs.Member do
@moduledoc """
Represents a Discord [Guild Member Object](https://discordapp.com/developers/docs/resources/guild#guild-member-object-guild-member-structure).
Differences opposed to the Discord API Object:
- `:user` is just the user id
"""
@behaviour Crux.Structs
ali... | lib/structs/member.ex | 0.846689 | 0.519948 | member.ex | starcoder |
defmodule Cloak.AES.CTR do
@moduledoc """
A `Cloak.Cipher` which encrypts values with the AES cipher in CTR (stream) mode.
Internally relies on Erlang's `:crypto.stream_encrypt/2`.
## Configuration
In addition to the normal `:default` and `:tag` configuration options, this
cipher takes a `:keys` option to... | lib/cloak/ciphers/aes_ctr.ex | 0.892878 | 0.573081 | aes_ctr.ex | starcoder |
defmodule Shapeshifter.TXO do
@moduledoc """
Module for converting to and from [`TXO`](`t:Shapeshifter.txo/0`) structured
maps.
Usually used internally, although can be used directly for specific use cases
such as converting single inputs and outputs to and from [`TXO`](`t:Shapeshifter.txo/0`)
formatted ma... | lib/shapeshifter/txo.ex | 0.767733 | 0.672601 | txo.ex | starcoder |
defmodule Tensorflow.TypeSpecProto.TypeSpecClass do
@moduledoc false
use Protobuf, enum: true, syntax: :proto3
@type t ::
integer
| :UNKNOWN
| :SPARSE_TENSOR_SPEC
| :INDEXED_SLICES_SPEC
| :RAGGED_TENSOR_SPEC
| :TENSOR_ARRAY_SPEC
| :DATA_DATASE... | lib/tensorflow/core/protobuf/struct.pb.ex | 0.790126 | 0.456228 | struct.pb.ex | starcoder |
defmodule RGG.Shared do
@doc """
This function calculates the maximum number of buckets we can use when connecting nodes to achieve linear runtime when connecting the nodes..
The only parameter is r as we need to make sure we place nodes within radius r of each other within 1 bucket of each other.
## Examples
... | lib/rgg/shared.ex | 0.832373 | 0.764935 | shared.ex | starcoder |
defmodule Flamelex.Fluxus.RadixReducer do
@moduledoc """
The RootReducer for all flamelex actions.
These pure-functions are called by ActionListener, to handle specific
actions within the application. Every action that gets processed, is
routed down to the sub-reducers, through this module. Every possible
... | lib/flamelex/fluxus/reducers/radix_reducer.ex | 0.714728 | 0.698946 | radix_reducer.ex | starcoder |
defmodule Wand.CLI.Commands.Core do
use Wand.CLI.Command
alias Wand.CLI.Display
alias Wand.CLI.CoreValidator
@io Wand.Interfaces.IO.impl()
@moduledoc """
# Core
Manage the related wand_core package
### Usage
```
wand core install
wand core version
```
Wand comes in two parts, the CLI and th... | lib/cli/commands/core.ex | 0.558327 | 0.655274 | core.ex | starcoder |
defmodule Timex do
@moduledoc File.read!("README.md")
defmacro __using__(_) do
quote do
alias Timex.DateTime
alias Timex.AmbiguousDateTime
alias Timex.Date
alias Timex.Time
alias Timex.Interval
alias Timex.TimezoneInfo
alias Timex.AmbiguousTimezoneInfo
alias Time... | lib/timex.ex | 0.912723 | 0.550366 | timex.ex | starcoder |
defmodule Versioned.Schema do
@moduledoc """
Enhances `Ecto.Schema` modules to track a full history of changes.
The `versioned_schema` macro works just like `schema` in `Ecto.Schema` but it
also builds an `OriginalModule.Version` schema module as well to represent a
version at a particular point in time.
... | lib/versioned/schema.ex | 0.908686 | 0.554893 | schema.ex | starcoder |
defmodule Zest do
@doc """
Add some debug information to the context for the duration of a
block or expression. If a `raise`, `throw` or `exit` occurs, the
context will be pretty printed to the screen to aid with debugging.
Examples:
```scope [foo: :bar[, assert(true == false)```
```scope [foo... | lib/zest.ex | 0.788949 | 0.86431 | zest.ex | starcoder |
defmodule Kernel.Typespec do
@moduledoc false
## Deprecated API moved to Code.Typespec
@doc false
@deprecated "Use Code.Typespec.spec_to_quoted/2 instead"
def spec_to_ast(name, spec) do
Code.Typespec.spec_to_quoted(name, spec)
end
@doc false
@deprecated "Use Code.Typespec.type_to_quoted/1 instead... | lib/elixir/lib/kernel/typespec.ex | 0.537284 | 0.496338 | typespec.ex | starcoder |
defmodule AshPolicyAuthorizer.SatSolver do
@moduledoc false
def solve(expression) do
expression
|> add_negations_and_solve([])
|> get_all_scenarios(expression)
|> case do
[] ->
{:error, :unsatisfiable}
scenarios ->
static_checks = [
{AshPolicyAuthorizer.Check.S... | lib/ash_policy_authorizer/sat_solver.ex | 0.66769 | 0.40116 | sat_solver.ex | starcoder |
defmodule Serum.Page do
@moduledoc """
Defines a struct describing a normal page.
## Fields
* `file`: Source path
* `type`: Type of source file
* `title`: Page title
* `label`: Page label
* `group`: A group the page belongs to
* `order`: Order of the page within its group
* `url`: Absolute URL of t... | lib/serum/page.ex | 0.808861 | 0.468791 | page.ex | starcoder |
defmodule AWS.Backup do
@moduledoc """
AWS Backup
AWS Backup is a unified backup service designed to protect AWS services and
their associated data. AWS Backup simplifies the creation, migration,
restoration, and deletion of backups, while also providing reporting and
auditing.
"""
@doc """
Backup ... | lib/aws/backup.ex | 0.893379 | 0.494446 | backup.ex | starcoder |
defmodule OT.Text.Transformation do
@moduledoc """
The transformation of two concurrent operations such that they satisfy the
[TP1][tp1] property of operational transformation.
[tp1]: https://en.wikipedia.org/wiki/Operational_transformation#Convergence_properties
"""
alias OT.Text.{Component, Operation, S... | lib/ot/text/transformation.ex | 0.845481 | 0.742095 | transformation.ex | starcoder |
defmodule Logger.Backends.Gelf do
@moduledoc """
GELF Logger Backend
# GelfLogger [](https://travis-ci.org/jschniper/gelf_logger)
A logger backend that will generate Graylog Extended Log Format messages. The
current version only su... | lib/gelf_logger.ex | 0.795658 | 0.757458 | gelf_logger.ex | starcoder |
defmodule Prometheus do
@moduledoc """
[Prometheus.io](https://prometheus.io) client library powered by
[prometheus.erl](https://hexdocs.pm/prometheus)
Prometheus.ex is a thin, mostly macro-based wrapper around prometheus.erl.
While it's pretty straightforward to use prometheus.erl from Elixir,
you might ... | astreu/deps/prometheus_ex/lib/prometheus.ex | 0.916992 | 0.783036 | prometheus.ex | starcoder |
defmodule Absinthe.Blueprint.Transform do
@moduledoc false
alias Absinthe.Blueprint
@doc """
Apply `fun` to a node, then walk to its children and do the same
"""
@spec prewalk(
Blueprint.node_t(),
(Blueprint.node_t() -> Blueprint.node_t() | {:halt, Blueprint.node_t()})
) :: Blu... | lib/absinthe/blueprint/transform.ex | 0.728265 | 0.544014 | transform.ex | starcoder |
defmodule EEx.TransformerEngine do
@moduledoc """
An abstract engine that is meant to be used and
built upon in other modules. This engine implements
the `EEx.Engine` behavior and provides a `transform`
overridable directive that allows a developer to
customize the expression returned by the engine.
Chec... | lib/eex/lib/eex/smart_engine.ex | 0.841517 | 0.514156 | smart_engine.ex | starcoder |
defmodule DeltaCrdt do
@moduledoc """
Start and interact with the Delta CRDTs provided by this library.
A CRDT is a conflict-free replicated data-type. That is to say, it is a distributed data structure that automatically resolves conflicts in a way that is consistent across all replicas of the data. In other wo... | lib/delta_crdt.ex | 0.916661 | 0.819424 | delta_crdt.ex | starcoder |
defmodule Freecodecamp.BasicAlgo do
@moduledoc """
Documentation for Freecodecamp (Basic Alogrithmic Scripting).
"""
@moduledoc since: "0.1.0"
@doc """
Convert Celsius to Fahrenheit
## Examples
iex> BasicAlgo.convert_to_f(30)
86
"""
@spec convert_to_f(integer) :: integer
def convert_... | lib/freecodecamp/basic_algo.ex | 0.850142 | 0.413625 | basic_algo.ex | starcoder |
defmodule SweetXpath do
defmodule Priv do
@moduledoc false
@doc false
def self_val(val), do: val
end
defstruct path: ".",
is_value: true,
is_list: false,
is_keyword: false,
is_optional: false,
cast_to: false,
transform_fun: &(Priv.self_val/1),
namespaces: []
end
defmodul... | lib/sweet_xml.ex | 0.766294 | 0.550124 | sweet_xml.ex | starcoder |
defmodule PhoenixActiveLink do
@moduledoc """
PhoenixActiveLink provides helpers to add active links in views.
## Configuration
Default options can be customized in the configuration:
```elixir
use Mix.Config
config :phoenix_active_link, :defaults,
wrap_tag: :li,
class_active: "enabled",
c... | lib/phoenix_active_link.ex | 0.921865 | 0.822296 | phoenix_active_link.ex | starcoder |
defmodule Pique do
@moduledoc """
Main Pique application. Starts the `gen_smtp_server` with the
default configuration. If the configuration states
that `auth` is `true` then the application will not start unless
it is configured with `sessionoptions` that specify a cert and key
file as well as listening on ... | lib/pique.ex | 0.826081 | 0.693642 | pique.ex | starcoder |
defmodule OpenGraph do
@moduledoc """
Fetch and parse websites to extract Open Graph meta tags.
The example above shows how to fetch the GitHub Open Graph rich objects.
```
OpenGraph.fetch("https://github.com")
%OpenGraph{description: "GitHub is where people build software. More than 15 million...",
ima... | lib/open_graph.ex | 0.796609 | 0.885136 | open_graph.ex | starcoder |
defmodule DBConnection.Sojourn do
@moduledoc """
A `DBConnection.Pool` using sbroker.
### Options
* `:pool_size` - The number of connections (default: `10`)
* `:broker` - The sbroker callback module (see `:sbroker`,
default: `DBConnection.Sojourn.Timeout`)
* `:broker_start_opts` - Start options ... | deps/db_connection/lib/db_connection/sojourn.ex | 0.827759 | 0.468487 | sojourn.ex | starcoder |
defmodule Dwolla.Transfer do
@moduledoc """
Functions for `transfers` endpoint.
"""
alias Dwolla.Utils
defstruct id: nil, created: nil, status: nil, amount: nil, metadata: nil,
source_resource: nil, source_resource_id: nil,
source_funding_source_id: nil, dest_resource: nil,
... | lib/dwolla/transfer.ex | 0.801509 | 0.568116 | transfer.ex | starcoder |
defmodule ElixirSense.Providers.Suggestion do
@moduledoc """
Provider responsible for finding suggestions for auto-completing.
It provides suggestions based on a list of pre-defined reducers.
## Reducers
A reducer is a function with the following spec:
@spec reducer(
String.t(),
Stri... | lib/elixir_sense/providers/suggestion.ex | 0.85022 | 0.409427 | suggestion.ex | starcoder |
defmodule Ash.Query.Function.GetPath do
@moduledoc """
Gets the value at the provided path in the value, which must be a map or embed.
If you are using a datalayer that provides a `type` function (like AshPostgres), it is a good idea to
wrap your call in that function, e.g `type(author[:bio][:title], :string)`... | lib/ash/query/function/get_path.ex | 0.855323 | 0.634883 | get_path.ex | starcoder |
defmodule Aecore.Channel.Updates.ChannelTransferUpdate do
@moduledoc """
State channel update implementing transfers in the state channel. This update can be included in ChannelOffchainTx.
This update allows for transfering tokens between peers in the state channel(later for transfers to offchain contract account... | apps/aecore/lib/aecore/channel/updates/channel_transfer_update.ex | 0.852798 | 0.415936 | channel_transfer_update.ex | starcoder |
defmodule MerklePatriciaTree.Trie.Node do
@moduledoc """
This module encodes and decodes nodes from a
trie encoding back into RLP form. We effectively implement
`c(I, i)` from the Yellow Paper.
TODO: Add richer set of tests, esp. in re: storage and branch values.
"""
alias MerklePatriciaTree.Trie
alia... | apps/merkle_patricia_tree/lib/trie/node.ex | 0.665845 | 0.576333 | node.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.