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 CCSP.Chapter4.Start do
alias CCSP.Chapter4.Graph
alias CCSP.Chapter4.WeightedGraph
alias CCSP.Chapter4.WeightedEdge
alias CCSP.Chapter4.MST
alias CCSP.Chapter4.Dijkstra
alias CCSP.Chapter2.GenericSearch
@moduledoc """
Convenience module for setting up and running more elaborate sections.
... | lib/ccsp/chapter4/start.ex | 0.674158 | 0.422922 | start.ex | starcoder |
defmodule Day2 do
@moduledoc """
Decode the bathroom lock code.
Given a string of commands, figure out the number to enter
"""
# The lookup table for the keypad in part 1
@keypad1 %{
1 => %{?U => 1, ?L => 1, ?D => 4, ?R => 2},
2 => %{?U => 2, ?L => 1, ?D => 5, ?R => 3},
3 => %{?U => 3, ?L => 2... | day2/lib/day2.ex | 0.57821 | 0.530236 | day2.ex | starcoder |
defmodule AdventOfCode.Day7 do
@spec add_get_node({atom, atom}, :digraph.graph()) :: {:digraph.graph(), :digraph.vertex()}
def add_get_node(node_key, graph) do
case :digraph.vertex(graph, node_key) do
false ->
vertex = :digraph.add_vertex(graph, node_key)
{graph, vertex}
{vertex, _}... | lib/day7.ex | 0.851475 | 0.598136 | day7.ex | starcoder |
defmodule Membrane.RawVideo do
@moduledoc """
This module provides a struct (`t:#{inspect(__MODULE__)}.t/0`) describing raw video frames.
"""
require Integer
@typedoc """
Width of single frame in pixels.
"""
@type width_t :: pos_integer()
@typedoc """
Height of single frame in pixels.
"""
@typ... | lib/membrane_raw_video.ex | 0.943165 | 0.662868 | membrane_raw_video.ex | starcoder |
defmodule FinTex.Parser.Tokenizer do
@moduledoc false
alias FinTex.Parser.Lexer
require Record
@type t :: record(:tokenization, tokens: [String.t] | String.t, escape_sequences: %{String.t => String.t})
Record.defrecordp :tokenization,
tokens: nil,
escape_sequences: nil
@spec split(String.t) :: ... | lib/parser/tokenizer.ex | 0.596786 | 0.426441 | tokenizer.ex | starcoder |
defmodule Talan.CountingBloomFilter do
@moduledoc """
Counting bloom filter implementation with **concurrent accessibility**,
powered by [:atomics](http://erlang.org/doc/man/atomics.html) module.
## Features
* Fixed size Counting Bloom filter
* Concurrent reads & writes
* Custom & default hash fun... | lib/talan/counting_bloom_filter.ex | 0.919335 | 0.681256 | counting_bloom_filter.ex | starcoder |
defmodule Taxes.Calculator do
@moduledoc """
Module with logic to calculate taxes based at Taxes tree
"""
alias Taxes.Types
alias Taxes.Logic
@hundred_percents 100
@doc """
Method to get Net price from `raw_price` by exclude inclusive taxes
"""
@spec set_net_price(Types.payload()) :: Types.payload... | lib/taxes/calculator.ex | 0.851197 | 0.738551 | calculator.ex | starcoder |
defmodule BrDocs.CNPJ.Formatter do
@moduledoc ~S"""
CNPJ Formatter.
"""
alias BrDocs.Doc
@raw_size 14
@regex_replacement "\\1.\\2.\\3/\\4-\\5"
@doc_regex ~r/(\d{2})?(\d{3})?(\d{3})?(\d{4})?(\d{2})/
@doc """
Formats a `BrDocs.Doc` CNPJ value into CNPJ format. Returns a formatted `BrDocs.Doc`.
CNP... | lib/brdocs/cnpj/formatter.ex | 0.842053 | 0.428084 | formatter.ex | starcoder |
defmodule Mix.Tasks.Dialyzer do
@shortdoc "Runs dialyzer with default or project-defined flags."
@moduledoc """
This task compiles the mix project, creates a PLT with dependencies if needed and runs `dialyzer`. Much of its behavior can be managed in configuration as described below.
If executed outside of a m... | deps/dialyxir/lib/mix/tasks/dialyzer.ex | 0.852537 | 0.765681 | dialyzer.ex | starcoder |
defmodule Ockam.Examples.Stream.BiDirectional.Local do
@moduledoc """
Ping-pong example for bi-directional stream communication using local subsctiption
Use-case: integrate ockam nodes which implement stream protocol consumer and publisher
Pre-requisites:
Ockam cloud node running with stream service and T... | implementations/elixir/ockam/ockam/lib/ockam/examples/stream/bi_directional/local.ex | 0.823115 | 0.515193 | local.ex | starcoder |
defmodule ParkingTweets.IdMapSet do
@moduledoc """
Similar interface to `MapSet`, but items are unique only by an ID.
"""
defstruct [:id_fun, :map]
@opaque t :: %__MODULE__{}
@doc """
Returns a new IdMapSet.
iex> new(& &1)
#ParkingTweets.IdMapSet<[]>
iex> new(&elem(&1, 0), [a: 1, b: ... | lib/parking_tweets/id_map_set.ex | 0.793066 | 0.412353 | id_map_set.ex | starcoder |
defmodule EVM.Stack do
@moduledoc """
Operations to read / write to the EVM's stack.
"""
@type t :: [EVM.val()]
@doc """
Pushes value onto stack.
## Examples
iex> EVM.Stack.push([], 5)
[5]
iex> EVM.Stack.push([5], 6)
[6, 5]
iex> EVM.Stack.push([], [5, 6])
[5, 6]
... | apps/evm/lib/evm/stack.ex | 0.851845 | 0.449091 | stack.ex | starcoder |
defmodule FuzzyCompare.ChunkSet do
@moduledoc """
For strings which among shared words also contain many dissimilar words the
ChunkSet is ideal.
It works in the following way:
Our input strings are
* `"<NAME>"`
* `"<NAME> was the wife of <NAME>"`
From the input string three strings are created.
... | lib/fuzzy_compare/chunk_set.ex | 0.89041 | 0.501709 | chunk_set.ex | starcoder |
defmodule Concentrate.Filter.Alert.TimeTable do
@moduledoc """
Wrapper for an ETS table which maintains a mapping of keys to values at particular times.
"""
@epoch_seconds :calendar.datetime_to_gregorian_seconds({{1970, 1, 1}, {0, 0, 0}})
@one_day_minus_one 86_399
@doc "Creates a new TimeTable with the giv... | lib/concentrate/filter/alert/time_table.ex | 0.731442 | 0.552781 | time_table.ex | starcoder |
defmodule GraphQL.Plug.Endpoint do
@moduledoc """
This is the core plug for mounting a GraphQL server.
You can build your own pipeline by mounting the
`GraphQL.Plug.Endpoint` plug directly.
```elixir
forward "/graphql", GraphQL.Plug.Endpoint, schema: {MyApp.Schema, :schema}
```
You may want to look a... | lib/graphql/plug/endpoint.ex | 0.812533 | 0.734191 | endpoint.ex | starcoder |
defmodule AWS.Rekognition do
@moduledoc """
This is the Amazon Rekognition API reference.
"""
@doc """
Compares a face in the *source* input image with each of the 100 largest
faces detected in the *target* input image.
<note> If the source image contains multiple faces, the service detects the
large... | lib/aws/rekognition.ex | 0.959564 | 0.930521 | rekognition.ex | starcoder |
defmodule Pandadoc do
@moduledoc """
This library provides an Elixir API for accessing the [Pandadoc Developer APIs](https://developers.pandadoc.com/reference/about).
The API access uses the [Tesla](https://github.com/teamon/tesla) library and
relies on the caller passing in an an API Key to create a
client.... | lib/pandadoc.ex | 0.851011 | 0.76388 | pandadoc.ex | starcoder |
defmodule Trans do
@moduledoc """
Manage translations embedded into structs.
Although it can be used with any struct **`Trans` shines when paired with an `Ecto.Schema`**. It
allows you to keep the translations into a field of the schema and avoids requiring extra tables
for translation storage and complex _j... | lib/trans.ex | 0.93749 | 0.715264 | trans.ex | starcoder |
defmodule Herd.Pool do
@moduledoc """
Builds a connection pool manager for a given herd. The manager has a number of overrideable
functions, including:
* spec_for_node/1 - infers a child spec for a given node in the cluster
* nodename/1 - generates an atom for a given node
* poolname/1 - generates a {:via... | lib/herd/pool.ex | 0.820433 | 0.770853 | pool.ex | starcoder |
defmodule Segment.Http.Stub do
@moduledoc """
The `Segment.Http.Stub` is used to replace the Tesla adapter with something that logs and returns success. It is used if `send_to_http` has been set to false
"""
require Logger
def call(env, _opts) do
Logger.debug("[Segment] HTTP API called with #{inspect(env... | lib/segment/client/http.ex | 0.876271 | 0.76782 | http.ex | starcoder |
defmodule Supermemo do
@default_ef 2.5
@min_ef 1.3
@first_interval 1
@second_interval 6
@iteration_reset_boundary 0.4
@repeat_boundary 4.0 / 5.0
@doc """
Given a value between 0.0 and 1.0, returns an initial `%Supermemo.Rep{}`.
"""
def rep(score) do
%Supermemo.Rep{
due: first_due_date(),
... | lib/supermemo.ex | 0.821008 | 0.467757 | supermemo.ex | starcoder |
defmodule Phoenix.PubSub.PG2 do
use Supervisor
@moduledoc """
Phoenix PubSub adapter based on [PG2](http://erlang.org/doc/man/pg2.html).
To use it as your PubSub adapter, simply add it to your Endpoint's config:
config :my_app, MyApp.Endpoint,
pubsub: [name: MyApp.PubSub,
adapt... | lib/phoenix/pubsub/pg2.ex | 0.797557 | 0.455986 | pg2.ex | starcoder |
defmodule Cloudevents.Format.V_1_0.Event do
@desc "Cloudevents format v1.0."
@moduledoc @desc
use TypedStruct
alias Cloudevents.Format.ParseError
@typedoc @desc
typedstruct do
field(:specversion, String.t(), default: "1.0")
field(:type, String.t(), enforce: true)
field(:source, String.t(), enfo... | lib/cloudevents/format/v_1_0/event.ex | 0.743727 | 0.409162 | event.ex | starcoder |
defmodule Dogmatix do
@moduledoc """
This module provides the main API to interface with a StasD/DogStatsD agent.
## Getting started
A new instance of Dogmatix can be started via the `start_link/2` function:
{:ok, pid} = Dogmatix.start_link("my_dogmatix", "localhost", 8125)
This will create a new in... | lib/dogmatix.ex | 0.941782 | 0.731251 | dogmatix.ex | starcoder |
defmodule Xema.Utils do
@moduledoc """
Some utilities for Xema.
"""
@doc """
Converts the given `string` to an existing atom. Returns `nil` if the
atom does not exist.
## Examples
iex> import Xema.Utils
iex> to_existing_atom(:my_atom)
:my_atom
iex> to_existing_atom("my_a... | lib/xema/utils.ex | 0.926968 | 0.558959 | utils.ex | starcoder |
defmodule Weaver.IntegrationCase do
@moduledoc """
This module defines the test case to be used by
tests that require setting up a store.
Such tests rely on `Weaver.Store` and also
import other functionality to make it easier
to build common data structures and query the schema.
Finally, if the test cas... | test/support/integration_case.ex | 0.829734 | 0.668784 | integration_case.ex | starcoder |
defmodule ExQueb do
@moduledoc """
Build Ecto filter Queries.
"""
import Ecto.Query
@doc """
Create the filter
Uses the :q query parameter to build the filter.
"""
def filter(query, params) do
q = params[Application.get_env(:ex_queb, :filter_param, :q)]
if q do
filters = Map.to_list(q)... | lib/ex_queb.ex | 0.654232 | 0.41253 | ex_queb.ex | starcoder |
defmodule Sippet.Transports.UDP do
@moduledoc """
Implements an UDP transport.
The UDP transport consists basically in a single listening and sending
process, this implementation itself.
This process creates an UDP socket and keeps listening for datagrams in
active mode. Its job is to forward the datagram... | lib/sippet/transports/udp.ex | 0.81468 | 0.485051 | udp.ex | starcoder |
defmodule HoneylandWeb.Schema.AstarteTypes do
use Absinthe.Schema.Notation
use Absinthe.Relay.Schema.Notation, :modern
alias HoneylandWeb.Middleware
alias HoneylandWeb.Resolvers
@desc """
Describes a set of filters to apply when fetching a list of devices.
When multiple filters are specified, they are... | backend/lib/honeyland_web/schema/astarte_types.ex | 0.834508 | 0.594021 | astarte_types.ex | starcoder |
defmodule OcrNumbers do
@doc """
Given a 3 x 4 grid of pipes, underscores, and spaces, determine which number is represented, or
whether it is garbled.
"""
@spec convert([String.t()]) :: {:ok, String.t()} | {:error, charlist()}
def convert(input) do
Enum.chunk_every(input, 4)
|> Enum.map(fn row_set ... | exercises/practice/ocr-numbers/.meta/example.ex | 0.714827 | 0.441011 | example.ex | starcoder |
defmodule Cashtrail.Users.User do
@moduledoc """
This is an `Ecto.Schema` struct that represents a user of the application.
The user is any individual that uses the application. They can create their
entities or be assigned to an entity as a member. See `Cashtrail.Entities.Entity`
to know more about what is ... | apps/cashtrail/lib/cashtrail/users/user.ex | 0.733643 | 0.444625 | user.ex | starcoder |
defmodule Cldr.Unit.Additional do
@moduledoc """
Additional domain-specific units can be defined
to suit application requirements. In the context
of `ex_cldr` there are two parts of configuring
additional units.
1. Configure the unit, base unit and conversion in
`config.exs`. This is a requirement since ... | lib/cldr/unit/additional.ex | 0.950445 | 0.95297 | additional.ex | starcoder |
defmodule ExthCrypto.AES do
@moduledoc """
Defines standard functions for use with AES symmetric cryptography in block mode.
"""
@block_size 32
@doc """
Returns the blocksize for AES encryption when used as block mode encryption.
## Examples
iex> ExthCrypto.AES.block_size
32
"""
@spec ... | apps/exth_crypto/lib/exth_crypto/aes.ex | 0.852859 | 0.4165 | aes.ex | starcoder |
defmodule BetTelemetry.Instrumentation do
@moduledoc ~S"""
Provides a way to generate telemetry events
We can generate `start`, `stop` and `exception` events.
This works in conjuction with `BetTelemetry.OpenTelemetryReporter`, if we
generate a telemetry event and we have subscribed to that event with the Ope... | lib/instrumentation.ex | 0.8339 | 0.479321 | instrumentation.ex | starcoder |
defmodule Plymio.Ast.Vorm.Field do
@moduledoc ~S"""
Convenience wrappers for using a *vorm* held in a *struct*.
Most of these wrappers assumes a *vorm* is, or will be, held in the `:vorm` field of a *struct* and allow function such as `add` to be called where the first argument is the struct. For example `stru... | lib/ast/vorm/field.ex | 0.880605 | 0.721651 | field.ex | starcoder |
defimpl Timex.Protocol, for: NaiveDateTime do
@moduledoc """
This module implements Timex functionality for NaiveDateTime
"""
alias Timex.{Types, Duration}
import Timex.Macros
@epoch_seconds :calendar.datetime_to_gregorian_seconds({{1970,1,1},{0,0,0}})
@spec now() :: NaiveDateTime.t
def now() do
T... | data/web/deps/timex/lib/datetime/naivedatetime.ex | 0.776792 | 0.582432 | naivedatetime.ex | starcoder |
defmodule Terp.Evaluate.Boolean do
@moduledoc """
Boolean values and conditional evaluation.
"""
alias Terp.Evaluate
@doc """
true
## Examples
iex> Terp.Evaluate.Boolean.t
true
"""
def t(), do: true
@doc """
false
## Examples
iex> Terp.Evaluate.Boolean.f
false
"""... | lib/evaluate/boolean.ex | 0.783077 | 0.434521 | boolean.ex | starcoder |
defmodule Delugex.MessageStore.Mnesia do
@moduledoc """
This is the real implementation of MessageStore.
You should be able to infer what to write, it's just passing the
required arguments to the SQL functions and converting any returned value.
Whenever a stream name is expected, please use the %StreamName st... | lib/delugex/message_store/mnesia.ex | 0.824427 | 0.563858 | mnesia.ex | starcoder |
defmodule Absinthe.Phoenix.Controller do
@moduledoc """
Supports use of GraphQL documents inside Phoenix controllers.
## Example
First, `use Absinthe.Phoenix.Controller`, passing your `schema`:
```elixir
defmodule MyAppWeb.UserController do
use MyAppWeb, :controller
use Absinthe.Phoenix.Controlle... | lib/absinthe/phoenix/controller.ex | 0.941034 | 0.837221 | controller.ex | starcoder |
defmodule BitcrowdEcto.DateTime do
@moduledoc """
Functions to work with date and time values.
"""
@moduledoc since: "0.2.0"
@type unit :: :second | :minute | :hour | :day | :week
@type period :: {integer(), unit()}
@doc """
Converts a `{<value>, <unit>}` tuple into seconds.
#Examples
iex> i... | lib/bitcrowd_ecto/date_time.ex | 0.913334 | 0.547887 | date_time.ex | starcoder |
defmodule KafkaEx.GenConsumer do
@moduledoc """
A behaviour module for implementing a Kafka consumer.
A `KafkaEx.GenConsumer` is an Elixir process that consumes messages from
Kafka. A single `KafkaEx.GenConsumer` process consumes from a single
partition of a Kafka topic. Several `KafkaEx.GenConsumer` process... | lib/kafka_ex/gen_consumer.ex | 0.946138 | 0.894927 | gen_consumer.ex | starcoder |
defmodule JsonApiClient.Middleware.StatsTracker do
@moduledoc """
Stats Tracking Middleware
### Options
- `:name` - name of the stats (used in logging)
- `:log` - The log level to log at. No logging is done if `false`. Defaults to `false`
Middleware that adds stats data to response, and optionally logs it... | lib/json_api_client/middleware/stats_tracker.ex | 0.908156 | 0.792665 | stats_tracker.ex | starcoder |
defmodule Parser do
use Platform.Parsing.Behaviour
## test payloads
# 0211c90003119b117611bc119e118a119411a811a81194006401990abd
# 0211c900020abd
def fields do
[
%{field: "distance_average", display: "Distance: average", unit: "mm"},
%{field: "distance_minimum", display: "Distance: mini... | DL-LID/DL-LID.ELEMENT-IoT.ex | 0.551695 | 0.54825 | DL-LID.ELEMENT-IoT.ex | starcoder |
defmodule DiscoveryApi.Search.Elasticsearch.Document do
@moduledoc """
Manages basic CRUD operations for a Dataset Document
"""
alias DiscoveryApi.Data.Model
import DiscoveryApi.Search.Elasticsearch.Shared
require Logger
def get(id) do
case elastic_get(id) do
{:ok, document} ->
{:ok, st... | apps/discovery_api/lib/discovery_api/search/elasticsearch/document.ex | 0.651577 | 0.408129 | document.ex | starcoder |
defmodule ToyRobot.Robot do
alias ToyRobot.Robot
defstruct north: 0, east: 0, facing: :north
@doc """
Move the robot forward one space in the facing direction
## Examples
iex> alias ToyRobot.Robot
ToyRobot.Robot
iex> robot = %Robot{north: 0, facing: :north}
%Robot{north: 0, facing: :north}... | lib/toy_robot/robot.ex | 0.889954 | 0.764232 | robot.ex | starcoder |
defmodule Crux.Gateway.Connection.Gun do
@moduledoc false
# Wrapper module for `:gun`, making it easier to swap out the WebSocket clients if necessary in the future.
# Sends messages to the invoking process:
# - `{:connected, pid}`
# - `{:disconnected, pid, {:close, code, message}}`
# - `{:packet, pid, pa... | lib/gateway/connection/gun.ex | 0.794066 | 0.508605 | gun.ex | starcoder |
defmodule Change do
@error_message "cannot change"
@doc """
Determine the least number of coins to be given to the user such
that the sum of the coins' value would equal the correct amount of change.
It returns {:error, "cannot change"} if it is not possible to compute the
right amount of coins. Ot... | elixir/change/lib/change.ex | 0.829388 | 0.560614 | change.ex | starcoder |
defmodule Edeliver.Relup.Instructions.SoftPurge do
@moduledoc """
Upgrade instruction which replaces `:brutal_purge` with `:soft_purge`
for `:load_module`, `:load`, `:update` and `:remove` relup instructions.
If `:brutal_purge` is used, processes running old code are killed.
If `:soft_purge` is used... | lib/edeliver/relup/instructions/soft_purge.ex | 0.635901 | 0.457924 | soft_purge.ex | starcoder |
defmodule Molasses do
alias Molasses.StorageAdapter.Redis
alias Molasses.StorageAdapter.Postgres
alias Molasses.StorageAdapter.MongoDB
@moduledoc ~S"""
A feature toggle library using redis or SQL (using Ecto) as a backing service. It allows you to roll out to users based on a percentage. Alternatively, you c... | lib/molasses.ex | 0.750004 | 0.863161 | molasses.ex | starcoder |
defmodule PasswordValidator.Validators.CharacterSetValidator do
@moduledoc """
Validates a password by checking the different types of characters contained
within.
"""
@behaviour PasswordValidator.Validator
@initial_counts %{
upper_case: 0,
lower_case: 0,
numbers: 0,
special: 0,
other:... | lib/password_validator/validators/character_set_validator.ex | 0.876397 | 0.464051 | character_set_validator.ex | starcoder |
defmodule SmartCity.Event do
@moduledoc """
Defines macros for encoding event types the Smart City platform
will respond to in any of the various micro service components
in a central location shared by all components.
"""
@doc """
Defines an update event to a dataset within the system. The
system trea... | lib/smart_city/event.ex | 0.765856 | 0.609728 | event.ex | starcoder |
defmodule ShopDeed do
@moduledoc """
Documentation for ShopDeed.
"""
alias ShopDeed.{Deck, Decoder, DecodeError, Encoder, EncodeError}
@doc """
Returns the base64 encoded string as a Deck or a DecodeError.
## Examples
iex> ShopDeed.decode("<KEY>")
{:error, %ShopDeed.DecodeError{message: "M... | lib/shop_deed.ex | 0.896294 | 0.429758 | shop_deed.ex | starcoder |
defmodule Plaid.Institution.Status do
@moduledoc """
[Plaid institution status schema.](https://plaid.com/docs/api/institutions/#institutions-get-response-status)
"""
@behaviour Plaid.Castable
alias Plaid.Castable
defmodule Breakdown do
@moduledoc """
[Plaid institution status breakdown schema.](... | lib/plaid/institution/status.ex | 0.845273 | 0.430088 | status.ex | starcoder |
defmodule MatrixOperation do
@moduledoc """
Documentation for Matrix operation library.
"""
@doc """
Numbers of row and column of a matrix are got.
## Examples
iex> MatrixOperation.row_column_matrix([[3, 2, 3], [2, 1, 2]])
[2, 3]
"""
def row_column_matrix(a) when is_list(hd(a)) do
columns_n... | lib/matrix_operation.ex | 0.81134 | 0.720319 | matrix_operation.ex | starcoder |
defmodule EdgeDB.Sandbox do
@moduledoc since: "0.2.0"
@moduledoc """
Custom connection for tests that involve modifying the database through the driver.
This connection, when started, wraps the actual connection to EdgeDB into a transaction using
the `START TRANSACTION` statement. And then further calls to... | lib/edgedb/sandbox.ex | 0.855535 | 0.773794 | sandbox.ex | starcoder |
defmodule ExAliyunOts.PlainBuffer do
@moduledoc false
@header 0x75
# tag type
@tag_row_pk 0x1
@tag_row_data 0x2
@tag_cell 0x3
@tag_cell_name 0x4
@tag_cell_value 0x5
@tag_cell_type 0x6
@tag_cell_timestamp 0x7
@tag_delete_row_marker 0x8
@tag_row_checksum 0x9
@tag_cell_checksum 0x0A
# cell o... | lib/ex_aliyun_ots/plainbuffer/plainbuffer.ex | 0.550849 | 0.417806 | plainbuffer.ex | starcoder |
defmodule Univrse.Signature do
@moduledoc """
A Univrse Signature is a structure attached to an `t:Univrse.Envelope.t/0`,
containing a set of headers and a cryptographic signature (or MAC).
An Envelope may contain one or multiple Signature structures.
The Signature structure headers must contain an `alg` he... | lib/univrse/signature.ex | 0.877339 | 0.682137 | signature.ex | starcoder |
defmodule Day08 do
def part1(input) do
parse(input)
|> Enum.flat_map(&(elem(&1, 1)))
|> Enum.filter(fn output ->
byte_size(output) in [2, 3, 4, 7]
end)
|> Enum.count
end
def part2(input) do
input = parse(input)
mappings = Enum.map(?a..?g, fn wire ->
{to_string([wire]), En... | day08/lib/day08.ex | 0.530966 | 0.558146 | day08.ex | starcoder |
defmodule ExAws.Kinesis.Lazy do
alias ExAws.Kinesis
@moduledoc """
Kinesis has a few functions that require paging.
These functions operate just like those in Kinesis,
except that they return streams instead of lists that can be iterated through
and will automatically retrieve additional pages as necessary.... | lib/ex_aws/kinesis/lazy.ex | 0.717804 | 0.547343 | lazy.ex | starcoder |
defmodule Minecraft.Connection do
@moduledoc """
Maintains the state of a client's connection, and provides utilities for sending and receiving
data. It is designed to be chained in a fashion similar to [`Plug`](https://hexdocs.pm/plug/).
"""
alias Minecraft.Crypto
alias Minecraft.Packet
require Lo... | lib/minecraft/connection.ex | 0.885043 | 0.423279 | connection.ex | starcoder |
defmodule Sanbase.Billing.Plan.AccessChecker do
@moduledoc """
Module that contains functions for determining access based on the subscription
plan.
Adding new queries or updating the subscription plan does not require this
module to be changed.
The subscription plan needed for a given query is given in t... | lib/sanbase/billing/plan/access_checker.ex | 0.884664 | 0.680067 | access_checker.ex | starcoder |
defmodule X.Tokenizer do
@moduledoc """
X template tokenizer module.
"""
alias X.Ast
@whitespaces ' \n\r\t'
@attr_stop_chars @whitespaces ++ '/>'
@namechars '.-_:'
@singleton_tags ~w[
area base br col embed hr
img input keygen link meta
param source track wbr
]c
defguardp is_whitespa... | lib/x/tokenizer.ex | 0.857679 | 0.497131 | tokenizer.ex | starcoder |
defmodule OMG.API.BlackBoxMe do
@moduledoc """
Generates dumb wrapper for pure library that keeps state in process dictionary.
Wrapper creates module with :"GS" attached at the end.
Example:
```
defmodule YourProject.State.Core do
use OMG.API.BlackBoxMe
...
```
would create a YourProject.Stat... | apps/omg_api/lib/black_box_me.ex | 0.878503 | 0.700434 | black_box_me.ex | starcoder |
defmodule Cizen.Pattern.Compiler do
@moduledoc false
alias Cizen.Pattern.Code
import Code, only: [as_code: 2]
# filter style
# input: `fn %{a: a} -> a == :ok end`
def compile(pattern_or_filter, env) do
{:fn, _, fncases} = to_filter(pattern_or_filter)
# Merges cases
{codes, _guards} =
fnca... | lib/cizen/pattern/compiler.ex | 0.793346 | 0.47025 | compiler.ex | starcoder |
defmodule Garlic.NetworkStatus.Document do
@moduledoc "Network status document"
@spec parse(binary) :: {:ok, Garlic.NetworkStatus.t()} | {:error, atom}
def parse(text) do
text
|> String.split("\n")
|> Enum.map(&String.split(&1, " "))
|> parse_tokens(%Garlic.NetworkStatus{})
end
defp parse_to... | lib/garlic/network_status/document.ex | 0.751283 | 0.413181 | document.ex | starcoder |
defmodule Cog.Pipeline.InitialContext do
alias Experimental.GenStage
alias Cog.Pipeline.DoneSignal
@moduledoc ~s"""
`GenStage` producer responsible for initiating pipeline execution.
`InitialContext` begins with its `GenStage` demand set to `:accumulate`
pausing the pipeline until it is fully constructed... | lib/cog/pipeline/initial_context.ex | 0.819785 | 0.502991 | initial_context.ex | starcoder |
defmodule ExFuzzywuzzy.Algorithms.PartialMatch do
@moduledoc """
Implementation for the partial matching algorithms used by the library interface.
The model defined is linked to the calling ratio functions, making no sense to be used externally
"""
alias ExFuzzywuzzy.Algorithms.LongestCommonSubstring
defs... | lib/ex_fuzzywuzzy/algorithms/partial_match.ex | 0.906661 | 0.772273 | partial_match.ex | starcoder |
defmodule Scenic.Primitive.Triangle do
@moduledoc """
Draw a triangle on the screen.
## Data
`{point_a, point_b, point_c}`
The data for a line is a tuple containing three points.
* `point_a` - position to start drawing from
* `point_b` - position to draw to
* `point_c` - position to draw to
## St... | lib/scenic/primitive/triangle.ex | 0.947186 | 0.912202 | triangle.ex | starcoder |
defmodule Cafex.Consumer.LoadBalancer do
@moduledoc """
Balance partition assignment between Cafex consumers
"""
@type layout :: [{node, [partition]}]
@type partition :: non_neg_integer
@doc """
Balance partition assignment between Cafex consumers
## Examples
iex> rebalance [], 5
[]
... | lib/cafex/consumer/load_balancer.ex | 0.775817 | 0.540621 | load_balancer.ex | starcoder |
defmodule JWKSURIUpdater do
@moduledoc """
JWKSURIUpdater dynamically loads jwks URIs keys (lazy-loading) and keeps it in memory for
further access.
## Options
The `get_keys/2` function can be called with the following options:
- `:refresh_interval`: the number of seconds to keep keys unchanged in cache b... | lib/jwks_uri_updater.ex | 0.836187 | 0.800614 | jwks_uri_updater.ex | starcoder |
defmodule Graft do
@moduledoc """
An API of the raft consensus algorithm, allowing for custom client requests
and custom replicated state machines.
## Example
Let's create a distributed stack. The first step is to set up the state machine.
Here we will use the `Graft.Machine` behaviour.
```
defmodule... | lib/graft.ex | 0.868896 | 0.931025 | graft.ex | starcoder |
defmodule Bluetooth.HCI.PortEmulator do
@moduledoc """
Emulates the port program for accessing HCI and enables testing
on a host without accessing a real bluetooth device.
"""
use GenServer
require Logger
# Constants for HCI commands etc
@hci_command_package_type 1
@hci_event_package_type 4
def ... | test/support/hci_emulator.ex | 0.637708 | 0.481088 | hci_emulator.ex | starcoder |
defmodule Litelist.Auth do
@moduledoc """
The Auth context.
"""
import Ecto.Query, warn: false
alias Litelist.Repo
alias Litelist.Auth.Neighbor
alias Bcrypt
@doc """
Returns the list of neighbors.
## Examples
iex> list_neighbors()
[%Neighbor{}, ...]
"""
def list_neighbors do
... | lib/litelist/auth/auth.ex | 0.884912 | 0.471284 | auth.ex | starcoder |
defmodule Phoenix.Socket do
@moduledoc ~S"""
Defines a socket and its state.
`Phoenix.Socket` is used as a module for establishing and maintaining
the socket state via the `Phoenix.Socket` struct.
Once connected to a socket, incoming and outgoing events are routed to
channels. The incoming client data is ... | assets/node_modules/phoenix/lib/phoenix/socket.ex | 0.891793 | 0.540196 | socket.ex | starcoder |
defmodule Stripe.Webhook do
@moduledoc """
Creates a Stripe Event from webhook's payload if signature is valid.
Use `construct_event/3` to verify the authenticity of a webhook request and
convert its payload into a `Stripe.Event` struct.
case Stripe.Webhook.construct_event(payload, signature, secret) do
... | lib/stripe/webhook.ex | 0.890342 | 0.565899 | webhook.ex | starcoder |
defmodule ExTwilio.Parser do
@moduledoc """
A JSON parser tuned specifically for Twilio API responses. Based on Poison's
excellent JSON decoder.
"""
@type metadata :: map
@type http_status_code :: number
@type key :: String.t
@type success :: {:ok, [map]}
@type success_l... | lib/ex_twilio/parser.ex | 0.867682 | 0.460107 | parser.ex | starcoder |
defmodule Chunky.Sequence.OEIS.Powers do
@moduledoc """
Sequences from the [Online Encyclopedia of Integer Sequences](https://oeis.org) dealing with powers
and simple polynomials.
## Available Sequences
### Powers of specific integers
- `create_sequence_a000351/1` - A000351 - Powers of 5: a(n) = 5^n.
... | lib/sequence/oeis/powers.ex | 0.845113 | 0.806205 | powers.ex | starcoder |
defmodule DataBase.Schemas.AccountMovement do
@moduledoc """
The bank account funds movimentation.
Every time a `t:DataBase.Schemas.Account.t/0` adds or removes
funds, it's in other words: Inserting a new `t:t/0`. Which are
simply called **Movements**. They can add *(inbound)* or remove
*(outbound)* funds.... | apps/database/lib/database/schemas/account_movement.ex | 0.894723 | 0.754892 | account_movement.ex | starcoder |
defmodule Strukt.Field do
@moduledoc false
defstruct type: nil,
name: nil,
meta: nil,
value_type: nil,
options: [],
validations: [],
block: nil
@validation_opts [
:required,
:length,
:format,
:one_of,
:none_of,
:subs... | lib/field.ex | 0.832543 | 0.473414 | field.ex | starcoder |
defmodule Crux.Rest.Util do
@moduledoc """
Collection of util functions.
"""
alias Crux.Structs.{Channel, Emoji, Guild, Member, Message, Overwrite, Reaction, Role, User}
@doc """
Resolves a string or a binary to a `t:binary/0`.
* http / https url
* local file path
* a binary itself
"""
... | lib/rest/util.ex | 0.855293 | 0.650772 | util.ex | starcoder |
defmodule Asteroid.OAuth2.DeviceAuthorization do
@moduledoc """
Types and convenience functions to work with the device flow
"""
import Asteroid.Utils
defmodule ExpiredTokenError do
@moduledoc """
Error returned when a device code has expired
"""
defexception []
@type t :: %__MODULE__{... | lib/asteroid/oauth2/device_authorization.ex | 0.850562 | 0.417925 | device_authorization.ex | starcoder |
defmodule Ecto.Query do
@moduledoc """
This module is the query DSL. Queries are used to fetch data from a repository
(see `Ecto.Repo`).
## Examples
import Ecto.Query
from w in Weather,
where: w.prcp > 0,
select: w.city
The above example will create a query that can be run agai... | lib/ecto/query.ex | 0.92597 | 0.812012 | query.ex | starcoder |
defmodule AWS.GlobalAccelerator do
@moduledoc """
AWS Global Accelerator
This is the *AWS Global Accelerator API Reference*.
This guide is for developers who need detailed information about AWS Global
Accelerator API actions, data types, and errors. For more information about
Global Accelerator features,... | lib/aws/generated/global_accelerator.ex | 0.900073 | 0.738121 | global_accelerator.ex | starcoder |
defmodule Scenic.Primitive.Style.Paint.Color do
@moduledoc false
# ============================================================================
# data verification and serialization
# --------------------------------------------------------
# verify that a color is correctly described
def verify(color) ... | lib/scenic/primitive/style/paint/color.ex | 0.581422 | 0.482856 | color.ex | starcoder |
defmodule Stripe.Price do
@moduledoc """
Work with Stripe price objects.
The Prices API adds more flexibility to how you charge customers.
It also replaces the Plans API, so Stripe recommends migrating your existing
integration to work with prices.
To migrate, you need to identify how you use plans, prod... | lib/stripe/subscriptions/price.ex | 0.863406 | 0.789842 | price.ex | starcoder |
defmodule Oban.Plugins.Cron do
@moduledoc """
Periodically enqueue jobs through CRON based scheduling.
## Using the Plugin
Schedule various jobs using `{expr, worker}` and `{expr, worker, opts}` syntaxes:
config :my_app, Oban,
plugins: [
{Oban.Plugins.Cron,
crontab: [
... | lib/oban/plugins/cron.ex | 0.863262 | 0.455865 | cron.ex | starcoder |
defmodule Nebulex.Adapters.Local.Generation do
@moduledoc """
Generations Handler. This GenServer acts as garbage collector, everytime
it runs, a new cache generation is created a the oldest one is deleted.
The only way to create new generations is through this module (this
server is the metadata owner) call... | lib/nebulex/adapters/local/generation.ex | 0.922543 | 0.429908 | generation.ex | starcoder |
defmodule MasteringBitcoin.ProofOfWorkExample do
@moduledoc """
Example 10-11. Simplified Proof-of-Work implementation
Port over of some code contained in the `proof-of-work-example.py` file.
"""
import MasteringBitcoin, only: [pow: 2]
@starting_nonce 0
# max nonce: 4 billion
@max_nonce pow(2, 32)
... | lib/mastering_bitcoin/proof_of_work_example.ex | 0.778313 | 0.612223 | proof_of_work_example.ex | starcoder |
defmodule Absinthe.Middleware do
@moduledoc """
Middleware enables custom resolution behaviour on a field.
All resolution happens through middleware. Even `resolve` functions are
middleware, as the `resolve` macro is just
```
quote do
middleware Absinthe.Resolution, unquote(function_ast)
end
```
... | lib/absinthe/middleware.ex | 0.944408 | 0.89289 | middleware.ex | starcoder |
defmodule Honeylixir.Event do
@moduledoc """
Used for managing Events and holding their data. It also has a send function
that really just kicks off the sending process which happens asynchronously.
"""
@moduledoc since: "0.1.0"
# This one is mainly for testing only so we an force a timestamp for comparing... | lib/event.ex | 0.893632 | 0.797951 | event.ex | starcoder |
defmodule Hunter.Relationship do
@moduledoc """
Relationship entity
This module defines a `Hunter.Relationship` struct and the main functions
for working with Relationship.
## Fields
* `id` - target account id
* `following` - whether the user is currently following the account
* `followed_by` -... | lib/hunter/relationship.ex | 0.843943 | 0.521654 | relationship.ex | starcoder |
defmodule Eden do
import Eden.Parser
@moduledoc """
Provides functions to `encode/1` and `decode/2` between *Elixir* and
*edn* data format.
"""
alias Eden.Encode
alias Eden.Decode
alias Eden.Exception, as: Ex
@default_handlers %{"inst" => &Eden.Tag.inst/1,
"uuid" => &Eden.Tag.... | lib/eden.ex | 0.874961 | 0.689671 | eden.ex | starcoder |
defmodule Cognixir.FaceApi.DetectOptions do
@moduledoc """
Options for function detect_face. See official api doc for supported options.
## Keys
- returnFaceId: boolean, return detected face ids
- returnFaceLandmarks: boolean, return face landmarks
- returnFaceAttributes: comma separated strings, analyze s... | lib/face_api.ex | 0.883381 | 0.4112 | face_api.ex | starcoder |
defmodule AdaptableCostsEvaluator.Computations do
@moduledoc """
The Computations context.
"""
import Ecto.Query, warn: false
alias AdaptableCostsEvaluator.Repo
alias AdaptableCostsEvaluator.Computations.Computation
alias AdaptableCostsEvaluator.Users.User
alias AdaptableCostsEvaluator.{Users, Organiz... | lib/adaptable_costs_evaluator/computations.ex | 0.895878 | 0.571916 | computations.ex | starcoder |
defmodule InteropProxy.Session do
@moduledoc """
Keeps an internal state with the url and cookie for requests.
Will also keep making sure the login is valid every 5 seconds. If
the cookie no longer works, because for example, a new server was
created, the cookie would be updated.
"""
use Agent
alias ... | services/interop-proxy/lib/interop_proxy/session.ex | 0.560854 | 0.416144 | session.ex | starcoder |
defmodule ReWeb.Types.SellerLead do
@moduledoc """
GraphQL types for seller leads
"""
use Absinthe.Schema.Notation
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
alias ReWeb.Resolvers
object :site_seller_lead do
field :uuid, :uuid
field :complement, :string
field :type, :string
... | apps/re_web/lib/graphql/types/seller_lead.ex | 0.652906 | 0.514827 | seller_lead.ex | starcoder |
defimpl Timex.Protocol, for: DateTime do
@moduledoc """
A type which represents a date and time with timezone information (optional, UTC will
be assumed for date/times with no timezone information provided).
Functions that produce time intervals use UNIX epoch (or simly Epoch) as the
default reference date. ... | lib/datetime/datetime.ex | 0.892538 | 0.54958 | datetime.ex | starcoder |
defmodule Plug.AccessLog.DefaultFormatter do
@moduledoc """
Default log message formatter.
"""
alias Plug.AccessLog.DefaultFormatter
alias Plug.AccessLog.Formatter
@behaviour Formatter
@doc """
Formats a log message.
The following formatting directives are available:
- `%%` - Percentage sign
... | lib/plug/accesslog/default_formatter.ex | 0.788217 | 0.470554 | default_formatter.ex | starcoder |
defmodule AtomTweaksWeb.FormHelpers do
@moduledoc """
Functions for building HTML forms, specifically designed to work with
[GitHub Primer](https://primer.style).
"""
use Phoenix.HTML
alias Phoenix.HTML.Form
alias AtomTweaks.Markdown
alias AtomTweaksWeb.ErrorHelpers
@doc """
Displays the appropri... | lib/atom_tweaks_web/helpers/form_helpers.ex | 0.778228 | 0.422177 | form_helpers.ex | starcoder |
defmodule Gringotts.Gateways.Trexle do
@moduledoc """
[Trexle][home] Payment Gateway implementation.
> For further details, please refer [Trexle API documentation][docs].
Following are the features that have been implemented for the Trexle Gateway:
| Action | Method |
| -----... | lib/gringotts/gateways/trexle.ex | 0.86988 | 0.84075 | trexle.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.