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 Spiral do
@doc """
Given the dimension, return a square matrix of numbers in clockwise spiral order.
"""
@spec matrix(dimension :: integer) :: list(list(integer))
def matrix(0), do: []
def matrix(dimension) do
Matrix.new(dimension, dimension)
|> generate(0, 0, 1, :right, dimension * dimen... | exercism/elixir/spiral-matrix/lib/spiral.ex | 0.814274 | 0.666716 | spiral.ex | starcoder |
defmodule Phoenix.Router.Route do
# This module defines the Route struct that is used
# throughout Phoenix's router. This struct is private
# as it contains internal routing information.
@moduledoc false
alias Phoenix.Router.Route
@doc """
The `Phoenix.Router.Route` struct. It stores:
* :verb - the... | lib/phoenix/router/route.ex | 0.825238 | 0.425187 | route.ex | starcoder |
defmodule P11 do
@moduledoc """
- `W`: ใใผใฏ (`1 <= W <= 1_000_000`)
- `H`: ็ชๅท (`1 <= H <= 1_000_000`)
- `N`: ๆๆญใฎๆๆฐ (`1 <= N <= min(W * H, 100)`)
- `(Si, Ki)`: (i็ช็ฎใฎๆๆญใฎใใผใฏ,i็ช็ฎใฎๆๆญใฎๆฐๅญ)
ๅฎ็พฉ: ใใใ = ใใผใฏใพใใฏๆฐๅญใฎใฉใกใใใไธ่ดใใใใจใ
ๅบๅ: [ๆๆญใฎใซใผใไปฅๅค]ใฎใใใใใใซใผใใฎๆๆฐ
่งฃๆณ)
- ใซใผใใฎ็ทๆฐใฏ `W * H`
- ๆๆญใฎใใผใฏ`Si`ๅใณๆฐๅญ`Ki`ใใ้่คใๆ... | lib/100/p11.ex | 0.686265 | 0.796055 | p11.ex | starcoder |
defmodule OpcUA.Client do
use OpcUA.Common
@config_keys ["requestedSessionTimeout", "secureChannelLifeTime", "timeout"]
alias OpcUA.NodeId
@moduledoc """
OPC UA Client API module.
This module provides functions for configuration, read/write nodes attributes and discovery of a OPC UA Client.
`OpcUA.C... | lib/opc_ua/client.ex | 0.758332 | 0.584775 | client.ex | starcoder |
defmodule Openpayex.Charges do
@moduledoc """
Functions for working with charges at Openpay. Through this API you can:
* create a charge
* get a charge
* list charges
"""
alias Openpayex.OpenPay.OpenPayHelper
@doc """
Create charge without client.
## Example:
```
params = %{
method: "ban... | lib/openpayex/charges.ex | 0.810028 | 0.618032 | charges.ex | starcoder |
defmodule Mcrypt do
@moduledoc """
This is a thin wrapper around [`libmcrypt`](http://linux.die.net/man/3/mcrypt).
Please see the linked man page for details on the available ciphers and modes.
"""
@on_load :init
def init do
path = :filename.join(:code.priv_dir(:mcrypt), 'lib_mcrypt')
:ok = :erl... | lib/mcrypt.ex | 0.825167 | 0.459743 | mcrypt.ex | starcoder |
defmodule Nixa.NaiveBayes.Categorical do
@moduledoc """
Implements a categorical Naive Bayes classifier
"""
import Nixa.Shared
import Nixa.Stats
import Nixa.NaiveBayes.Shared
defstruct [
class_probs: nil,
feature_probs: nil,
alpha: nil
]
@doc """
Train a model using the provided input... | lib/nixa/naive_bayes/categorical.ex | 0.833968 | 0.58264 | categorical.ex | starcoder |
defmodule Tokenizers do
@moduledoc """
Elixir bindings to [Hugging Face Tokenizers](https://github.com/huggingface/tokenizers).
Hugging Face describes the Tokenizers library as:
> Fast State-of-the-art tokenizers, optimized for both research and production
>
> ๐ค Tokenizers provides an implementation of t... | lib/tokenizers.ex | 0.92686 | 0.76921 | tokenizers.ex | starcoder |
defmodule ConciergeSite.Schedule do
@moduledoc """
The schedule for a route or trip.
"""
alias AlertProcessor.{ApiClient, DayType, ExtendedTime, ServiceInfoCache}
alias AlertProcessor.Model.{Route, Subscription, TripInfo}
alias ConciergeSite.Schedule
@typedoc """
A tuple of a mode and route ID
"""
... | apps/concierge_site/lib/schedule.ex | 0.842475 | 0.416915 | schedule.ex | starcoder |
defmodule StrawHat.Utils.Map do
@moduledoc """
Functions for transforming maps, keys and values.
"""
defmodule AtomizeKeyError do
@type t :: %__MODULE__{key: any}
defexception [:key]
@spec message(%{key: String.t()}) :: String.t()
def message(%{key: key}) do
"\"#{key}\" binary hasn't be... | lib/straw_hat/utils/map.ex | 0.927207 | 0.61383 | map.ex | starcoder |
defmodule Matrix do
@moduledoc """
Documentation Matrix Module
"""
@doc """
Converts a multidimensional list into a zero-indexed map.
## Parameters
- list: the list to convert.
## Example
iex> Matrix.from_list([])
%{}
iex> Matrix.from_list(["x", "o", "x"])
... | apps/room/lib/matrix.ex | 0.829871 | 0.494446 | matrix.ex | starcoder |
defmodule IntelHex.Decoder do
alias IntelHex.{DecodeError, Record}
use Bitwise
@moduledoc false
@doc """
Decode one hex record.
If the record is not in Intel Hex format, an exception will be raised.
"""
@spec decode_record!(String.t()) :: IntelHex.Record.t() | no_return
def decode_record!(string) d... | lib/intel_hex/decoder.ex | 0.821939 | 0.420659 | decoder.ex | starcoder |
defmodule EpicenterWeb.Test.Pages.InvestigationCompleteInterview do
import Euclid.Test.Extra.Assertions
import ExUnit.Assertions
import Phoenix.LiveViewTest
alias Epicenter.Cases.CaseInvestigation
alias Epicenter.ContactInvestigations.ContactInvestigation
alias Epicenter.Test
alias EpicenterWeb.Test.Page... | test/support/pages/investigation_complete_interview.ex | 0.516595 | 0.466724 | investigation_complete_interview.ex | starcoder |
defmodule Exfile.LocalFile do
@moduledoc """
Represents a file on the local filesystem.
"""
alias Exfile.LocalFile, as: LF
defmacrop not_nil(term) do
quote do
not is_nil(unquote(term))
end
end
defstruct(
path: nil,
io: nil,
meta: %{}
)
@type t :: %LF{path: String.t, io: :... | lib/exfile/local_file.ex | 0.628977 | 0.478712 | local_file.ex | starcoder |
if Code.ensure_loaded?(Mint.HTTP) do
defmodule Tesla.Adapter.Mint do
@moduledoc """
Adapter for [mint](https://github.com/ericmj/mint)
Caution: The minimum supported Elixir version for mint is 1.5.0
Remember to add `{:mint, "~> 0.2.0"}` and `{:castore, "~> 0.1.0"}` to dependencies
Also, ... | lib/tesla/adapter/mint.ex | 0.759181 | 0.619457 | mint.ex | starcoder |
defmodule Avrora.Utils.Registrar do
@moduledoc """
Memory store-aware schema registration with extended functionality
designed to be used in the intensive loops.
It gives you control over the name under which schema will be registered
(i.e subject in Schema Registry) and allows you to enforce registration
... | lib/avrora/utils/registrar.ex | 0.849706 | 0.564759 | registrar.ex | starcoder |
defmodule Benchee.Conversion do
@moduledoc """
Integration of the conversion of multiple units with benchee.
Can be used by plugins to use benchee unit scaling logic.
"""
alias Benchee.Scenario
alias Benchee.Conversion.{Count, Duration, Memory}
@doc """
Takes scenarios and a given scaling_strategy, r... | lib/benchee/conversion.ex | 0.90325 | 0.620047 | conversion.ex | starcoder |
defmodule Mxpanel.Batcher do
@moduledoc """
Manages a pool of buffers that accumulate the events and sends them to the
Mixpanel API in batches in background. It implements a registry-based routing
pool with round-robing as routing strategy.
Checkout `start_link/1` for all supported options.
## Usage
1.... | lib/mxpanel/batcher.ex | 0.925458 | 0.769557 | batcher.ex | starcoder |
defmodule Delta.Producer do
@moduledoc """
GenStage which fulfills demand by making HTTP requests on a configurable frequency.
"""
alias Delta.File
use GenStage
require Logger
@type opts :: [opt]
@type opt ::
{:url, binary}
| {:frequency, non_neg_integer}
| {:http_mod, mod... | lib/delta/producer.ex | 0.800068 | 0.404772 | producer.ex | starcoder |
defmodule Towwwer.Job do
@moduledoc """
Enqueue job for later execution and return immediately:
Rihanna.enqueue(Towwwer.Job, [arg1, arg2])
A recurring job is implemented by having the job reschedule itself after completion
and Postgresโ ACID guarantees will ensure that it continues running.
NOTE: You will... | lib/towwwer/job.ex | 0.700895 | 0.47725 | job.ex | starcoder |
defmodule Bolt.Cogs.Guide do
@moduledoc false
@behaviour Nosedrum.Command
alias Bolt.Constants
alias Bolt.Paginator
alias Nostrum.Struct.Embed
@pages [
%Embed{
title: "guide - introduction",
description: """
bolt is a moderation bot intended for use on medium to large sized guilds.
... | lib/bolt/cogs/guide.ex | 0.868827 | 0.529993 | guide.ex | starcoder |
defmodule RDF.Serialization do
@moduledoc """
General functions for working with RDF serializations.
"""
alias RDF.{Dataset, Graph}
@type format :: module
@formats [
RDF.Turtle,
JSON.LD,
RDF.NTriples,
RDF.NQuads,
]
@doc """
The list of all known `RDF.Serialization.Format`s in the R... | lib/rdf/serialization/serialization.ex | 0.89765 | 0.592431 | serialization.ex | starcoder |
defmodule Geo.CheapRuler do
# via https://blog.mapbox.com/fast-geodesic-approximations-with-cheap-ruler-106f229ad016
@type point() :: %{:lat => float(), :lon => float(), optional(atom()) => any()}
ref_lat =
if Mix.env() == :test do
53.551
else
[_, lat1, _, lat2] = Settings.bounds()
(la... | lib/geo/cheap_ruler.ex | 0.913182 | 0.61086 | cheap_ruler.ex | starcoder |
defmodule ExampleFiles.Fileglobs do
@moduledoc """
Converts filespecs into example-file fileglobs.
"""
@spec parse([binary]) :: [binary]
@doc """
Converts the specified filespec or `List` of zero or more filespecs into a
`List` of one or more fileglob expressions. The resultant fileglob
expressions are... | lib/example_files/fileglobs.ex | 0.82251 | 0.489748 | fileglobs.ex | starcoder |
defmodule Iona.Template.Engine do
@moduledoc false
@behaviour EEx.Engine
defdelegate escape(value), to: Iona.Template.Helper
@impl true
def init(_opts) do
%{
iodata: [],
dynamic: [],
vars_count: 0
}
end
@impl true
def handle_begin(state) do
%{state | iodata: [], dynami... | lib/iona/template/engine.ex | 0.659515 | 0.480296 | engine.ex | starcoder |
defmodule ExLink do
@moduledoc """
Handles WebSocket connections to a Lavalink node, providing:
- `ExLink.Player`s to keep track of Lavalink players and control them
- `ExLink.Message`s to send via `ExLink.Connection`(s)
A somewhat example:
```
# define a player
defmodule MyApp.Player do
@be... | lib/ex_link.ex | 0.729905 | 0.660532 | ex_link.ex | starcoder |
defmodule TrainLoc.Vehicles.State do
@moduledoc """
GenServer for tracking and querying the vehicles in the system. Each vehicle
is represented by a `TrainLoc.Vehicles.Vehicle` struct.
"""
use GenServer
alias TrainLoc.Vehicles.Vehicles
require Logger
# Client Interface
def start_link(opts \\ []) ... | apps/train_loc/lib/train_loc/vehicles/state.ex | 0.732974 | 0.49292 | state.ex | starcoder |
defmodule Cog.Command.Service.PipelineMonitor do
alias Cog.Command.Service
alias Cog.Util.ETSWrapper
require Logger
@doc """
Finds the pid of the pipeline executor corresponding to token provided which
is then monitored and stored in the monitor table provided. Calling this
function with the same token m... | lib/cog/command/service/pipeline_monitor.ex | 0.661376 | 0.423816 | pipeline_monitor.ex | starcoder |
defmodule Solar.Events do
@moduledoc """
The `Solar.Events` module provides the calculations for sunrise and sunset
times. This is likely to be refactored as other events are added.
"""
@doc """
The event function takes a minimum of two parameters, the event of interest
which can be either :rise or :set ... | lib/events/events.ex | 0.94062 | 0.696158 | events.ex | starcoder |
defmodule ExTimezoneDB.Timezone do
@moduledoc """
Defines the structure and ancillary functions handling the valid return
data from the TimezoneDB service.
TimezoneDB returns for each zone
- countryName (as a string)
- countryCode (as ISO 3166-1 alpha-2 codes (2 letter codes))
- zoneName (as a string r... | lib/timezone.ex | 0.873276 | 0.581838 | timezone.ex | starcoder |
defmodule Loadex do
@moduledoc """
A simple distributed load test runner.
`Loadex` was created with two things in mind - genarating huge loads in a controlled manner, while being able to fully customize the test's flow.
These goals are achieved by using plain Elixir to create *scenarios* and then laveraging El... | lib/loadex.ex | 0.846578 | 0.782538 | loadex.ex | starcoder |
defmodule Calliope.Engine do
import Calliope.Render
@doc """
The Calliope Engine allows you to precompile your haml templates to be accessed
through functions at runtime.
Example:
defmodule Simple do
use Calliope.Engine
def show do
content_for(:show, [title: Calliope])
end
end
... | lib/calliope/engine.ex | 0.732974 | 0.433082 | engine.ex | starcoder |
defmodule ExifParser.Tag.Value do
alias ExifParser.Tag
# 2^31
@max_signed_32_bit_int 2_147_483_648
# 2^15
@max_signed_16_bit_int 632_768
@typedoc """
The data types that are represented in TIFF tags.
"""
@type data_types ::
:tiff_byte
| :tiff_ascii
| :tiff_short
... | lib/exif_parser/tag/value.ex | 0.609989 | 0.710653 | value.ex | starcoder |
defmodule Exzeitable.HTML.ActionButton do
@moduledoc """
For the actions buttons such as :new, :edit etc, as well as custom buttons.
Custom buttons can be added to the list in :action_buttons
## Example
```elixir
action_buttons: [:new, :edit, :super_cool_custom_action]
```
You can then define the ... | lib/exzeitable/html/action_button.ex | 0.808446 | 0.823044 | action_button.ex | starcoder |
defmodule Number.Percentage do
@moduledoc """
Provides functions for converting numbers into percentages.
"""
import Number.Delimit, only: [number_to_delimited: 2]
@doc """
Formats a number into a percentage string.
## Parameters
* `number` - A value to convert. Can be any value that implements
... | lib/number/percentage.ex | 0.928368 | 0.680547 | percentage.ex | starcoder |
defmodule Mix.Tasks.Incident.Postgres.Init do
@moduledoc """
This task will generate some basic setup when using `PostgresAdapter`.
When using this adapter you will need to have a table to store the events and aggregate locks.
This task will generate an `Ecto` migration to create the `events` and `aggregate_lo... | lib/mix/tasks/postgres_init.ex | 0.818556 | 0.740409 | postgres_init.ex | starcoder |
defmodule Range do
@moduledoc """
Defines a Range.
"""
@type t :: { Range, any, any }
@type t(first, last) :: { Range, first, last }
@doc """
Creates a new range.
"""
def new(first, last) do
{ Range, first, last }
end
@doc """
Returns the first item of the range.
"""
def first({ Range... | lib/elixir/lib/range.ex | 0.816077 | 0.574693 | range.ex | starcoder |
defmodule Workflows.Retrier do
@moduledoc """
Implements a state retrier.
## References
* https://states-language.net/#errors
"""
@type t :: term()
defstruct [:error_equals, :interval_seconds, :max_attempts, :backoff_rate, :attempt]
@default_interval_seconds 1
@default_max_attempts 3
@default_... | lib/workflows/retrier.ex | 0.833121 | 0.453201 | retrier.ex | starcoder |
defmodule Aoc.Year2015.Day02 do
@moduledoc """
Solution to Day 02 of 2015: I Was Told There Would Be No Math
## --- Day 02: I Was Told There Would Be No Math ---
The elves are running low on wrapping paper, and so they need to submit an order
for more. They have a list of the dimensions (length `l`, width `... | lib/aoc/year_2015/day_02.ex | 0.899674 | 0.881207 | day_02.ex | starcoder |
defmodule AWS.API.Pricing do
@moduledoc """
AWS Price List Service API (AWS Price List Service) is a centralized and
convenient way to programmatically query Amazon Web Services for services,
products, and pricing information.
The AWS Price List Service uses standardized product attributes such as
`Locati... | lib/aws/generated/api_pricing.ex | 0.84699 | 0.635654 | api_pricing.ex | starcoder |
defmodule Calendar.AmbiguousDateTime do
@moduledoc """
AmbiguousDateTime provides a struct which represents an ambiguous time and
date in a certain time zone. These structs will be returned from the
DateTime.from_erl/2 function when the provided time is ambiguous.
AmbiguousDateTime contains two DateTime stru... | data/web/deps/calendar/lib/calendar/ambiguous_date_time.ex | 0.877418 | 0.656469 | ambiguous_date_time.ex | starcoder |
defmodule MeshxRpc.Server.Pool do
# @behaviour :ranch_protocol
alias MeshxRpc.App.T
alias MeshxRpc.Common.{Options, Structs.Data, Structs.Svc}
@opts [
timeout_execute: [
type: :timeout,
default: :infinity,
doc: """
request function execution timeout, milliseconds. If timeout is exce... | lib/server/pool.ex | 0.834238 | 0.67393 | pool.ex | starcoder |
defmodule Brave.Equiptment do
@armor [
%{name: "No Armor", defense: 11, bonus: 1, slots: 0, quality: 7},
%{name: "Gambeson", defense: 12, bonus: 2, slots: 1, quality: 3},
%{name: "Brigandine", defense: 13, bonus: 3, slots: 1, quality: 4},
%{name: "Chain", defense: 14, bonus: 4, slots: 3, quality: 5},
... | lib/brave/equiptment.ex | 0.524395 | 0.691684 | equiptment.ex | starcoder |
defmodule Daguex.Processor.StorageHelper do
@moduledoc """
Helpers for using `Daguex.Processor` in the `Daguex.Processor`
"""
@local_storage_key "__local__"
alias Daguex.{Image, ImageFile, ImageHelper}
def local_storage_key, do: @local_storage_key
def put_local_image(context, image_file, format) do
... | lib/daguex/processor/storage_helper.ex | 0.778313 | 0.460653 | storage_helper.ex | starcoder |
defmodule Day05 do
@typedoc """
width, height, data
"""
@type grid_t :: %{width: integer, height: integer, data: tuple}
@typedoc """
x, y
"""
@type point_t :: {integer, integer}
@typedoc """
start, end
"""
@type line_t :: {point_t, point_t}
@spec parse_point(String.t()) :: point_t
def par... | aoc21/lib/day05.ex | 0.851706 | 0.612628 | day05.ex | starcoder |
defmodule Mix.Tasks.Graphme do
@moduledoc """
Generates a relationship graph of your modules using the DOT language
mix graphme
## Command line options
* `-f` `--filter` - One part of a module name, eg: from A.B.C you can filter the B [default: nil]
* `-F` `--filter_at` - The index of ... | lib/mix/tasks/graphme.ex | 0.846419 | 0.599632 | graphme.ex | starcoder |
defmodule Dnsimple.Tlds do
@moduledoc """
Provides functions to interact with the
[TLD endpoints](https://developer.dnsimple.com/v2/tlds/).
See:
- https://developer.dnsimple.com/v2/tlds/
"""
alias Dnsimple.Client
alias Dnsimple.Listing
alias Dnsimple.Response
alias Dnsimple.Tld
alias Dnsimple.Tl... | lib/dnsimple/tlds.ex | 0.731634 | 0.419797 | tlds.ex | starcoder |
defmodule Nostrum.Cache.PresenceCache do
@moduledoc """
Cache for presences.
The ETS table name associated with the User Cache is `:presences`. Besides the
methods provided below you can call any other ETS methods on the table.
## Example
```elixir
info = :ets.info(:presences)
[..., heir: :none, name:... | lib/nostrum/cache/presence_cache.ex | 0.84653 | 0.730674 | presence_cache.ex | starcoder |
defmodule Trans.Translator do
@moduledoc """
Provides functions to easily access translated values from schemas and fallback
to a default locale when the translation does not exist in the required one.
The functions provided by this module require structs declared in modules
using `Trans`.
"""
@doc """
... | lib/trans/translator.ex | 0.887796 | 0.499146 | translator.ex | starcoder |
defmodule ExULID.Crockford do
@moduledoc """
This module provides data encoding and decoding functions
according to [Crockford's Base32](http://www.crockford.com/wrmg/base32.html).
"""
@bits 5
@encoding '0123456789ABCDEFGHJKMNPQRSTVWXYZ'
defmodule UnknownCharacterError do
defexception [:message]
... | lib/ex_ulid/crockford.ex | 0.78789 | 0.496338 | crockford.ex | starcoder |
defmodule Litmus.Type.List do
@moduledoc """
This type validates that a value is list.
## Options
* `:default` - Setting `:default` will populate a field with the provided
value, assuming that it is not present already. If a field already has a
value present, it will not be altered.
* `:min... | lib/litmus/type/list.ex | 0.915498 | 0.606557 | list.ex | starcoder |
defmodule AdventOfCode.Day06 do
@moduledoc ~S"""
[Advent Of Code day 6](https://adventofcode.com/2018/day/6).
iex> input = Enum.join(["1, 1", "1, 6", "8, 3", "3, 4", "5, 5", "8, 9"], "\n")
iex> AdventOfCode.Day06.solve("1", input)
17
iex> AdventOfCode.Day06.solve("2", input, 32)
16
... | lib/advent_of_code/day_06.ex | 0.792825 | 0.65132 | day_06.ex | starcoder |
defmodule LocalHex.Storage.S3 do
@moduledoc """
Adapter module to provide S3 abilities
In the config files (ex. config.exs) you can configure each repository individually by
providing a `:store` field that contains a tuple with the details.
Additionally you need to configure `ex_aws` as well to be able to c... | lib/local_hex/storage/s3.ex | 0.853593 | 0.760562 | s3.ex | starcoder |
defmodule ChattingHangmans.Hangman do
@moduledoc """
Handles Hangman gameplay
"""
@lifes_number 8
alias ChattingHangmans.Game
@doc "Transforms current game state into new one"
def play(%Game{} = game) do
game
|> parse
|> validate_input
|> initialize_new_game
|> advance_game
|> dr... | chatting_hangmans/lib/chatting_hangmans/hangman.ex | 0.570331 | 0.404684 | hangman.ex | starcoder |
defmodule Cloak.Ciphers.Deprecated.AES.CTR do
@moduledoc """
DEPRECATED version of the `Cloak.Ciphers.AES.CTR` cipher, for use in
migrating existing data to the new format used by `Cloak.Ciphers.AES.CTR`.
## Rationale
The old `Cloak.AES.CTR` cipher used the following format for ciphertext:
+---------... | lib/cloak/ciphers/deprecated/aes_ctr.ex | 0.782288 | 0.406361 | aes_ctr.ex | starcoder |
defmodule Cassandrax do
@moduledoc ~S"""
Cassandrax is a Cassandra ORM built on top of [Xandra](https://github.com/lexhide/xandra) and
[Ecto](https://github.com/elixir-ecto/ecto). `Xandra` provides the driver for communication
with the Database, and `Ecto` provides the data mapping functionality as well as chan... | lib/cassandrax.ex | 0.828488 | 0.750667 | cassandrax.ex | starcoder |
defmodule Skout.Document do
@moduledoc """
A structure for Skout documents for terse descriptions of SKOS concept schemes.
A Skout document consists of a graph with the description of the [SKOS](http://www.w3.org/TR/skos-reference)
concept scheme and its concepts and a manifest with general settings for the
... | lib/skout/document.ex | 0.886408 | 0.724432 | document.ex | starcoder |
defmodule HKDF do
@moduledoc """
Provides a simple Hashed Message Authentication Code (HMAC)-based
key derivation function (HKDF).
## Process
Keys are derived in two steps:
1. Extract - a pseudorandom key is extracted from an input key material and optional salt.
2. Expand - an output key material ... | lib/hkdf.ex | 0.829181 | 0.556942 | hkdf.ex | starcoder |
defmodule ArtemisWeb.TeamView do
use ArtemisWeb, :view
import Artemis.Helpers, only: [keys_to_atoms: 2]
alias Artemis.Permission
# Bulk Actions
def available_bulk_actions() do
[
%BulkAction{
action: &Artemis.DeleteTeam.call_many(&1, &2),
authorize: &has?(&1, "teams:delete"),
... | apps/artemis_web/lib/artemis_web/views/team_view.ex | 0.594669 | 0.437944 | team_view.ex | starcoder |
defmodule Cartel.Message.Wns do
@moduledoc """
Microsoft WNS message
For more details on the format see [Push notification service request and response headers (Windows Runtime apps)](https://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx)
section of the [Sending push notifications with WNS](https... | lib/cartel/message/wns.ex | 0.857545 | 0.433022 | wns.ex | starcoder |
defmodule Sanbase.SocialData.TrendingWords do
@moduledoc ~s"""
Module for fetching the list of trending words
This list does NOT calculate the most popular words on crypto social
media overall - those would often be the same, redundant words
such as โBitcoinโ, โEthereumโ, โcryptoโ etc.
Instead, our list a... | lib/sanbase/social_data/trending_words.ex | 0.843702 | 0.6711 | trending_words.ex | starcoder |
defmodule ExUnit.Case do
@moduledoc """
This module is meant to be used in other modules
as a way to configure and prepare them for testing.
When used, it allows the following options:
* :async - configure Elixir to run that specific test case
in parallel with others. Must be used for performan... | lib/ex_unit/lib/ex_unit/case.ex | 0.782247 | 0.486758 | case.ex | starcoder |
defmodule Liquor.Whitelist do
@moduledoc """
Whitelist takes a list of search items and attempts to filter them
"""
@type filter_func :: ((atom, atom, term) -> {:ok, {atom, atom, term} | {atom, term}} | :reject)
@type filter_item ::
nil |
boolean |
atom |
{:apply, module, atom, list} |
fil... | lib/liquor/whitelist.ex | 0.599133 | 0.704376 | whitelist.ex | starcoder |
defmodule Record.Backend do
# Callback functions invoked by defrecord, defrecordp and friends.
@moduledoc false
@doc """
Splits a keywords list into fields and types.
This logic is shared by records and structs.
"""
def split_fields_and_types(tag, kv) when is_list(kv) do
split_fields_and_types(tag, ... | lib/elixir/lib/record/backend.ex | 0.689828 | 0.589716 | backend.ex | starcoder |
defmodule Crux.Structs.Snowflake do
@moduledoc """
Custom non discord api module to help with working with Discord's snowflakes.
For more information see [Discord Docs](https://discord.com/developers/docs/reference#snowflakes).
"""
@moduledoc since: "0.2.1"
alias Crux.Structs.Snowflake
use Bitwise
@t... | lib/structs/snowflake.ex | 0.81946 | 0.846006 | snowflake.ex | starcoder |
defmodule RandomString do
@moduledoc """
An utility to generate random strings of desired character sets.
"""
@simple_classes %{
# {base, number_of_chars}
numeric: {?0, 10},
uppercase: {?A, 26},
lowercase: {?a, 26},
printable_chars: {?!, 94}
}
@misleading_chars '012... | lib/random_string.ex | 0.812459 | 0.476519 | random_string.ex | starcoder |
defmodule Bgp.Protocol.Capability do
@moduledoc """
Capability encoding/decoding for BGP open messages.
"""
defmodule Capability do
@moduledoc """
Capability struct for encoding/decoding.
"""
@enforce_keys [:type, :value]
defstruct [:type, :value]
@type capability_type :: 0..255
@ty... | lib/bgp/protocol/capability.ex | 0.801237 | 0.415017 | capability.ex | starcoder |
defmodule Geocalc.Shape do
@moduledoc """
`Geocalc.Shape` contains `Circle`, `Rectangle` and `Ellipse` shapes.
Those shapes define a geographical area projection and are designed to be
used for geofencing, ie: the user can determine if one point is inside or
outside a geographical zone.
Geographical zones... | lib/geocalc/shape.ex | 0.940993 | 0.995497 | shape.ex | starcoder |
defmodule ThousandIsland.Transports.TCP do
@moduledoc """
Defines a `ThousandIsland.Transport` implementation based on clear TCP sockets
as provided by Erlang's `:gen_tcp` module. For the most part, users of Thousand
Island will only ever need to deal with this module via `transport_options`
passed to `Thous... | lib/thousand_island/transports/tcp.ex | 0.917884 | 0.76708 | tcp.ex | starcoder |
defmodule Cards do
@moduledoc """
Documentation for Cards.
"""
@doc """
create_deck
## Example
iex> Cards.create_deck
["Ace of Spades", "Two of Spades", "Three of Spades",
"Four of Spades", "Five of Spades", "Ace of Clubs", "Two of Clubs",
"Three of Clubs", "Four of Clu... | cards/lib/cards.ex | 0.693369 | 0.64839 | cards.ex | starcoder |
defmodule DefUnit do
@moduledoc """
DefUnit defines macros used to create type specs and documentation
when working with a "core" set of measurement units, and also defines
operators to convert them to and from other units.
## Example
```
use DefUnit
@doc_to_operator "to SI"
@doc_from_operato... | lib/def_unit.ex | 0.897415 | 0.831964 | def_unit.ex | starcoder |
defmodule Commanded.Event do
@moduledoc ~S"""
Creates a domain event structure.
## Options
* `from` - A struct to adapt the keys from.
* `with` - A list of keys to add to the event.
* `drop` - A list of keys to drop from the keys adapted from a struct.
* `version` - An optional ... | lib/commanded/event.ex | 0.862496 | 0.501587 | event.ex | starcoder |
defmodule SteamEx.IPublishedFileService do
@moduledoc """
Provides additional methods for interacting with Steam Workshop items.
See [ISteamRemoteStorage](https://partner.steamgames.com/doc/webapi/ISteamRemoteStorage) for the primary interface.
**NOTE:** This is a Service interface, methods in this interface ... | lib/interfaces/i_published_file_service.ex | 0.719679 | 0.547101 | i_published_file_service.ex | starcoder |
defmodule Broca.Naive.NN do
@moduledoc """
Module to handle `list` and `list of lists` for Neural Network.
"""
defguard is_2dlist(list) when is_list(hd(list)) and not is_list(hd(hd(list)))
defguard is_3dlist(list) when is_list(hd(hd(list))) and not is_list(hd(hd(hd(list))))
defguard is_4dlist(list) when is... | lib/broca/naive/nn.ex | 0.799599 | 0.470493 | nn.ex | starcoder |
defmodule ExchemaCoercion.Coercions.Numeric do
@moduledoc """
Coercion functions for numeric types
"""
alias Exchema.Types, as: T
@doc """
Converts string to a numeric type.
It is a Higher-Order-Function because it allows
customization based on wether or not we want the
coercion to be strict (it is, ... | lib/coercions/numeric.ex | 0.819496 | 0.775987 | numeric.ex | starcoder |
defmodule Geometry do
@forca "ahhhh!"
def rectangle_area(a, b) do
a * b
end
def square(a) do
a * a
end
# using pipeline operator
def power_of_four(a) do
a
|> square
|> square
end
# manipulating string
def manipulate_string(str) do
# Embedded expression defined inside strin... | geometry.ex | 0.66628 | 0.535281 | geometry.ex | starcoder |
defmodule FontAwesome do
@moduledoc """
This package adds a convenient way of using [Font Awesome](https://fontawesome.com) SVGs with your Phoenix, Phoenix LiveView and Surface applications.
You can find the original docs [here](https://fontawesome.com) and repo [here](https://github.com/FortAwesome/Font-Awesome... | lib/fontawesome.ex | 0.893674 | 0.55441 | fontawesome.ex | starcoder |
require Logger
defmodule Day23.NAT do
@moduledoc """
A process that is responsible for keeping the network active.
The NAT receives packets addressed to address `255` during the course of normal
network traffic. When the router informs the NAT that all addresses are idling,
the NAT may rebroadcast the last ... | aoc2019_elixir/apps/day23/lib/nat.ex | 0.834103 | 0.656896 | nat.ex | starcoder |
defmodule Custodian.Github.Tentacat.Client do
@moduledoc """
Provides an implementation of the `Custodian.Github.Client` behaviour with
the GitHub API.
This provides two different authentication methods for interacting
with the GitHub v3 API over HTTPS.
"""
@behaviour Custodian.Github.Client
alias JO... | lib/custodian/github/tentacat/client.ex | 0.625324 | 0.422594 | client.ex | starcoder |
defmodule Cardanoex.Transaction do
alias Cardanoex.Backend
alias Cardanoex.Util
@type asset :: %{
policy_id: String.t(),
asset_name: String.t(),
quantity: non_neg_integer()
}
@type payment :: %{
address: String.t(),
amount: non_neg_integer(),
... | lib/transaction.ex | 0.901044 | 0.6162 | transaction.ex | starcoder |
defmodule BitPalWeb.ConnCase do
@moduledoc """
This module defines the test case to be used by
tests that require setting up a connection.
Such tests rely on `Phoenix.ConnTest` and also
import other functionality to make it easier
to build common data structures and query the data layer.
Finally, if the... | test/bitpal_web/support/conn_case.ex | 0.80077 | 0.408719 | conn_case.ex | starcoder |
defmodule AsyncWith.Runner do
@moduledoc false
import AsyncWith.Clauses
import AsyncWith.Macro, only: [rename_ignored_vars: 1, var_map: 1]
@doc """
Transforms the list of `clauses` into a format that the runner can work with.
The runner expects each clause to be represented by a map with these fields:
... | lib/async_with/runner.ex | 0.791338 | 0.650433 | runner.ex | starcoder |
defmodule Multiverses.Clone do
@moduledoc """
allows a module to directly clone all of the public functions of a
given module, except as macros.
thus multiverse equivalents replicate the functionality of the parent
module. Consider dropping a cloned module into a `test/support`
directory so that it can ex... | lib/multiverses/macro_clone.ex | 0.862714 | 0.881258 | macro_clone.ex | starcoder |
defmodule Phoenix.SimpleForm.FormInput do
@moduledoc ~S"""
Configuration struct that defines the entrypoint for a SimpleForm invokation
<%= input f, :user_id, collection: @form_collections.users %>
The following options are supported
- `label` - Overwrite the default labelname with is the name of the fiel... | lib/phoenix/simple_form/form_input.ex | 0.889039 | 0.765944 | form_input.ex | starcoder |
defmodule Chatter.MessageHandler do
require Record
require Chatter.NetID
alias Chatter.NetID
Record.defrecord :message_handler,
tag: nil,
code: nil,
extract_netids: nil,
encode_with: nil,
decode_with: nil,
... | lib/message_handler.ex | 0.736495 | 0.469885 | message_handler.ex | starcoder |
defmodule ExUssd.Utils do
@moduledoc false
alias ExUssd.Executer
@default_value 436_739_010_658_356_127_157_159_114_145
@spec to_int(term() | {integer(), String.t()}, ExUssd.t(), map(), String.t()) :: integer()
def to_int(input, menu, _, input_value)
def to_int({0, _}, %ExUssd{is_zero_based: is_zero_base... | lib/ex_ussd/utils.ex | 0.655115 | 0.432663 | utils.ex | starcoder |
defmodule OMG.Performance.SimplePerftest do
@moduledoc """
The simple performance tests runs the critical transaction processing chunk of the child chain.
This allows to easily test the critical path of processing transactions, and profile it using `:fprof`.
"""
use OMG.Utils.LoggerExt
require OMG.Utxo
... | apps/omg_performance/lib/omg_performance/simple_perftest.ex | 0.906656 | 0.854703 | simple_perftest.ex | starcoder |
defmodule Advent20.Cubes do
@moduledoc """
Day 17: Conway Cubes
"""
defp parse(input, dimensions) do
input
|> String.split("\n", trim: true)
|> Enum.with_index()
|> Enum.reduce(%{}, fn {line, y}, all_coordinates ->
String.codepoints(line)
|> Enum.with_index()
|> Enum.reject(fn... | lib/advent20/17_cubes.ex | 0.717606 | 0.590366 | 17_cubes.ex | starcoder |
defmodule LiveMap.Tile do
@moduledoc """
This module contains functions to manipulate map tiles.
"""
alias :math, as: Math
alias __MODULE__, as: Tile
require Logger
@type latitude :: number()
@type longitude :: number()
@type zoom :: pos_integer()
@type x :: pos_integer()
@type y :: pos_integer()... | lib/live_map/tile.ex | 0.935095 | 0.687276 | tile.ex | starcoder |
defmodule EctoPolymorphic.Schema do
@moduledoc """
"""
alias EctoPolymorphic.Type, as: PolymorphicType
defmacro __using__(_opts) do
quote do
import EctoPolymorphic.Schema
end
end
defmacro polymorphy(name, types) do
check_polymorphic!(types)
{:module, module, _, _} = PolymorphicType... | lib/ecto_polymorphic/schema.ex | 0.703244 | 0.498413 | schema.ex | starcoder |
defmodule Bincode do
@moduledoc ~S"""
Module defining the functionalities of Bincode.
Bincode allows you to share data between Elixir and Rust using
Rust's [Bincode](https://github.com/servo/bincode) binary format.
You can implement your custom serialization manually, but for most use cases
you can simply... | lib/bincode.ex | 0.926154 | 0.913792 | bincode.ex | starcoder |
defmodule Elasticlunr.DB do
defstruct [:name, :options]
@type t :: %__MODULE__{
name: atom(),
options: list(atom())
}
@spec init(atom(), list()) :: t()
def init(name, opts \\ []) when is_atom(name) do
default = ~w[compressed named_table]a
options = Enum.uniq(default ++ opts... | lib/elasticlunr/db.ex | 0.734501 | 0.409929 | db.ex | starcoder |
defmodule Liquor.Filter do
@moduledoc """
Applies search terms as filters to a given Ecto.Query
"""
import Ecto.Query
@type filter ::
((Ecto.Query.t, Liquor.op, atom, term) -> Ecto.Query.t) |
map |
{:apply, module, atom, list}
@spec apply_filter(Ecto.Query.t, Liquor.op, atom, term, filter) :: ... | lib/liquor/filter.ex | 0.788583 | 0.565149 | filter.ex | starcoder |
defmodule AWS.Config do
@moduledoc """
AWS Config
AWS Config provides a way to keep track of the configurations of all the
AWS resources associated with your AWS account. You can use AWS Config to
get the current and historical configurations of each AWS resource and also
to get information about the rela... | lib/aws/config.ex | 0.890145 | 0.542984 | config.ex | starcoder |
defmodule FinancialSystem do
alias FinancialSystem.Account, as: Account
alias FinancialSystem.Converter, as: Converter
@moduledoc """
After you create accounts with the Account module, you can register with the functions available in
the FinancialSystem module.
"""
@doc """
Transaction function is in ... | apps/financial_system/lib/financial_system.ex | 0.811078 | 0.798226 | financial_system.ex | starcoder |
defmodule Sherbet.Service.Contact.Communication do
@moduledoc """
Provides interfaces to communications.
"""
import Ecto.Query
require Logger
alias Sherbet.Service.Contact.Communication
@type uuid :: String.t
@doc """
Add a communication type to be associated with the given i... | apps/sherbet_service/lib/sherbet.service/contact/communication.ex | 0.881608 | 0.444927 | communication.ex | starcoder |
defmodule BinFormat.FieldType.Util do
@moduledoc """
Implementations of the AST generator functions for builtin types with the
BinFormat.FieldType.BuiltIn struct replaced by the relevant variables.
These functions are useful for other types and are provided to reduce
duplication.
"""
@doc """
Builds a... | lib/bin_format/field_type/util.ex | 0.761671 | 0.697442 | util.ex | starcoder |
defmodule Genex.Evolution do
alias Genex.Tools.{Crossover, Selection}
alias Genex.Support.{Genealogy, HallOfFame}
alias Genex.Types.Population
@moduledoc """
Evolution behaviour definition for Evolutionary algorithms.
Evolutions begin with `init` after the population has been created. The purpose of `init... | lib/genex/evolution.ex | 0.869271 | 0.631296 | evolution.ex | starcoder |
defmodule ExUssd.Nav do
@moduledoc """
USSD Nav module
"""
@type t :: %__MODULE__{
name: String.t(),
match: String.t(),
type: atom(),
orientation: atom(),
delimiter: String.t(),
reverse: boolean(),
top: integer(),
bottom: integer()... | lib/ex_ussd/nav.ex | 0.904961 | 0.796688 | nav.ex | starcoder |
defmodule JsonJanitor do
@moduledoc """
`JsonJanitor` helps sanitize elixir terms so that they can be serialized to
JSON.
It makes some opinionated decisions to keep as much structure as possible
while guaranteeing that the resulting structure can be serialized to JSON.
"""
@doc """
Accepts anything a... | lib/json_janitor.ex | 0.834441 | 0.580382 | json_janitor.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.