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 Remedy.Schema.Component do
@moduledoc """
Components are a framework for adding interactive elements to the messages your app or bot sends. They're accessible, customizable, and easy to use. There are several different types of components; this documentation will outline the basics of this new framework a... | components/component.ex | 0.873512 | 0.734715 | component.ex | starcoder |
defmodule Rolodex.Headers do
@moduledoc """
Exposes functions and macros for defining reusable headers in route doc
annotations or responses.
It exposes the following macros, which when used together will set up the headers:
- `headers/2` - for declaring the headers
- `header/3` - for declaring a single h... | lib/rolodex/headers.ex | 0.873674 | 0.534612 | headers.ex | starcoder |
defmodule Exchange do
@moduledoc """
The best Elixir Exchange supporting limit and market orders. Restful API and fancy dashboard supported soon!
"""
@doc """
Places an order on the Exchange
## Parameters
- order_params: Map that represents the parameters of the order to be placed
- ticker: Atom ... | lib/exchange.ex | 0.898819 | 0.732879 | exchange.ex | starcoder |
defmodule Janus do
@moduledoc """
Core public API for `Janus`.
There are two foundational components this graph query language
is built upon: fully namespaced property names, and resolving
functions with specified inputs and outputs (i.e. resolvers).
## Fully Namespaced Property Names
Let's look at an ... | lib/janus.ex | 0.871591 | 0.739446 | janus.ex | starcoder |
defmodule Animu.Media.Anime.Video do
@moduledoc """
Stores video metadata from ffprobe plus the location of the file.
Should be immutable after initial generation.
"""
use Animu.Ecto.Schema
alias __MODULE__
@derive Jason.Encoder
embedded_schema do
field :filename, :string
field :dir, ... | lib/animu/media/anime/video.ex | 0.754599 | 0.415017 | video.ex | starcoder |
defmodule StarWars.GraphQL.DB do
@moduledoc """
DB is a "in memory" database implemented with Elixir.Agent to support the [Relay Star Wars example](https://github.com/relayjs/relay-examples/blob/master/star-wars)
NOTICE: in the original example the format of the data is id => name where name is a string.
"""
... | apps/star_wars/graphql/db.ex | 0.778986 | 0.404625 | db.ex | starcoder |
defmodule Flawless.Spec do
@moduledoc """
A structure for defining the spec of a schema element.
The `for` attribute allows to define type-specific specs.
"""
defstruct checks: [],
late_checks: [],
type: :any,
cast_from: [],
nil: :default,
on_error:... | lib/flawless/spec.ex | 0.899296 | 0.670072 | spec.ex | starcoder |
defmodule Timex.DateFormat do
@moduledoc """
Date formatting and parsing.
This module provides an interface and core implementation for converting date
values into strings (formatting) or the other way around (parsing) according
to the specified template.
Multiple template formats are supported, each one ... | lib/date/date_format.ex | 0.919706 | 0.608943 | date_format.ex | starcoder |
defmodule OAuth2TokenManager.Store.Local do
@default_cleanup_interval 15
@moduledoc """
Simple token store using ETS and DETS
Access tokens are stored in an ETS, since they can easily be renewed with an access
token. Refresh tokens and claims are stored in DETS.
This implementation is probably not suited... | lib/oauth2_token_manager/store/local.ex | 0.777638 | 0.54468 | local.ex | starcoder |
defmodule Day16 do
def part1(input) do
{rules, _, nearby} = parse(input)
rules = flatten_rules(rules)
nearby
|> List.flatten()
|> Enum.filter(fn field ->
not valid_field?(field, rules)
end)
|> Enum.sum
end
def part2(input) do
{rules, yours, nearby} = parse(input)
nearby ... | day16/lib/day16.ex | 0.624408 | 0.532243 | day16.ex | starcoder |
defmodule Similarity.Cosine do
@moduledoc """
A struct that can be used to accumulate ids & attributes and calcuate similarity between them.
"""
alias Similarity.Cosine
defstruct attributes_counter: 0, attributes_map: %{}, map: %{}
@doc """
Returns a new `%Cosine{}` struct to be first used with `add/3`... | lib/similarity/cosine.ex | 0.90445 | 0.50592 | cosine.ex | starcoder |
defmodule Ello.V3.Schema.DiscoveryTypes do
use Absinthe.Schema.Notation
alias Ello.V3.Resolvers
object :category do
field :id, :id
field :name, :string
field :slug, :string
field :level, :string
field :order, :integer
field :description, :string
field :tile_image, :tshirt_image_versio... | apps/ello_v3/lib/ello_v3/schema/discovery_types.ex | 0.574872 | 0.537223 | discovery_types.ex | starcoder |
defmodule Central.Helpers.StructureHelper do
@moduledoc """
A module to make import/export of JSON objects easier. Currently only tested with a single parent object and multiple sets of child objects.
Designed to not take the IDs with it as they are liable to change based on the database they go into.
"""
ali... | lib/central/helpers/structure_helper.ex | 0.663124 | 0.514827 | structure_helper.ex | starcoder |
defmodule Relay.Marathon.App do
@moduledoc """
Turns Marathon API JSON into consistent App objects.
"""
alias Relay.Marathon.{Labels, Networking}
@enforce_keys [:id, :networking_mode, :ports_list, :port_indices, :labels, :version]
defstruct [:id, :networking_mode, :ports_list, :port_indices, :labels, :ver... | lib/relay/marathon/app.ex | 0.797833 | 0.415847 | app.ex | starcoder |
defmodule Membrane.Element.Action do
@moduledoc """
This module contains type specifications of actions that can be returned
from element callbacks.
Returning actions is a way of element interaction with
other elements and parts of framework. Each action may be returned by any
callback (except for `c:Membr... | lib/membrane/element/action.ex | 0.968036 | 0.573141 | action.ex | starcoder |
defmodule AWS.CodeBuild do
@moduledoc """
CodeBuild is a fully managed build service in the cloud.
CodeBuild compiles your source code, runs unit tests, and produces artifacts
that are ready to deploy. CodeBuild eliminates the need to provision, manage,
and scale your own build servers. It provides prepacka... | lib/aws/generated/code_build.ex | 0.78842 | 0.431704 | code_build.ex | starcoder |
defmodule ParseClient do
@moduledoc """
REST API client for Parse in Elixir
## Example usage
To get information about an object (and print out the whole response):
ParseClient.get("classes/Lumberjacks")
To just see the body, use the `query` function:
ParseClient.query("classes/Lumberjacks")
... | lib/parse_elixir_client.ex | 0.842653 | 0.514949 | parse_elixir_client.ex | starcoder |
defmodule StreamSplit do
@enforce_keys [:continuation, :stream]
defstruct @enforce_keys
@doc """
This function is a combination of `Enum.take/2` and `Enum.drop/2` returning
first `n` dropped elements and the rest of the enum as a stream.
The important difference is that the enumerable is only iterated onc... | lib/stream_split.ex | 0.840864 | 0.663742 | stream_split.ex | starcoder |
defmodule Nx.Defn do
@moduledoc ~S"""
Numerical functions.
A numerical function is a subset of Elixir tailored for
numerical computations. For example, the following function:
defn add_and_mult(a, b, c) do
a * b + c
end
will work with scalars, vector, matrices, and n-dimensional
tenso... | lib/nx/defn.ex | 0.926304 | 0.843895 | defn.ex | starcoder |
defmodule Membrane.FLV.Muxer do
@moduledoc """
Element for muxing AAC and H264 streams into FLV format.
Input pads are dynamic, but you nend to connect them before transitioning to state `playing`.
Due to limitations of the FLV format, only one audio and one video stream can be muxed and they both need to hav... | lib/membrane_flv_plugin/muxer.ex | 0.84338 | 0.456773 | muxer.ex | starcoder |
defmodule Phoenix.PubSub do
@moduledoc """
Front-end to Phoenix pubsub layer.
Used internally by Channels for pubsub broadcast but
also provides an API for direct usage.
## Adapters
Phoenix pubsub was designed to be flexible and support
multiple backends. We currently ship with two backends:
... | deps/phoenix_pubsub/lib/phoenix/pubsub.ex | 0.908634 | 0.430207 | pubsub.ex | starcoder |
defmodule Absinthe.Resolution.Helpers do
@moduledoc """
Handy functions for returning async or batched resolution functions
Using `Absinthe.Schema.Notation` or (by extension) `Absinthe.Schema` will
automatically import the `batch` and `async` helpers. Dataloader helpers
require an explicit `import Absinthe.R... | lib/absinthe/resolution/helpers.ex | 0.905431 | 0.769102 | helpers.ex | starcoder |
defmodule Ash.OptionsHelpers do
@type schema :: NimbleOptions.schema()
@moduledoc false
def merge_schemas(left, right, section \\ nil) do
new_right =
Enum.map(right, fn {key, value} ->
{key, Keyword.put(value, :subsection, section)}
end)
Keyword.merge(left, new_right)
end
def va... | lib/ash/options_helpers.ex | 0.681939 | 0.408837 | options_helpers.ex | starcoder |
defmodule Membrane.RawVideo.Parser do
@moduledoc """
Simple module responsible for splitting the incoming buffers into
frames of raw (uncompressed) video frames of desired format.
The parser sends proper caps when moves to playing state.
No data analysis is done, this element simply ensures that
the result... | lib/membrane_raw_video/parser.ex | 0.877247 | 0.555918 | parser.ex | starcoder |
defmodule Stripe.Webhook do
@moduledoc """
Creates a Stripe Event from webhook's payload if signature is valid.
"""
@default_tolerance 300
@expected_scheme "v1"
@doc """
Verify webhook payload and return a Stripe event.
`payload` is the raw, unparsed content body sent by Stripe, which can be
retrie... | lib/stripe/webhook.ex | 0.892331 | 0.60577 | webhook.ex | starcoder |
defmodule Forage.Codec.Decoder do
@moduledoc """
Functionality to decode a Phoenix `params` map into a form suitable for use
with the query builders and pagination libraries
"""
alias Forage.Codec.Exceptions.InvalidAssocError
alias Forage.Codec.Exceptions.InvalidFieldError
alias Forage.Codec.Exceptions.In... | lib/forage/codec/decoder.ex | 0.77949 | 0.578061 | decoder.ex | starcoder |
defmodule Chess.Utils do
@moduledoc """
"""
alias Chess.{Figure}
defmacro __using__(_opts) do
quote do
defp coordinates(move_from), do: String.split(move_from, "", trim: true)
defp opponent("w"), do: "b"
defp opponent(_), do: "w"
defp define_active_figures(squares, active) do
... | lib/chess/utils/utils.ex | 0.729327 | 0.625824 | utils.ex | starcoder |
defmodule Kitt.Message.PSM do
@moduledoc """
Defines the structure and instantiation function
for creating a J2735-compliant PersonalSafetyMessage.
A `PSM` defines the information exchanged between non-vehicle
actors within a DSRC-capable environment and the vehicles
and infrastructure of the environment
... | lib/kitt/message/psm.ex | 0.782538 | 0.673051 | psm.ex | starcoder |
defmodule Grizzly.SmartStart.MetaExtension.UUID16 do
@moduledoc """
This is used to advertise 16 bytes of manufactured-defined information that
is unique for a given product.
Z-Wave UUIDs are not limited to the format outlined in RFC 4122 but can also
be ASCII characters and a relevant prefix.
"""
@type... | lib/grizzly/smart_start/meta_extension/uuid16.ex | 0.88631 | 0.590012 | uuid16.ex | starcoder |
defmodule Advent20.GameConsole do
@moduledoc """
Day 8: Handheld Halting
"""
defp parse_input(input) do
input
|> String.split("\n", trim: true)
|> Stream.map(&Regex.run(~r/(.{3}) (.+)$/, &1, capture: :all_but_first))
|> Stream.map(fn [instruction, string_value] -> {instruction, String.to_intege... | lib/advent20/08_game_console.ex | 0.755096 | 0.586671 | 08_game_console.ex | starcoder |
defmodule Model.Stop do
@moduledoc """
Stop represents a physical location where the transit system can pick up or drop off passengers. See
[GTFS `stops.txt`](https://github.com/google/transit/blob/master/gtfs/spec/en/reference.md#stopstxt)
"""
use Recordable, [
:id,
:name,
:description,
:ad... | apps/model/lib/model/stop.ex | 0.91715 | 0.74468 | stop.ex | starcoder |
defmodule Typo.Utils.PageSize do
@moduledoc false
import Typo.Utils.Guards
@page_sizes %{
# a-series
"a0" => {2380, 3368},
"a1" => {1684, 2380},
"a2" => {1190, 1684},
"a3" => {842, 1190},
"a4" => {595, 842},
"a5" => {421, 595},
"a6" => {297, 421},
"a7" => {210, 297},
"a8... | lib/typo/utils/page_size.ex | 0.708616 | 0.408277 | page_size.ex | starcoder |
defmodule Elixpath do
# Import some example from README.md to run doctests.
# Make sure to touch (i.e. update timestamp of) this file
# when editing examples in README.md.
readme = File.read!(__DIR__ |> Path.expand() |> Path.dirname() |> Path.join("README.md"))
[examples] = Regex.run(~r/##\s*Examples.+/s, rea... | lib/elixpath.ex | 0.813794 | 0.432663 | elixpath.ex | starcoder |
defmodule DBConnection.Proxy do
@moduledoc """
A behaviour module for implementing a proxy module during the check out of a
connection.
`DBConnection.Proxy` callback modules can wrap a `DBConnection` callback
module and state while it is outside the pool.
"""
@doc """
Setup the initial state of the pr... | deps/db_connection/lib/db_connection/proxy.ex | 0.893864 | 0.608769 | proxy.ex | starcoder |
defmodule Segment.Analytics.Batch do
@derive [Poison.Encoder]
defstruct [
:batch,
:sentAt
]
end
defmodule Segment.Analytics.Track do
@derive [Poison.Encoder]
@method "track"
defstruct [
:anonymousId,
:context,
:event,
:messageId,
:properties,
:timestamp,
:userId,
:... | lib/segment/analytics/model.ex | 0.679498 | 0.491029 | model.ex | starcoder |
defmodule Gringotts.Adapter do
@moduledoc """
Validates the "required" configuration.
All gateway modules must `use` this module, which provides a run-time
configuration validator.
Gringotts picks up the merchant's Gateway authentication secrets from the
Application config. The configuration validator can... | lib/gringotts/adapter.ex | 0.89093 | 0.774626 | adapter.ex | starcoder |
defmodule AWS.FraudDetector do
@moduledoc """
This is the Amazon Fraud Detector API Reference.
This guide is for developers who need detailed information about Amazon Fraud
Detector API actions, data types, and errors. For more information about Amazon
Fraud Detector features, see the [Amazon Fraud Detector... | lib/aws/generated/fraud_detector.ex | 0.883041 | 0.481027 | fraud_detector.ex | starcoder |
defmodule GrovePi.PivotPi.PCA9685 do
alias GrovePi.Board
use Bitwise
@moduledoc """
This module provides lower level functions to interact with the
[PivotPi](https://www.dexterindustries.com/pivotpi-tutorials-documentation/)
through the [GrovePi](https://www.dexterindustries.com/grovepi/). Most users
sh... | lib/grovepi/pivotpi/PCA9685.ex | 0.784236 | 0.519217 | PCA9685.ex | starcoder |
defmodule AWS.ApplicationAutoScaling do
@moduledoc """
With Application Auto Scaling, you can configure automatic scaling for the
following resources:
* Amazon AppStream 2.0 fleets
* Amazon Aurora Replicas
* Amazon Comprehend document classification and entity recognizer
endpoints
* Amazon ... | lib/aws/generated/application_auto_scaling.ex | 0.930268 | 0.668163 | application_auto_scaling.ex | starcoder |
defmodule ReadDoc.Options do
use ReadDoc.Types
defstruct begin_trigger:
~s{\\A \\s* <!-- \\s+ begin \\s @doc \\s ([\\w.?!]+) \\s+ --> \\s* \\z },
end_trigger: ~s{\\A \\s* <!-- \\s+ end \\s @doc \\s ([\\w.?!]+) \\s+ --> \\s* \\z },
keep_copy: false,
silent: false,
... | lib/read_doc/options.ex | 0.65368 | 0.55438 | options.ex | starcoder |
defmodule HSLuv do
@moduledoc """
Convert colors between HSLuv and RGB color spaces
"""
import :math
@min_f 0.00000001
@max_f 99.9999999
@m {
{3.240969941904521, -1.537383177570093, -0.498610760293},
{-0.96924363628087, 1.87596750150772, 0.041555057407175},
{0.055630079696993, -0.2039769588... | lib/hsluv.ex | 0.912924 | 0.463869 | hsluv.ex | starcoder |
defmodule Exconfig do
@moduledoc """
The module _Exconfig_ provides the API for the Exconfig-package.
This is
- `get/0` ... get all cached settings
- `get/3` ... get a specific entry (read if not cached) [macro]
- and `clear_cache!/0` ... remove all entries from the cache
All usage of `Exconfig.g... | lib/exconfig.ex | 0.85315 | 0.406273 | exconfig.ex | starcoder |
defmodule StepFlow.WorkflowDefinitions do
@moduledoc """
The WorkflowDefinitions context.
"""
import Ecto.Query, warn: false
alias StepFlow.Repo
alias StepFlow.WorkflowDefinitions.WorkflowDefinition
require Logger
@doc """
Returns the list of Workflow Definitions.
"""
def list_workflow_definitio... | lib/step_flow/workflow_definitions/workflow_definitions.ex | 0.746693 | 0.531757 | workflow_definitions.ex | starcoder |
defmodule CFXXL.CertUtils do
@moduledoc """
A module containing utility functions to extract informations from PEM certificates
"""
@aki_oid {2, 5, 29, 35}
@common_name_oid {2, 5, 4, 3}
@z_char 90
require Record
Record.defrecordp(
:certificate,
:Certificate,
Record.extract(:Certificate, ... | lib/cfxxl/cert_utils.ex | 0.871174 | 0.491395 | cert_utils.ex | starcoder |
defmodule AWS.GameLift do
@moduledoc """
Amazon GameLift Service
GameLift provides solutions for hosting session-based multiplayer game
servers in the cloud, including tools for deploying, operating, and scaling
game servers. Built on AWS global computing infrastructure, GameLift helps
you deliver high-pe... | lib/aws/generated/game_lift.ex | 0.876634 | 0.730398 | game_lift.ex | starcoder |
defmodule Hitbtc.Socket do
alias Hitbtc.Socket.Conn
@type request_id :: binary
@doc """
Open new Websocket connection to HitBTC server
Parameter is process that will receive all notifications from WS
The `consumer_pid` of the process can be set using
the `consumer_pid` argument and defaults to the call... | lib/hitbtc/socket.ex | 0.832441 | 0.601067 | socket.ex | starcoder |
defmodule CoursePlanner.Classes do
@moduledoc """
This module provides custom functionality for controller over the model
"""
import Ecto.Changeset
import Ecto.Query
alias CoursePlanner.{Repo, Classes.Class, Notifications.Notifier, Notifications, Settings}
alias CoursePlanner.Terms.Term
alias Ecto.{Cha... | lib/course_planner/classes/classes.ex | 0.71123 | 0.413033 | classes.ex | starcoder |
defmodule RigOutboundGateway.Kafka.GroupSubscriber do
@moduledoc """
A group subscriber that handles all assignments (i.e., all topic-partitions
this group subscriber is assigned to by the broker). Incoming messages are
handled in partition handlers that run in subprocesses (they're spawned in
`init`).
Sca... | apps/rig_outbound_gateway/lib/rig_outbound_gateway/kafka/group_subscriber.ex | 0.811676 | 0.488893 | group_subscriber.ex | starcoder |
defmodule Exnoops.Mazebot do
@moduledoc """
Module to interact with Github's Noop: Mazebot
See the [official `noop` documentation](https://noopschallenge.com/challenges/mazebot) for API information including the accepted parameters.
"""
require Logger
import Exnoops.API
@noop "mazebot"
@doc ~S"""
... | lib/exnoops/mazebot.ex | 0.587233 | 0.561275 | mazebot.ex | starcoder |
defmodule XlsxReader do
@moduledoc """
Opens XLSX workbook and reads its worksheets.
## Example
```elixir
{:ok, package} = XlsxReader.open("test.xlsx")
XlsxReader.sheet_names(package)
# ["Sheet 1", "Sheet 2", "Sheet 3"]
{:ok, rows} = XlsxReader.sheet(package, "Sheet 1")
# [
# ["Date", "Temper... | lib/xlsx_reader.ex | 0.944074 | 0.906942 | xlsx_reader.ex | starcoder |
defmodule Oban.Worker do
@moduledoc """
Defines a behavior and macro to guide the creation of worker modules.
Worker modules do the work of processing a job. At a minimum they must define a `perform/1`
function, which will be called with an `args` map.
## Defining Workers
Define a worker to process jobs ... | lib/oban/worker.ex | 0.82573 | 0.561425 | worker.ex | starcoder |
defmodule Ecto.Query.JoinBuilder do
@moduledoc false
alias Ecto.Query.BuilderUtil
alias Ecto.Query.Query
alias Ecto.Query.QueryExpr
alias Ecto.Query.JoinExpr
@doc """
Escapes a join expression (not including the `on` expression).
It returns a tuple containing the binds, the on expression (if availabl... | lib/ecto/query/join_builder.ex | 0.855776 | 0.457258 | join_builder.ex | starcoder |
defmodule Elixoids.Collision.Server do
@moduledoc """
Simplistic collision detections.
Runs as a separate process to avoid slowing game loop in busy screens.
Tests everything against everything else - no bounding boxes or culling.
A bullet may take out multiple ships, or multiple asteroids, but not both a shi... | lib/elixoids/collision/server.ex | 0.8339 | 0.537466 | server.ex | starcoder |
defmodule RemoteIp.Headers do
@moduledoc """
Functions for parsing IPs from multiple types of forwarding headers.
"""
@doc """
Extracts all headers with the given names.
Note that `Plug.Conn` headers are assumed to have been normalized to
lowercase, so the names you give should be in lowercase as well.
... | lib/remote_ip/headers.ex | 0.913907 | 0.547162 | headers.ex | starcoder |
defmodule ComplexNumber do
@moduledoc """
Functions for complex number operations.
"""
@pi :math.pi()
@type t :: number | %ComplexNumber{radius: number, theta: number}
defstruct [:radius, :theta]
@doc """
Checks if the argument is a complex (including real) number or not.
iex> ComplexNumber.is_c... | lib/complex_number.ex | 0.932699 | 0.637299 | complex_number.ex | starcoder |
defmodule ExPng.Image do
@moduledoc """
The primary API module for `ExPng`, `ExPng.Image` provides functions for
reading, editing, and saving images.
"""
alias ExPng.Image.{Decoding, Drawing, Encoding}
alias ExPng.{Color, RawData}
@type row :: [Color.t(), ...]
@type canvas :: [row, ...]
@type t :: %... | lib/ex_png/image.ex | 0.928668 | 0.610831 | image.ex | starcoder |
defmodule Samples.FormatterPlugin do
@behaviour Mix.Tasks.Format
@line_break ["\n", "\r\n", "\r"]
def features(_opts) do
[extensions: [".ex", ".exs"]]
end
def format(code, opts) do
formatted_code =
code
|> Code.format_string!(opts)
|> to_string()
|> format_samples()
for... | lib/formatter_plugin.ex | 0.569254 | 0.512693 | formatter_plugin.ex | starcoder |
defmodule ApiWeb.Plugs.ModifiedSinceHandler do
@moduledoc """
Checks for the `If-Modified-Since` header.
Whenever the header is found, the value is parsed and compared to a the value
returned from an expected state module. If a resource hasn't been updated
since the provided timestamp, a 304 status is given.... | apps/api_web/lib/api_web/plugs/modified_since_handler.ex | 0.823435 | 0.534248 | modified_since_handler.ex | starcoder |
defmodule FTTZ do
@hours 0..23
@daytime 8..20
def stats(screen_name, scale \\ :log10) do
data = screen_name |> times
data |> timezone
IO.puts "\nTweet distribution throughout the day (at UTC±00:00):\n"
data |> graph(scale)
end
defp times(screen_name) do
timeline(screen_name)
|> St... | lib/fttz.ex | 0.550124 | 0.40645 | fttz.ex | starcoder |
defmodule GGity.Scale.Shape do
@moduledoc false
alias GGity.{Draw, Labels}
alias GGity.Scale.Shape
@palette_values [:circle, :triangle, :square, :plus, :square_cross]
defstruct transform: nil,
levels: nil,
labels: :waivers,
guide: :legend
@type t() :: %__MODULE__{}
... | lib/ggity/scale/shape.ex | 0.832849 | 0.449091 | shape.ex | starcoder |
defmodule TrentoWeb.OpenApi.Schema.ChecksCatalog do
@moduledoc false
require OpenApiSpex
alias OpenApiSpex.Schema
alias TrentoWeb.OpenApi.Schema.Provider
defmodule Check do
@moduledoc false
OpenApiSpex.schema(%{
title: "Check",
description: "An available check to be executed on the tar... | lib/trento_web/openapi/schema/checks_catalog.ex | 0.799521 | 0.463626 | checks_catalog.ex | starcoder |
defmodule Classifiers.Perceptron.Average do
defstruct weights: %{},
edges: %{},
count: 0,
epoch: 0
@stream_chunks 10
@doc """
Get a new classifier pid.
"""
def new do
{:ok, pid} = Agent.start_link fn ->
%Classifiers.Perceptron.Average{}
end
pid
en... | lib/classifiers/perceptron/average.ex | 0.839931 | 0.666166 | average.ex | starcoder |
defmodule Toby.Data.Server do
@moduledoc """
A caching layer on top of `Toby.Data.Provider` so that system information can
be retrieved on an interval independent of the window refresh rate.
"""
use GenServer
alias Toby.Data.{Provider, Samples}
@cache_ms 2000
def start_link(_) do
GenServer.start... | lib/toby/data/server.ex | 0.844714 | 0.454412 | server.ex | starcoder |
defmodule Vix.Vips.Image do
defstruct [:ref]
alias __MODULE__
@moduledoc """
Vips Image
"""
alias Vix.Type
alias Vix.Nif
@behaviour Type
@typedoc """
Represents an instance of libvips image
"""
@type t() :: %Image{ref: reference()}
@impl Type
def typespec do
quote do
unquote(... | lib/vix/vips/image.ex | 0.917585 | 0.851768 | image.ex | starcoder |
defmodule Zaryn.Governance.Code.Proposal do
@moduledoc """
Represents a proposal for code changes
"""
alias __MODULE__.Parser
alias Zaryn.Crypto
alias Zaryn.TransactionChain.Transaction
alias Zaryn.TransactionChain.Transaction.ValidationStamp
alias Zaryn.TransactionChain.TransactionData
defstruct ... | lib/zaryn/governance/code/proposal.ex | 0.851274 | 0.404566 | proposal.ex | starcoder |
defmodule Calypte.Rule do
@moduledoc """
Execution of a rule. Works as interpreter at the moment.
"""
alias Calypte.Ast.{Expr, Var, Value}
alias Calypte.{Binding, Changeset, Rule, Utils}
import Utils
@type id :: term()
@type exec_id :: {id(), Binding.hash()}
defstruct id: nil, if: nil, vars: %{}, t... | lib/calypte/rule.ex | 0.752922 | 0.477371 | rule.ex | starcoder |
defmodule Graph.Pathfindings.Dijkstra do
@moduledoc """
This module contains implementation code for path finding algorithms used by `libgraph`.
"""
import Graph.Utils, only: [vertex_id: 1, edge_weight: 3]
@type heuristic_fun :: (Graph.vertex() -> integer)
@compile {:inline, do_bfs: 4, construct_path: 3, ... | lib/graph/pathfindings/dijkstra.ex | 0.874681 | 0.719211 | dijkstra.ex | starcoder |
defmodule BoggleEngine do
@moduledoc """
Boggle board generator and solver.
Versions:
* `:boggle` - 4x4
* `:big_boggle` - 5x5
* `:super_big_boggle` - 6x6
Rules:
* `:standard` - All neighbors are valid
* `:edge` - Only edge neighbors
* `:corner` - Only corner neighbors
* `:wrap` - Out of bo... | lib/boggle_engine.ex | 0.92462 | 0.761893 | boggle_engine.ex | starcoder |
defmodule Wand.Mode do
@type t :: :caret | :tilde | :exact | :custom
@type requirement :: String.t() | {:latest, t}
@type version :: String.t() | :latest | Version.t()
@no_patch ~r/^(\d+)\.(\d+)($|\+.*$|-.*$)/
@moduledoc """
Each requirement in a wand.json follows some type of pattern. An exact pattern is ... | lib/mode.ex | 0.827759 | 0.407599 | mode.ex | starcoder |
alias Graphqexl.Schema
alias Graphqexl.Schema.{
Argument,
Field,
Interface,
Mutation,
Query,
Ref,
Subscription,
TEnum,
Type,
Union,
}
alias Graphqexl.Tokens
alias Treex.Tree
defmodule Graphqexl.Schema.Dsl do
@moduledoc """
Domain-Specific Language for expressing and parsing a GQL string as a `t... | lib/graphqexl/schema/dsl.ex | 0.713631 | 0.619068 | dsl.ex | starcoder |
defmodule RRPproxy do
@moduledoc """
Documentation for `RRPproxy` which provides API for rrpproxy.net.
## Installation
This package can be installed by adding `rrpproxy` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:rrpproxy, "~> 0.1.7"}
]
end
```
## Configurat... | lib/rrpproxy.ex | 0.886285 | 0.836087 | rrpproxy.ex | starcoder |
defmodule Membrane.Element.LiveAudioMixer do
@moduledoc """
An element producing live audio stream by mixing a dynamically changing
set of input streams.
When the mixer goes to `:playing` state it sends some silence
(configured by `out_delay` see the [docs for options](#module-element-options)).
From that ... | lib/mixer.ex | 0.899865 | 0.657043 | mixer.ex | starcoder |
defmodule Membrane.AudioInterleaver do
@moduledoc """
Element responsible for interleaving several mono audio streams into single interleaved stream.
All input streams should be in the same raw audio format, defined by `input_caps` option.
Channels are interleaved in order given in `order` option - currently r... | lib/membrane_audio_interleaver.ex | 0.895344 | 0.509947 | membrane_audio_interleaver.ex | starcoder |
defmodule MangoPay do
@moduledoc """
The elixir client for MangoPay API.
This module is the root of all the application.
## Configuring
Set your API key by configuring the :mangopay application.
```
config :mangopay, :client, id: YOUR_MANGOPAY_CLIENT_ID
config :mangopay, :client, passphrase: <PAS... | lib/mango_pay.ex | 0.765418 | 0.621684 | mango_pay.ex | starcoder |
defmodule Exile do
@moduledoc """
Exile is an alternative for beam ports with back-pressure and non-blocking IO
"""
use Application
@doc false
def start(_type, _args) do
opts = [
name: Exile.WatcherSupervisor,
strategy: :one_for_one
]
# we use DynamicSupervisor for cleaning up ext... | lib/exile.ex | 0.808294 | 0.882782 | exile.ex | starcoder |
defmodule EctoFacade.Repo do
@moduledoc """
Facade repository that should be used for all operations regarding ecto.
It forwards all write/update/delete operations to `master_repo` and do all read operations on one of `read_repos` - which read repository is depending on the algorithm.
Should be used as:
u... | lib/ecto_facade/repo.ex | 0.632049 | 0.484197 | repo.ex | starcoder |
defmodule Exop.Utils do
@moduledoc """
A bunch of common functions.
"""
@no_value :exop_no_value
alias Exop.ValidationChecks
@doc "Tries to make a map from a struct and keyword list"
@spec try_map(any()) :: map() | nil
def try_map(%_{} = struct), do: Map.from_struct(struct)
def try_map(%{} = map),... | lib/exop/utils.ex | 0.732305 | 0.411052 | utils.ex | starcoder |
defmodule Sanbase.Mock do
import Mock
@doc ~s"""
Return a function of the specified arity that on its N-th call returns the
result of executing the length(list) % N
"""
def wrap_consecutives(list, opts) do
arity = Keyword.fetch!(opts, :arity)
cycle? = Keyword.get(opts, :cycle?, true)
do_wrap_co... | test/support/mock.ex | 0.665519 | 0.441673 | mock.ex | starcoder |
defmodule State.Alert.InformedEntityActivity do
@moduledoc """
A flattended cache of the current alert activities as matchspecs can't be used to find if an element of a list matches
a value as that's not a guard expressable pattern.
"""
@table __MODULE__
@doc """
If no activities are specified to `filter... | apps/state/lib/state/alert/informed_entity_activity.ex | 0.796688 | 0.536556 | informed_entity_activity.ex | starcoder |
defmodule Checksum.Crc do
@moduledoc """
CRC computation functions
"""
use Bitwise
import Checksum.Helpers
alias Checksum.Crc, as: Crc
defstruct [:width, :poly, :table, :init, :xor_out, :ref_in, :ref_out, :bits_mask, :top_bit]
@doc """
Initializes a `Crc` struct and compute a Crc table
Args:
... | lib/crc.ex | 0.844168 | 0.511046 | crc.ex | starcoder |
defmodule Ecto.Migrator do
@moduledoc """
This module provides the migration API.
## Example
defmodule MyApp.MigrationExample do
use Ecto.Migration
def up do
execute "CREATE TABLE users(id serial PRIMARY_KEY, username text)"
end
def down do
execute "DR... | lib/ecto/migrator.ex | 0.898252 | 0.465387 | migrator.ex | starcoder |
defmodule Phoenix.Component do
@moduledoc ~S'''
API for function components.
A function component is any function that receives
an assigns map as argument and returns a rendered
struct built with [the `~H` sigil](`LiveElement.Helpers.sigil_H/2`).
Here is an example:
defmodule MyComponent do
... | lib/phoenix_component.ex | 0.862134 | 0.639652 | phoenix_component.ex | starcoder |
defmodule Nerves.Network do
require Logger
alias Nerves.Network.Types
@moduledoc """
The Nerves.Network application handles the low level details of connecting
to networks. To quickly get started, create a new Nerves project and add
the following line someplace early on in your program:
Nerves.Netwo... | lib/nerves_network.ex | 0.817793 | 0.445771 | nerves_network.ex | starcoder |
defmodule Pummpcomm.Session.Exchange.ReadBgTargets do
@moduledoc """
Reads blood glucose targets for throughout the day.
"""
alias Pummpcomm.BloodGlucose
alias Pummpcomm.Session.{Command, Response}
# Constants
@mgdl 1
@mmol 2
@opcode 0x9F
@targets_max_count 8
# Functions
@doc """
Makes ... | lib/pummpcomm/session/exchange/read_bg_targets.ex | 0.829285 | 0.495484 | read_bg_targets.ex | starcoder |
defmodule Norm.Core.Spec do
@moduledoc false
# Provides a struct to encapsulate specs
alias __MODULE__
alias Norm.Core.Spec.{
And,
Or
}
defstruct predicate: nil, generator: nil, f: nil
def build({:or, _, [left, right]}) do
l = build(left)
r = build(right)
quote do
%Or{left: ... | lib/norm/core/spec.ex | 0.791176 | 0.625681 | spec.ex | starcoder |
defmodule Strabo.Compiler do
require Logger
require Macro
alias Strabo.Types, as: T
alias Strabo.Functions, as: F
alias Strabo.Util, as: U
defmodule Sigils do
@doc "Causes a regex to match only at the beginning of a string."
def sigil_p(string, []) do
{:ok, regex} = Regex.compile("^" <> stri... | lib/strabo/compiler.ex | 0.673621 | 0.479869 | compiler.ex | starcoder |
defmodule GasCodes do
@moduledoc """
Module containing macro definitions for gas cost
From https://github.com/ethereum/go-ethereum/blob/master/params/gas_table.go
"""
# credo:disable-for-this-file
# Nothing paid for operations of the set Wzero.
defmacro _GZERO do quote do: 0 end
#Amount of gas to pay... | apps/aevm/lib/gas_codes.ex | 0.817756 | 0.512998 | gas_codes.ex | starcoder |
defmodule Docker do
@moduledoc ~S"""
Docker Client
docker engine 通过绑定 unix sockets 来对外暴露 Remote API
其本质是在 unix sockets 上进行 HTTP 协议的传输
"""
require Logger
defstruct addr: "",
req: &Docker.Request.get/2
@doc ~S"""
设置容器连接信息
## Examples
```elixir
iex > config = Docker.config("un... | lib/docker.ex | 0.531209 | 0.643693 | docker.ex | starcoder |
defmodule NewRelic.Plug.Instrumentation do
@moduledoc """
Utility methods for instrumenting parts of an Elixir app.
"""
@doc """
Instruments a database call and records the elapsed time.
* `conn` should be a `Plug.Conn` that has been configured by `NewRelic.Plug.Phoenix`.
* `action` is the name of the r... | lib/new_relic/plug/instrumentation.ex | 0.821939 | 0.550003 | instrumentation.ex | starcoder |
defmodule Pov do
# Structs and types
@typedoc """
A tree, which is made of a node with several branches
"""
@type tree :: {any, [tree]}
defmodule Crumb do
defstruct [:parent, left_siblings: [], right_siblings: []]
@type t :: %Crumb{parent: any, left_siblings: [Pov.tree()], right_siblings: [Pov.tre... | exercises/practice/pov/.meta/example.ex | 0.789599 | 0.744726 | example.ex | starcoder |
defmodule MyXQL.Query do
@moduledoc """
A struct for a prepared statement that returns a single result.
For the struct returned from a query that returns multiple
results, see `MyXQL.Queries`.
Its public fields are:
* `:name` - The name of the prepared statement;
* `:num_params` - The number of par... | lib/myxql/query.ex | 0.89151 | 0.716467 | query.ex | starcoder |
defmodule Timber.Config do
@application :timber
@default_http_body_max_bytes 2048
@doc """
Your Timber application API key. This can be obtained after you create your
application in https://app.timber.io
# Example
```elixir
config :timber, :api_key, "<KEY>"
```
"""
def api_key do
case Appli... | lib/timber/config.ex | 0.870418 | 0.773516 | config.ex | starcoder |
defmodule Strap do
@moduledoc """
A module for using SRP (Secure Remote Password) versions 6 and 6a in Elixir.
"""
@type hash_fn :: (iodata -> binary)
@type hash_types :: :sha | :sha256 | atom
@type srp_version :: :srp6 | :srp6a
@type protocol :: {srp_version, binary, non_neg_integer, non_neg_integer, ha... | lib/strap.ex | 0.919814 | 0.550728 | strap.ex | starcoder |
import Kernel, except: [apply: 2]
defmodule Ecto.Query.Builder.Distinct do
@moduledoc false
alias Ecto.Query.Builder
@doc """
Escapes a list of quoted expressions.
iex> escape(quote do true end, {[], :acc}, [], __ENV__)
{true, {[], :acc}}
iex> escape(quote do [x.x, 13] end, {[], :acc}, [x... | lib/ecto/query/builder/distinct.ex | 0.738009 | 0.440168 | distinct.ex | starcoder |
defmodule Jan.GameServer do
@moduledoc """
This module is responsible for managing a single game room.
Its state is the list of players in this single game, with their scores and weapons.
"""
use GenServer
def start_link(room_id) do
GenServer.start_link(__MODULE__,
[],
... | lib/jan/game_server.ex | 0.714728 | 0.493775 | game_server.ex | starcoder |
defmodule Calendar.NaiveDateTime.Parse do
import Calendar.ParseUtil
@doc """
Parse ASN.1 GeneralizedTime.
Returns tuple with {:ok, [NaiveDateTime], UTC offset (optional)}
## Examples
iex> "19851106210627.3" |> asn1_generalized
{:ok, %NaiveDateTime{year: 1985, month: 11, day: 6, hour: 21, minut... | data/web/deps/calendar/lib/calendar/naive_date_time/parse.ex | 0.831417 | 0.471649 | parse.ex | starcoder |
defmodule SegmentTree do
@moduledoc """
Data structure to compute efficiently operation on ranges.
## Problem
Given a range [0, n-1] of n values, we want to efficiently calculate an operation (e.g. sum), a naive approach is to
iterate through a list but we will get the answer in O(n) time.
list = [a, ... | lib/segment_tree.ex | 0.840357 | 0.79956 | segment_tree.ex | starcoder |
defmodule Absinthe.Federation.Notation do
@moduledoc """
Module that includes macros for annotating a schema with federation directives.
## Example
defmodule MyApp.MySchema.Types do
use Absinthe.Schema.Notation
+ use Absinthe.Federation.Notation
end
"""
defmacro __using__(_opts) ... | lib/absinthe/federation/notation.ex | 0.812123 | 0.430267 | notation.ex | starcoder |
defmodule Elixir99.Lists do
@moduledoc """
Documentation for `Elixir99.Lists`.
"""
@doc """
Hello world.
## Examples
iex> Elixir99.Lists.hello()
:world
"""
def hello do
:world
end
def last(list) when length(list) >= 1 do
[head | tail] = list
case tail do
[] -> hea... | lib/elixir99_lists.ex | 0.768473 | 0.53777 | elixir99_lists.ex | starcoder |
defmodule RateTheDubWeb.APIController do
@moduledoc """
This controller is for the read-only JSON API for ratings of anime series.
See the [API Documentation](../../../docs/API.md) for more info.
TODO caching and rate limiting?
"""
use RateTheDubWeb, :controller
alias RateTheDub.Anime
alias RateTheD... | lib/ratethedub_web/controllers/api_controller.ex | 0.548794 | 0.4184 | api_controller.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.