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 Alixir.OSS do
@moduledoc """
`Alixir.OSS` enables puting and deleting objects for Aliyun
OSS.
## Examples
```
Alixir.OSS.put_object(args...)
|> Alixir.request()
Alixir.OSS.delete_objects(args...)
|> Alixir.request()
```
See `put_object/4` and `delete_object/4` for more de... | lib/alixir_oss.ex | 0.858941 | 0.664362 | alixir_oss.ex | starcoder |
defmodule Tw.V1_1.Entities do
@moduledoc """
Entities data structure and related functions.
https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/entities
"""
alias Tw.V1_1.Hashtag
alias Tw.V1_1.Media
alias Tw.V1_1.Poll
alias Tw.V1_1.Schema
alias Tw.V1_1.Symbol
alias Tw.... | lib/tw/v1_1/entities.ex | 0.748628 | 0.424263 | entities.ex | starcoder |
defmodule AWS.Translate do
@moduledoc """
Provides translation between one source language and another of the same set of
languages.
"""
@doc """
A synchronous action that deletes a custom terminology.
"""
def delete_terminology(client, input, options \\ []) do
request(client, "DeleteTerminology",... | lib/aws/generated/translate.ex | 0.823399 | 0.482734 | translate.ex | starcoder |
defmodule Talib.Utility do
@moduledoc ~S"""
Module containing utility functions, used in the
calculation of indicators and oscillators.
"""
@doc """
Gets the change in the list.
The `direction` parameter is a direction filter, which defaults to 0.
Returns `{:ok, change}`, otherwise `{:error, reason}`.... | lib/talib/utility.ex | 0.917367 | 0.746994 | utility.ex | starcoder |
defmodule Ease do
import :math, only: [pow: 2, cos: 1, pi: 0, sin: 1, sqrt: 1]
@moduledoc """
Provides a number of popular easing functions.
Useful if you're doing animation or some sort of motion.
See [easings.net](http://easings.net) for nice graphs of each function.
"""
@type easing_function :: :li... | lib/ease.ex | 0.870032 | 0.692447 | ease.ex | starcoder |
defmodule Eurexa.EurexaServer do
@moduledoc """
This is a gen server process, handling one Elixir service for Eureka. Each
service requires one `EurexaServer`, which sends the regular heartbeats.
The data sent to the Eureka Server has to comply to this XML schema and can
be sent either as XML or as JSON data. We ... | lib/eurexa/eurexa_server.ex | 0.766075 | 0.583263 | eurexa_server.ex | starcoder |
defmodule Day4 do
@moduledoc """
Documentation for `Day4`.
"""
@doc """
Hello world.
"""
def run() do
inhalt = read_input()
|> adjust_input()
|> parse_input()
solve(inhalt)
solve_2(inhalt)
end
def solve(%{} = game) do
bingoed_boards = get_winning_boards(game.boards)
con... | apps/day4/lib/day4.ex | 0.685529 | 0.512815 | day4.ex | starcoder |
defmodule Time do
defmacro time(exp) do
quote do
{time, dict} = :timer.tc(fn -> unquote(exp) end)
IO.inspect("time: #{time} micro second")
IO.inspect("-------------")
dict
end
end
end
defmodule Network do
defmacro defnetwork(name, do: body) do
{_, _, [{arg, _, _}]} = name
... | lib/macro.ex | 0.572006 | 0.671948 | macro.ex | starcoder |
defmodule Rayray.Tuple do
def point(x, y, z) do
tuple(x, y, z, 1.0)
end
def vector(x, y, z) do
tuple(x, y, z, 0.0)
end
def color(r, g, b) do
%{red: r, green: g, blue: b}
end
def tuple(x, y, z, w) do
%{x: x, y: y, z: z, w: w}
end
def add(%{red: r1, green: g1, blue: b1}, %{red: r2, g... | lib/rayray/tuple.ex | 0.754915 | 0.832407 | tuple.ex | starcoder |
defmodule PersQueue do
use Application
@moduledoc """
`PersQueue` is persistent queue with `Mnesia` backend.
## Installation
1) Add `pers_queue` to your deps:
```elixir
def deps do
[
{:pers_queue, "~> 0.0.1"}
]
end
```
2) Add `pers_queue` to the list of application dependencies:
... | lib/pers_queue.ex | 0.793866 | 0.75158 | pers_queue.ex | starcoder |
defmodule Xandra.Prepared do
@moduledoc """
A data structure used to internally represent prepared queries.
These are the publicly accessible fields of this struct:
* `:tracing_id` - the tracing ID (as a UUID binary) if tracing was enabled,
or `nil` if no tracing was enabled. See the "Tracing" section... | lib/xandra/prepared.ex | 0.828037 | 0.46308 | prepared.ex | starcoder |
defmodule Distillery.Releases.Profile do
@moduledoc """
Represents the configuration profile for a specific environment and release.
More generally, a release has a profile, as does an environment, and
when determining the configuration for a release in a given environment, the
environment profile overrides t... | lib/distillery/releases/models/profile.ex | 0.799599 | 0.57063 | profile.ex | starcoder |
defmodule Tds.BinaryUtils do
@moduledoc false
@doc """
A single bit value of either 0 or 1
"""
defmacro bit(), do: quote(do: size(1))
@doc """
An unsigned single byte (8-bit) value. The range is 0 to 255.
"""
defmacro byte(), do: quote(do: unsigned - 8)
@doc """
An unsigned single byte (8-bit) ... | lib/tds/binary_utils.ex | 0.862308 | 0.586552 | binary_utils.ex | starcoder |
defmodule Buckaroo.Router do
@moduledoc ~S"""
An extension to `Plug.Router` now also supporting `websocket`.
"""
@doc false
defmacro __using__(opts) do
quote location: :keep do
use Plug.Router, unquote(opts)
import Buckaroo.Router, only: [sse: 2, websocket: 2]
Module.register_attribute(... | lib/buckaroo/router.ex | 0.786705 | 0.612657 | router.ex | starcoder |
defmodule Thumbnex do
@moduledoc """
Create thumbnails from images and videos.
"""
alias Thumbnex.Animations
alias Thumbnex.ExtractFrame
alias Thumbnex.Gifs
@doc """
Create a thumbnail image.
Image format is inferred from output path file extension.
To override, pass the `:format` option.
Opti... | lib/thumbnex.ex | 0.894873 | 0.506225 | thumbnex.ex | starcoder |
defmodule JMES do
@moduledoc """
JMES implements JMESPath, a query language for JSON.
It passes the official compliance tests.
See [jmespath.org](http://jmespath.org).
"""
alias JMES.{Functions, Parser}
@type expr :: String.t() | charlist
@type ast :: tuple | atom
@type error :: {:error, any}
@... | lib/jmes.ex | 0.837071 | 0.585783 | jmes.ex | starcoder |
defmodule Expletive do
@moduledoc """
A profanity detection and sanitization library.
"""
alias Expletive.Configuration, as: Configuration
alias Expletive.Replacement, as: Replacement
@type replacement :: :default | :garbled | :stars | :vowels | :nonconsonants | String.t | {:repeat, String.t} | :keep_f... | lib/expletive.ex | 0.877752 | 0.682574 | expletive.ex | starcoder |
defmodule Meeseeks.Selector do
@moduledoc """
Selector structs package some method of checking if a node matches some
condition with an optional `Meeseeks.Selector.Combinator`, an optional
list of filter selectors, and an optional method of validating the
Selector.
For instance, the css selector `ul > li` ... | lib/meeseeks/selector.ex | 0.919953 | 0.829975 | selector.ex | starcoder |
defmodule Pwned do
@moduledoc """
Check if your password has been pwned.
"""
alias Pwned.Utils.EmailFlattener
alias Pwned.Utils.EmailReducer
@doc """
It uses [have i been pwned?](https://haveibeenpwned.com) to verify if a password has appeared in a data breach. In order to protect the value of the source... | lib/pwned.ex | 0.719088 | 0.580322 | pwned.ex | starcoder |
defmodule Aoc2021.Day16 do
@moduledoc """
See https://adventofcode.com/2021/day/16
"""
alias Aoc2021.Day16.Packet
@type operator() :: :literal | :sum | :prod | :min | :max | :gt | :lt | :eq
defmodule Packet do
@moduledoc false
alias Aoc2021.Day16
defstruct [:version, :type, :value]
@ty... | lib/aoc2021/day16.ex | 0.718298 | 0.555918 | day16.ex | starcoder |
defmodule Honeylixir do
@moduledoc """
Used to interact with honeycomb.io's API for tracing and other data.
## Installation
Adding Honeylixir to your mix.exs as a dependency should suffice for installation:
```
def deps() do
[
{:honeylixir, "~> 0.3.0"}
]
end
```
## Configuration
... | lib/honeylixir.ex | 0.852537 | 0.944485 | honeylixir.ex | starcoder |
defmodule Hangman.Shard.Handler do
@moduledoc """
Module runs game play for the given shard of secrets
as determined by `Shard.Flow`. Basically, runs a chunk
of the overall original secrets vector.
Module drives `Player.Controller`, while
setting up the proper `Game` server and `Event` consumer states bef... | lib/hangman/shard_handler.ex | 0.759671 | 0.59075 | shard_handler.ex | starcoder |
defmodule Workflows.Retrier do
@moduledoc """
Implements a state retrier.
## References
* https://states-language.net/#errors
"""
alias Workflows.Error
@type t :: %__MODULE__{
error_equals: String.t(),
interval_seconds: pos_integer(),
max_attempts: non_neg_integer(),
... | lib/workflows/retrier.ex | 0.876905 | 0.470737 | retrier.ex | starcoder |
defmodule GoCD.Crypt do
@moduledoc false
require Logger
@doc ~S"""
Decrypt a GoCD secure variable.
Currently supports:
- AES
- DES
Note: DES has been replaced with AES in version 17 and will be deprecated in 18.
"""
@spec decrypt(String.t(), map) :: {:ok, String.t()} | {:error, atom}
def d... | lib/gocd/crypt.ex | 0.84039 | 0.443118 | crypt.ex | starcoder |
defmodule GrowthBook.FeatureResult do
@moduledoc """
Struct holding results of an evaluated Feature.
Holds the result of a feature evaluation, and is used to check if a feature is enabled, and
optionally what data it provides, if that was configured.
"""
@typedoc """
Feature result
The result of eval... | lib/growth_book/feature_result.ex | 0.900776 | 0.731155 | feature_result.ex | starcoder |
defmodule Annex.DataAssertion do
@moduledoc """
A helper module for making assertions about the returns of a Data
type's callbacks.
"""
use ExUnit.CaseTemplate
alias Annex.{
Data,
Shape
}
require Shape
def cast(type, data, shape) when Shape.is_shape(shape) do
product = Shape.product(sha... | test/support/data_assertion.ex | 0.852414 | 0.842151 | data_assertion.ex | starcoder |
defmodule Benchee.Statistics do
@moduledoc """
Statistics related functionality that is meant to take the raw benchmark data
and then compute statistics like the average and the standard deviation etc.
See `statistics/1` for a breakdown of the included statistics.
"""
alias Benchee.{CollectionData, Conver... | lib/benchee/statistics.ex | 0.933423 | 0.86916 | statistics.ex | starcoder |
defmodule Miss.Kernel do
@moduledoc """
Functions to extend the Elixir `Kernel` module.
"""
@doc """
Returns `true` if `term` is a charlist. Otherwise returns `false`.
A charlist is a list made of non-negative integers, where each integer represents a Unicode code
point. These integers must be:
- with... | lib/miss/kernel.ex | 0.91976 | 0.451871 | kernel.ex | starcoder |
defmodule AdventOfCode.Day04 do
import AdventOfCode.Utils
@type board :: [[integer]]
@spec part1([binary()]) :: integer()
def part1(args) do
{sequence, boards} = parse_args(args)
{winning_board, numbers} = find_winning_board([], sequence, boards)
(winning_board |> unmarked_numbers(numbers) |> Enum... | lib/advent_of_code/day_04.ex | 0.775817 | 0.46041 | day_04.ex | starcoder |
defmodule Sanbase.Clickhouse.MetricAdapter.HistogramMetric do
import Sanbase.DateTimeUtils, only: [str_to_sec: 1]
import Sanbase.Clickhouse.MetricAdapter.HistogramSqlQuery
alias Sanbase.Metric
alias Sanbase.ClickhouseRepo
@spent_coins_cost_histograms ["price_histogram", "spent_coins_cost", "all_spent_coins_... | lib/sanbase/clickhouse/metric/histogram_metric.ex | 0.857559 | 0.532547 | histogram_metric.ex | starcoder |
defmodule Addict.Interactors.ValidatePassword do
@moduledoc """
Validates a password according to the defined strategies.
For now, only the `:default` strategy exists: password must be at least 6 chars long.
Returns `{:ok, []}` or `{:error, [errors]}`
"""
@password_length 8
@uppercase_condition_regex ~r... | lib/addict/interactors/validate_password.ex | 0.759136 | 0.460228 | validate_password.ex | starcoder |
defmodule UBootEnv.IO do
@moduledoc """
Functions for reading and writing raw blocks to storage
This is the module that handles the low level CRC32 and redundant block
details.
"""
alias UBootEnv.{Config, Location}
@type generation() :: byte() | :unused
@doc """
Read a U-Boot environment block
T... | lib/uboot_env/io.ex | 0.765287 | 0.44553 | io.ex | starcoder |
defmodule TwoFactorInACan.Hotp do
@moduledoc """
Provides functions for working with the HMAC-based One Time Password
algorithm as defined in RFC 4226.
For details on RFC 4226, see https://tools.ietf.org/rfc/rfc4226.txt.
"""
use Bitwise, only_operators: true
@doc """
Generates a token from a shared s... | lib/hotp/hotp.ex | 0.910732 | 0.890628 | hotp.ex | starcoder |
defmodule MysterySoup.PCG32 do
@moduledoc """
Documentation for `MysterySoup`'s PCG32 implementation.
"""
@type t :: __MODULE__
defstruct [:state, :inc]
alias MysterySoup.PCG32.Nif
@doc """
Initializes a new PCG32 state, seeding with system random.
"""
@spec init() :: MysterySoup.t()
def init,... | lib/pcg32.ex | 0.811639 | 0.482429 | pcg32.ex | starcoder |
defmodule Reaper.DataExtract.ExtractStep do
@moduledoc """
This module processes extract steps as defined in an ingestion definition. After
iterating through the steps, accumulating any destination values in the assigns block
it is assumed the final step will be http (at this time) which returns a data stream
... | apps/reaper/lib/reaper/data_extract/extract_step.ex | 0.694717 | 0.485234 | extract_step.ex | starcoder |
defmodule Monet.Connection do
@moduledoc """
Represents a connection (a socket) to the MonetDB Server.
Although this can be accessed directy (staring with conn/1), the intention is
for it to be accessed via the Monet module (which manages a pool of these
connections).
"""
require Record
require Logger
alias... | lib/connection.ex | 0.532668 | 0.409575 | connection.ex | starcoder |
defmodule Knock do
@moduledoc """
Official SDK for interacting with Knock.
## Example usage
### As a module
The recommended way to configure Knock is as a module in your application. Doing so will
allow you to customize the options via configuration in your app.
```elixir
# lib/my_app/knock.ex
de... | lib/knock.ex | 0.836454 | 0.625638 | knock.ex | starcoder |
defmodule ShEx.OneOf do
@moduledoc false
defstruct [
# tripleExprLabel?
:id,
# [tripleExpr{2,}]
:expressions,
# INTEGER?
:min,
# INTEGER?
:max,
# [SemAct+]?
:sem_acts,
# [Annotation+]?
:annotations
]
import ShEx.TripleExpression.Shared
def matches(one_of, tri... | lib/shex/shape_expressions/one_of.ex | 0.584983 | 0.449816 | one_of.ex | starcoder |
defmodule Exhort.SAT.LinearExpression do
@moduledoc """
An expression in terms of variables and operators, constraining the overall
model.
Expressions should be defined through `Exhort.SAT.Constraint` or
`Exhort.SAT.Builder`. Alternatively, a new expression may be created using the
`Exhort.SAT.LinearExpres... | lib/exhort/sat/linear_expression.ex | 0.863478 | 0.550426 | linear_expression.ex | starcoder |
defmodule Flex.Variable do
alias Flex.{Set, Variable}
@moduledoc """
An interface to create Fuzzy Variables.
"""
defstruct tag: nil,
fuzzy_sets: nil,
mf_values: %{},
range: nil,
rule_output: nil,
type: nil
@typedoc """
Fuzzy Variable struct.
... | lib/variable.ex | 0.856077 | 0.751876 | variable.ex | starcoder |
defmodule EpicenterWeb.Test.Pages.Search do
import Euclid.Test.Extra.Assertions
import ExUnit.Assertions
import Phoenix.LiveViewTest
alias Epicenter.Test
alias Epicenter.Test.HtmlAssertions
alias Phoenix.LiveViewTest.View
def assert_disabled(view, link) when link in ~w[prev next]a do
assert view |> ... | test/support/pages/search.ex | 0.575946 | 0.489259 | search.ex | starcoder |
defmodule Battleship.Game.Board do
@moduledoc """
Game board
"""
alias Battleship.{Ship}
require Logger
@ships_sizes [5, 4, 3, 2, 2, 1, 1]
@size 10
@orientations [:horizontal, :vertical]
@grid_value_water "·"
@grid_value_ship "/"
@grid_value_water_hit "O"
@grid_value_ship_hit "*"
defstruct ... | lib/battleship/game/board.ex | 0.836521 | 0.400749 | board.ex | starcoder |
defprotocol Xema.Castable do
@moduledoc """
Converts data using the specified schema.
"""
@doc """
Converts the given data using the specified schema.
"""
def cast(value, schema)
end
defimpl Xema.Castable, for: Atom do
use Xema.Castable.Helper
def cast(nil, nil, _module, _schema), do: {:ok, nil}
... | lib/xema/castable.ex | 0.884177 | 0.521288 | castable.ex | starcoder |
defmodule Calamity.Stack do
@moduledoc """
The state object of `Calamity`.
This object contains all the stores and metadata necessary for command dispatch.
"""
defstruct aggregate_store: %{},
aggregate_versions: %{},
event_store: %Calamity.EventStore.ListEventStore{},
pro... | lib/calamity/stack.ex | 0.836388 | 0.408867 | stack.ex | starcoder |
defmodule Rayray.Renderings.Cube do
alias Rayray.Camera
alias Rayray.Canvas
alias Rayray.Lights
alias Rayray.Material
alias Rayray.Matrix
alias Rayray.Plane
alias Rayray.Cube
alias Rayray.Transformations
alias Rayray.Tuple
alias Rayray.World
def do_it() do
floor = Plane.new()
floor_materi... | lib/rayray/renderings/cube.ex | 0.815783 | 0.433622 | cube.ex | starcoder |
defmodule JSONRPC2.Clients.HTTP do
@moduledoc """
A client for JSON-RPC 2.0 using an HTTP transport with JSON in the body.
"""
@default_headers [{"content-type", "application/json"}]
@type batch_result :: {:ok, JSONRPC2.Response.id_and_response()} | {:error, any}
@doc """
Make a call to `url` for JSON-... | lib/jsonrpc2/clients/http.ex | 0.838084 | 0.413596 | http.ex | starcoder |
defmodule Monet.Transaction do
@moduledoc """
Created via `Monet.transaction/1` or `Monet.transaction/2`.
"""
require Record
alias Monet.{Connection, Error, Prepared, Reader, Writer}
Record.defrecord(:transaction, conn: nil, ref: nil, pool_name: nil)
def new(conn) do
transaction(
conn: conn,
ref: mak... | lib/transaction.ex | 0.687945 | 0.403302 | transaction.ex | starcoder |
defmodule AWS.SSOAdmin do
@moduledoc """
Amazon Web Services Single Sign On (SSO) is a cloud SSO service that makes it
easy to centrally manage SSO access to multiple Amazon Web Services accounts and
business applications.
This guide provides information on SSO operations which could be used for access
ma... | lib/aws/generated/sso_admin.ex | 0.895074 | 0.469338 | sso_admin.ex | starcoder |
defmodule Elasticlunr.Storage.S3 do
@moduledoc """
This provider writes to indexes to an s3 project. To use, you need
to include necessary s3 dependencies, see [repository](https://github.com/ex-aws/ex_aws_s3).
```elixir
config :elasticlunr,
storage: Elasticlunr.Storage.S3
config :elasticlunr, Elastic... | lib/storage/s3.ex | 0.653459 | 0.645637 | s3.ex | starcoder |
defmodule BSV.KeyPair do
@moduledoc """
Module for generating and using Bitcoin key pairs.
Bitcoin keys are ECDSA keys. Virtually any 256-bit number is a valid private
key, and the corresponding point on the `secp256k1` curve is the public key.
"""
alias BSV.Crypto.ECDSA
alias BSV.Crypto.ECDSA.{PublicKey... | lib/bsv/key_pair.ex | 0.860721 | 0.453201 | key_pair.ex | starcoder |
defmodule Tradehub.Wallet do
@moduledoc """
This module aims to signing, generating, and interacting with a Tradehub account.
"""
require Logger
import Tradehub.Raising
alias Tradehub.ExtendedKey
@network Application.get_env(:tradehub, :network, :testnet)
@typedoc "The wallet address"
@type address... | lib/tradehub/wallet.ex | 0.873532 | 0.443781 | wallet.ex | starcoder |
defmodule Aja.IO do
@moduledoc ~S"""
Some extra helper functions for working with IO data,
that are not in the core `IO` module.
"""
# TODO: Link about cowboy/mint, benchmarks with Jason
# TODO bench then inline
@doc ~S"""
Checks if IO data is empty in "constant" time.
Should only need to loop unti... | lib/io.ex | 0.523664 | 0.63114 | io.ex | starcoder |
defmodule Bs.Death do
alias Bs.GameState
alias Bs.World
alias Bs.Death.Collision
alias Bs.Point
alias Bs.Snake
alias __MODULE__
use Point
defstruct [:turn, :causes]
defmodule(Kill, do: defstruct([:turn, :with, :cause]))
defmodule(BodyCollisionCause, do: defstruct([:with]))
defmodule(Cause, do: d... | lib/bs/death.ex | 0.511961 | 0.462412 | death.ex | starcoder |
defmodule X.Html do
@moduledoc """
Contains a set of functions to build a valid and safe HTML from X templates.
"""
@escape_chars [
{?<, "<"},
{?>, ">"},
{?&, "&"},
{?", """},
{?', "'"}
]
@merge_attr_names ["class", "style"]
@doc ~S"""
Merges given attrs and ret... | lib/x/html.ex | 0.807612 | 0.561756 | html.ex | starcoder |
defmodule Cronex.Every do
@moduledoc """
This module defines scheduling macros.
"""
@doc """
`Cronex.Every.every/2` macro is used as a simple interface to add a job to the `Cronex.Table`.
## Input Arguments
`frequency` supports the following values: `:minute`, `:hour`, `:day`, `:month`, `:year`, `:mond... | lib/cronex/every.ex | 0.90532 | 0.82963 | every.ex | starcoder |
defmodule Bolt.Sips.Types do
@moduledoc """
Basic support for representing nodes, relationships and paths belonging to
a Neo4j graph database.
Four supported types of entities:
- Node
- Relationship
- UnboundRelationship
- Path
More details, about the Bolt protocol, here:
https://github.com/boltp... | lib/bolt_sips/types.ex | 0.911577 | 0.62458 | types.ex | starcoder |
defmodule TelemetryMetricsZabbix do
@moduledoc """
Provides a Zabbix format reporter and server for Telemetry.Metrics definitions.
## Installation
The package can be installed by adding `telemetry_metrics_zabbix` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:telemetry_met... | lib/telemetry_metrics_zabbix.ex | 0.913489 | 0.771241 | telemetry_metrics_zabbix.ex | starcoder |
defmodule Mason do
@moduledoc """
Mason is a small module to help you coerce values in structs. Note:
Since we cannot define structs in doctests we simply import the `User` module
from in our tests (see test/mason_test.exs).
"""
@doc """
The struct method takes a module and some params and coerces the pa... | lib/mason.ex | 0.762778 | 0.651286 | mason.ex | starcoder |
defmodule Commissar do
@moduledoc """
Commissar provides relatively simple pattern for creating sets of policies to
see if a subject is allowed to execute a particular action related to a given
context.
A subject is whatever is trying to execute a particular action. In most cases
this will probably be a us... | lib/commissar.ex | 0.832134 | 0.787032 | commissar.ex | starcoder |
defmodule Day07 do
def part1(input) do
program = read_program(input)
permutations(0, 4)
|> Stream.filter(&are_unique_phases/1)
|> Stream.map(fn phases -> run_amplifiers(phases, program) end)
|> Enum.max
end
def part2(input) do
program = read_program(input)
permutations(5, 9)
|> St... | day07/lib/day07.ex | 0.505615 | 0.405949 | day07.ex | starcoder |
defmodule SAXMap do
@moduledoc """
XML to Map conversion.
SAXMap uses a SAX parser (built on top of [Saxy](https://hex.pm/packages/saxy)) to transfer an XML string or file stream into a `Map` containing a collection
of pairs where the key is the element name and the value is its content, and it is a optional t... | lib/sax_map.ex | 0.906005 | 0.764496 | sax_map.ex | starcoder |
defmodule Vex.Validators.Number do
@moduledoc """
Ensure a value is a number.
## Options
At least one of the following must be provided:
* `:is`: The value is a number (integer or float) or not.
* `:equal_to`: The value is a number equal to this number.
* `:greater_than` : The value is a number greater... | lib/vex/validators/number.ex | 0.93086 | 0.782787 | number.ex | starcoder |
defmodule RGBMatrix.Animation.Config do
@moduledoc """
Provides a behaviour and macros for defining animation configurations.
"""
alias __MODULE__.FieldType
require Logger
@field_types %{
integer: FieldType.Integer,
option: FieldType.Option
}
@typedoc """
A struct containing runtime config... | lib/rgb_matrix/animation/config.ex | 0.945223 | 0.661622 | config.ex | starcoder |
defmodule Prometheus.Model do
@moduledoc """
Helpers for working with Prometheus data model. For advanced users.
`Prometheus.Collector` example demonstrates how to use this module.
"""
use Prometheus.Erlang, :prometheus_model_helpers
@doc """
Creates Metric Family of `type`, `name` and `help`.
`colle... | astreu/deps/prometheus_ex/lib/prometheus/model.ex | 0.934425 | 0.583648 | model.ex | starcoder |
defmodule Problem11 do
def solve do
grid = getGrid()
x = Enum.to_list 0..19
y = Enum.to_list 0..19
Enum.map( x, fn
x -> Enum.map y, fn
y -> targetToProducts grid, x, y
end
end )
|> List.flatten
|> Enum.reduce(0, fn x, acc -> if (x > acc), do: x, else: acc end)
end
... | elixir/lib/problem011.ex | 0.613005 | 0.640748 | problem011.ex | starcoder |
defmodule Membrane.Element.Base.Mixin.SourceBehaviour do
@moduledoc """
Module defining behaviour for source and filter 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/source_behaviour.ex | 0.854445 | 0.424591 | source_behaviour.ex | starcoder |
defmodule Calixir.SampleDates do
@moduledoc """
The main purpose of this module is to provide test data for functions
written in Elixir or Erlang to convert dates from one calendar into the
corresponding dates in another calendar.
This module provides the following calendrica-4.0 dates as Elixir data:
*Sa... | lib/calixir/sample_dates.ex | 0.925919 | 0.903847 | sample_dates.ex | starcoder |
defmodule Versioning.Adapter.Date do
@moduledoc """
A versioning adapter for date-based versions.
Under the hood, this adapter uses the `Date` module. For details on the rules
that are used for parsing and comparison, please see the `Date` module.
## Example
defmodule MyApp.Versioning do
use ... | lib/versioning/adapter/date.ex | 0.899261 | 0.491151 | date.ex | starcoder |
defmodule Day12 do
@moduledoc """
--- Day 12: Digital Plumber ---
Walking along the memory banks of the stream, you find a small village that is experiencing a little confusion: some
programs can't communicate with each other.
Programs in this village communicate using a fixed system of pipes. Messages are ... | lib/day12.ex | 0.749821 | 0.838481 | day12.ex | starcoder |
defmodule Advent.Day12 do
defmodule Ship do
defstruct [:location, :direction]
def new do
%__MODULE__{location: {0, 0}, direction: {1, 0}}
end
def action(%__MODULE__{location: {x, y}} = ship, {:move, {dx, dy}}) do
%{ship | location: {x + dx, y + dy}}
end
def action(%__MODULE__{di... | shritesh+elixir/lib/advent/day_12.ex | 0.801975 | 0.691452 | day_12.ex | starcoder |
defmodule ElixirDbf.Table do
@moduledoc """
ElixirDbf table module
"""
@empty_stream {"", ""}
@enforce_keys [:header, :rows]
defstruct [:header, :rows]
alias ElixirDbf.Header
def parse_row({:ok, stream}, columns, encoding) do
ElixirDbf.Row.parse(stream, columns, encoding)
after
{:ok, @em... | lib/elixir_dbf/table.ex | 0.612657 | 0.45532 | table.ex | starcoder |
defmodule CryptoCompare do
@moduledoc """
Provides a basic HTTP interface to allow easy communication with the CryptoCompare API, by wrapping `HTTPoison`
** For now only HTTP REST API is available**.
Work on Websocket one is in progress.
[API Documentation](https://www.cryptocompare.com/api/#-api-data-)
... | lib/crypto_compare.ex | 0.899938 | 0.827271 | crypto_compare.ex | starcoder |
defmodule GraphQL.QueryRegistry do
@moduledoc """
Functions to handle query registries.
A query registry stores several `GraphQL.Query` structs, so they
can be combined into a single query before the execution.
"""
alias GraphQL.{Client, Query}
@enforce_keys [:name]
defstruct name: nil, queries: [], v... | lib/graphql/query_registry.ex | 0.917958 | 0.684093 | query_registry.ex | starcoder |
defmodule StathamLogger.DatadogFormatter do
@moduledoc """
Datadog-specific formatting
Adheres to the
[default standard attribute list](https://docs.datadoghq.com/logs/processing/attributes_naming_convention/#default-standard-attribute-list).
Some code is borrowed from Nebo15 [logger_json](https://github.co... | lib/datadog_formatter.ex | 0.749271 | 0.426859 | datadog_formatter.ex | starcoder |
defmodule Xandra.Cluster do
@moduledoc """
A `DBConnection.Pool` pool that implements clustering support.
This module implements a `DBConnection.Pool` pool that implements support for
connecting to multiple nodes and executing queries on such nodes based on a
given "strategy".
## Usage
To use this pool... | lib/xandra/cluster.ex | 0.91462 | 0.645323 | cluster.ex | starcoder |
defmodule Commanded.EventStore.Adapters.Extreme do
@moduledoc """
Adapter to use <NAME>'s [Event Store](https://eventstore.org/), via the
Extreme TCP client, with Commanded.
"""
@behaviour Commanded.EventStore
require Logger
alias Commanded.EventStore.{
EventData,
RecordedEvent,
SnapshotDat... | lib/extreme.ex | 0.787032 | 0.520496 | extreme.ex | starcoder |
require Utils
require Program
defmodule D13 do
@moduledoc """
--- Day 13: Care Package ---
As you ponder the solitude of space and the ever-increasing three-hour roundtrip for messages between you and Earth, you notice that the Space Mail Indicator Light is blinking. To help keep you sane, the Elves have sent yo... | lib/days/13.ex | 0.705582 | 0.723432 | 13.ex | starcoder |
defmodule Relay.ProtobufUtil do
@moduledoc """
Utility functions for working with Protobuf structs, primarily when using the
Google.Protobuf types.
"""
alias Google.Protobuf.{Any, BoolValue, Struct, ListValue, Value}
defp oneof_actual_vals(message_props, struct) do
# Copy/pasta-ed from:
# https://... | lib/relay/protobuf_util.ex | 0.791982 | 0.494995 | protobuf_util.ex | starcoder |
defmodule Plug.Router do
@moduledoc ~S"""
A DSL to define a routing algorithm that works with Plug.
It provides a set of macros to generate routes. For example:
defmodule AppRouter do
use Plug.Router
plug :match
plug :dispatch
get "/hello" do
send_resp(conn, 200... | lib/plug/router.ex | 0.878145 | 0.503174 | router.ex | starcoder |
defmodule Kernel.SpecialForms do
@moduledoc """
In this module we define Elixir special forms. Those are called
special forms because they cannot be overridden by the developer
and sometimes have lexical scope (like `alias`, `import`, etc).
This module also documents Elixir's pseudo variables (`__MODULE__`,
... | lib/elixir/lib/kernel/special_forms.ex | 0.916692 | 0.425725 | special_forms.ex | starcoder |
defprotocol Observable do
@moduledoc """
Defines the subscribe function to subscribe to a calculation. The
observer must follow the `Observer` protocol to be signalled about
new values, errors and the completion of the calculation.
"""
@spec subscribe(Observable.t, Observer.t) :: {any, Disposable.t}
def subscrib... | lib/reaxive/rx_proto.ex | 0.866076 | 0.657748 | rx_proto.ex | starcoder |
defmodule ExWire.DEVp2p do
@moduledoc """
Functions that deal directly with the DEVp2p Wire Protocol.
For more information, please see:
https://github.com/ethereum/wiki/wiki/%C3%90%CE%9EVp2p-Wire-Protocol
"""
alias ExWire.{Config, Packet}
defmodule Session do
@moduledoc """
Module to hold str... | apps/ex_wire/lib/ex_wire/dev_p2p.ex | 0.718792 | 0.488649 | dev_p2p.ex | starcoder |
defmodule NervesTime.RTC.DS3231 do
@moduledoc """
DS3231 RTC implementation for NervesTime
To configure NervesTime to use this module, update the `:nerves_time` application
environment like this:
```elixir
config :nerves_time, rtc: NervesTime.RTC.DS3231
```
If not using `"i2c-1"` or the default I2C b... | lib/nerves_time/rtc/ds3231.ex | 0.812161 | 0.772874 | ds3231.ex | starcoder |
defmodule Processes do
use Koans
@intro "Processes"
koan "You are a process" do
assert Process.alive?(self()) == :true
end
koan "You can ask a process to introduce itself" do
information = Process.info(self())
assert information[:status] == :running
end
koan "Processes are referenced by t... | lib/koans/15_processes.ex | 0.669096 | 0.633906 | 15_processes.ex | starcoder |
defmodule Wallaby.Query.ErrorMessage do
@moduledoc false
alias Wallaby.Query
@doc """
Compose an error message based on the error method and query information
"""
@spec message(Query.t, any()) :: String.t
def message(%Query{} = query, :not_found) do
"Expected to find #{found_error_message(query)}"
... | lib/wallaby/query/error_message.ex | 0.837819 | 0.453201 | error_message.ex | starcoder |
defmodule ExAdmin do
@moduledoc """
ExAdmin is a an auto administration tool for the PhoenixFramework,
providing a quick way to create a CRUD interface for administering
Ecto models with little code and the ability to customize the
interface if desired.
After creating one or more Ecto models, the administr... | lib/ex_admin.ex | 0.929364 | 0.707493 | ex_admin.ex | starcoder |
defmodule PermastateOperator.Controller.V1.Action do
@moduledoc """
PermastateOperator: Action CRD.
## Kubernetes CRD Spec
Eigr Action CRD
### Examples
```
apiVersion: functions.eigr.io/v1
kind: Action
metadata:
name: shopping-cart
spec:
containers:
- image: my-docker-hub-username/shop... | lib/permastate_operator/controllers/v1/action.ex | 0.732209 | 0.66236 | action.ex | starcoder |
defmodule Square.CustomerSegments do
@moduledoc """
Documentation for `Square.Segments`.
"""
@doc """
Retrieves the list of customer segments of a business.
```
def list_customer_segments(client, [cursor: nil])
```
### Parameters
| Parameter | Type | Tags | Description |
| --- | --- | --- | -... | lib/api/customer_segments_api.ex | 0.906528 | 0.78083 | customer_segments_api.ex | starcoder |
defmodule Scidata.CIFAR10 do
@moduledoc """
Module for downloading the [CIFAR10 dataset](https://www.cs.toronto.edu/~kriz/cifar.html).
"""
require Scidata.Utils
alias Scidata.Utils
@base_url "https://www.cs.toronto.edu/~kriz/"
@dataset_file "cifar-10-binary.tar.gz"
@train_images_shape {50000, 3, 32, 3... | lib/scidata/cifar10.ex | 0.848628 | 0.762026 | cifar10.ex | starcoder |
defmodule Day3 do
@moduledoc """
Documentation for `Day3`.
"""
@doc """
Hello world.
## Examples
iex> Day3.test()
The answers are 253 and 1485
"""
def run() do
read_data()
|> solve()
end
def test(n \\ 5) do
{number_of_bits, _number_of_diagnostics, reports} = read_data()
... | apps/day3/lib/day3.ex | 0.812607 | 0.595845 | day3.ex | starcoder |
defmodule Wobserver.Util.Helper do
@moduledoc ~S"""
Helper functions and JSON encoders.
"""
alias Poison.Encoder
alias Encoder.BitString
defimpl Encoder, for: PID do
@doc ~S"""
JSON encodes a `PID`.
Uses `inspect/1` to turn the `pid` into a String and passes the `options` to `BitString.encode... | lib/wobserver/util/helper.ex | 0.842086 | 0.793986 | helper.ex | starcoder |
defmodule Extracker do
@moduledoc """
A fast & scaleable BitTorrent tracker.
"""
@doc """
Set the duration that an announced peer will be kept in the system.
"""
def set_interval(interval) do
Redix.command!(:redix, ["SET", "interval", interval])
:ok
end
@doc """
Announce a peer to the tra... | lib/extracker.ex | 0.674587 | 0.451327 | extracker.ex | starcoder |
defmodule ExJenga.KYC do
@moduledoc """
KYC enabales quering the various registrar of persons in the various countries in East Africa.
Visit https://developer.jengaapi.io/reference#identity-verification to see more details
"""
import ExJenga.JengaBase
alias ExJenga.Signature
@doc """
Makes a request to... | lib/ex_jenga/kyc/kyc.ex | 0.645455 | 0.429489 | kyc.ex | starcoder |
defmodule Ash.Engine do
@moduledoc """
The Ash engine handles the parallelization/running of requests to Ash.
Much of the complexity of this doesn't come into play for simple requests.
The way it works is that it accepts a list of `Ash.Engine.Request` structs.
Some of values on those structs will be instance... | lib/ash/engine/engine.ex | 0.819821 | 0.520253 | engine.ex | starcoder |
defmodule Earmark.Transform do
import Earmark.Helpers, only: [replace: 3]
alias Earmark.Options
@compact_tags ~w[a code em strong del]
# https://www.w3.org/TR/2011/WD-html-markup-20110113/syntax.html#void-element
@void_elements ~W(area base br col command embed hr img input keygen link meta param source t... | lib/earmark/transform.ex | 0.768386 | 0.610163 | transform.ex | starcoder |
defmodule Edeliver.Relup.InsertInstruction do
@moduledoc """
Provides functions to insert relup instructions at a given position
which can be used in `Edeliver.Relup.Instruction` behaviour implementations
in the relup file.
"""
alias Edeliver.Relup.Instructions
@doc """
Inserts instruction(s)... | lib/edeliver/relup/insert_instruction.ex | 0.826747 | 0.468061 | insert_instruction.ex | starcoder |
defmodule KingAlbertEx.Game do
@moduledoc """
This module defines a type representing the total game state at a given point in time, along with functions
relating to that type. A "game state" here includes everything about the current game: card positions, messages
to the the user, etc..
"""
alias KingAlbe... | lib/king_albert_ex/game.ex | 0.787482 | 0.497925 | game.ex | starcoder |
defmodule Tabula do
@moduledoc """
Tabula can transform a list of maps (structs too, e.g. Ecto schemas)
or Keywords into an ASCII/GitHub Markdown table.
"""
import Enum, only: [
concat: 2,
intersperse: 2,
map: 2,
max: 1,
with_index: 1,
zip: 2
]
@index "#"
@newline '\n'
@she... | lib/tabula.ex | 0.641647 | 0.477615 | tabula.ex | starcoder |
defmodule Number.Currency do
@moduledoc """
Provides functions for converting numbers into formatted currency strings.
"""
import Number.Delimit, only: [number_to_delimited: 2]
@doc """
Converts a number to a formatted currency string.
## Parameters
* `number` - A float or integer to convert.
* `... | lib/number/currency.ex | 0.925289 | 0.730506 | currency.ex | starcoder |
defmodule Roger.Job do
@moduledoc """
Base module for implementing Roger jobs.
To start, `use Roger.Job` in your module. The only required callback
to implement is the `perform/1` function.
defmodule TestJob do
use Roger.Job
def perform(_args) do
# perform some work here...
... | lib/roger/job.ex | 0.890818 | 0.45048 | job.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.