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 Day11 do
@doc """
Calculate square of any size with the largest power.
## Examples
iex> Day11.largest_total_square(7803)
{{230, 272, 17}, 125}
"""
def largest_total_square serial do
grid = build_grid serial
acc = {{0, 0, 0}, 0}
Enum.reduce(1..299, acc, fn x, acc ->
... | day11/lib/day11.ex | 0.802749 | 0.625281 | day11.ex | starcoder |
defmodule Posexional.Field.TypedField do
@moduledoc """
this module represent a single field in a row of a positional file
"""
use Timex
alias Posexional.Field
alias Posexional.Field.Value
defstruct [:name, :field_value, :type, :opts]
@type field_type() ::
:id
| :binary_id
... | lib/posexional/field/typed_field.ex | 0.841272 | 0.546859 | typed_field.ex | starcoder |
defmodule P7777776.ConfusionMatrix do
@moduledoc """
Documentation for P7777776ConfusionMatrix.
## Examples
iex> P7777776ConfusionMatrix.blah()
:ok
"""
alias P7777776.ConfusionMatrix
defstruct classes: MapSet.new(), counts: %{}, tp: 0, total: 0, n_actual: %{}, n_predicted: %{}
def new(),... | lib/p7777776_confusion_matrix.ex | 0.720762 | 0.464598 | p7777776_confusion_matrix.ex | starcoder |
defmodule Brainfux.Preprocessor do
@moduledoc """
Preprocessor of brainfuck code.
`process/1` conducts every process.
"""
alias Brainfux.Preprocessor.Base
alias Brainfux.State
@spec process!(String.t) :: {State.t, String.t} | none
def process!(raw_code) do
raw_code
|> Base.check_brackets!()
... | lib/brainfux/preprocessor.ex | 0.795142 | 0.53358 | preprocessor.ex | starcoder |
defmodule Staxx.Proxy.Chain.Storage.Record do
@moduledoc """
Details for chain process that will be stored into DB
"""
alias Staxx.Proxy.Chain.State
alias Staxx.Proxy.Chain.Storage
@type t :: %__MODULE__{
id: binary,
status: State.status(),
config: map(),
chain_deta... | apps/proxy/lib/proxy/chain/storage/record.ex | 0.78469 | 0.42665 | record.ex | starcoder |
defmodule LfuCache do
@moduledoc """
This modules implements a simple LRU cache, using 2 ets tables for it.
For using it, you need to start it:
iex> LruCache.start_link(:my_cache, 1000)
Or add it to your supervisor tree, like: `worker(LruCache, [:my_cache, 1000])`
## Using
iex> LruCache.start... | lib/lfu_cache.ex | 0.794465 | 0.58163 | lfu_cache.ex | starcoder |
defmodule Geolix do
@moduledoc """
IP location lookup provider.
## Usage
Fetching information for a single IP is done by passing it as a binary or
tuple to `Geolix.lookup/1`:
iex> Geolix.lookup("127.0.0.1")
%{
city: %{...},
country: %{...}
}
The result will be a map wit... | lib/geolix.ex | 0.898828 | 0.722013 | geolix.ex | starcoder |
defmodule BubbleLib.MapUtil.AutoMap do
@moduledoc """
Automagic map — creates deep elements inside. All map keys are
coerced to strings except for list indexes.
"""
alias BubbleLib.MapUtil.AutoMap
alias BubbleLib.MapUtil.AutoMap.ETS
import Kernel, except: [get_in: 2]
def put_in(data, keys, value) do
... | lib/bubble_lib/map_util/auto_map.ex | 0.538012 | 0.530115 | auto_map.ex | starcoder |
defmodule RobotSimulator do
defstruct direction: nil, position: nil
defguard is_direction(direction) when direction in [:north, :east, :south, :west]
defguard is_position(x, y) when is_integer(x) and is_integer(y)
@doc """
Create a Robot Simulator given an initial direction and position.
Valid directions... | elixir/robot-simulator/lib/robot_simulator.ex | 0.910568 | 0.883286 | robot_simulator.ex | starcoder |
defmodule Ecto.Adapters.DynamoDB.Cache do
@moduledoc """
An Elixir agent to cache DynamoDB table schemas and the first page of results for selected tables
"""
@typep table_name_t :: String.t
@typep dynamo_response_t :: %{required(String.t) => term}
@spec start_link() :: Agent.on_start
def start_link do
... | lib/ecto_adapters_dynamodb/cache.ex | 0.828315 | 0.409073 | cache.ex | starcoder |
defmodule Axon.Shared do
@moduledoc false
# Collection of private helper functions and
# macros for enforcing shape/type constraints,
# doing shape calculations, and even some
# helper numerical definitions.
import Nx.Defn
@doc """
Asserts `lhs` has same shape as `rhs`.
"""
defn assert_shape!(lhs... | lib/axon/shared.ex | 0.77949 | 0.630173 | shared.ex | starcoder |
defmodule Phoenix.Controller.Pipeline do
@moduledoc """
This module implements the controller pipeline responsible for handling requests.
## The pipeline
The goal of a controller is to receive a request and invoke the desired
action. The whole flow of the controller is managed by a single pipeline:
d... | lib/phoenix/controller/pipeline.ex | 0.877437 | 0.50653 | pipeline.ex | starcoder |
defmodule Path do
@moduledoc """
This module provides conveniences for manipulating or
retrieving file system paths.
The functions in this module may receive a chardata as
argument (i.e. a string or a list of characters / string)
and will always return a string (encoded in UTF-8).
The majority of the fu... | lib/elixir/lib/path.ex | 0.80112 | 0.478955 | path.ex | starcoder |
defmodule Robolia.Games.TicTacToes do
alias Robolia.Games.TicTacToes.{TicTacToeMatch, TicTacToeMoviment, Queries}
alias Robolia.{GameError, Repo}
alias TicTacToeBoard
def refresh(%TicTacToeMatch{} = match) do
TicTacToeMatch
|> Queries.for_match(%{id: match.id})
|> Repo.one!()
end
def create_ma... | lib/robolia/games/tic_tac_toes.ex | 0.508544 | 0.434341 | tic_tac_toes.ex | starcoder |
defmodule Antikythera.Router do
@moduledoc """
Defines the antikythera routing DSL.
## Routing macros
This module defines macros to be used in each gear's Router module.
The names of the macros are the same as the HTTP verbs: `get`, `post`, etc.
The macros take the following 4 arguments (although you ca... | lib/web/router/router.ex | 0.858807 | 0.464112 | router.ex | starcoder |
defmodule ExConfig.Type.EldapFilter do
@moduledoc """
LDAP filter parser for Erlang `:eldap` library.
"""
use ExConfig.Type
alias ExConfig.Type.EldapFilter.Parser
defstruct []
@type result() :: term()
@impl true
def handle(data, _opts), do: do_handle(data)
@doc """
Parses the human-readable rep... | lib/ex_config/type/eldap_filter.ex | 0.874218 | 0.483405 | eldap_filter.ex | starcoder |
defmodule AWS.ECR do
@moduledoc """
Amazon Elastic Container Registry
Amazon Elastic Container Registry (Amazon ECR) is a managed container image
registry service.
Customers can use the familiar Docker CLI, or their preferred client, to push,
pull, and manage images. Amazon ECR provides a secure, scalabl... | lib/aws/generated/ecr.ex | 0.884495 | 0.491578 | ecr.ex | starcoder |
defmodule Neo4j.Sips.Transaction do
@moduledoc """
This module is the main implementation for running Cypher commands using
transactions. It is using the transactional HTTP endpoint for Cypher and has
the ability to let you use the same transaction across multiple HTTP requests.
Every Cypher operation is exe... | lib/neo4j_sips/transaction.ex | 0.86411 | 0.535159 | transaction.ex | starcoder |
defmodule AWS.Cognito do
@moduledoc """
Amazon Cognito
Amazon Cognito is a web service that delivers scoped temporary credentials
to mobile devices and other untrusted environments. Amazon Cognito uniquely
identifies a device and supplies the user with a consistent identity over
the lifetime of an applica... | lib/aws/cognito.ex | 0.88754 | 0.616474 | cognito.ex | starcoder |
defmodule Gateway.Kafka do
@moduledoc """
Produce/send Kafka messages.
## About the Kafka Integration
In order to scale horizontally, [Kafka Consumer
Groups](https://kafka.apache.org/documentation/#distributionimpl) are used.
[Brod](https://github.com/klarna/brod), which is the library used for communicati... | lib/gateway/kafka.ex | 0.822403 | 0.50592 | kafka.ex | starcoder |
defmodule Grax.ValidationError do
@moduledoc """
Raised when the validation of a Grax fails.
"""
defexception [:errors, :context]
@type t :: %__MODULE__{errors: list, context: any}
def exception(opts \\ []) do
errors = Keyword.get(opts, :errors, []) |> List.wrap()
context = Keyword.get(opts, :cont... | lib/grax/exceptions.ex | 0.852629 | 0.486454 | exceptions.ex | starcoder |
defmodule Infer.Audio do
@moduledoc """
Audio type matchers based on the [magic number](https://en.wikipedia.org/wiki/Magic_number_(programming))
"""
@doc """
Takes the binary file contents as arguments. Returns `true` if it's a midi.
"""
@spec midi?(binary()) :: boolean()
def midi?(<<0x4D, 0x54, 0x68,... | lib/matchers/audio.ex | 0.883142 | 0.558809 | audio.ex | starcoder |
defmodule AWS.EBS do
@moduledoc """
You can use the Amazon Elastic Block Store (Amazon EBS) direct APIs to create
EBS snapshots, write data directly to your snapshots, read data on your
snapshots, and identify the differences or changes between two snapshots.
If you’re an independent software vendor (ISV) w... | lib/aws/generated/ebs.ex | 0.822439 | 0.582194 | ebs.ex | starcoder |
defmodule Absinthe.Type.Interface do
@moduledoc """
A defined interface type that represent a list of named fields and their
arguments.
Fields on an interface have the same rules as fields on an
`Absinthe.Type.Object`.
If an `Absinthe.Type.Object` lists an interface in its `:interfaces` entry,
it guaran... | lib/absinthe/type/interface.ex | 0.877431 | 0.888469 | interface.ex | starcoder |
defmodule Advent20.Bags do
@moduledoc """
Day 7: Handy Haversacks
"""
# Parse the bag input
defp parse_bags(bag_input) do
bag_input
|> String.split("\n", trim: true)
|> Stream.map(&String.replace(&1, ~r/ bags?/, ""))
|> Stream.map(&String.replace(&1, ~r/\.$/, ""))
|> Stream.map(&String.sp... | lib/advent20/07_bags.ex | 0.713332 | 0.453262 | 07_bags.ex | starcoder |
defmodule OMG.Utils.HttpRPC.Validator.Base do
@moduledoc """
Implements simple validation engine with basic validators provided and allows to chain them
to make more comprehensive one.
"""
alias OMG.Utils.HttpRPC.Encoding
@type validation_error_t() :: {:error, {:validation_error, binary(), any()}}
# C... | apps/omg_utils/lib/omg_utils/http_rpc/validators/base.ex | 0.908168 | 0.672547 | base.ex | starcoder |
defmodule Saucexages.SauceBlock do
@moduledoc """
Represents a full SAUCE block, including both a SAUCE record and comments.
Used for in-memory representations of SAUCE data when reading and writing SAUCE. Can also be used to extract further metadata from SAUCE data such as font information, detailed data type a... | lib/saucexages/sauce_block.ex | 0.88573 | 0.688226 | sauce_block.ex | starcoder |
defmodule Telehashname do
@moduledoc """
Telehash hashname handling
https://github.com/telehash/telehash.org/blob/master/v3/hashname.md
"""
@typedoc """
Cipher Set ID
As an affordance, many functions will take a 4-byte CSID (the CSID with a pre-pended `cs`.)
These will be normalized in most return val... | lib/telehashname.ex | 0.885749 | 0.54353 | telehashname.ex | starcoder |
defmodule Membrane.RTP.TWCCReceiver.PacketInfoStore do
@moduledoc false
# The module stores TWCC sequence number along with their arrival timestamps, handling sequence
# number rollovers if necessary. Stored packet info can used for generating statistics used for
# assembling a TWCC feedback packet.
alias M... | lib/membrane/rtp/twcc_receiver/packet_info_store.ex | 0.830216 | 0.421641 | packet_info_store.ex | starcoder |
defmodule TextBasedFPS.ServerState.Rooms do
alias TextBasedFPS.{Notification, Player, Room, ServerState, Text}
@spec add_room(ServerState.t(), String.t()) :: ServerState.t()
def add_room(state, room_name) do
put_in(state.rooms[room_name], Room.new(room_name))
end
@spec add_room(ServerState.t(), String.t... | lib/text_based_fps/server_state/rooms.ex | 0.671686 | 0.492371 | rooms.ex | starcoder |
defmodule Kalevala.Event.Movement do
@moduledoc """
An event to move from one room to another
"""
defstruct [:character, :direction, :reason, :room_id]
@typedoc """
A movement event
- `character` is the character performing the movement
- `direction` is one of two options, `:to` or `:from`, depending... | lib/kalevala/event/movement.ex | 0.840619 | 0.855308 | movement.ex | starcoder |
defmodule Grizzly.ZWave.Commands.MultiChannelCapabilityReport do
@moduledoc """
This command is used to advertise the Generic and Specific Device Class and the supported command
classes of an End Point.
Params:
* `:end_point` - the end point capabilities are being reported about (required)
* `:dynami... | lib/grizzly/zwave/commands/multi_channel_capability_report.ex | 0.903348 | 0.498779 | multi_channel_capability_report.ex | starcoder |
defmodule Routeguide.RouteGuide.Server do
use Falco.Server, service: Routeguide.RouteGuide.Service
alias Falco.Server
alias RouteGuide.Data
@spec get_feature(Routeguide.Point, Falco.Server.Stream.t()) :: Routeguide.Feature.t()
def get_feature(point, _stream) do
features = Data.fetch_features()
defaul... | examples/route_guide/lib/server.ex | 0.790004 | 0.467332 | server.ex | starcoder |
defmodule Grizzly.CommandClass.ThermostatSetpoint do
@moduledoc """
Module for generating the thermostat setpoint command
"""
import Bitwise
@typedoc """
Type for the different setpoint types.
Possible to send raw byte for a different setpoint type if
needed. Otherwise, `:cooling` and `:heating` atom... | lib/grizzly/command_class/thermostat_setpoint.ex | 0.851753 | 0.438004 | thermostat_setpoint.ex | starcoder |
defmodule Joystick do
@moduledoc """
Simple wrapper to get Linux Joystick events.
# Usage
```
iex()> {:ok, js} = Joystick.start_link(0, self())
iex()> flush()
{:joystick, %Joystick.Event{number: 1, timestamp: 1441087318, type: :axis, value: -60}}
{:joystick, %Joystick.Event{number: 4, timestamp: 144108... | lib/joystick.ex | 0.750964 | 0.610395 | joystick.ex | starcoder |
defmodule Crit.Assertions.Changeset do
import Crit.Assertions.Defchain
import ExUnit.Assertions
import Crit.Extras.ChangesetT, only: [errors_on: 1]
import Crit.Assertions.Map
alias Ecto.Changeset
defchain assert_valid(%Changeset{} = changeset),
do: assert changeset.valid?
defchain assert_invalid(%Ch... | test/support/assertions/changeset.ex | 0.791741 | 0.601155 | changeset.ex | starcoder |
defmodule ATECC508A.DataZone do
@moduledoc """
This module handles operations on the data zone.
"""
alias ATECC508A.{Request, Transport}
@doc """
Read a slot
"""
@spec read(Transport.t(), Request.slot()) :: {:ok, binary()} | {:error, atom()}
def read(transport, slot) do
do_read(transport, slot, ... | lib/atecc508a/data_zone.ex | 0.857753 | 0.593521 | data_zone.ex | starcoder |
defmodule Mimic do
@moduledoc """
Mimic is a library that simplifies the usage of mocks in Elixir.
Mimic is mostly API compatible with [mox](https://hex.pm/packages/mox) but
doesn't require explicit contract checking with behaviours. It's also faster.
You're welcome.
Mimic works by copying your module ou... | lib/mimic.ex | 0.866345 | 0.894881 | mimic.ex | starcoder |
defmodule Cloak do
@moduledoc """
Cloak makes it easy to encrypt and decrypt database fields using
[Ecto](http://hexdocs.pm/ecto).
This `Cloak` module is Cloak's main entry point. It wraps the encryption
and decryption process, ensuring that everything works smoothly without
downtime, even when there are m... | lib/cloak.ex | 0.928002 | 0.688622 | cloak.ex | starcoder |
defmodule Livebook.Storage.Ets do
@moduledoc """
Ets implementation of `Livebook.Storage` behaviour.
The module is supposed to be started just once as it
is responsible for managing a named ets table.
`insert` and `delete` operations are supposed to be called using a GenServer
while all the lookups can be... | lib/livebook/storage/ets.ex | 0.79534 | 0.465448 | ets.ex | starcoder |
defmodule MonEx.Result do
@moduledoc """
Result module provides Result type with utility functions.
"""
alias MonEx.Option
defmacro ok(res) do
quote do
{:ok, unquote(res)}
end
end
defmacro error(err) do
quote do
{:error, unquote(err)}
end
end
@typedoc """
Result type.... | lib/monex/result.ex | 0.930718 | 0.507385 | result.ex | starcoder |
defmodule Cadet.SharedHelper do
@moduledoc """
Contains utility functions that may be commonly used across Cadet and CadetWeb..
"""
defmacro is_ecto_id(id) do
quote do
is_integer(unquote(id)) or is_binary(unquote(id))
end
end
def rename_keys(map, key_map) do
Enum.reduce(key_map, map, fn ... | lib/cadet/helpers/shared_helper.ex | 0.754644 | 0.41404 | shared_helper.ex | starcoder |
defmodule Riak do
@moduledoc """
# Riak Elixir Client
[](https://travis-ci.org/drewkerrigan/riak-elixir-client)
A Riak client written in Elixir. Now includes connection pooling with [pooler](http://github.com/seth/pooler) ... | lib/riak.ex | 0.908256 | 0.943295 | riak.ex | starcoder |
defmodule Ash.Query.Operator do
@moduledoc """
An operator is a predicate with a `left` and a `right`
For more information on being a predicate, see `Ash.Filter.Predicate`. Most of the complexities
are there. An operator must meet both behaviours.
"""
@doc """
Create a new predicate. There are various r... | lib/ash/query/operator/operator.ex | 0.881251 | 0.767625 | operator.ex | starcoder |
defmodule OliWeb.Curriculum.HierarchyPicker do
@moduledoc """
Hierarchy Picker Component
A general purpose curriculum location picker. When a new location is selected,
this component will trigger an "update_selection" event to the parent liveview
with the new selection.
Example:
```
def handle_event("... | lib/oli_web/live/curriculum/hierarchy_picker.ex | 0.671901 | 0.596844 | hierarchy_picker.ex | starcoder |
defmodule DeltaCrdt.CausalCrdt do
use GenServer
require Logger
require BenchmarkHelper
BenchmarkHelper.inject_in_dev()
@type delta :: {k :: integer(), delta :: any()}
@type delta_interval :: {a :: integer(), b :: integer(), delta :: delta()}
@moduledoc false
defstruct node_id: nil,
nam... | lib/delta_crdt/causal_crdt.ex | 0.543833 | 0.482734 | causal_crdt.ex | starcoder |
defmodule Faker do
@moduledoc """
Main module to start application with some helper functions.
"""
@doc """
Starts Faker with default locale.
"""
@spec start() :: :ok
def start do
:application.start(:faker)
end
@doc """
Starts Faker with `lang` locale.
"""
@spec start(atom) :: :ok
def ... | lib/faker.ex | 0.804214 | 0.406597 | faker.ex | starcoder |
defmodule Theriac do
import Enum
@moduledoc """
Theriac is an implementation of clojure style transducers in elixir.
"""
@doc ~S"""
Transduces a given enumerable into a list.
## Examples
iex> Theriac.transduce([1,2,7,9], Theriac.take(1))
[1]
"""
def transduce enum, {id, initial_state, ... | lib/theriac.ex | 0.619126 | 0.58062 | theriac.ex | starcoder |
defmodule EctoEnum do
@moduledoc """
Provides `defenum/2` and `defenum/3` macro for defining an Enum Ecto type.
This module can also be `use`d to create an Ecto Enum like:
defmodule CustomEnum do
use EctoEnum, ready: 0, set: 1, go: 2
end
Or in place of using `EctoEnum.Postgres` like:
... | lib/ecto_enum.ex | 0.875747 | 0.550184 | ecto_enum.ex | starcoder |
defmodule ToyRobot.Server do
@moduledoc """
The ToyRobot.Server module manages state for the ToyRobot simulation.
The `ToyRobot.Logic` module is aliased to provide the logic for valid moves and
rules for state changes.
"""
use GenServer, restart: :transient
alias ToyRobot.Logic
@doc """
Starts a supervised ... | lib/toy_robot/server.ex | 0.8818 | 0.702186 | server.ex | starcoder |
defmodule Stripe.Customers do
@moduledoc """
Main API for working with Customers at Stripe. Through this API you can:
-change subscriptions
-create invoices
-create customers
-delete single customer
-delete all customer
-count customers
Supports Connect workflow by allowing to pass in any API key exp... | lib/stripe/customers.ex | 0.828245 | 0.794943 | customers.ex | starcoder |
defmodule Day0601 do
def parse_line(line) do
line
|> String.split(",")
|> Enum.map(&String.trim/1)
|> Enum.map(&String.to_integer/1)
|> List.to_tuple
end
def taxi_dist({px, py}, {x, y}), do: abs(px-x) + abs(py-y)
def taxi_dist_closest(coordinates, p) do
{_d, winners} = coordinates
... | lib/day_0601.ex | 0.581303 | 0.525186 | day_0601.ex | starcoder |
defmodule Cldr.Number.Backend.Number do
@moduledoc false
def define_number_module(config) do
backend = config.backend
quote location: :keep, bind_quoted: [backend: backend, config: Macro.escape(config)] do
defmodule Number do
@moduledoc false
if Cldr.Config.include_module_docs?(confi... | lib/cldr/number/backend/number.ex | 0.926864 | 0.635053 | number.ex | starcoder |
defmodule Membrane.RTP.SilenceDiscarder do
@moduledoc """
Element responsible for dropping silent audio packets.
For a packet to be discarded it needs to contain a `RTP.HeaderExtension` struct in its
metadata under `:rtp` key. The header should contain information about audio level (VAD extension is required).... | lib/membrane/rtp/silence_discarder.ex | 0.817101 | 0.427606 | silence_discarder.ex | starcoder |
defmodule Spf do
@moduledoc """
Check SPF for a specific `sender` and possible options.
The `Spf.check/2` function takes a sender and possible options and returns an
evaluation [`context`](`t:Spf.Context.t/0`) that contains the verdict and
some statistics of the evaluation.
## Example
iex> unless F... | lib/spf.ex | 0.813794 | 0.630045 | spf.ex | starcoder |
defmodule Spear.PersistentSubscription do
@moduledoc """
A struct representing a persistent subscription and its settings
"""
require Spear.Records.Shared, as: Shared
require Spear.Records.Persistent, as: Persistent
@typedoc """
The action the EventStoreDB should take for an event's nack
* `:park` - ... | lib/spear/persistent_subscription.ex | 0.886758 | 0.531392 | persistent_subscription.ex | starcoder |
defmodule Nebulex.Adapters.Local do
@moduledoc ~S"""
Adapter module for Local Generational Cache; inspired by
[epocxy](https://github.com/duomark/epocxy).
Generational caching using an ets table (or multiple ones when used with
`:shards`) for each generation of cached data. Accesses hit the newer
generatio... | lib/nebulex/adapters/local.ex | 0.920337 | 0.754553 | local.ex | starcoder |
defmodule SurveyTool.ContentParser do
@moduledoc """
Responsible for parsing content in question and answer CSV files.
"""
alias SurveyTool.{RatingQuestion, SingleSelect, Survey}
@answers_range 3..-1
@rows_per_chunk 1
@question_error_message """
Could not generate report. Responses file contained \
... | lib/survey_tool/content_parser.ex | 0.813127 | 0.468365 | content_parser.ex | starcoder |
defmodule ExIcal.Recurrence do
@moduledoc """
Adds support for recurring events.
Events can recur by frequency, count, interval, and/or start/end date. To
see the specific rules and examples, see `add_recurring_events/2` below.
"""
alias ExIcal.Event
@doc """
Add recurring events to events list
##... | lib/ex_ical/recurrence.ex | 0.91764 | 0.563918 | recurrence.ex | starcoder |
defmodule Monad.Result do
@moduledoc """
A monad that represents success and failure conditions.
In a series of bind operations, if any function returns an error monad, the
following binds are skipped. This allows for easy flow control for both
success and error cases.
"""
@typedoc """
The possible ty... | lib/monad/result.ex | 0.892454 | 0.588061 | result.ex | starcoder |
defmodule Scidata.MNIST do
@moduledoc """
Module for downloading the [MNIST dataset](http://yann.lecun.com/exdb/mnist/).
"""
alias Scidata.Utils
@base_url "https://storage.googleapis.com/cvdf-datasets/mnist/"
@train_image_file "train-images-idx3-ubyte.gz"
@train_label_file "train-labels-idx1-ubyte.gz"
... | lib/scidata/mnist.ex | 0.776792 | 0.694626 | mnist.ex | starcoder |
defmodule Nx.Shared do
# A collection of **private** helpers and macros shared in Nx.
@moduledoc false
alias Nx.Tensor, as: T
## Macros
@doc """
Match the cartesian product of all given types.
A macro that allows us to writes all possibles match types
in the most efficient format. This is done by lo... | lib/nx/shared.ex | 0.800731 | 0.573619 | shared.ex | starcoder |
defmodule Legolas do
@moduledoc """
Legolas is a process message interceptor for debugging purposes, under the hood
it uses `dbg` to trace calls over a single process. All received messages to the process
are intercepted and sent to the designed collectors processes.
## Adding targets
In order to start, f... | lib/legolas.ex | 0.763307 | 0.614322 | legolas.ex | starcoder |
defmodule PhoenixFeathers.SideBar do
use PhoenixFeathers.LiveComponent
alias PhoenixFeathers.Icon
@doc """
Example
```
<%= live_component @socket,
PhoenixFeathers.SideBar,
id: "phoenix_feathers_side_bar",
is_open: false
do %>
<div>
My inner content
</div>
<% end %>... | lib/phoenix_feathers/components/side_bar.ex | 0.629433 | 0.541106 | side_bar.ex | starcoder |
defmodule Peptide do
@key_value_delimeter "="
@moduledoc """
Provides explicit and auto loading of env files.
## Example
The following will set the `FOO` environment variable with the value of `bar`.
```
foo=bar
```
You can define comments with `#` but can't use `#` in values without wrapping
t... | lib/peptide.ex | 0.807195 | 0.840062 | peptide.ex | starcoder |
defmodule Sherbet.Service.Contact.Communication.Method.Email.VerificationKey.Template do
@moduledoc """
Template used to create the email for verification email requests.
## Configuration
There are two configuration options for this template. The first is customising
the fields (sender, su... | apps/sherbet_service/lib/sherbet.service/contact/communication/method/email/verification_key/template.ex | 0.807916 | 0.409044 | template.ex | starcoder |
defmodule Auctoritas do
@moduledoc """
# Auctoritas
## Basic Usage
```elixir
iex> alias Auctoritas.AuthenticationManager, as: Auth
Auctoritas.AuthenticationManager
iex> auth_data = %{user_id: 123}
%{user_id: 123}
iex> {:ok, token} = Auth.authenticate(auth_data)
{:ok, "<KEY>"}
iex> {:ok, data}... | lib/auctoritas.ex | 0.787482 | 0.410874 | auctoritas.ex | starcoder |
defmodule SFSObject.Binary.Encoder do
def encode(data_wrapper, output \\ <<>>)
def encode({:null, _}, output) do
output <> <<0>>
end
def encode({:bool, v}, output) do
output <> <<1, encode_bool(v)>>
end
def encode({:byte, v}, output) do
output <> <<2, v::signed-size(8)>>
end
def encode({:... | lib/sfsobject/binary/encoder.ex | 0.513912 | 0.536434 | encoder.ex | starcoder |
defmodule Keyboards.Switch.Cherry do
use OpenSCAD
## Square Dimensions of a Cherry MX compatible switch
@keyswitch_width 14.4
@keyswitch_depth 14.4
## how wide/deep the walls are around the switch
@border 3
@y_translate (@border/2)+(@keyswitch_depth/2)
@x_translate (@border/2)+(@keyswitch_width/2)
... | lib/switch/cherry.ex | 0.541409 | 0.456289 | cherry.ex | starcoder |
defmodule YNAB.ParseResponse do
alias YNAB.ParseData
def parse(raw_response = %HTTPoison.Response{body: %{data: data}}) do
case data do
%{accounts: account_maps} ->
format_response(raw_response, ParseData.parse_accounts(account_maps))
%{account: account_map} ->
format_response(raw_... | lib/ynab/parse_response.ex | 0.534127 | 0.516717 | parse_response.ex | starcoder |
defmodule IndifferentAccess.Plug do
@moduledoc """
Several modes of indifferent access can be configured via the opts passed in to
a pipeline plug.
The default constructs a new IndifferentAccess.Params struct in place of Conn.params and Conn.query_params.
That struct has two behaviors, the default where any ... | lib/plug.ex | 0.793666 | 0.559049 | plug.ex | starcoder |
defmodule ExTimeAgo do
@moduledoc """
"xxx ago" past indicator from a previous project in 2019, ported to Elixir
"""
defmodule Timespan do
@moduledoc """
Millisecond-precise date and timespan
"""
@enforce_keys [:dt]
defstruct dt: {{0, 0, 0}, {0, 0, 0}}, ms: nil
@type t :: %__MODULE__{
... | apps/extimeago/lib/extimeago.ex | 0.768993 | 0.552751 | extimeago.ex | starcoder |
defmodule SMPPEX.ESME do
@moduledoc """
Module for implementing custom SMPP ESME entities.
`SMPPEX.ESME` represents a `GenServer` process which spawns and interacts with `SMPPEX.Session`
`ranch_protocol`. The session is spawned under control of `ranch` supervision tree.
The session makes all requests to the ... | lib/smppex/esme.ex | 0.840701 | 0.85318 | esme.ex | starcoder |
defmodule Analyzer do
import SumMag
@moduledoc """
Provides optimizer for anonymous functions.
"""
@doc """
iex> var = quote do [x] end
iex> Analyzer.parse(var)
[var: {:x, [], AnalyzerTest}]
"""
def parse(args) when is_list(args) do
func = fn node, asm ->
[supported?(node) | asm]
en... | lib/pelemay/analyzer.ex | 0.556882 | 0.482429 | analyzer.ex | starcoder |
defmodule Crux.Gateway.Command do
# credo:disable-for-this-file Credo.Check.Readability.SinglePipe
@moduledoc """
Builds [Gateway Commands](https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-commands).
Note: Only the sent ones can be found here.
A list of available op codes:
|... | lib/gateway/command.ex | 0.819207 | 0.463262 | command.ex | starcoder |
defmodule CloudflareStream do
require Logger
@opts_keys %{
# media
"TYPE" => :type,
"GROUP-ID" => :group_id,
"NAME" => :name,
"LANGUAGE" => :language,
"DEFAULT" => :default,
"AUTOSELECT" => :autoselect,
"URI" => :uri,
# extension
"EXT" => :extension,
# track info
"... | lib/cloudflare_stream.ex | 0.611962 | 0.58599 | cloudflare_stream.ex | starcoder |
defmodule ExPlasma do
@moduledoc """
Documentation for ExPlasma.
"""
alias ExPlasma.Transaction
alias ExPlasma.Transaction.TypeMapper
# constants that identify payment types, make sure that
# when we introduce a new payment type, you name it `paymentV2`
# https://github.com/omisego/plasma-contracts/bl... | lib/ex_plasma.ex | 0.862482 | 0.456834 | ex_plasma.ex | starcoder |
defmodule XDR do
@moduledoc """
Basic XDR usage
"""
@typedoc """
Because the protocol function signatures must match for all types,
arguments are sometimes unused. The `ignored()` type is used to annotate them.
"""
@type ignored() :: any()
alias XDR.Type.Const
@doc """
Build a concrete XDR type... | lib/xdr.ex | 0.920128 | 0.546678 | xdr.ex | starcoder |
defmodule SyncPrimitives.CountDownLatch do
@moduledoc """
A CountDownLatch expects `count` calls to `count_down/2` before calls to
`await/2` can continue.
A CountDownLatch is initialized with a `count`.
`await/2` blocks until the current count reaches 0 due to invocations of the
`count_down/2` method, aft... | lib/sync_primitives/count_down_latch.ex | 0.811003 | 0.434221 | count_down_latch.ex | starcoder |
defmodule ExDoc.Formatter.HTML.Autolink do
@moduledoc """
Conveniences for autolinking locals, types and more.
"""
import ExDoc.Formatter.HTML.Templates, only: [h: 1, enc_h: 1]
@elixir_docs "https://hexdocs.pm/"
@erlang_docs "http://www.erlang.org/doc/man/"
@basic_types_page "typespecs.html#basic-types"... | spec/fixtures/mix/deps/ex_doc/lib/ex_doc/formatter/html/autolink.ex | 0.625324 | 0.431464 | autolink.ex | starcoder |
defmodule QueryElf.Plugins.Preloader do
@moduledoc """
A module for preloading associations using joins.
Based on https://hexdocs.pm/ecto_preloader (licensed under WTFPL)
By default, Ecto preloads associations using a separate query for each association, which can degrade performance.
You could make it run... | lib/query_elf/plugins/preloader.ex | 0.792223 | 0.884788 | preloader.ex | starcoder |
defmodule Cldr.Calendar.Preference do
alias Cldr.LanguageTag
@territory_preferences Cldr.Config.calendar_preferences()
def territory_preferences do
@territory_preferences
end
def preferences_for_territory(territory) do
with {:ok, territory} <- Cldr.validate_territory(territory) do
territory_p... | lib/cldr/calendar/preference.ex | 0.884539 | 0.572842 | preference.ex | starcoder |
defmodule Artemis.Drivers.IBMCloudant.Request do
use HTTPoison.Base
require Logger
alias Artemis.Drivers.IBMCloudant
defmodule CloudantError do
defexception message: "IBM Cloudant Error"
end
@doc """
Wraps the HTTPoison.request/1 function.
# Params
Takes two additional params in addition to ... | apps/artemis/lib/artemis/drivers/ibm_cloudant/request.ex | 0.742235 | 0.445831 | request.ex | starcoder |
defmodule JQ do
@moduledoc """
Provides capability to run jq queries on elixir structures.
[jq docs](https://stedolan.github.io/jq/)
## Examples
iex> JQ.query(%{key: "value"}, ".key")
{:ok, "value"}
iex> JQ.query!(%{key: "value"}, ".key")
"value"
"""
alias JQ.{MaxByteSizeExceeded... | lib/jq.ex | 0.892848 | 0.47457 | jq.ex | starcoder |
alias Spear.{Connection.Response, Grpc, Rpc}
defmodule Grpc.Response do
@moduledoc false
# a structure and functions for turning a `Spear.Connection.Response` into
# a more friendly and usable data structure
defstruct [:status, :status_code, :message, :data]
# status code information and usages from
# h... | lib/spear/grpc/response.ex | 0.810366 | 0.406833 | response.ex | starcoder |
defmodule Mix.Tasks.Ggity.Visual.Scale.Color.Viridis do
@shortdoc "Launch a browser and draw sample plots using the Viridis color scale."
@moduledoc @shortdoc
use Mix.Task
import GGity.Element.{Line, Rect}
alias GGity.{Examples, Labels, Plot}
@default_browser "firefox"
@doc false
@spec run(list(any)... | lib/mix/tasks/ggity_visual_scale_color_viridis.ex | 0.836388 | 0.433981 | ggity_visual_scale_color_viridis.ex | starcoder |
defmodule Benchee.Benchmark.Scenario do
@moduledoc """
A Scenario in Benchee is a particular case of a whole benchmarking suite. That
is the combination of a particular function to benchmark (`job_name` and
`function`) in combination with a specific input (`input_name` and `input`).
It then gathers all data ... | lib/benchee/benchmark/scenario.ex | 0.851104 | 0.816662 | scenario.ex | starcoder |
defmodule Portal do
@moduledoc """
Create a Portal with two colored doors for transferring data.
"""
alias Portal.Door
@doc """
The `left` and `right` doors of the Portal.
"""
defstruct [:left, :right]
@doc """
Create a new Portal door with given `color` in the supervisor.
Returns `{:ok, pid}`... | lib/portal.ex | 0.921939 | 0.881155 | portal.ex | starcoder |
defmodule GenWorker do
@moduledoc ~S"""
Generic Worker behavior that helps to run task at a specific time with a specified frequency.
## Usage
Define you worker module
```elixir
defmodule MyWorker do
use GenWorker, run_at: [hour: 13, minute: 59], run_each: [days: 1]
def run(_prev_args) do
I... | lib/gen_worker.ex | 0.848078 | 0.839405 | gen_worker.ex | starcoder |
defmodule ExHmac do
@moduledoc ~S"""
HMAC Authentication
## Example
This Example Project is the basis for ExHmac, help you use well.
Download via [Gitee](https://gitee.com/lizhaochao/exhmac_example) or [Github](https://github.com/lizhaochao/exhmac_example).
Once downloaded, Two Things Todo:
```bash
m... | lib/exhmac.ex | 0.851753 | 0.859723 | exhmac.ex | starcoder |
defmodule AWS.Batch do
@moduledoc """
AWS Batch enables you to run batch computing workloads on the AWS Cloud.
Batch computing is a common way for developers, scientists, and engineers to
access large amounts of compute resources, and AWS Batch removes the
undifferentiated heavy lifting of configuring and m... | lib/aws/generated/batch.ex | 0.893852 | 0.792002 | batch.ex | starcoder |
defmodule ElixirRigidPhysics.Dynamics do
@moduledoc """
Dynamics module responsible for handling physics stepping and substepping of a world.
"""
alias ElixirRigidPhysics.World
alias ElixirRigidPhysics.Collision.Broadphase
alias ElixirRigidPhysics.Collision.Narrowphase
alias Graphmath.Vec3
alias Graphm... | lib/dynamics/dynamics.ex | 0.885928 | 0.472623 | dynamics.ex | starcoder |
defmodule ExUnit do
@moduledoc """
Unit testing framework for Elixir.
## Example
A basic setup for ExUnit is shown below:
# File: assertion_test.exs
# 1) Start ExUnit.
ExUnit.start()
# 2) Create a new test module (test case) and use "ExUnit.Case".
defmodule AssertionTest do
... | lib/ex_unit/lib/ex_unit.ex | 0.84489 | 0.83346 | ex_unit.ex | starcoder |
defmodule Adapter do
@moduledoc """
Documentation for `Adapter`.
"""
@default_app :adapter
@default_mode :compile
@default_log :debug
@default_random true
@default_validate true
@typedoc ~S"""
`:app` and `:key`.
"""
@type option ::
{:app, atom}
| {:key, atom}
| {... | lib/adapter.ex | 0.867471 | 0.564459 | adapter.ex | starcoder |
defmodule PaperTrail.VersionQueries do
import Ecto.Query
alias PaperTrail.Version
@repo PaperTrail.RepoClient.repo()
@doc """
Gets all the versions of a record.
"""
@spec get_versions(record :: Ecto.Schema.t()) :: Ecto.Query.t()
def get_versions(record), do: get_versions(record, [])
@doc """
Gets... | lib/paper_trail/version_queries.ex | 0.785679 | 0.53127 | version_queries.ex | starcoder |
defmodule MazesWeb.MazeHelper do
alias Mazes.MazeColors
# doesn't matter that much because the svg is responsive
# but affects how stroke looks like
def max_svg_width, do: 1000
def svg_padding, do: 16
def show_solution?(settings, solution) do
settings.show_solution && is_list(solution) && Enum.count(... | lib/mazes_web/views/maze_helper.ex | 0.628521 | 0.433981 | maze_helper.ex | starcoder |
defmodule Credo.Check.Readability.PreferUnquotedAtoms do
use Credo.Check,
run_on_all: true,
base_priority: :high,
elixir_version: "< 1.7.0-dev",
explanations: [
check: """
Prefer unquoted atoms unless quotes are necessary.
This is helpful because a quoted atom can be easily mistaken ... | lib/credo/check/readability/prefer_unquoted_atoms.ex | 0.520984 | 0.421403 | prefer_unquoted_atoms.ex | starcoder |
defmodule OpenTelemetry.Span do
@moduledoc """
This module contains macros for Span operations that update the active current Span in the current process.
An example of creating an Event and adding it to the current Span:
require OpenTelemetry.Span
...
event = "ecto.query"
ecto_attributes... | apps/opentelemetry_api/lib/open_telemetry/span.ex | 0.849815 | 0.458591 | span.ex | starcoder |
defmodule PhoenixLiveReact do
@moduledoc """
Render React.js components in Phoenix LiveView views.
"""
import Phoenix.HTML
import Phoenix.HTML.Tag
@doc """
Render a react component in a live view.
```
<%= PhoenixLiveReact.live_react_component("Components.MyComponent", %{name: "Bob"}, id: "my-compon... | lib/phoenix_live_react.ex | 0.784979 | 0.716144 | phoenix_live_react.ex | starcoder |
defmodule Framer do
@moduledoc ~S"""
Module contains helper functions to resize iodata streams and lists.
The two main functions are:
- `resize_stream/2` for resizing an iodata stream
- `resize/2` for resizing iodata
## Examples
Resizing a iodata stream:
iex> stream = ["The brown", " fox", ["tha... | lib/framer.ex | 0.892615 | 0.706811 | framer.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.