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 FlowAssertions.TabularA do
alias FlowAssertions.MiscA
import FlowAssertions.Define.BodyParts
@moduledoc """
Builders that create functions tailored to tabular tests.
Here are some tabular tests for how
`Previously.parse` copes with one of its keyword arguments:
[insert: :a ... | lib/tabular_a.ex | 0.881283 | 0.96859 | tabular_a.ex | starcoder |
defmodule APIacAuthClientJWT do
@moduledoc """
An `APIac.Authenticator` plug that implements the client authentication part of
[RFC7523](https://tools.ietf.org/html/rfc7523) (JSON Web Token (JWT) Profile for OAuth 2.0
Client Authentication and Authorization Grants).
This method consists in sending a MACed or... | lib/apiac_auth_client_jwt.ex | 0.941163 | 0.794185 | apiac_auth_client_jwt.ex | starcoder |
defmodule Rbt.Consumer.Handler do
@moduledoc """
The `Rbt.Consumer.Handler` behaviour can be used to model RabbitMQ consumers.
See the [relevant RabbitMQ tutorial](https://www.rabbitmq.com/tutorials/tutorial-five-elixir.html)
for the principles behind topic-based consumers.
To use it:
### 1. Define a con... | lib/rbt/consumer/handler.ex | 0.909887 | 0.774541 | handler.ex | starcoder |
defmodule Kino.Bridge do
@moduledoc false
import Kernel, except: [send: 2]
# This module encapsulates the communication with Livebook
# achieved via the group leader. For the implementation of
# that group leader see Livebook.Evaluator.IOProxy
@type request_error :: :unsupported | :terminated
@doc """... | lib/kino/bridge.ex | 0.793666 | 0.456773 | bridge.ex | starcoder |
defmodule Saucexages.IO.FileReader do
@moduledoc """
Reads SAUCE data from files according to the SAUCE specification.
SAUCE data is decoded decoded according to the SAUCE spec.
If you are working with small files, it is recommended to use `Saucexages.IO.BinaryReader` instead.
Files are opened with read an... | lib/saucexages/io/file_reader.ex | 0.836454 | 0.654046 | file_reader.ex | starcoder |
defmodule Mix.Tasks.Absinthe.Gen.Scaffold do
use Mix.Task
alias AbsintheGen.{RenderTemplate, OutputFiles}
@shortdoc "Create absinthe scaffold files."
@moduledoc """
Will generate a scaffold consisting of a schema, type and resolver files. Multiple fields are accepted.
Example:
```
mix absinthe.gen.sca... | lib/mix/absinthe.gen.scaffold.ex | 0.798619 | 0.40539 | absinthe.gen.scaffold.ex | starcoder |
defmodule LruCacheGenServer do
@moduledoc """
This module implements a simple LRU cache that support storing any type of value,
implemented as a GenServer backed by ETS using 3 ets tables.
For using it, you need to start it:
iex> LruCacheGenServer.start_link(1000)
## Using it
iex> Lru... | lib/lru_cache_gen_server.ex | 0.708717 | 0.494507 | lru_cache_gen_server.ex | starcoder |
defmodule Madness.Story do
@moduledoc """
Stories are a graph of areas, along with a pointer
to the starting area.
Stories are driven by choices given to a player,
rather than natural language parsing which may be frustrating.
"""
require Logger
alias Madness.Story.Areas.Supervisor, as: SArea
# Track ... | lib/madness/story.ex | 0.564939 | 0.472014 | story.ex | starcoder |
defmodule BMP280.BMP280Calibration do
@moduledoc false
@type t() :: %{
type: :bmp280,
dig_t1: char,
dig_t2: integer,
dig_t3: integer,
dig_p1: char,
dig_p2: integer,
dig_p3: integer,
dig_p4: integer,
dig_p5: integer,
... | lib/bmp280/calibration/bmp280_calibration.ex | 0.613237 | 0.473901 | bmp280_calibration.ex | starcoder |
defmodule Mecab do
@moduledoc """
Elixir bindings for MeCab, a Japanese morphological analyzer.
Each parser function returns a list of map.
The map's keys meanings is as follows.
- `surface_form`: 表層形
- `part_of_speech`: 品詞
- `part_of_speech_subcategory1`: 品詞細分類1
- `part_of_speech_subcategory2`: 品詞細分類... | lib/mecab.ex | 0.63443 | 0.438184 | mecab.ex | starcoder |
defmodule Blake3 do
@moduledoc """
Blake3 provides bindings to the rust implementaion of the BLAKE3 hashing algorithm.
See the [README](readme.html) for installation and usage examples
"""
alias Blake3.Native
@type hasher :: reference()
@doc """
computes a message digest for the given data
"""
@... | lib/blake3.ex | 0.861407 | 0.601418 | blake3.ex | starcoder |
defmodule SvgSprite do
@moduledoc """
> Want the wonderful goodness of SVG without having the need for our SVG + JS framework at the moment? Have no fear, SVG Sprites are here. We have lovingly prepped all the icon set styles into their own SVG sprites.
This quote is taken from the Font Awesome documentation abo... | lib/svg_sprite.ex | 0.741955 | 0.8809 | svg_sprite.ex | starcoder |
defmodule ESpec.Assertions.EnumString.Have do
@moduledoc """
Defines 'have' assertion.
it do: expect(enum).to have(value)
it do: expect(string).to have(value)
"""
use ESpec.Assertions.Interface
defp match(enum, [{_key, _value} = tuple]) do
match(enum, tuple)
end
defp match(%{} = map, {key, val... | lib/espec/assertions/enum_string/have.ex | 0.678966 | 0.604807 | have.ex | starcoder |
defmodule Helper.Validator.Schema do
@moduledoc """
validate json data by given schema, mostly used in editorjs validator
currently support boolean / string / number / enum
"""
# use Helper.Validator.Schema.Matchers, [:string, :number, :list, :boolean]
@doc """
cast data by given schema
## example
... | lib/helper/validator/schema.ex | 0.781914 | 0.546617 | schema.ex | starcoder |
defmodule Blockchain.Ethash do
@moduledoc """
This module contains the logic found in Appendix J of the
yellow paper concerning the Ethash implementation for POW.
"""
use Bitwise
alias Blockchain.Ethash.{FNV, RandMemoHash}
alias ExthCrypto.Hash.Keccak
@j_epoch 30_000
@j_datasetinit round(:math.pow(... | apps/blockchain/lib/blockchain/ethash.ex | 0.799403 | 0.407363 | ethash.ex | starcoder |
defmodule AbsinthePermission do
@moduledoc """
This middleware allows to restrict operations on
queries, mutations and subscriptions in declarative manner
by leveraging `meta` field.
This middleware especially useful if you have role based
access management.
There are 3 types policies:
1. You can defi... | lib/absinthe_permission.ex | 0.795817 | 0.780077 | absinthe_permission.ex | starcoder |
defmodule DateTimeParser.Parser.Date do
@moduledoc """
Tokenizes the string for date formats. This prioritizes the international standard for
representing dates.
"""
@behaviour DateTimeParser.Parser
import NimbleParsec
import DateTimeParser.Combinators.Date
import DateTimeParser.Formatters, only: [form... | lib/parser/date.ex | 0.894853 | 0.481454 | date.ex | starcoder |
defmodule Fugue.Assertions do
import ExUnit.Assertions
for call <- [:assert, :refute] do
def unquote(:"#{call}_status")(conn, status_code) do
a = conn.status
e = status_code
ExUnit.Assertions.unquote(call)(a == e, [
left: a,
message: "Expected status code #{inspect(e)}, got #{... | lib/fugue/assertions.ex | 0.666171 | 0.590425 | assertions.ex | starcoder |
defmodule Workflows.Activity.Wait do
@moduledoc false
alias Workflows.Activity
alias Workflows.ActivityUtil
alias Workflows.Event
alias Workflows.Path
alias Workflows.ReferencePath
@behaviour Activity
@type wait ::
{:seconds, pos_integer()}
| {:seconds_path, Path.t()}
| ... | lib/workflows/activity/wait.ex | 0.770939 | 0.423816 | wait.ex | starcoder |
defmodule Numbers do
require Integer
use Koans
@intro "Why is the number six so scared? Because seven eight nine!\nWe should get to know numbers a bit more!"
koan "Is an integer equal to its float equivalent?" do
assert 1 == 1.0 == ___
end
koan "Is an integer threequal to its float equivalent?" do
... | lib/koans/03_numbers.ex | 0.808408 | 0.834744 | 03_numbers.ex | starcoder |
defmodule Cldr.Substitution do
@moduledoc """
Compiles substituation formats that are of the form
"{0} something {1}" into a token list that allows for
more efficient parameter substituation at runtime.
"""
@doc """
Parses a substitution template into a list of tokens to
allow efficient parameter subst... | lib/cldr/substitution.ex | 0.887339 | 0.686101 | substitution.ex | starcoder |
defmodule ExDiet.Food.NutritionFacts do
@moduledoc """
Calculates nutrition facts per 100g of product.
* `ExDiet.Food.Ingredient`
* `ExDiet.Food.RecipeIngredient`
* `ExDiet.Food.Meal`
* `ExDiet.Food.Calendar`
"""
@type t :: %__MODULE__{
protein: Decimal.t(),
fat: Decimal.t(),
... | lib/ex_diet/food/nutrition_facts.ex | 0.769557 | 0.606848 | nutrition_facts.ex | starcoder |
defmodule CoursePlanner.Attendances do
@moduledoc """
This module provides custom functionality for controller over the model
"""
import Ecto.Query
alias CoursePlanner.{Repo, Courses.OfferedCourse, Attendances.Attendance, Classes}
alias CoursePlannerWeb.{Endpoint, Router.Helpers}
alias Ecto.{Multi, DateT... | lib/course_planner/attendances/attendances.ex | 0.693161 | 0.707051 | attendances.ex | starcoder |
defmodule RateTheDub.DubVotes do
@moduledoc """
The DubVotes context.
"""
import Ecto.Query, warn: false
alias RateTheDub.Repo
alias RateTheDub.DubVotes.Vote
@doc """
Returns the list of dubvotes.
## Examples
iex> list_dubvotes()
[%Vote{}, ...]
"""
def list_dubvotes do
Repo.a... | lib/ratethedub/dub_votes.ex | 0.82566 | 0.442817 | dub_votes.ex | starcoder |
defmodule Brando.Datasource do
@moduledoc """
Helpers to register datasources for interfacing with the block editor
### List
A set of entries is returned automatically
#### Example
list :all_posts_from_year, fn module, arg ->
{:ok, Repo.all(from t in module, where: t.year == ^arg)}
... | lib/brando/datasource.ex | 0.733547 | 0.677717 | datasource.ex | starcoder |
defmodule Rtmp.Handshake do
@moduledoc """
Provides functionality to handle the RTMP handshake process.
## Examples
The following is an example of handling a handshake as a server:
# Since we are a server we don't know what handshake type
# the client will send
{handshake, %RtmpHandshake.Pa... | apps/rtmp/lib/rtmp/handshake.ex | 0.793986 | 0.468669 | handshake.ex | starcoder |
defmodule Timex.Parse.DateTime.Tokenizers.Directive do
@moduledoc false
alias Timex.Parse.DateTime.Parsers
alias Timex.Parse.DateTime.Tokenizers.Directive
defstruct type: :literal,
value: nil,
modifiers: [],
flags: [],
width: [min: -1, max: nil],
pars... | lib/parse/datetime/tokenizers/directive.ex | 0.874238 | 0.5526 | directive.ex | starcoder |
defmodule Lonely.Result do
@moduledoc """
Composes the tuples `{:ok, a}` and `{:error, e}` as the type `Result.t`.
It is common to get either a value or `nil`. A way to apply a function to
a value letting `nil` untouched.
The following example will return `20` when `n = 2` and `nil` when `n > 3`.
impo... | lib/lonely/result.ex | 0.87308 | 0.700101 | result.ex | starcoder |
defmodule Access do
@moduledoc """
Key-based access to data structures.
The `Access` module defines a behaviour for dynamically accessing
keys of any type in a data structure via the `data[key]` syntax.
`Access` supports keyword lists (`Keyword`) and maps (`Map`) out
of the box. Keywords supports only ato... | lib/elixir/lib/access.ex | 0.913378 | 0.672832 | access.ex | starcoder |
defmodule Pbkdf2KeyDerivation do
@doc ~S"""
Derives a key of length `key_bytes` for `pass`,
using `algo` and `salt` for `count` iterations.
To raise on error use `Pbkdf2KeyDerivation.pbkdf2!/5`
## Example
```
iex> Pbkdf2KeyDerivation.pbkdf2("password", "<PASSWORD>", :sha512, 1000, 64)
{:ok,
<<175, 2... | lib/pbkdf2_key_derivation.ex | 0.882035 | 0.823328 | pbkdf2_key_derivation.ex | starcoder |
defmodule Opus.Pipeline do
@moduledoc ~S"""
Defines a pipeline.
A pipeline defines a single entry point function to start running the defined stages.
A simple pipeline module can be defined as:
defmodule ArithmeticPipeline do
use Opus.Pipeline
step :to_integer, with: &:erlang.binary_to... | lib/opus/pipeline.ex | 0.914715 | 0.908456 | pipeline.ex | starcoder |
defmodule Instream.Decoder.CSV do
@moduledoc false
alias Instream.Decoder.RFC3339
NimbleCSV.define(__MODULE__.Parser, separator: ",", escape: "\"")
@doc """
Converts a full CSV response into a list of maps.
"""
@spec parse(binary) :: [map]
def parse(response) do
response
|> String.trim_traili... | lib/instream/decoder/csv.ex | 0.720762 | 0.521715 | csv.ex | starcoder |
defmodule AWS.CloudWatchEvents do
@moduledoc """
Amazon EventBridge helps you to respond to state changes in your AWS
resources. When your resources change state, they automatically send events
into an event stream. You can create rules that match selected events in
the stream and route them to targets to ta... | lib/aws/generated/cloud_watch_events.ex | 0.872184 | 0.498962 | cloud_watch_events.ex | starcoder |
defmodule Mudkip.Rules.Default do
@moduledoc """
Default rendering rules set. The other rendering rules may be written using this one as
an example.
Every rules set should has method `render/1` accepting the list of binary strings as
the only parameter. Then this list should be compiled to HTML in a... | lib/rules/default.ex | 0.530966 | 0.456046 | default.ex | starcoder |
defmodule OpcUA.BaseNodeAttrs do
@moduledoc """
Base Node Attributes
Nodes contain attributes according to their node type. The base node
attributes are common to all node types. In the OPC UA `services`,
attributes are referred to via the `nodeid` of the containing node and
an integer `at... | lib/opc_ua/nodestore/node_types.ex | 0.662469 | 0.798933 | node_types.ex | starcoder |
defmodule UAInspector.Config do
@remote_release "6.0.0"
@moduledoc """
Module to simplify access to configuration values with default values.
There should be no configuration required to start using `:ua_inspector` if
you rely on the default values:
remote_database = "https://raw.githubusercontent.co... | lib/ua_inspector/config.ex | 0.868813 | 0.476701 | config.ex | starcoder |
defmodule Ewebmachine.Plug.Debug do
@moduledoc ~S"""
A ewebmachine debug UI at `/wm_debug`
Add it before `Ewebmachine.Plug.Run` in your plug pipeline when you
want debugging facilities.
```
if Mix.env == :dev, do: plug Ewebmachine.Plug.Debug
```
Then go to `http://youhost:yourport/wm_debug`, you will... | lib/ewebmachine/plug.debug.ex | 0.665411 | 0.574932 | plug.debug.ex | starcoder |
defmodule ExRabbitMQ.Connection do
@moduledoc """
A `GenServer` implementing a long running connection to a RabbitMQ server.
Consumers and producers share connections and when a connection reaches the default limit of **65535** channels
or the maximum channels per connection that has been set in the configurat... | lib/ex_rabbit_m_q/connection.ex | 0.878555 | 0.445952 | connection.ex | starcoder |
if Code.ensure_loaded?(:telemetry) do
defmodule Tesla.Middleware.Telemetry do
@moduledoc """
Emits events using the `:telemetry` library to expose instrumentation.
## Examples
```
defmodule MyClient do
use Tesla
plug Tesla.Middleware.Telemetry
end
:telemetry.attach(
"... | lib/tesla/middleware/telemetry.ex | 0.866683 | 0.81648 | telemetry.ex | starcoder |
defmodule Nabo.Post do
@moduledoc """
A struct that represents a post.
This struct represents a post with its metadata, excerpt and post body, returned by
`Nabo.Repo`.
## Format
Post should be in this format:
metadata (JSON, mandatory)
---
post excerpt (Markdown, optional)
---
... | lib/nabo/post.ex | 0.908661 | 0.404302 | post.ex | starcoder |
defmodule AWS.SNS do
@moduledoc """
Amazon Simple Notification Service
Amazon Simple Notification Service (Amazon SNS) is a web service that
enables you to build distributed web-enabled applications. Applications can
use Amazon SNS to easily push real-time notification messages to interested
subscribers o... | lib/aws/generated/sns.ex | 0.840717 | 0.629746 | sns.ex | starcoder |
defmodule Neoscan.Vm.Disassembler do
@moduledoc ""
# credo:disable-for-lines:118
@opcodes_list %{
# An empty array of bytes is pushed onto the stack.
"00" => "PUSH0",
"PUSH0" => "PUSHF",
# 0x01-0x4B The next opcode bytes is data to be pushed onto the stack
"01" => "PUSHBYTES1",
"4b" => "PU... | apps/neoscan/lib/neoscan/vm/disassembler.ex | 0.570451 | 0.452415 | disassembler.ex | starcoder |
defmodule Session.Answer do
@moduledoc false
use Protobuf, syntax: :proto3
@type t :: %__MODULE__{
answer: {atom, any}
}
defstruct [:answer]
oneof(:answer, 0)
field(:answerGroup, 1, type: Session.AnswerGroup, oneof: 0)
field(:conceptMap, 2, type: Session.ConceptMap, oneof: 0)
field(:... | lib/proto/Answer.pb.ex | 0.757391 | 0.544075 | Answer.pb.ex | starcoder |
defmodule TwelveDays do
# define word list using sigil ~w
# zero is only used to make the number equal to the word
@number_in_word ~w(
zero
first
second
third
fourth
fifth
sixth
seventh
eighth
ninth
tenth
eleventh
twelfth
)
# value for index 0 is not used
... | twelve-days/lib/twelve_days.ex | 0.694095 | 0.556821 | twelve_days.ex | starcoder |
defmodule Ivy.Core.Datom do
alias Ivy.Core
alias Ivy.Core.{Anomaly, Database, Transaction}
@behaviour Access
@type value :: String.t | atom | boolean | ref | DateTime.t | UUID.t | number
@type ref :: ivy_identifier | Core.temp_id
@type ivy_identifier :: eid | lookup_ref | Core.ident
@type lookup_ref :: ... | lib/core/datom.ex | 0.779909 | 0.49048 | datom.ex | starcoder |
defmodule Graphqexl.Tokens do
@moduledoc """
Mostly a databag module containing keywords, tokens and regex patterns related to the GraphQL
spec. Also contains functions for fetching them by key.
"""
@moduledoc since: "0.1.0"
# TODO: Make the structure here more closely represent the definitions exactly as ... | lib/graphqexl/tokens.ex | 0.561816 | 0.494019 | tokens.ex | starcoder |
defmodule HTMLAssertion.DSL do
@moduledoc ~S"""
Add additional syntax to passing current context inside block
### Example: pass context
```
assert_select html, ".container" do
assert_select "form", action: "/users" do
refute_select ".flash_message"
assert_select ".control_group" do
as... | lib/html_assertion/dsl.ex | 0.813016 | 0.807005 | dsl.ex | starcoder |
defmodule HorasTrabalhadasElixir.Business do
@moduledoc """
Módulo com as Regras de Negócio da Aplicação.
"""
alias HorasTrabalhadasElixir.Utils.TimeUtils
@space_delimiters [" ", "\t"]
@doc """
Realiza o processamento do arquivo de entrada `filepath`.
"""
@spec proccess_file(String.t) :: [[String... | horas_trabalhadas_elixir/lib/horas_trabalhadas_elixir/business.ex | 0.727589 | 0.436922 | business.ex | starcoder |
defmodule Similarity do
@moduledoc """
Contains basic functions for similarity calculation.
`Similarity.Cosine` - easy cosine similarity calculation
`Similarity.Simhash` - simhash similarity calculation between two strings
"""
defdelegate simhash(left, right, options \\ []), to: Similarity.Simhash, as: :... | lib/similarity.ex | 0.920834 | 0.83901 | similarity.ex | starcoder |
defmodule HTTPEventClient do
@moduledoc """
Emits events to an HTTP event server. Events can get sent either async or inline.
Events are sent over the default http method `POST`. This can be configured with
the `default_http_method` config option. Events are sent to the url provided with
the `event_server_... | lib/http_event_client.ex | 0.837421 | 0.540803 | http_event_client.ex | starcoder |
defmodule Kaffy.Routes do
@moduledoc """
Kaffy.Routes must be "used" in your phoenix routes:
```elixir
use Kaffy.Routes, scope: "/admin", pipe_through: [:browser, :authenticate]
```
`:scope` defaults to `"/admin"`
`:pipe_through` defaults to kaffy's `[:kaffy_browser]`
"""
# use Phoenix.Router
d... | lib/kaffy/routes.ex | 0.708112 | 0.456168 | routes.ex | starcoder |
defmodule Taco do
@moduledoc """
Composition and error handling of sequential computations, similar to
`Ecto.Multi`
Taco allows to create a chain of actions which might either succeed,
fail, or halt the execution of further actions in the pipeline.
Let's start with an example!
number = 2
Tac... | lib/taco.ex | 0.904808 | 0.716987 | taco.ex | starcoder |
defmodule Isotope.Noise do
@moduledoc """
Provide functions to create and work with different types of noises.
"""
@noise_types [
:perlin,
:perlin_fractal,
:simplex,
:simplex_fractal,
:value,
:value_fractal,
:cubic,
:cubic_fractal,
:cellular,
:white
]
alias Isotope.... | lib/noise.ex | 0.911266 | 0.779532 | noise.ex | starcoder |
defmodule ExMustang.Responders.Howdoi do
@moduledoc """
Implements [howdoi](https://github.com/gleitz/howdoi) like functionality
"""
use Hedwig.Responder
@google_base_url "https://www.google.com/search?q=site:stackoverflow.com%20"
@ua [
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like G... | lib/ex_mustang/responders/howdoi.ex | 0.601477 | 0.434341 | howdoi.ex | starcoder |
defmodule Spotter.Endpoint.Dynamic do
@moduledoc """
Wrapper for a resource with the dynamic path.
"""
use Spotter.Endpoint.Base
@good_match "[^{}\/.]+"
@dynamic_parameter ~r/({\s*[\w\d_-]+\s*})/
@valid_dynamic_parameter ~r/{(?P<var>[\w][\w\d_-]*)}/
@doc """
Defines the endpoint with dynamic path.
... | lib/endpoint/dynamic.ex | 0.776538 | 0.411406 | dynamic.ex | starcoder |
defmodule Phoenix.PubSub do
@moduledoc """
Serves as a Notification and PubSub layer for broad use-cases. Used internally
by Channels for pubsub broadcast.
## PubSub Adapter Contract
PubSub adapters need to only implement `start_link/2` and respond to a few
process-based messages to integrate with Phoenix... | lib/phoenix/pubsub.ex | 0.851027 | 0.558026 | pubsub.ex | starcoder |
defmodule Plug.Crypto.MessageVerifier do
@moduledoc """
`MessageVerifier` makes it easy to generate and verify messages
which are signed to prevent tampering.
For example, the cookie store uses this verifier to send data
to the client. The data can be read by the client, but cannot be
tampered with.
The... | lib/plug/crypto/message_verifier.ex | 0.834508 | 0.59705 | message_verifier.ex | starcoder |
defmodule MerklePatriciaTree.Trie.Destroyer do
@moduledoc """
Destroyer is responsible for removing keys from a
merkle trie. To remove a key, we need to make a
delta to our trie which ends up as the canonical
form of the given tree as defined in http://gavwood.com/Paper.pdf.
Note: this algorithm is non-obv... | lib/trie/destroyer.ex | 0.67854 | 0.550366 | destroyer.ex | starcoder |
defmodule Picam.FakeCamera do
@moduledoc """
A fake version of `Picam.Camera` that can be used in test and development
when a real Raspberry Pi Camera isn't available.
All the normal configuration commands are accepted and silently ignored,
except that:
* `size` can be set to one of 1920x1080, 1280x720,... | lib/picam/fake_camera.ex | 0.901364 | 0.86681 | fake_camera.ex | starcoder |
defmodule BlueHeron.HCI.Event.CommandComplete do
use BlueHeron.HCI.Event, code: 0x0E
@moduledoc """
> The Command Complete event is used by the Controller for most commands to
> transmit return status of a command and the other event parameters that are
> specified for the issued HCI command.
Reference: V... | lib/blue_heron/hci/events/command_complete.ex | 0.730001 | 0.415136 | command_complete.ex | starcoder |
defmodule IntersectionController.TrafficModel do
require Logger
def get_traffic_light_state(direction, intended_state)
def get_traffic_light_state("RTG", :initial) do
0
end
def get_traffic_light_state("RTG", :transition) do
1
end
def get_traffic_light_state("RTG", :end) do
2
end
def g... | lib/intersection_controller/traffic_model.ex | 0.574514 | 0.454896 | traffic_model.ex | starcoder |
defmodule Cldr.Unit.Backend do
def define_unit_module(config) do
module = inspect(__MODULE__)
backend = config.backend
config = Macro.escape(config)
quote location: :keep, bind_quoted: [module: module, backend: backend, config: config] do
defmodule Unit do
@moduledoc false
if Cl... | lib/cldr/unit/backend.ex | 0.867204 | 0.586345 | backend.ex | starcoder |
defmodule OrderedList do
@moduledoc ~S"""
Provides a set of algorithms for sorting and reordering the position number of maps in a list.
All of the functions expect a `List` where each element is a `Map` with a `:postion` key.
iex> original_list = [%{id: 1, position: 1},%{id: 2, position: 2}, %{id: 3, posi... | lib/ordered_list.ex | 0.865736 | 0.834542 | ordered_list.ex | starcoder |
defmodule Andi.InputSchemas.DatasetInput do
@moduledoc """
Module for validating Ecto.Changesets on flattened dataset input.
"""
import Ecto.Changeset
alias Andi.DatasetCache
alias Andi.InputSchemas.DatasetSchemaValidator
alias Andi.InputSchemas.Options
@business_fields %{
benefitRating: :float,
... | apps/andi/lib/andi/input_schemas/dataset_input.ex | 0.676513 | 0.440349 | dataset_input.ex | starcoder |
defmodule Mix.Deps.Retriever do
@moduledoc false
@doc """
Gets all direct children of the current `Mix.Project`
as a `Mix.Dep` record. Umbrella project dependencies
are included as children.
"""
def children do
scms = Mix.SCM.available
from = Path.absname("mix.exs")
Enum.map(Mix.project[:deps... | lib/mix/lib/mix/deps/retriever.ex | 0.731155 | 0.407274 | retriever.ex | starcoder |
defmodule ExUssd.Op do
@moduledoc false
alias ExUssd.{Display, Utils}
@allowed_fields [
:error,
:title,
:next,
:previous,
:should_close,
:split,
:delimiter,
:default_error,
:show_navigation,
:data,
:resolve,
:orientation,
:name,
:nav
]
@doc """
Add m... | lib/ex_ussd/op.ex | 0.671363 | 0.690331 | op.ex | starcoder |
defmodule Absinthe.Type.Field do
alias Absinthe.Type
@moduledoc """
Used to define a field.
Usually these are defined using `Absinthe.Schema.Notation.field/4`
See the `t` type below for details and examples of how to define a field.
"""
alias Absinthe.Type
alias Absinthe.Type.Deprecation
alias Abs... | lib/absinthe/type/field.ex | 0.946745 | 0.896704 | field.ex | starcoder |
defmodule AWS.Budgets do
@moduledoc """
Budgets enable you to plan your service usage, service costs, and your RI
utilization. You can also track how close your plan is to your budgeted
amount or to the free tier limits. Budgets provide you with a quick way to
see your usage-to-date and current estimated cha... | lib/aws/budgets.ex | 0.752104 | 0.557123 | budgets.ex | starcoder |
defmodule Cldr.DateTime.Interval do
@moduledoc """
Interval formats allow for software to format intervals like "Jan 10-12, 2008" as a
shorter and more natural format than "Jan 10, 2008 - Jan 12, 2008". They are designed
to take a start and end date, time or datetime plus a formatting pattern
and use that inf... | lib/cldr/interval/date_time.ex | 0.939109 | 0.60013 | date_time.ex | starcoder |
defmodule HubStops do
@moduledoc """
Represents a list of Hub Stops
"""
alias Routes.Route
@commuter_hubs [
{"place-sstat", "/images/stops/south_station",
"Entrances to Red Line and Commuter Rail outside South Station"},
{"place-north", "/images/stops/north_station_commuter",
"People walki... | apps/site/lib/hub_stops.ex | 0.716417 | 0.462291 | hub_stops.ex | starcoder |
defmodule Romeo.Stanza do
@moduledoc """
Provides convenience functions for building XMPP stanzas.
"""
use Romeo.XML
@doc """
Converts an `xml` record to an XML binary string.
"""
def to_xml(record) when Record.is_record(record) do
Romeo.XML.encode!(record)
end
def to_xml(record) when Record.... | lib/romeo/stanza.ex | 0.816772 | 0.42674 | stanza.ex | starcoder |
defmodule Faker.Address do
defdelegate postcode, to: Faker.Address, as: :zip_code
defdelegate zip, to: Faker.Address, as: :zip_code
data_path = Path.expand(Path.join(__DIR__, "../../priv/address.json"))
json = File.read!(data_path) |> Poison.Parser.parse!
Enum.each json, fn(el) ->
{lang, data} = el
E... | lib/faker/address.ex | 0.527803 | 0.418489 | address.ex | starcoder |
defmodule Livebook.Utils.ANSI.Modifier do
@moduledoc false
defmacro defmodifier(modifier, code, terminator \\ "m") do
quote bind_quoted: [modifier: modifier, code: code, terminator: terminator] do
defp ansi_prefix_to_modifier(unquote("[#{code}#{terminator}") <> rest) do
{:ok, unquote(modifier), r... | lib/livebook/utils/ansi.ex | 0.786336 | 0.455259 | ansi.ex | starcoder |
defmodule Familiar do
@moduledoc """
Helper functions for creating database views and functions - your database's
familiars.
View and function definitions are stored as SQL files in `priv/repo/views` and
`priv/repo/functions` respectively.
Each definition file has the following file name format:
NA... | lib/familiar.ex | 0.884782 | 0.63409 | familiar.ex | starcoder |
defmodule SymmetricEncryption do
@moduledoc """
Symmetric Encryption.
Supports AES symmetric encryption using the CBC block cipher.
"""
@doc """
Encrypt String data.
## Examples
iex> SymmetricEncryption.encrypt("Hello World")
"QEVuQwIAPiplaSyln4bywEKXYKDOqQ=="
"""
defdelegate encrypt... | lib/symmetric_encryption.ex | 0.879257 | 0.455804 | symmetric_encryption.ex | starcoder |
defmodule URI do
@moduledoc """
Utilities for working with and creating URIs.
"""
defrecord Info, [scheme: nil, path: nil, query: nil,
fragment: nil, authority: nil,
userinfo: nil, host: nil, port: nil]
import Bitwise
@ports [
{ "ftp", 21 },
{ "http", 80 },
... | lib/elixir/lib/uri.ex | 0.847653 | 0.534187 | uri.ex | starcoder |
defmodule Mimic.Cover do
@moduledoc """
Abuse cover private functions to move stuff around.
Completely based on meck's solution:
https://github.com/eproxus/meck/blob/2c7ba603416e95401500d7e116c5a829cb558665/src/meck_cover.erl#L67-L91
"""
@doc false
def export_private_functions do
{_, binary, _} = :c... | lib/mimic/cover.ex | 0.639849 | 0.464355 | cover.ex | starcoder |
defmodule Mix.Tasks.Espec do
alias Mix.Utils.Stale
defmodule Cover do
@moduledoc false
def start(compile_path, opts) do
Mix.shell().info("Cover compiling modules ... ")
_ = :cover.start()
case :cover.compile_beam_directory(compile_path |> to_charlist) do
results when is_list(res... | lib/mix/tasks/espec.ex | 0.705988 | 0.54462 | espec.ex | starcoder |
defmodule Parser do
use Platform.Parsing.Behaviour
## test payloads
# 02035a0003800a8000800080008009812b8014810880b4a57c820c810980027fe88056800880040bf5
# 02035a00020bf5
def fields do
[
%{field: "solar_radiation", display: "Solar radiation", unit: "W⋅m⁻²"},
%{field: "precipitation", dis... | DL-ATM41/DL-ATM41.ELEMENT-IoT.ex | 0.51879 | 0.522385 | DL-ATM41.ELEMENT-IoT.ex | starcoder |
defmodule ICouch.Document do
@moduledoc """
Module which handles CouchDB documents.
The struct's main use is to to conveniently handle attachments. You can
access the fields transparently with `doc["fieldname"]` since this struct
implements the Elixir Access behaviour. You can also retrieve or pattern match... | lib/icouch/document.ex | 0.857813 | 0.495545 | document.ex | starcoder |
defmodule Aja.Enum do
@moduledoc """
Drop-in replacement for the `Enum` module, optimized to work with Aja's data structures such as `Aja.Vector`.
It currently only covers a subset of `Enum`, but `Aja.Enum` aims to completely mirror the API of `Enum`,
and should behave exactly the same for any type of `Enumera... | lib/enum.ex | 0.798029 | 0.824391 | enum.ex | starcoder |
defmodule Ockam.SecureChannel.EncryptedTransportProtocol.AeadAesGcm do
@moduledoc false
alias Ockam.Message
alias Ockam.Router
alias Ockam.Vault
alias Ockam.Wire
def setup(_options, initial_state, data) do
{:ok, initial_state, data}
end
## TODO: batter name to not collide with Ockam.Worker.handle... | implementations/elixir/ockam/ockam/lib/ockam/secure_channel/encrypted_transport_protocol/aead_aes_gcm.ex | 0.547948 | 0.480418 | aead_aes_gcm.ex | starcoder |
defmodule Dust.Parsers.URI do
@moduledoc """
Parse document and returl all links/URIs to
styles with absolute urls.
"""
@css_url_regex ~r/url\(['"]?(?<uri>.*?)['"]?\)/
@doc """
Extract all CSS `url(...)` links
"""
@spec parse(String.t()) :: list(String.t())
def parse(content) do
@css_url_regex
... | lib/dust/parsers/uri.ex | 0.723016 | 0.546254 | uri.ex | starcoder |
if Code.ensure_loaded?(Ecto.Type) do
defmodule Money.Ecto.Map.Type do
@moduledoc """
Implements Ecto.Type behaviour for Money, where the underlying schema type
is a map.
This is the required option for databases such as MySQL that do not support
composite types.
In order to preserve precisio... | lib/money/ecto/money_ecto_map_type.ex | 0.654784 | 0.463748 | money_ecto_map_type.ex | starcoder |
defmodule AttributeRepository.Write do
@moduledoc """
Callbacks for modification of entries
There are 3 callbacks:
- `put/3` that entirely replaces the resource with new attribute values
- `modify/3` that replaces some attributes
- `delete/2` that deletes an entire resource
"""
@doc """
Replaces a n... | lib/attribute_repository/write.ex | 0.884233 | 0.57827 | write.ex | starcoder |
defmodule Cerebrum.Genotype.Cypher do
alias Cerebrum.Neuron
alias Cerebrum.Sensor
alias Cerebrum.Actuator
def create_node(%Neuron{name: name, activation_function: activation_function, bias: bias}, graph_name) do
"CREATE (#{name}:Neuron {activation_function:'#{activation_function}', bias: #{bias}, #{graph_name}: ... | lib/Genotype/cypher.ex | 0.654453 | 0.647074 | cypher.ex | starcoder |
defmodule ExRaft.StateMachine do
@moduledoc """
A behaviour module for implementing consistently replicated state machines.
## Example
To start things off, let's see a code example implementing a simple
key value store in `ExRaft` style:
defmodule KeyValueStore do
@behaviour ExRaft.StateMachi... | lib/ex_raft/state_machine.ex | 0.889 | 0.600745 | state_machine.ex | starcoder |
defmodule CQL.Result.Rows do
@moduledoc """
Represents a CQL rows result
"""
import CQL.DataTypes.Decoder, except: [decode: 2]
defstruct [
:columns,
:columns_count,
:column_types,
:rows,
:rows_count,
:paging_state,
]
@doc false
def decode_meta(buffer) do
with {:ok, %CQL.Fr... | lib/cql/result/rows.ex | 0.789518 | 0.512449 | rows.ex | starcoder |
defmodule Exchange.OrderBook do
@moduledoc """
The Order Book is the Exchange main data structure. It holds the Order Book
in Memory where the MatchingEngine realizes the matches and register the Trades.
Example of and Order Book for Physical Gold (AUX) in London Market
Orders with currency in Great British ... | lib/exchange/order_book.ex | 0.93034 | 0.924586 | order_book.ex | starcoder |
defmodule Kino.Output do
@moduledoc """
A number of output formats supported by Livebook.
"""
@typedoc """
Livebook cell output may be one of these values and gets rendered accordingly.
"""
@type t ::
ignored()
| text_inline()
| text_block()
| markdown()
... | lib/kino/output.ex | 0.854019 | 0.480296 | output.ex | starcoder |
defmodule Grizzly.ZWave.Commands.LearnModeSetStatus do
@moduledoc """
This command is used to indicate the progress of the Learn Mode Set command.
Params:
* `:seq_number` - the command sequence number
* `:status` - the outcome of the learn mode, one of :done, :failed or :security_failed
* `:new_no... | lib/grizzly/zwave/commands/learn_mode_set_status.ex | 0.847826 | 0.517327 | learn_mode_set_status.ex | starcoder |
defmodule RandomBytes do
@moduledoc ~S"""
Generate random strings in a few different formats.
"""
@doc """
Generates a random base62 string.
A `base64` string typically contains the `+` and `\/` characters as its extra 2 characters.
When the string will be used in a url, the `+` and `\/` are usually rep... | lib/random_bytes.ex | 0.842653 | 0.619989 | random_bytes.ex | starcoder |
defmodule BSV.Util do
@moduledoc """
A collection of commonly used helper methods.
"""
@doc """
Encodes the given binary data with the specified encoding scheme.
## Options
The accepted encoding schemes are:
* `:base64` - Encodes the binary using Base64
* `:hex` - Encodes the binary using Base16 (... | lib/bsv/util.ex | 0.904217 | 0.613497 | util.ex | starcoder |
defmodule Phoenix.Config do
@moduledoc """
Handles Mix Config lookup and default values from Application env
Uses Mix.Config `:phoenix` settings as configuration with `@defaults` fallback
Each Router requires an `:endpoint` mapping with Router specific options.
See `@defaults` for a full list of available... | lib/phoenix/config.ex | 0.861101 | 0.435841 | config.ex | starcoder |
defmodule Kukumo.Feature.MissingStepError do
@moduledoc """
Raises an error, because a feature step is missing its implementation.
The message of the error will give the user a useful code snippet where
variables in feature steps are converted to regex capture groups.
"""
defexception [:message]
@numbe... | lib/cabbage/feature/missing_step_error.ex | 0.52756 | 0.402921 | missing_step_error.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.915393 | 0.671093 | fraud_detector.ex | starcoder |
defmodule LocalLedger.Transaction do
@moduledoc """
This module is responsible for preparing and formatting the transactions
before they are passed to an entry to be inserted in the database.
"""
alias LocalLedgerDB.{Balance, MintedToken, Transaction}
@doc """
Get or insert the given minted token and all... | apps/local_ledger/lib/local_ledger/transaction.ex | 0.820793 | 0.523055 | transaction.ex | starcoder |
defmodule LiveViewStudio.Boats do
@moduledoc """
The Boats context.
"""
import Ecto.Query, warn: false
alias LiveViewStudio.Repo
alias LiveViewStudio.Boats.Boat
# [type: "sporting", prices: ["$", "$$"]]
def list_boats(criteria) when is_list(criteria) do
query = from(b in Boat)
Enum.reduce(c... | live_view_studio/lib/live_view_studio/boats.ex | 0.850748 | 0.515132 | boats.ex | starcoder |
defmodule OpenTelemetry.Honeycomb.Json do
@moduledoc """
JSON back end.
The OpenTelemetry Honeycomb Exporter uses a `Jason`-style JSON encoder via a behaviour so you
can adapt it to your preferred JSON encoder or decode/encode options.
To use `Poison`, install it. The exporter defaults `json_backend` to
`... | lib/open_telemetry/honeycomb/json.ex | 0.909679 | 0.764056 | json.ex | starcoder |
defmodule Rackla do
@moduledoc Regex.replace(~r/```(elixir|json)(\n|.*)```/Us, File.read!("README.md"),
fn(_, _, code) -> Regex.replace(~r/^/m, code, " ") end)
import Plug.Conn
require Logger
@type t :: %__MODULE__{producers: [pid]}
defstruct producers: []
@doc """
Takes a single string (URL) o... | lib/rackla.ex | 0.728265 | 0.634458 | rackla.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.