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 Appsignal.Utils.DataEncoder do
@moduledoc """
Encodes data
"""
alias Appsignal.Nif
def encode(%{__struct__: _} = data) do
data |> Map.from_struct() |> encode
end
def encode(data) when is_tuple(data) do
data |> Tuple.to_list() |> encode
end
def encode(data) when is_map(data) do
... | lib/appsignal/utils/data_encoder.ex | 0.64791 | 0.443179 | data_encoder.ex | starcoder |
defmodule EWalletConfig.Setting do
@moduledoc """
Schema overlay acting as an interface to the StoredSetting schema.
This is needed because some transformation is applied to the
attributes before saving them to the database. Indeed, value is stored
in a map to allow any type to be saved, but is for simplicit... | apps/ewallet_config/lib/ewallet_config/setting.ex | 0.799912 | 0.431464 | setting.ex | starcoder |
defmodule NeuralNetwork do
defstruct layers: []
alias NeuralNetwork.Layer
def create(configuration) do
layers = create_layers(configuration)
connect_layers(layers)
%NeuralNetwork{layers: layers}
end
def create_layers(configuration) do
Enum.map configuration, fn num ->
Layer.create(nu... | lib/neural_network.ex | 0.892132 | 0.587973 | neural_network.ex | starcoder |
defmodule CodeFlow.Streams do
@moduledoc """
Code that sets up scenarios where you can play and develop a better sense for
how Enum and Stream compare.
"""
def experiment_1_enum(data) do
simple_measurements(fn ->
data
|> Enum.map(&(&1 * 2))
|> Enum.map(&(&1 + 1))
|> Enum.map(&(&1 ... | code_flow/lib/streams.ex | 0.658418 | 0.45423 | streams.ex | starcoder |
defmodule Arfficionado.Handler do
@moduledoc """
Handler behaviour.
`Arfficionado.read/4` will:
1. call `init(arg)` to obtain the initial handler state (`arg` defaults to `nil`)
2. parse the ARFF header and
- call `relation` with the relation name and optional comment
- call `attributes` with the... | lib/handler.ex | 0.879354 | 0.663785 | handler.ex | starcoder |
defmodule Membrane.RTSP.Response do
@moduledoc """
This module represents a RTSP response.
"""
alias Membrane.Protocol.SDP
@start_line_regex ~r/^RTSP\/(\d\.\d) (\d\d\d) [A-Z a-z]+$/
@line_ending ["\r\n", "\r", "\n"]
@enforce_keys [:status, :version]
defstruct @enforce_keys ++ [headers: [], body: ""]
... | lib/membrane_rtsp/response.ex | 0.884788 | 0.665818 | response.ex | starcoder |
defmodule PiviEx do
@moduledoc """
Documentation for `PiviEx`.
Creates a pivot table from a list.
The strcut holds its original data in the data attribute.
data
|> pivot(fn r -> {r.company_id, r.account_id} end,
fn r -> {Period.period(r.date)} end,
fn r -> Decimal.sub(r.deb... | lib/pivi_ex.ex | 0.809916 | 0.560072 | pivi_ex.ex | starcoder |
defmodule Comeonin.Otp do
@moduledoc """
Generate and verify HOTP and TOTP one-time passwords.
Module to generate and check HMAC-based one-time passwords and
time-based one-time passwords, in accordance with
[RFC 4226](https://tools.ietf.org/html/rfc4226) and
[RFC 6238](https://tools.ietf.org/html/rfc6238)... | deps/comeonin/lib/comeonin/otp.ex | 0.750187 | 0.826502 | otp.ex | starcoder |
defmodule Scientist do
@moduledoc ~S"""
A library for carefully refactoring critical paths in your elixir application.
"""
defmacro __using__(opts) do
mod = Keyword.get(opts, :experiment, Scientist.Default)
quote do
import unquote(__MODULE__)
Module.put_attribute(__MODULE__, :scientist_exp... | lib/scientist.ex | 0.658637 | 0.679611 | scientist.ex | starcoder |
defmodule Strava.Segment do
@moduledoc """
Segments are specific sections of road. Athletes’ times are compared on these segments and leaderboards are created.
https://strava.github.io/api/v3/segments/
"""
import Strava.Util, only: [parse_date: 1]
@type t :: %__MODULE__{
id: number,
resource_state... | lib/strava/segment.ex | 0.933188 | 0.624623 | segment.ex | starcoder |
defmodule Sanbase.Validation do
import Sanbase.DateTimeUtils, only: [str_to_sec: 1]
defguard is_valid_price(price) when is_number(price) and price >= 0
defguard is_valid_percent(percent) when is_number(percent) and percent >= -100
defguard is_valid_percent_change(percent) when is_number(percent) and percent > 0... | lib/sanbase/utils/validation.ex | 0.791055 | 0.561636 | validation.ex | starcoder |
defmodule RemoteIp do
@moduledoc """
A plug to overwrite the `Plug.Conn`'s `remote_ip` based on request headers.
To use, add the `RemoteIp` plug to your app's plug pipeline:
```elixir
defmodule MyApp do
use Plug.Builder
plug RemoteIp
end
```
Keep in mind the order of plugs in your pipeline a... | lib/remote_ip.ex | 0.898961 | 0.822902 | remote_ip.ex | starcoder |
defmodule Day2 do
def solve do
input = prepare_input()
start = System.monotonic_time(unquote(:milli_seconds))
IO.puts("Solving part one:")
Day2.Part1.solve(input)
|> IO.puts()
time_part_one = System.monotonic_time(unquote(:milli_seconds)) - start
IO.puts("Part one took #{time_part_one} ... | elixir/day2/lib/day2.ex | 0.570092 | 0.581927 | day2.ex | starcoder |
defmodule ApiAccounts.Keys do
@moduledoc """
Validates and caches API keys.
When validating a key, the API key is looked up in the cache. If a key isn't
present in the cache, the key will be validated against the V2 API and V3 set
of API keys and stored in the cache if it's a valid key.
"""
use GenServer... | apps/api_accounts/lib/api_accounts/keys.ex | 0.71123 | 0.407304 | keys.ex | starcoder |
defmodule Bingo.BingoChecker do
@doc """
Checks for a bingo!
Given a 2D list of `squares`, returns `true` if all the squares of
any row, column, or diagonal have been marked by the same player.
Otherwise `false` is returned.
"""
def bingo?(squares) do
possible_winning_square_sequences(squares)
... | apps/bingo/lib/bingo/bingo_checker.ex | 0.937089 | 0.726304 | bingo_checker.ex | starcoder |
defmodule Harnais.Form.Schatten.Workflow.Filter do
@moduledoc false
require Plymio.Fontais.Option
alias Harnais.Utility, as: HUU
alias Harnais.Form.Schatten.Workflow.Utility, as: HASWU
use Harnais.Form.Attribute.Schatten
import Harnais.Error,
only: [
new_error_result: 1
],
warn: false
... | lib/schatten/workflow/filter.ex | 0.696268 | 0.431165 | filter.ex | starcoder |
defmodule SurfaceBulma.TabUtils do
@moduledoc false
# TODO make this dependent on the version of LiveView used. It would be preferable to use JS commands instead of a LiveComponent.
defmacro __using__(opts \\ []) do
moduledoc =
Keyword.get(opts, :doc, "") <>
"""
Tab selection is handle... | lib/surface_bulma/tab_utils.ex | 0.537284 | 0.677431 | tab_utils.ex | starcoder |
defmodule AWS.IoTAnalytics do
@moduledoc """
AWS IoT Analytics allows you to collect large amounts of device data,
process messages, and store them. You can then query the data and run
sophisticated analytics on it. AWS IoT Analytics enables advanced data
exploration through integration with Jupyter Notebook... | lib/aws/iot_analytics.ex | 0.83612 | 0.706646 | iot_analytics.ex | starcoder |
defmodule Fxnk.List do
@moduledoc """
`Fxnk.List` are functions for working with lists.
"""
@doc """
Returns a list of whatever was passed to it.
## Example
iex> Fxnk.List.of(3)
[3]
iex> Fxnk.List.of([])
[[]]
"""
@spec of(any()) :: [any(), ...]
def of(x), do: [x]
@doc """
... | lib/fxnk/list.ex | 0.857723 | 0.565599 | list.ex | starcoder |
defmodule Ryal.Payments.Method do
@moduledoc """
A standard adapter to multiple payment methods.
You can specify which payment you'd like to use via the `type` field and
placing the data of a payment in the `data` field.
The `data` field uses PostgreSQL's JSONB column to store the dynamic
information. We ... | lib/ryal/payments/method.ex | 0.855384 | 0.598664 | method.ex | starcoder |
defmodule Spell.Role.Session do
@moduledoc """
The `Spell.Role.Session` module implements the behaviour for a session
role.
Sessions are pseudo-roles; each peer started with `Spell.Connect`
has `Spell.Role.Session` added as the first role in `roles`.
"""
use Spell.Role
import Spell.Message, only: [re... | lib/spell/role/session.ex | 0.604866 | 0.412234 | session.ex | starcoder |
defmodule Aja.String do
@moduledoc ~S"""
Some extra helper functions for working with strings,
that are not in the core `String` module.
"""
@type mode :: :default | :ascii | :greek
@modes [:default, :ascii, :greek]
@doc ~S"""
Transforms the text as a slug. Removes whitespace, special characters and
... | lib/string.ex | 0.727685 | 0.503601 | string.ex | starcoder |
defmodule PhoneToString do
@mapping %{
"1" => ["1"],
"2" => ["A", "B", "C"],
"3" => ["D", "E", "F"],
"4" => ["G", "H", "I"],
"5" => ["J", "K", "L"],
"6" => ["M", "N", "O"],
"7" => ["P", "Q", "R", "S"],
"8" => ["T", "U", "V"],
"9" => ["W", "X", "Y", "Z"],
"0" => ["0"]
}
@do... | lib/phoneToString.ex | 0.708616 | 0.462898 | phoneToString.ex | starcoder |
defmodule TrademarkFreeStrategicLandWarfare.Players.JeffsBeard do
alias TrademarkFreeStrategicLandWarfare.{Board, Player, Piece}
@behaviour Player
@type direction() :: :north | :west | :east | :south
@type count() :: Integer.t()
@type state() :: any()
@spec name() :: binary()
def name(), do: "<NAME> 🧔"... | lib/trademark_free_strategic_land_warfare/players/jeffs_beard.ex | 0.661376 | 0.48688 | jeffs_beard.ex | starcoder |
defmodule RDF.Resource.Generator do
@moduledoc """
A configurable and customizable way to generate resource identifiers.
The basis are different implementations of the behaviour defined in this
module for configurable resource identifier generation methods.
Generally two kinds of identifiers are differentia... | lib/rdf/resource_generator.ex | 0.890306 | 0.628436 | resource_generator.ex | starcoder |
defmodule MaterializedStore do
@moduledoc """
Materialized Store implements the consumer-side of a Kafka-backed KV store.
Messages are written to Kafka as (key,val) tuples and read by the store. Each
message passed through the provided parser, and the resulting, deserialized,
representation is then stored fo... | lib/materialized_store.ex | 0.840488 | 0.563948 | materialized_store.ex | starcoder |
defmodule Cards do
@moduledoc """
Provides methods for creating and handling a deck of cards
"""
#run shell with iex -S mix
# run file with Cards.fx name
def help do
"hello, there! This module provides functions for creating deck, shuffling, checking if card is in deck, "
end
@doc """
Return... | cards/lib/cards.ex | 0.645455 | 0.575916 | cards.ex | starcoder |
defmodule Changex.Grouper do
@moduledoc """
This module will take a list of commits and sort them based on the
type of the commit.
"""
@doc """
Take a list of `commits` in the format:
[hash, subject | body]
And transform them into a map based on the type of the commits. the
map could look like:... | lib/changex/grouper.ex | 0.651577 | 0.537041 | grouper.ex | starcoder |
defmodule OAuth2Utils do
@moduledoc """
Util functions for OAuth2 and connected (OpenID Connect, UMA2) standards
Standard sets are the following:
* `:oauth2`: refers to RFC6749 and all other RFCs published by the IETF
* `:oidc`: refers to OpenID Connect ([https://openid.net/developers/specs/](speifications))... | lib/oauth2_utils.ex | 0.630344 | 0.652394 | oauth2_utils.ex | starcoder |
defmodule CanvasAPI.CommentService do
@moduledoc """
A service for viewing and manipulating comments.
"""
alias CanvasAPI.{Account, Canvas, CanvasService, Comment,
SlackNotifier, Team, User, UserService}
alias Ecto.Changeset
use CanvasAPI.Web, :service
@preload [:creator, canvas: [:te... | lib/canvas_api/services/comment_service.ex | 0.740362 | 0.414603 | comment_service.ex | starcoder |
defmodule Presto.Table.Manager do
@moduledoc """
It's more performant to write a data file directly to object storage
than to write through PrestoDB, but writing some formats directly to
object storage results in poor read performance. JSON, for example.
In these cases, we write data files directly to object... | apps/definition_presto/lib/presto/table/manager.ex | 0.753557 | 0.421433 | manager.ex | starcoder |
defprotocol Casus.Domain.Root do
@moduledoc """
The Casus.Domain.Root protocol.
Implemented by an adapter to standardise all Root Domain Modules behaviour.
The protocol is implemented on a struct representing the aggregate root identity.
This is the struct that will be used to guaranty the uniqueness of the ... | lib/casus/domain/root.ex | 0.869438 | 0.645672 | root.ex | starcoder |
defmodule Bepaid.Gateway do
@moduledoc """
Utility module for the [bePaid API](https://docs.bepaid.by/ru/introduction)
Provides API wrapper functions for remote API.
## Examples:
iex> {"uid" => uid} = Gateway.put_authorization(%Payment{amount: 10})
%{...}
iex> Gateway.void_authorization(uid... | lib/bepaid/gateway.ex | 0.841793 | 0.492676 | gateway.ex | starcoder |
defmodule LexibombServer.Rack do
@moduledoc """
Provides functions related to dealing with a rack of tiles.
A rack is a list of (usually 7) tiles, like `["E", "E", "L", "R", "T", "T", "S"]`.
"""
defstruct tiles: []
alias LexibombServer.WordList
@type t :: %{tiles: [String.t]}
@blank "_"
@alpha ~w... | apps/lexibomb_server/lib/lexibomb_server/rack.ex | 0.891163 | 0.589185 | rack.ex | starcoder |
defmodule Raygun do
@moduledoc """
Send errors to Raygun. Errors can be captured in three different ways.
1. Any errors that are logged
2. Any exceptions that occur in a Plug
3. Programmatically
All the functions will return `:ok` or `{:error, reason}`
"""
@api_endpoint "https://api.raygun.io/entries... | lib/raygun.ex | 0.845942 | 0.468487 | raygun.ex | starcoder |
defmodule Vector do
@moduledoc ~S"""
A library of two- and three-dimensional vector operations. All vectors
are represented as tuples with either two or three elements.
## Examples
iex> # Vector Tripple Product Identity
...> a = {2, 3, 1}
...> b = {1, 4, -2}
...> c = {-1, 2, 1}
.... | lib/vector.ex | 0.947137 | 0.880951 | vector.ex | starcoder |
defmodule UnicodeEmojiFlag do
@moduledoc """
Convert country codes to emoji flags 🔡 ➡️ 🇹🇼.
For the list of available country codes please refer to https://en.wikipedia.org/wiki/Regional_indicator_symbol#Emoji_flag_sequences
"""
@codes %{
"a" => 0x1F1E6,
"b" => 0x1F1E7,
"c" => 0x1F1E8,
"d" ... | lib/unicode_emoji_flag.ex | 0.713831 | 0.405272 | unicode_emoji_flag.ex | starcoder |
defmodule Adventofcode.Circle do
@moduledoc """
Circle is a circular data structure.
It's implemented using a map where every value is a three-element tuple
containing the id of the previous item, the value of the current item and then
the id of the next item.
There are also meta-keys like size, current a... | lib/circle.ex | 0.694613 | 0.77949 | circle.ex | starcoder |
defmodule ElixirLeaderboard.TermStore do
@moduledoc """
Use this storage engine to make small size one-off leaderboards that are
stored entirely in a variable. Useful for leaderboards scoped to small groups
of participants.
"""
@behaviour ElixirLeaderboard.Storage
alias ElixirLeaderboard.{Indexer, Entry... | lib/elixir_leaderboard/term_store.ex | 0.605799 | 0.45647 | term_store.ex | starcoder |
defmodule Grizzly.ZWave.Commands.DoorLockCapabilitiesReport do
@moduledoc """
This command is used to advertise the Door Lock capabilities supported by the sending node.
Params:
* `:supported_operations` - the supported door lock operation types
* `:supported_door_lock_modes` - the supported door lock ... | lib/grizzly/zwave/commands/door_lock_capabilities_report.ex | 0.879069 | 0.458894 | door_lock_capabilities_report.ex | starcoder |
defmodule Membrane.RTP.VP9.PayloadDescriptor do
@moduledoc """
Defines a structure representing VP9 payload descriptor
Described here: https://tools.ietf.org/html/draft-ietf-payload-vp9-10#section-4.2
Flexible mode:
```
0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|I|P|L|F|B|E|V|Z| (REQUIRED)
... | lib/rtp_vp9/payload_descriptor.ex | 0.641871 | 0.641338 | payload_descriptor.ex | starcoder |
defmodule SmartCity.Helpers do
@moduledoc """
Functions used across SmartCity modules.
"""
@type file_type :: String.t()
@type mime_type :: String.t()
@doc """
Convert a map with string keys to one with atom keys. Will convert keys nested in a sub-map or a
map that is part of a list. Ignores atom keys... | lib/smart_city/helpers.ex | 0.858199 | 0.501892 | helpers.ex | starcoder |
defmodule Crux.Structs.Channel do
@moduledoc """
Represents a Discord [Channel Object](https://discord.com/developers/docs/resources/channel#channel-object).
List of where every property can be present:
| Property | Text (0) | DM (1) | Voice (2) | Group (3) | Category (4) | News (5) |
... | lib/structs/channel.ex | 0.875348 | 0.789822 | channel.ex | starcoder |
defmodule AWS.IoT do
@moduledoc """
AWS IoT
AWS IoT provides secure, bi-directional communication between
Internet-connected devices (such as sensors, actuators, embedded devices,
or smart appliances) and the AWS cloud. You can discover your custom
IoT-Data endpoint to communicate with, configure rules fo... | lib/aws/generated/iot.ex | 0.796213 | 0.531635 | iot.ex | starcoder |
defmodule BertInt do
@moduledoc """
Binary Erlang Term encoding for internal node-to-node encoding.
"""
@spec encode!(any()) :: binary()
def encode!(term) do
term
|> :erlang.term_to_binary()
|> :zlib.zip()
end
@spec decode!(binary()) :: any()
def decode!(term) do
try do
:zlib.unzi... | lib/bert.ex | 0.744656 | 0.440168 | bert.ex | starcoder |
defmodule SecureStorage.Schema.EncryptedMessage do
@moduledoc """
Schema for an encrypted message
# States
- New: EncryptedMessage created but has no significance
- Pending: EncryptedMessage waiting for encryption (Used for incoming)
- Encryption Failed: Failed to encrypted message
- Encrypted: M... | apps/secure_storage/lib/secure_storage/schema/encrypted_message.ex | 0.850949 | 0.4016 | encrypted_message.ex | starcoder |
defmodule QRCode.Svg do
@moduledoc """
SVG structure and helper functions.
"""
alias MatrixReloaded.Matrix
alias QRCode.{QR, SvgSettings}
@type t :: %__MODULE__{
xmlns: String.t(),
xlink: String.t(),
width: ExMaybe.t(integer),
height: ExMaybe.t(integer),
b... | lib/qr_code/svg.ex | 0.858303 | 0.848408 | svg.ex | starcoder |
defmodule CcValidation do
@moduledoc """
CcValidation implements methods to verify validity of a credit card number
"""
@doc """
Validate a credit card number using Luhn Algorithm
## Examples
Valid credit card
iex> CcValidation.validate("4716892095589823")
{:ok, true}
Invalid credit card
iex> ... | lib/cc_validation.ex | 0.799247 | 0.509703 | cc_validation.ex | starcoder |
defmodule Trans.Translator do
@moduledoc """
Provides easy access to struct translations.
Although translations are stored in regular fields of an struct and can be accessed directly, **it
is recommended to access translations using the functions provided by this module** instead. This
functions present addi... | lib/trans/translator.ex | 0.902229 | 0.457743 | translator.ex | starcoder |
defmodule Plug.Adapters.Wait1 do
@moduledoc """
Adapter interface for the Wait1 websocket subprotocol.
## Options
* `:ip` - the ip to bind the server to.
Must be a tuple in the format `{x, y, z, w}`.
* `:port` - the port to run the server.
Defaults to 4000 (http) and 4040 (https).
* `:acceptors`... | deps/plug_wait1/lib/plug/adapters/wait1.ex | 0.811078 | 0.58347 | wait1.ex | starcoder |
defmodule StarkInfra.CreditNote do
alias __MODULE__, as: CreditNote
alias StarkInfra.Error
alias StarkInfra.Utils.API
alias StarkInfra.Utils.Rest
alias StarkInfra.Utils.Check
alias StarkInfra.User.Project
alias StarkInfra.User.Organization
alias StarkInfra.CreditNote.Signer
alias StarkInfra.CreditNote... | lib/credit_note/credit_note.ex | 0.872646 | 0.712382 | credit_note.ex | starcoder |
defmodule Meeseeks.Selector.CSS.Parser do
@moduledoc false
alias Meeseeks.{Error, Selector}
alias Meeseeks.Selector.{Combinator, Element}
alias Meeseeks.Selector.Element.{Attribute, Namespace, PseudoClass, Tag}
# Parse Elements
def parse_elements(toks) do
parse_elements(toks, [])
end
defp parse_... | lib/meeseeks/selector/css/parser.ex | 0.72086 | 0.551876 | parser.ex | starcoder |
defmodule Magritte do
@moduledoc """
Alternative pipe operator definition.
## Usage
Just add `use Magritte` to the top of your module and then
follow the documentation for `Margitte.|>/2` below.
"""
defmacro __using__(_) do
quote do
import Kernel, except: [|>: 2]
import unquote(__MODUL... | lib/magritte.ex | 0.897529 | 0.945601 | magritte.ex | starcoder |
defmodule CredoContrib.CheckUtils do
@moduledoc """
Test utils cribbed from the main credo repo:
https://git.io/vNxf5
"""
alias Credo.Execution.{ExecutionIssues, ExecutionSourceFiles}
alias Credo.SourceFile
alias ExUnit.Assertions
def assert_issue(source_file, callback) when is_function(callback) do
... | test/support/check_utils.ex | 0.631481 | 0.444685 | check_utils.ex | starcoder |
defmodule Solana.Transaction do
@moduledoc """
Functions for building and encoding Solana
[transactions](https://docs.solana.com/developing/programming-model/transactions)
"""
require Logger
alias Solana.{Account, CompactArray, Instruction}
@typedoc """
All the details needed to encode a transaction.
... | lib/solana/tx.ex | 0.861858 | 0.427397 | tx.ex | starcoder |
defmodule Harald.HCI.ArrayedData do
@moduledoc """
Serialization functions for arrayed data.
> Arrayed parameters are specified using the following notation: ParameterA[i]. If more than one
> set of arrayed parameters are specified (e.g. ParameterA[i], ParameterB[i]), then, unless
> noted otherwise, the orde... | lib/harald/hci/arrayed_data.ex | 0.91054 | 0.946892 | arrayed_data.ex | starcoder |
defmodule DataDaemon.Extensions.DataDog do
@moduledoc false
import DataDaemon.Util, only: [config: 5, iso8601: 1]
@event_fields ~w(
timestamp
hostname
aggregation_key
priority
source_type_name
alert_type
)a
@doc false
@spec build_event(String.t(), Keyword.t()) :: iodata
def build... | lib/data_daemon/extensions/data_dog.ex | 0.867654 | 0.582729 | data_dog.ex | starcoder |
defmodule P1 do
@moduledoc """
## Examples
iex> P1.solve(3, 100, 3, [1, 2, 1], [2, 3, 3], [10, 90, 10], [10, 10, 50])
20
iex> P1.solve(3, 100, 3, [1, 2, 1], [2, 3, 3], [1, 100, 10], [10, 10, 50])
50
iex> P1.solve(10, 10, 19,
...> [1, 1, 2, 4, 5, 1, 3, 4, 6, 4, 6, 4, 5, 7, 8, 2, 3, 4, ... | lib/100/p1.ex | 0.64646 | 0.541954 | p1.ex | starcoder |
defmodule Chess.Move.Parse do
@moduledoc """
Module for parsing moves
"""
alias Chess.Game
defmacro __using__(_opts) do
quote do
defp do_parse_move(%Game{status: "check", check: check}, move, active)
when check != active and (move == "0-0" or move == "0-0-0"),
do: {:error, "Your ki... | lib/chess/move/parse.ex | 0.701202 | 0.409516 | parse.ex | starcoder |
defmodule GatherSubmissions.DOMjudge.Connection do
@moduledoc """
Defines a struct containing connection information to a server, and provides basic functions for
issuing authorized GET requests.
This information consists in the URL of the DOMjudge server (`endpoint`), and
login data (`username` and `passwor... | lib/domjudge/connection.ex | 0.741674 | 0.57341 | connection.ex | starcoder |
defmodule DSMR do
@moduledoc """
A library for parsing Dutch Smart Meter Requirements (DSMR) telegram data.
"""
alias DSMR.Telegram
defmodule ParseError do
@type t() :: %__MODULE__{}
defexception [:message]
end
@doc """
Parses telegram data from a string and returns a struct.
If the teleg... | lib/dsmr.ex | 0.812459 | 0.494263 | dsmr.ex | starcoder |
defmodule ExUnit.ClusteredCase.Cluster.Partition do
@moduledoc false
alias ExUnit.ClusteredCase.Cluster.PartitionChange
@type opts ::
pos_integer
| [pos_integer]
| [[node]]
@type t :: [[node]]
@doc """
Given a list of nodes and partitioning options, generates a partition sp... | lib/cluster/partition.ex | 0.778018 | 0.507873 | partition.ex | starcoder |
defmodule TextBasedFPS.RoomPlayer do
alias TextBasedFPS.{Direction, Player, RoomPlayer}
@max_health 100
@max_loaded_ammo 8
@max_unloaded_ammo 24
@type t :: %TextBasedFPS.RoomPlayer{
player_key: Player.key_t(),
coordinates: TextBasedFPS.GameMap.Coordinates.t() | nil,
direction: ... | lib/text_based_fps/room_player.ex | 0.704262 | 0.408572 | room_player.ex | starcoder |
defmodule Piton.Port do
@moduledoc """
`Piton.Port` is a `GenServer` which will be on charge of the Python Port.
It is prepared to be the base of your own Port.
## Make your own Port
```elixir
defmodule MyPort do
use Piton.PythonPort
# rest of the code if it is need.
end
```
The arguments ha... | lib/piton/port.ex | 0.768125 | 0.795102 | port.ex | starcoder |
defmodule Stripe.Accounts do
@moduledoc """
Functions for working with accounts at Stripe. Through this API you can:
* create an account,
* get an account,
* delete an account,
* delete all accounts,
* list accounts,
* list all accounts,
* count accounts.
Stripe API reference: https:... | lib/stripe/accounts.ex | 0.889697 | 0.442335 | accounts.ex | starcoder |
defmodule Solana.SPL.TokenSwap do
@moduledoc """
Functions for interacting with Solana's [Token Swap
Program](https://spl.solana.com/token-swap).
"""
alias Solana.{Instruction, Account, SystemProgram}
import Solana.Helpers
@curves [:product, :price, :stable, :offset]
@doc """
The Token Swap Program'... | lib/solana/spl/token_swap.ex | 0.892729 | 0.460895 | token_swap.ex | starcoder |
defmodule Spandex do
@moduledoc """
Provides the entry point for the application, in addition to a standardized
interface. The functions here call the corresponding functions on the
configured adapter.
"""
require Logger
import Spandex.Adapters.Helpers
defmacro span(name, do: body) do
quote do
... | lib/spandex.ex | 0.581422 | 0.452354 | spandex.ex | starcoder |
defmodule Comb.Naive do
@moduledoc false
# This module implements naive implementations of each function in `Comb`. They
# serve as reference implementations for testing and benchmarking. These
# methods may return an `Enum` instead of a `Stream`.
def cartesian_product(a, b), do: (for x <-a, y <-b, do: [x, ... | lib/comb/naive.ex | 0.742795 | 0.661955 | naive.ex | starcoder |
defmodule MPEGAudioFrameParser do
@moduledoc """
This is the public API for MPEGAudioFrameParser application.
MPEGAudioFrameParser is implemented as a GenServer that, when fed consecutive
packets of binary data (for example, from a file or network source), will
parse individual MPEG audio frames from the inc... | lib/mpeg_audio_frame_parser.ex | 0.926984 | 0.457743 | mpeg_audio_frame_parser.ex | starcoder |
defmodule Day04 do
@moduledoc """
Advent of Code 2019
Day 4: Secure Container
"""
alias Day04.{Part1, Part2}
def get_range() do
Path.join(__DIR__, "inputs/day04.txt")
|> File.read!()
|> String.trim()
|> String.split("-")
|> Enum.map(&String.to_integer/1)
end
def execute() do
[... | lib/day04.ex | 0.793386 | 0.60996 | day04.ex | starcoder |
defmodule ExVCR.Adapter.Hackney.Converter do
@moduledoc """
Provides helpers to mock :hackney methods.
"""
use ExVCR.Converter
defp string_to_response(string) do
response = Enum.map(string, fn {x, y} -> {String.to_atom(x), y} end)
response = struct(ExVCR.Response, response)
response =
if ... | lib/exvcr/adapter/hackney/converter.ex | 0.68763 | 0.452354 | converter.ex | starcoder |
defmodule StepFlow.Step do
@moduledoc """
The Step context.
"""
require Logger
alias StepFlow.Artifacts
alias StepFlow.Jobs
alias StepFlow.Repo
alias StepFlow.Step.Helpers
alias StepFlow.Step.Launch
alias StepFlow.Workflows
alias StepFlow.Workflows.Workflow
def start_next(%Workflow{id: workfl... | lib/step_flow/step/step.ex | 0.621081 | 0.598752 | step.ex | starcoder |
defmodule XlsxStream.StyleSheet do
alias XmlStream, as: X
alias XlsxStream.Schema
def document(styles) do
[
X.declaration(),
X.element("styleSheet", %{xmlns: Schema.spreedsheetml()}, styles)
]
end
def num_fmts(entries \\ [], attrs \\ %{}) do
counted("numFmts", entries, attrs)
end
... | lib/xlsx_stream/style_sheet.ex | 0.545528 | 0.504211 | style_sheet.ex | starcoder |
defmodule Contex.Dataset do
@moduledoc """
`Dataset` is a simple wrapper around a datasource for plotting charts.
Dataset marshalls a couple of different data structures into a consistent form for consumption
by the chart plotting functions. For example, it allows a list of lists or a list of tuples to be
treated the ... | lib/chart/dataset.ex | 0.8505 | 0.91452 | dataset.ex | starcoder |
defmodule LineBot.Message.Template do
use LineBot.Message
@moduledoc """
Represents a [Template message](https://developers.line.biz/en/reference/messaging-api/#template-messages).
"""
@type t :: %__MODULE__{
altText: String.t(),
template:
LineBot.Message.Template.Buttons.t()
... | lib/line_bot/message/template.ex | 0.83772 | 0.439507 | template.ex | starcoder |
defmodule Leaflet.MapData do
@moduledoc """
Represents leaflet map data.
"""
alias GoogleMaps.MapData, as: GoogleMapData
alias GoogleMaps.MapData.Marker, as: GoogleMapsMarker
alias GoogleMaps.MapData.Path, as: GoogleMapsPath
alias Leaflet.MapData.{
Marker,
Polyline
}
@type lat_lng :: %{latit... | apps/site/lib/leaflet/map_data.ex | 0.852782 | 0.553143 | map_data.ex | starcoder |
defmodule Month.Range do
@moduledoc """
Represents a range of months.
iex> range = Month.Range.new(~M[2019-01], ~M[2019-03])
{:ok, #Month.Range<~M[2019-01], ~M[2019-03]>}
iex> range.months
[~M[2019-01], ~M[2019-02], ~M[2019-03]]
The `months` field contains all months within the range, in... | lib/month/range.ex | 0.855987 | 0.539287 | range.ex | starcoder |
defmodule AWS.ComputeOptimizer do
@moduledoc """
Compute Optimizer is a service that analyzes the configuration and utilization
metrics of your Amazon Web Services compute resources, such as Amazon EC2
instances, Amazon EC2 Auto Scaling groups, Lambda functions, and Amazon EBS
volumes.
It reports whether ... | lib/aws/generated/compute_optimizer.ex | 0.940237 | 0.552238 | compute_optimizer.ex | starcoder |
defmodule Xgit.ConfigEntry do
@moduledoc ~S"""
Represents one entry in a git configuration dictionary.
This is also commonly referred to as a "config _line_" because it typically
occupies one line in a typical git configuration file.
The semantically-important portion of a configuration file (i.e. everythin... | lib/xgit/config_entry.ex | 0.862829 | 0.452354 | config_entry.ex | starcoder |
defmodule Collidex.Detection.Polygons do
@moduledoc """
Detects collisions between polygons using the separating
axis theorem. Has two variants, :fast and :accurate. :fast
will miss a few rare tyes of collisions but is much faster.
"""
alias Graphmath.Vec2
alias Collidex.Geometry.Polygon
alias Collid... | lib/collidex/detection/polygons.ex | 0.89411 | 0.772058 | polygons.ex | starcoder |
defmodule XmerlAccess do
@moduledoc """
Use Elixir meta-programming to generate test and accessor functions.
For each Xmerl record type generate the following:
- A test function, e.g. `is_element/1`, `is_attribute/1`, etc.
- A set of assessor functions, one for each field, e.g. `get_element_name/1`,
`... | lib/xmlmetaprogramming.ex | 0.733261 | 0.457016 | xmlmetaprogramming.ex | starcoder |
defmodule Distance do
@moduledoc ~S"""
Basic distance calculations for cartesian coordinates for calculting
distances on a single plane. If you are looking to calculating distance
on the surface of Earth, check out the `Distance.GreatCircle` module.
## Examples
iex> Distance.distance({2.5, 2.5}, {4, 0... | lib/distance.ex | 0.962267 | 0.887984 | distance.ex | starcoder |
defmodule ExAequo.KeywordParams do
use ExAequo.Types
@moduledoc """
## Tools to facilitate dispatching on keyword parameters, used in contexts like the following
@defaults [a: 1, b: false] # Keyword or Map
def some_fun(..., options \\ []) # options again can be a Keyword or Map
{a, b}... | lib/ex_aequo/keyword_params.ex | 0.798501 | 0.911849 | keyword_params.ex | starcoder |
defmodule Hanoi do
@moduledoc """
The Tower of Hanoi data structure and operations
"""
defstruct started: false,
ended: false,
duration: 0,
picked: nil,
num_pieces: 4,
num_moves: 0,
tower_a: [],
tower_b: [],
tower_c... | lib/techblog/lib/hanoi.ex | 0.765418 | 0.721136 | hanoi.ex | starcoder |
defmodule Day10 do
def part_one(file_reader \\ InputFile) do
deltas =
jolts(file_reader)
|> Enum.sort()
|> List.insert_at(0, 0)
|> Enum.chunk_every(2, 1, :discard)
|> Enum.map(fn [a, b] -> b - a end)
# Add an extra delta of 3 bc our device has 3 jolts more than the last adapter
... | year_2020/lib/day_10.ex | 0.644561 | 0.507446 | day_10.ex | starcoder |
defmodule AWS.CloudWatch do
@moduledoc """
Amazon CloudWatch monitors your Amazon Web Services (Amazon Web Services)
resources and the applications you run on Amazon Web Services in real time.
You can use CloudWatch to collect and track metrics, which are the variables you
want to measure for your resources... | lib/aws/generated/cloud_watch.ex | 0.889475 | 0.576184 | cloud_watch.ex | starcoder |
defmodule HelloOperator.Controller.V1.Greeting do
@moduledoc """
HelloOperator: Greeting CRD.
## Kubernetes CRD Spec
By default all CRD specs are assumed from the module name, you can override them using attributes.
### Examples
```
# Kubernetes API version of this CRD, defaults to value in module name... | lib/hello_operator/controllers/v1/greeting.ex | 0.853913 | 0.792745 | greeting.ex | starcoder |
defmodule Pow.Store.Backend.MnesiaCache do
@moduledoc """
GenServer based key value Mnesia cache store with auto expiration.
When the MnesiaCache starts, it'll initialize invalidators for all stored
keys using the `expire` value. If the `expire` datetime is past, it'll
send call the invalidator immediately.
... | lib/pow/store/backend/mnesia_cache.ex | 0.8796 | 0.434941 | mnesia_cache.ex | starcoder |
defmodule Timex.Ecto.DateTimeWithTimezone do
@moduledoc """
This is a special type for storing datetime + timezone information as a composite type.
To use this, you must first make sure you have the `datetimetz` type defined in your database:
```sql
CREATE TYPE datetimetz AS (
dt timestamptz,
tz... | lib/types/datetimetz.ex | 0.844024 | 0.785144 | datetimetz.ex | starcoder |
defmodule AMQP.Connection do
@moduledoc """
Functions to operate on Connections.
"""
import AMQP.Core
alias AMQP.Connection
defstruct [:pid]
@type t :: %Connection{pid: pid}
@doc """
Opens an new Connection to an AMQP broker.
The connections created by this module are supervised under amqp_cli... | lib/amqp/connection.ex | 0.88677 | 0.815122 | connection.ex | starcoder |
defmodule Codepagex do
# unfortunately exdoc doesnt support ``` fenced blocks
@moduledoc File.read!("README.md")
|> String.split("\n")
|> Enum.reject(&String.match?(&1, ~r/#.Codepagex/))
|> Enum.reject(&String.match?(&1, ~r/```|Build Status|Documentation Status/))
... | lib/codepagex.ex | 0.763396 | 0.448366 | codepagex.ex | starcoder |
defmodule Raxx.Request do
@moduledoc """
HTTP requests to a Raxx application are encapsulated in a `Raxx.Request` struct.
A request has all the properties of the url it was sent to.
In addition it has optional content, in the body.
As well as a variable number of headers that contain meta data.
Where appr... | lib/raxx/request.ex | 0.893988 | 0.590543 | request.ex | starcoder |
defmodule Bunch.KVList do
@deprecated "Use `Bunch.KVEnum` instead"
@moduledoc """
A bunch of helper functions for manipulating key-value lists (including keyword
lists).
Key-value lists are represented as lists of 2-element tuples, where the first
element of each tuple is a key, and the second is a value.
... | lib/bunch/kv_list.ex | 0.912514 | 0.674771 | kv_list.ex | starcoder |
defmodule Multihash do
@moduledoc """
Multihash library that follows jbenet multihash protocol so that the hash contains information
about the hashing algorithm used making it more generic so that one can switch algorithm in future without
much consequences
"""
@type t :: %Multihash{name: atom, code: integ... | lib/multihash.ex | 0.86792 | 0.520618 | multihash.ex | starcoder |
defmodule ExWire.Packet.Capability.Par.GetBlockHeaders do
@moduledoc """
Requests block headers starting from a given hash.
```
**GetBlockHeaders** [`+0x03`: `P`, `block`: { `P` , `B_32` }, `maxHeaders`: `P`, `skip`: `P`, `reverse`: `P` in { `0` , `1` } ]
Require peer to return a BlockHeaders message. Reply
... | apps/ex_wire/lib/ex_wire/packet/capability/par/get_block_headers.ex | 0.895383 | 0.834002 | get_block_headers.ex | starcoder |
defmodule Hierbautberlin.GeoData.NewsItem do
use Ecto.Schema
import Ecto.Query, warn: false
import Ecto.Changeset
alias Geo.PostGIS.Geometry
alias Hierbautberlin.Repo
alias Hierbautberlin.GeoData.{
GeoPlace,
GeoPosition,
GeoStreet,
GeoStreetNumber,
GeoMapItem,
NewsItem,
Source
... | lib/hierbautberlin/geo_data/news_item.ex | 0.561575 | 0.490114 | news_item.ex | starcoder |
defmodule Scrivener.HTML.SEO do
@moduledoc """
SEO related functions for pagination. See [https://support.google.com/webmasters/answer/1663744?hl=en](https://support.google.com/webmasters/answer/1663744?hl=en)
for more information.
`Scrivener.HTML.pagination_links/4` will use this module to add `rel` to each l... | lib/scrivener/html/seo.ex | 0.761184 | 0.562537 | seo.ex | starcoder |
defmodule Tournament do
@default_team %{mp: 0, w: 0, d: 0, l: 0, p: 0}
@doc """
Given `input` lines representing two teams and whether the first of them won,
lost, or reached a draw, separated by semicolons, calculate the statistics
for each team's number of games played, won, drawn, lost, and total points
... | exercism/elixir/tournament/lib/tournament.ex | 0.729134 | 0.521471 | tournament.ex | starcoder |
defmodule Accent.Plug.Response do
@moduledoc """
Transforms the keys of an HTTP response to the case requested by the client.
A client can request what case the keys are formatted in by passing the case
as a header in the request. By default the header key is `Accent`. If the
client does not request a case o... | lib/accent/plug/response.ex | 0.884039 | 0.782704 | response.ex | starcoder |
defmodule Wand.CLI.Commands.Upgrade do
use Wand.CLI.Command
alias Wand.CLI.Display
alias Wand.CLI.Commands.Upgrade
@banner """
# Upgrade
Upgrade dependencies in your wand.json file
### Usage
```
wand upgrade
wand upgrade poison ex_doc --latest
wand upgrade --skip=cowboy --skip=mox
```
## O... | lib/cli/commands/upgrade.ex | 0.669853 | 0.5564 | upgrade.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.