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 Mix.Releases.Archiver.Archive do
@moduledoc false
defstruct [:name, :working_dir, :manifest]
@type path :: String.t()
@type t :: %__MODULE__{
name: String.t(),
working_dir: path,
manifest: %{path => path}
}
@doc """
Creates a new Archive with the given nam... | lib/mix/lib/releases/archiver/archive.ex | 0.758466 | 0.419321 | archive.ex | starcoder |
defmodule Absinthe.Phase.Document.Validation.ArgumentsOfCorrectType do
@moduledoc false
# Validates document to ensure that all arguments are of the correct type.
alias Absinthe.{Blueprint, Phase, Phase.Document.Validation.Utils, Schema, Type}
use Absinthe.Phase
@doc """
Run this validation.
"""
@sp... | lib/absinthe/phase/document/validation/arguments_of_correct_type.ex | 0.835685 | 0.423875 | arguments_of_correct_type.ex | starcoder |
defmodule Scidata.FashionMNIST do
@moduledoc """
Module for downloading the [FashionMNIST dataset](https://github.com/zalandoresearch/fashion-mnist#readme).
"""
require Scidata.Utils
alias Scidata.Utils
@base_url "http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/"
@train_image_file "train-imag... | lib/scidata/fashionmnist.ex | 0.639061 | 0.630856 | fashionmnist.ex | starcoder |
defmodule Model.Service do
@moduledoc """
Service represents a set of dates on which trips run.
"""
use Recordable,
id: nil,
start_date: ~D[1970-01-01],
end_date: ~D[9999-12-31],
valid_days: [],
description: nil,
schedule_name: nil,
schedule_type: nil,
schedule_typicality: 0,
... | apps/model/lib/model/service.ex | 0.872619 | 0.439868 | service.ex | starcoder |
defmodule Kino.VegaLite do
@moduledoc """
A widget wrapping [VegaLite](https://hexdocs.pm/vega_lite) graphic.
This widget allow for rendering regular VegaLite graphic
and then streaming new data points to update the graphic.
## Examples
widget =
Vl.new(width: 400, height: 400)
|> Vl.m... | lib/kino/vega_lite.ex | 0.759493 | 0.613135 | vega_lite.ex | starcoder |
defmodule Commanded.Registration.LocalRegistry do
@moduledoc """
Local process registration, restricted to a single node, using Elixir's
[Registry](https://hexdocs.pm/elixir/Registry.html).
"""
@behaviour Commanded.Registration
@doc """
Return an optional supervisor spec for the registry
"""
@spec c... | lib/commanded/registration/local_registry.ex | 0.873795 | 0.418489 | local_registry.ex | starcoder |
defmodule Sqlitex.Server.StatementCache do
@moduledoc """
Implements a least-recently used (LRU) cache for prepared SQLite statements.
Caches a fixed number of prepared statements and purges the statements which
were least-recently used when that limit is exceeded.
"""
defstruct db: false, size: 0, limit:... | deps/sqlitex/lib/sqlitex/server/statement_cache.ex | 0.770594 | 0.468487 | statement_cache.ex | starcoder |
defmodule PhoenixGuardian.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
imports other functionality to make it easier
to build and query models.
Finally, if the test case interacts wit... | test/support/conn_case.ex | 0.724286 | 0.428712 | conn_case.ex | starcoder |
defmodule DataBase.Schemas.Account do
@moduledoc """
The main abstraction to a bank account per say.
Provides a set of functions to interact with it, since its creation
to queries about its data. Express information over the `accounts`
database table.
"""
import Ecto.Query
use Ecto.Schema
alias Da... | apps/database/lib/database/schemas/account.ex | 0.911431 | 0.61832 | account.ex | starcoder |
defmodule Guachiman.Plug.MetaPipeline do
@moduledoc """
Defines a plug pipeline that applies `Guardian.Plug.Pipeline`
and use `:guachiman` as its `otp_app`.
"""
defmacro __using__(options \\ []) do
otp_app = Keyword.get(options, :otp_app, :guachiman)
quote do
use Guardian.Plug.Pipeline, otp_app... | lib/guachiman/plug/pipeline.ex | 0.838911 | 0.888275 | pipeline.ex | starcoder |
defmodule Grizzly.ZWave.Commands.FirmwareMDReport do
@moduledoc """
The Firmware Meta Data Report Command is used to advertise the status of the current firmware in the device.
Params:
* `:manufacturer_id` - A unique ID identifying the manufacturer of the device
* `:firmware_id` - A manufacturer SHOULD ... | lib/grizzly/zwave/commands/firmware_md_report.ex | 0.845273 | 0.409339 | firmware_md_report.ex | starcoder |
defmodule Sanbase.Anomaly.SqlQuery do
@table "anomalies_v2"
@metadata_table "anomalies_model_metadata"
@moduledoc ~s"""
Define the SQL queries to access to the anomalies in Clickhouse
The anomalies are stored in the '#{@table}' clickhouse table
"""
use Ecto.Schema
import Sanbase.DateTimeUtils, only:... | lib/sanbase/anomaly/anomaly_sql_query.ex | 0.793786 | 0.418935 | anomaly_sql_query.ex | starcoder |
defmodule Day11 do
@moduledoc """
Documentation for Day11.
"""
def part1 do
Day11.read_seats("input.txt") |> Day11.stabilize() |> Day11.occupied_seats() |> IO.puts()
end
def part2 do
Day11.read_seats("input.txt")
|> Day11.stabilize(&Day11.step2/1)
|> Day11.occupied_seats()
|> IO.puts()... | day11/lib/day11.ex | 0.552057 | 0.481941 | day11.ex | starcoder |
import TypeClass
defclass Witchcraft.Apply do
@moduledoc """
An extension of `Witchcraft.Functor`, `Apply` provides a way to _apply_ arguments
to functions when both are wrapped in the same kind of container. This can be
seen as running function application "in a context".
For a nice, illustrated introducti... | lib/witchcraft/apply.ex | 0.865324 | 0.769514 | apply.ex | starcoder |
defmodule Farmbot.Farmware do
@moduledoc """
Farmware is Farmbot's plugin system. Developing a farmware is simple.
You will need 3 things:
* A `manifest.json` hosted on the internet somewhere.
* A zip package of your farmware.
# Prerequisites
While it is _technically_ possible to use any language to ... | lib/farmbot/farmware/farmware.ex | 0.863536 | 0.590071 | farmware.ex | starcoder |
defmodule ExIsbndb.Book do
@moduledoc """
The `ExIsbndb.Book` module contains all the available endpoints for Books.
All functions need to receive a map with params, but only those
needed for the endpoint will be taken.
"""
alias ExIsbndb.Client
@valid_column_values ["", "title", "author", "date_publis... | lib/book.ex | 0.894424 | 0.643182 | book.ex | starcoder |
defmodule Pbkdf2.Base do
@moduledoc """
Base module for the Pbkdf2 password hashing library.
"""
use Bitwise
alias Pbkdf2.{Base64, Tools}
@max_length bsl(1, 32) - 1
@deprecated "Use Pbkdf2.gen_salt/1 (with `format: :django`) instead"
def django_salt(len) do
Tools.get_random_string(len)
end
@... | lib/pbkdf2/base.ex | 0.87185 | 0.472623 | base.ex | starcoder |
defmodule AWS.QuickSight do
@moduledoc """
Amazon QuickSight API Reference
Amazon QuickSight is a fully managed, serverless business intelligence service
for the AWS Cloud that makes it easy to extend data and insights to every user
in your organization.
This API reference contains documentation for a pr... | lib/aws/generated/quick_sight.ex | 0.835416 | 0.455562 | quick_sight.ex | starcoder |
defmodule Ada.Email.Quickchart do
@moduledoc """
Minimal DSL and functions to create image charts
via <https://quickchart.io>.
Doesn't support all api options (yet).
"""
@default_width 516
@default_height 300
@base_url "https://quickchart.io/chart"
defstruct type: "bar",
width: @default... | lib/ada/email/quickchart.ex | 0.805976 | 0.62395 | quickchart.ex | starcoder |
defmodule Turtle do
@moduledoc """
Turtle graphics is a popular and fun way to learn programming.
It was part of the original Logo programming language developed by <NAME> and <NAME> in 1966.
To give you an idea, imagine a robotic turtle starting at `{0, 0}` in the x-y
plane. And after giving a command like... | turtle/lib/turtle.ex | 0.868241 | 0.803135 | turtle.ex | starcoder |
defmodule EctoSearcher do
@moduledoc """
EctoSearcher is an attempt to bring dynamicly built queries (hello [Ransack](https://github.com/activerecord-hackery/ransack)) to the world of [Ecto](https://github.com/elixir-ecto/ecto).
## Installation
Add `ecto_searcher` to your mix.ex deps:
```elixir
def deps ... | lib/ecto_searcher.ex | 0.80969 | 0.804751 | ecto_searcher.ex | starcoder |
defmodule Prexent.Parser do
@moduledoc """
This module is the parser from markdown to HTML
"""
require Logger
@typedoc """
A single slide
"""
@type slide() :: [
Map.t(
type ::
:html
| :code
| :header
| :footer
|... | lib/prexent/parser.ex | 0.682574 | 0.436862 | parser.ex | starcoder |
defmodule AWS.ElasticBeanstalk do
@moduledoc """
AWS Elastic Beanstalk
AWS Elastic Beanstalk makes it easy for you to create, deploy, and manage
scalable, fault-tolerant applications running on the Amazon Web Services cloud.
For more information about this product, go to the [AWS Elastic Beanstalk](http://... | lib/aws/generated/elastic_beanstalk.ex | 0.852721 | 0.561155 | elastic_beanstalk.ex | starcoder |
defmodule OT.Server.ETSAdapter do
@moduledoc """
This is an adapter for OT.Server that stores data and operations in ETS
tables.
It is not meant for production use, as all of its data is publicly available
for testing purposes.
"""
@behaviour OT.Server.Adapter
use GenServer
@ops_table :ot_ops
@d... | lib/ot/server/ets_adapter.ex | 0.658088 | 0.44903 | ets_adapter.ex | starcoder |
defmodule Mix.Tasks.Edeliver do
use Mix.Task
@shortdoc "Build and deploy releases"
@moduledoc """
Build and deploy Elixir applications and perform hot-code upgrades
# Usage:
* mix edeliver <build-command|deploy-command|node-command|local-command> command-info [Options]
* mix edeliver --help|--vers... | lib/mix/tasks/edeliver.ex | 0.753648 | 0.519034 | edeliver.ex | starcoder |
defmodule Yggdrasil.Ethereum.Application do
@moduledoc """
[](https://travis-ci.org/etherharvest/yggdrasil_ethereum) [](https://hex.pm/packages/yggdrasil_... | lib/yggdrasil/ethereum/application.ex | 0.897814 | 0.948251 | application.ex | starcoder |
defmodule Static.Folder do
@moduledoc """
As you generate html documents from a folder structure,
a `Static.Folder` structure describes a main entry point.
A `Static.Folder` can consist of
- a `Static.Site` or
- a `Static.Folder`
"""
alias __MODULE__
alias Static.Site
alias Static.Parameter
a... | lib/folder.ex | 0.789477 | 0.482368 | folder.ex | starcoder |
defmodule Entrance.Mix.Phoenix.Inflector do
@moduledoc false
@doc """
Inflects path, scope, alias and more from the given name.
## Examples
```
[alias: "User",
human: "User",
base: "Phoenix",
web_module: "PhoenixWeb",
module: "Phoenix.User",
scoped: "User",
singular: "user",
path: "u... | lib/mix/phoenix/inflector.ex | 0.693369 | 0.546738 | inflector.ex | starcoder |
defmodule Infer do
@moduledoc """
A dependency free library to infer file and MIME type by checking the [magic number](https://en.wikipedia.org/wiki/Magic_number_(programming)) signature.
An elixir adaption of the [`infer`](https://github.com/bojand/infer) rust library.
"""
defmodule Type do
defstruct [... | lib/infer.ex | 0.916321 | 0.660857 | infer.ex | starcoder |
defmodule WinInfo do
require Logger
@moduledoc """
A process wide table containing the window information
"""
def new_table() do
try do
:ets.new(table_name(), [:set, :protected, :named_table])
rescue
_ ->
Logger.warn("Attempt to create #{inspect(table_name())} failed: Table exists... | lib/ElixirWx/wxWinInfo.ex | 0.635901 | 0.439687 | wxWinInfo.ex | starcoder |
defmodule UeberauthToken.Config do
@moduledoc """
Helper functions for ueberauth_token configuration.
Cachex may be used for the storage of tokens temporarily by setting the option
`:use_cache` to `true`. Cached tokens increase speed of token payload lookup but
with the tradeoff that token invalidation may b... | lib/ueberauth_token/config.ex | 0.909857 | 0.517754 | config.ex | starcoder |
defmodule Pathex.Lenses.Star do
@moduledoc """
Private module for `star()` lens
"""
# Helpers
defmacrop extend_if_ok(func, value, acc) do
quote do
case unquote(func).(unquote(value)) do
{:ok, result} -> [result | unquote(acc)]
:error -> unquote(acc)
end
end
end
defma... | lib/pathex/lenses/star.ex | 0.826397 | 0.465995 | star.ex | starcoder |
defmodule Storage do
@moduledoc """
This module wraps a lot of the internal storage calls. The goal
here is to provide an API abstraction layer so we can swap out
how the storage of these systems work in general
"""
require Logger
# ----------------------------------------------------------------------... | src/apps/storage/lib/storage.ex | 0.784979 | 0.490114 | storage.ex | starcoder |
defmodule Tesseract.Tree.R.Util do
alias Tesseract.Geometry.AABB3
alias Tesseract.Geometry.Point3D
alias Tesseract.Math.Vec3
def point2entry({label, point}, padding \\ 0) do
{Point3D.mbb(point, padding), label}
end
def points2entries(points, padding \\ 0) when is_list(points) do
points |> Enum.map... | lib/tree/r/util.ex | 0.717705 | 0.590189 | util.ex | starcoder |
defmodule Tw.V1_1.Media do
@moduledoc """
Media data structure and related functions.
https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/entities
"""
alias Tw.V1_1.Client
alias Tw.V1_1.Schema
alias Tw.V1_1.Sizes
alias Tw.V1_1.Tweet
alias Tw.V1_1.User
@type id :: pos... | lib/tw/v1_1/media.ex | 0.884651 | 0.549761 | media.ex | starcoder |
defmodule Block do
@derive [Poison.Encoder]
defstruct [:index, :timestamp, :transactions, :hash, :previous_hash, :difficulty, :nonce]
@difficulty 5
def generate(previous_block, from, to, value) do
new = %Block{
index: previous_block.index + 1,
timestamp: DateTime.utc_now() |> DateTime.to_unix(... | lib/block/block.ex | 0.720958 | 0.475362 | block.ex | starcoder |
defmodule AshGraphql.Resource.Query do
@moduledoc "Represents a configured query on a resource"
defstruct [
:name,
:action,
:type,
:identity,
:allow_nil?,
:modify_resolution,
as_mutation?: false
]
@get_schema [
name: [
type: :atom,
doc: "The name to use for the query... | lib/resource/query.ex | 0.840177 | 0.552419 | query.ex | starcoder |
defmodule Arangoex.Database do
@moduledoc """
This module contains functions used to manage databases.
"""
@doc """
Create a new database.
The `conn` parameter is an ArangoDB connection PID. The `database` parameter is a map describing the database to be
created.
## Endpoint
POST /_api/database
... | lib/arangoex/database.ex | 0.858793 | 0.475788 | database.ex | starcoder |
defmodule Indicado.SMA do
@moduledoc """
This is the SMA module used for calculating Simple Moving Average.
"""
@doc """
Calculates SMA for the list.
Returns `{:ok, sma_list}` or `{:error, reason}`
## Examples
iex> Indicado.SMA.eval([1, 3, 5, 7], 2)
{:ok, [2.0, 4.0, 6.0]}
iex> Indic... | lib/indicado/sma.ex | 0.89253 | 0.532 | sma.ex | starcoder |
defmodule BMP280.Calibration do
@moduledoc false
defstruct [
:has_humidity?,
:dig_T1,
:dig_T2,
:dig_T3,
:dig_P1,
:dig_P2,
:dig_P3,
:dig_P4,
:dig_P5,
:dig_P6,
:dig_P7,
:dig_P8,
:dig_P9,
:dig_H1,
:dig_H2,
:dig_H3,
:dig_H4,
:dig_H5,
:dig_H6
... | lib/bmp280/calibration.ex | 0.632276 | 0.575349 | calibration.ex | starcoder |
defmodule Daguex.Processor.PutImage do
use Daguex.Processor
alias Daguex.Image
import Daguex.Processor.StorageHelper
def init(opts) do
%{storage: init_storage(required_option(:storage)), name: required_option(:name)}
end
def process(context, %{storage: storage, name: name}) do
image = context.ima... | lib/daguex/processor/put_image.ex | 0.61173 | 0.417895 | put_image.ex | starcoder |
defmodule Abacus do
@moduledoc """
A math-expression parser, evaluator and formatter for Elixir.
## Features
### Supported operators
- `+`, `-`, `/`, `*`
- Exponentials with `^`
- Factorial (`n!`)
- Bitwise operators
* `<<` `>>` bitshift
* `&` bitwise and
* `|` bitwise or
* `|... | lib/abacus.ex | 0.723212 | 0.724627 | abacus.ex | starcoder |
defmodule RDF.Serialization.ParseHelper do
@moduledoc false
alias RDF.IRI
@rdf_type RDF.Utils.Bootstrapping.rdf_iri("type")
def rdf_type, do: @rdf_type
def to_iri_string({:iriref, _line, value}), do: value |> iri_unescape
def to_iri({:iriref, line, value}) do
with iri = RDF.iri(iri_unescape(value)) ... | lib/rdf/serialization/parse_helper.ex | 0.609524 | 0.491883 | parse_helper.ex | starcoder |
defmodule Surgex.Guide.CodeStyle do
@moduledoc """
Basic code style and formatting guidelines.
"""
@doc """
Indentation must be done with 2 spaces.
## Reasoning
This is [kind of a delicate subject](https://youtu.be/SsoOG6ZeyUI), but seemingly both Elixir and
Ruby communities usually go for spaces, so... | lib/surgex/guide/code_style.ex | 0.840292 | 0.615435 | code_style.ex | starcoder |
defmodule MazesWeb.HexagonalMazeView do
use MazesWeb, :view
import MazesWeb.MazeHelper
alias Mazes.Maze
def hex_radius(maze) do
max_width = max_svg_width() - 2 * svg_padding()
max_height = max_svg_width() - 2 * svg_padding()
r1 = trunc(max_width / (0.5 + maze.width * 1.5))
h = trunc(max_height... | lib/mazes_web/views/hexagonal_maze_view.ex | 0.632276 | 0.41938 | hexagonal_maze_view.ex | starcoder |
defmodule Annex.Perceptron do
@moduledoc """
A simple perceptron Learner capable of making good predictions given a linearly separable
dataset and labels.
"""
use Annex.Learner
alias Annex.{
Data.List1D,
Dataset,
Perceptron,
Utils
}
import Annex.Utils, only: [is_pos_integer: 1]
@typ... | lib/annex/perceptron.ex | 0.884008 | 0.693849 | perceptron.ex | starcoder |
defmodule Andi.InputSchemas.InputConverter do
@moduledoc """
Used to convert between SmartCity.Datasets, form data (defined by Andi.InputSchemas.DatasetInput), and Ecto.Changesets.
"""
alias SmartCity.Dataset
alias Andi.InputSchemas.DatasetInput
@type dataset :: map() | Dataset.t()
@spec changeset_from... | apps/andi/lib/andi/input_schemas/input_converter.ex | 0.727201 | 0.40869 | input_converter.ex | starcoder |
defmodule LearnKit.Math do
@moduledoc """
Math module
"""
@type row :: [number]
@type matrix :: [row]
@doc """
Sum of 2 numbers
## Examples
iex> LearnKit.Math.summ(1, 2)
3
"""
@spec summ(number, number) :: number
def summ(a, b), do: a + b
@doc """
Division for 2 elements
... | lib/learn_kit/math.ex | 0.933119 | 0.764188 | math.ex | starcoder |
defmodule Bolt.Cogs.Warn do
@moduledoc false
@behaviour Nosedrum.Command
alias Bolt.Converters
alias Bolt.ErrorFormatters
alias Bolt.Helpers
alias Bolt.Humanizer
alias Bolt.ModLog
alias Bolt.Repo
alias Bolt.Schema.Infraction
alias Nosedrum.Predicates
alias Nostrum.Api
alias Nostrum.Struct.User... | lib/bolt/cogs/warn.ex | 0.803135 | 0.474449 | warn.ex | starcoder |
defmodule Cryptopunk.Crypto.Bitcoin do
@moduledoc """
Bitcoin address generation logic.
All addresses use compressed public keys.
"""
alias Cryptopunk.Crypto.Bitcoin.Bech32Address
alias Cryptopunk.Crypto.Bitcoin.LegacyAddress
alias Cryptopunk.Crypto.Bitcoin.P2shP2wpkhAddress
alias Cryptopunk.Key
@d... | lib/cryptopunk/crypto/bitcoin.ex | 0.856362 | 0.40251 | bitcoin.ex | starcoder |
defmodule Spaceentropy do
alias Faker
alias Comeonin.Bcrypt
@random_faker [
1, 2, 3, 4, 5, 6, 7, 8, 9, 0
]
@moduledoc """
Spaceentropy generates random passwords with the glorious power of faker data,
comeonin, and bcrypt.
"""
@doc """
gen_faker
## Examples
iex> Spaceentropy.gen_fake... | lib/spaceentropy.ex | 0.648132 | 0.474327 | spaceentropy.ex | starcoder |
defmodule Mongo.InsertOneResult do
@moduledoc """
The successful result struct of `Mongo.insert_one/4`. Its fields are:
* `:inserted_id` - The id of the inserted document
"""
@type t :: %__MODULE__{
acknowledged: boolean,
inserted_id: nil | BSON.ObjectId.t()
}
defstruct ackn... | lib/mongo/results.ex | 0.744285 | 0.541348 | results.ex | starcoder |
defmodule Rubbergloves.Struct do
@moduledoc"""
A series of macros to define how to convert from a raw %{} map to a well defined struct.
Supports nested struct mapping, and global conventions.
Using *Rubbergloves.Struct* give you access to the `defmapping` module that defines how to convert the input into your... | lib/mapper/struct.ex | 0.809991 | 0.915507 | struct.ex | starcoder |
defmodule RojakAPI.V1.NewsController do
use RojakAPI.Web, :controller
alias RojakAPI.Data.News
@apidoc """
@api {get} /news Get list of news
@apiGroup News
@apiName NewsList
@apiDescription Get a list of news, optionally with <code>media</code>, <code>mentions</code>, and <code>sentiments</code>... | rojak-api/web/v1/news/news_controller.ex | 0.770681 | 0.436082 | news_controller.ex | starcoder |
defmodule OddJob.Async.Proxy do
@moduledoc """
The `OddJob.Async.Proxy` links the job caller to the worker as the job is being performed.
The process that calls `async_perform/2` or `async_perform_many/3` must link and monitor the worker
performing the job so it can receive the results and be notified of failu... | lib/odd_job/async/proxy.ex | 0.828731 | 0.564939 | proxy.ex | starcoder |
defmodule Cuda.Compiler.Context do
@moduledoc """
Compilation context
"""
alias Cuda.Graph.GraphProto
@type t :: %__MODULE__{
env: Cuda.Env.t,
assigns: map,
root: Cuda.Graph.t | Cuda.Node.t,
path: [Cuda.Graph.id]
}
defstruct [:env, :root, assigns: %{}, path: []]
def new(opts) do
... | lib/cuda/compiler/context.ex | 0.641535 | 0.400105 | context.ex | starcoder |
defmodule Ui.Pins do
@moduledoc """
This is an abstraction layer for the underlying GPIO pin interface.
Holds the GPIO pin pids internally to allow easier manipulation.
"""
use GenServer
@type pin_number :: non_neg_integer()
defmodule GPIOPin do
@moduledoc """
Information about a GPIO pin.
"... | apps/ui/lib/ui/pins.ex | 0.834069 | 0.535706 | pins.ex | starcoder |
defmodule ExOauth2Provider.Plug.EnsureScopes do
@moduledoc """
Use this plug to ensure that there are the correct scopes on
the token found on the connection.
### Example
alias ExOauth2Provider.Plug.EnsureScopes
# With custom handler
plug EnsureScopes, scopes: ~w(read write), handler: SomeMo... | lib/ex_oauth2_provider/plug/ensure_scopes.ex | 0.713631 | 0.40695 | ensure_scopes.ex | starcoder |
defmodule Filtrex.Condition.Date do
use Filtrex.Condition
use Timex
@string_date_comparators ["equals", "does not equal", "after", "on or after", "before", "on or before"]
@start_end_comparators ["between", "not between"]
@comparators @string_date_comparators ++ @start_end_comparators
@type t :: Filtrex.Co... | lib/filtrex/conditions/date.ex | 0.866599 | 0.534612 | date.ex | starcoder |
defmodule Membrane.MP4.Muxer.ISOM do
@moduledoc """
Puts payloaded streams into an MPEG-4 container.
Due to the structure of MPEG-4 containers, the muxer has to be used along with
`Membrane.File.Sink` or any other sink that can handle `Membrane.File.SeekEvent`.
The event is used to fill in `mdat` box size af... | lib/membrane_mp4/muxer/isom.ex | 0.873923 | 0.555556 | isom.ex | starcoder |
defmodule Bcrypt do
@moduledoc """
Elixir wrapper for the Bcrypt password hashing function.
Most applications will just need to use the `add_hash/2` and `check_pass/3`
convenience functions in this module.
For a lower-level API, see Bcrypt.Base.
## Configuration
The following parameter can be set in t... | deps/bcrypt_elixir/lib/bcrypt.ex | 0.852813 | 0.649037 | bcrypt.ex | starcoder |
defmodule Bonbon.API.Schema.Cuisine do
use Absinthe.Schema
use Translecto.Query
import_types Bonbon.API.Schema.Cuisine.Region
@moduledoc false
@desc "An cuisine used in food"
object :cuisine do
field :id, :id, description: "The id of the cuisine"
field :name, :string, descriptio... | web/api/schema/cuisine.ex | 0.539226 | 0.421463 | cuisine.ex | starcoder |
defmodule Jason.EncodeError do
defexception [:message]
@type t :: %__MODULE__{message: String.t}
def new({:duplicate_key, key}) do
%__MODULE__{message: "duplicate key: #{key}"}
end
def new({:invalid_byte, byte, original}) do
%__MODULE__{message: "invalid byte #{inspect byte, base: :hex} in #{inspect... | lib/encode.ex | 0.72952 | 0.47457 | encode.ex | starcoder |
defmodule Exq.Enqueuer.Server do
@moduledoc """
The Enqueuer is responsible for enqueueing jobs into Redis. It can
either be called directly by the client, or instantiated as a standalone process.
It supports enqueuing immediate jobs, or scheduling jobs in the future.
## Initialization:
* `:name` - Name... | lib/exq/enqueuer/server.ex | 0.625324 | 0.550668 | server.ex | starcoder |
defmodule Tensor.Vector do
alias Tensor.{Vector, Tensor}
import Kernel, except: [length: 1]
defmodule Inspect do
@doc false
def inspect(vector, _opts) do
"#Vector<(#{Tensor.Inspect.dimension_string(vector)})#{inspect(Vector.to_list(vector))}>"
end
end
def new() do
Tensor.new([], [0], ... | lib/tensor/vector.ex | 0.815416 | 0.909907 | vector.ex | starcoder |
defmodule HomeWeb.Models.GraphModel do
@moduledoc "This model constructs data for graphs"
import HomeBot.Tools
alias HomeBot.DataStore
use Timex
def gas_usage_data(start_time, end_time, group_quantity, group_unit, title \\ "Gas usage") do
result = DataStore.get_energy_usage(start_time, end_time, group... | lib/home_web/models/graph_model.ex | 0.782621 | 0.455199 | graph_model.ex | starcoder |
defmodule MeshxConsul.Ttl do
@moduledoc """
Manages TTL health check workers used by mesh services.
Consul agent can use multiple kinds of checks, e.g. script checks, HTTP and TCP checks, gRPC and [others](https://www.consul.io/docs/discovery/checks).
`MeshxConsul` is using TTL (Time To Live) health checks fo... | lib/ttl/ttl.ex | 0.843863 | 0.85984 | ttl.ex | starcoder |
defmodule Xema.ValidationError do
@moduledoc """
Raised when a validation fails.
"""
@type path :: [atom | integer | String.t()]
@type opts :: [] | [path: path]
defexception [:message, :reason]
@impl true
def message(%{message: nil} = exception), do: format_error(exception.reason)
def message(%{me... | lib/xema/validation_error.ex | 0.942374 | 0.755321 | validation_error.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.Except... | lib/forage/codec/decoder.ex | 0.736969 | 0.445831 | decoder.ex | starcoder |
defmodule MrRoboto.Agent do
@moduledoc """
The Agent fetches the `robots.txt` file from a given site.
The agent is a very simple `GenServer` with the sole purpose of requesting the `robots.txt` file from a site.
The agent responds to a single call `{:check, site}` where site is the URL of the site from which ... | lib/mr_roboto/agent.ex | 0.742608 | 0.702683 | agent.ex | starcoder |
defmodule Coxir.Struct.User do
@moduledoc """
Defines methods used to interact with Discord users.
Refer to [this](https://discordapp.com/developers/docs/resources/user#user-object)
for a list of fields and a broader documentation.
In addition, the following fields are also embedded.
- `voice` - a channel... | lib/coxir/struct/user.ex | 0.871187 | 0.418103 | user.ex | starcoder |
defmodule CircuitsLED.GPIOServer do
use GenServer
alias Circuits.GPIO
def start_link(pin) do
GenServer.start_link(__MODULE__, pin, name: pin_to_atom(pin))
end
def on(pid) do
GenServer.call(pid, :on)
end
def off(pid) do
GenServer.call(pid, :off)
end
def blink(pid, duration, count) do
... | lib/circuits_led/gpio_led_server.ex | 0.721253 | 0.448789 | gpio_led_server.ex | starcoder |
defmodule Vex do
def valid?(data) do
valid?(data, Vex.Extract.settings(data))
end
def valid?(data, settings) do
errors(data, settings) |> length == 0
end
def validate(data) do
validate(data, Vex.Extract.settings(data))
end
def validate(data, settings) do
case errors(data, settings) do
... | lib/vex.ex | 0.73077 | 0.402744 | vex.ex | starcoder |
defmodule ExDadata.Address do
@moduledoc """
Entry point for address DaData API.
For more information see [docs](https://dadata.ru/api/#address-clean).
"""
alias __MODULE__.{GeocodeAddress, GeolocateAddress, SuggestAddress}
alias ExDadata.Client
alias ExDadata.HTTPAdapter.Response
@suggest_address_ur... | lib/ex_dadata/address.ex | 0.838382 | 0.650776 | address.ex | starcoder |
defmodule Mechanize.Page.Element do
@moduledoc """
The HMTL element.
This module provides functions to manipulate and extract information from HMTL element nodes.
## Public fields
* `name` - name of the HTML tag.
* `attrs` - List of the element attributes.
* `text` - Inner text of the element.
... | lib/mechanize/page/element.ex | 0.918859 | 0.887644 | element.ex | starcoder |
defmodule Record do
@moduledoc """
Module to work with, define, and import records.
Records are simply tuples where the first element is an atom:
iex> Record.is_record {User, "john", 27}
true
This module provides conveniences for working with records at
compilation time, where compile-time fiel... | lib/elixir/lib/record.ex | 0.891993 | 0.794704 | record.ex | starcoder |
defmodule Jason do
@moduledoc """
A blazing fast JSON parser and generator in pure Elixir.
"""
alias Jason.{Encode, Decoder, DecodeError, EncodeError, Formatter}
@type escape :: :json | :unicode_safe | :html_safe | :javascript_safe
@type maps :: :naive | :strict
@type encode_opt :: {:escape, escape} | ... | minimal_server/deps/jason/lib/jason.ex | 0.930466 | 0.761206 | jason.ex | starcoder |
defmodule Can do
import Plug.Conn
defstruct [
policy: nil,
action: nil,
authorized?: false
]
def can(conn, policy, action, context) do
action = action || get_action(conn)
policy = policy || get_policy(conn)
conn =
conn
|> put_action(action)
|> put_policy(policy)
... | lib/can.ex | 0.50293 | 0.420094 | can.ex | starcoder |
defmodule Logger.Backends.Gelf do
@moduledoc """
GELF Logger Backend
# GelfLogger [](https://travis-ci.org/jschniper/gelf_logger)
A logger backend that will generate Graylog Extended Log Format messages. The
current version only su... | lib/gelf_logger.ex | 0.722233 | 0.841272 | gelf_logger.ex | starcoder |
defmodule Phoenix.LiveDashboard.HomePage do
@moduledoc false
use Phoenix.LiveDashboard.PageBuilder
import Phoenix.HTML
import Phoenix.LiveDashboard.Helpers
alias Phoenix.LiveDashboard.SystemInfo
@memory_usage_sections [
{:atom, "Atoms", "green", nil},
{:binary, "Binary", "blue", nil},
{:code,... | lib/phoenix/live_dashboard/pages/home_page.ex | 0.708313 | 0.426142 | home_page.ex | starcoder |
defmodule Timber.Integrations.HTTPContextPlug do
@moduledoc """
Automatically captures the HTTP method, path, and request_id in Plug-based frameworks
like Phoenix and adds it to the context.
By adding this data to the context, you'll be able to associate
all the log statements that occur while processing tha... | lib/timber/integrations/http_context_plug.ex | 0.89792 | 0.670308 | http_context_plug.ex | starcoder |
defmodule Mix.Project do
@moduledoc """
A module that provides conveniences for defining and working
with projects.
## Examples
In order to configure Mix, a developer needs to use
`Mix.Project` in a module and define a function named
`project` that returns a keywords list with configuration.
defm... | lib/mix/lib/mix/project.ex | 0.761006 | 0.407216 | project.ex | starcoder |
defmodule Astarte.Flow.Blocks.MqttSource do
@moduledoc """
An Astarte Flow source that produces data from an MQTT connection.
When a message is received on a subscribed topic, `MqttSource` generates
an `%Astarte.Flow.Message{}` containing these fields:
* `key` contains the topic on which the message was r... | lib/astarte_flow/blocks/mqtt_source.ex | 0.851367 | 0.491273 | mqtt_source.ex | starcoder |
defmodule Bloomex do
@moduledoc """
This module implements a [Scalable Bloom Filter](http://haslab.uminho.pt/cbm/files/dbloom.pdf).
## Examples
iex> bf = Bloomex.scalable(1000, 0.1, 0.1, 2)
%Bloomex.ScalableBloom...
iex> bf = Bloomex.add(bf, 5)
%Bloomex.ScalableBloom...
iex> Bloo... | lib/bloomex.ex | 0.930494 | 0.660487 | bloomex.ex | starcoder |
defmodule ExWeather.WeatherManager do
@moduledoc """
The WeatherManager is a higher level client for getting certain weather
aspects.
"""
require Logger
alias ExWeather.WeatherClient
alias ExWeather.MetaWeatherClient
defmodule TemperatureResponse do
@type t :: %__MODULE__{
title: String... | lib/ex_weather/weather_manager.ex | 0.810366 | 0.425784 | weather_manager.ex | starcoder |
defmodule Membrane.RTP.Serializer do
@moduledoc """
Given following RTP payloads and their minimal metadata, creates their proper header information,
incrementing timestamps and sequence numbers for each packet. Header information then is put
inside buffer's metadata under `:rtp` key.
Accepts the following m... | lib/membrane/rtp/serializer.ex | 0.892848 | 0.500366 | serializer.ex | starcoder |
defmodule Benchmarks.GoogleMessage3.Message35546.Message35547 do
@moduledoc false
use Protobuf, protoc_gen_elixir_version: "0.10.1-dev", syntax: :proto2
field :field35569, 5, required: true, type: :int32
field :field35570, 6, required: true, type: :int32
end
defmodule Benchmarks.GoogleMessage3.Message35546.Me... | bench/lib/datasets/google_message3/benchmark_message3_3.pb.ex | 0.571767 | 0.40204 | benchmark_message3_3.pb.ex | starcoder |
defmodule AWS.Client do
@moduledoc """
Provides credentials and connection details for making requests to AWS services.
You can configure `access_key_id` and `secret_access_key` which are the credentials
needed by [IAM](https://aws.amazon.com/iam), and also the `region` for your services.
The list of regions... | lib/aws/client.ex | 0.861596 | 0.485234 | client.ex | starcoder |
defmodule Grapevine.Telnet.Options do
@moduledoc """
Parse telnet IAC options coming from the game
"""
alias Grapevine.Telnet.GMCP
alias Grapevine.Telnet.MSSP
@se 240
@nop 241
@ga 249
@sb 250
@will 251
@wont 252
@iac_do 253
@dont 254
@iac 255
@term_type 24
@line_mode 34
@charset 42
... | lib/grapevine/telnet/options.ex | 0.679072 | 0.419113 | options.ex | starcoder |
defmodule Grizzly.ZWave.SmartStart.MetaExtension.SmartStartInclusionSetting do
@moduledoc """
This extension is used to advertise the SmartStart inclusion setting of the
provisioning list entry
"""
@typedoc """
The setting for SmartStart inclusion. This tells the controller if it must
listen and/or inclu... | lib/grizzly/zwave/smart_start/meta_extension/smart_start_inclusion_setting.ex | 0.888493 | 0.429489 | smart_start_inclusion_setting.ex | starcoder |
defmodule JSONC.Tokenizer do
@whitespace ["\v", "\f", "\r", "\n", "\s", "\t", "\b"]
@invalid_for_generics [
"{",
"}",
"[",
"]",
",",
":",
"\\",
"/",
"\"",
"`",
"'",
"~",
"*",
"(",
")",
"<",
">",
"!",
"?",
"@",
"#",
"$",
"%"... | lib/tokenizer.ex | 0.590071 | 0.549036 | tokenizer.ex | starcoder |
defmodule UTM do
import :math
@a 6_378_137.0
@f 1 / 298.2572236
@drad pi() / 180
@k_0 0.9996
@b @a * (1 - @f)
@e sqrt(1 - pow(@b / @a, 2))
@esq pow(@e, 2)
@e0sq @esq / (1 - @esq)
@e_1 (1 - sqrt(1 - @esq)) / (1 + sqrt(1 - @esq))
@doc """
Converts from WGS84 to UTM
## Examples:
iex> UT... | lib/utm.ex | 0.646014 | 0.461138 | utm.ex | starcoder |
defmodule Faker.Dog.PtBr do
import Faker, only: [sampler: 2]
@moduledoc """
Functions for Dog names, breeds and characteristics in Portuguese
"""
@doc """
Returns a dog name.
## Examples
iex> Faker.Dog.PtBr.name()
"Simba"
iex> Faker.Dog.PtBr.name()
"Max"
iex> Faker.Dog.Pt... | lib/faker/dog/pt_br.ex | 0.66061 | 0.422624 | pt_br.ex | starcoder |
defmodule Phoenix.LiveView.Diff do
@moduledoc false
alias Phoenix.LiveView.{Rendered, Comprehension}
# entry point
# {thing_to_be_serialized, fingerprint_tree} = traverse(result, nil)
# nexttime
# {thing_to_be_serialized, fingerprint_tree} = traverse(result, fingerprint_tree)
def render(%Rendered{} = ... | lib/phoenix_live_view/diff.ex | 0.721645 | 0.547404 | diff.ex | starcoder |
defmodule Absinthe.Language do
@moduledoc false
alias Absinthe.Language
alias __MODULE__
@type t ::
Language.Argument.t()
| Language.BooleanValue.t()
| Language.Directive.t()
| Language.Document.t()
| Language.EnumTypeDefinition.t()
| Language.EnumV... | lib/absinthe/language.ex | 0.781831 | 0.470919 | language.ex | starcoder |
defmodule BPE.Account do
@moduledoc """
`PLM.Account` is a process that handles user investments.
"""
require ERP
require BPE
require Record
Record.defrecord(:close_account, [])
Record.defrecord(:tx, [])
def def() do
BPE.process(
name: :n2o.user(),
flows: [
BPE.sequenceFlow(so... | lib/actors/account.ex | 0.623492 | 0.579698 | account.ex | starcoder |
defmodule Poison.ParseError do
@type t :: %__MODULE__{pos: integer, value: String.t()}
alias Code.Identifier
defexception pos: 0, value: nil, rest: nil
def message(%{value: "", pos: pos}) do
"Unexpected end of input at position #{pos}"
end
def message(%{value: <<token::utf8>>, pos: pos}) do
"Une... | lib/poison/parser.ex | 0.607197 | 0.595551 | parser.ex | starcoder |
defmodule ExBreak do
@moduledoc """
Provides circuit breaker functionality around function calls
"""
alias ExBreak.Breaker
@type opt ::
{:timeout_sec, pos_integer}
| {:threshold, pos_integer}
| {:match_exception, (any -> boolean)}
| {:match_return, (any -> boolean)}
... | lib/ex_break.ex | 0.856332 | 0.604428 | ex_break.ex | starcoder |
defmodule SlackLoggerBackend do
@moduledoc """
A logger backend for posting errors to Slack.
You can find the hex package
[here](https://hex.pm/packages/slack_logger_backend), and the docs
[here](http://hexdocs.pm/slack_logger_backend).
## Usage
First, add the client to your `mix.exs` dependencies:
... | lib/slack_logger_backend.ex | 0.821903 | 0.828592 | slack_logger_backend.ex | starcoder |
defmodule ElixirLokaliseApi.Processor do
@moduledoc """
Performs processing of user-supplied data and data returned by the API.
"""
@pagination_headers %{
"x-pagination-total-count" => :total_count,
"x-pagination-page-count" => :page_count,
"x-pagination-limit" => :per_page_limit,
"x-pagination... | lib/elixir_lokalise_api/processor.ex | 0.721743 | 0.487734 | processor.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.