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 Terp.Evaluate.Function do
@moduledoc """
Function/anonymous function definition and application.
Functions in `terp` are defined with the `lambda` keyword.
The list of arguments must be quoted; multiple arguments can be specified.
Terp functions are curried out-of-the-box.
## Examples
i... | lib/evaluate/function.ex | 0.779238 | 0.591664 | function.ex | starcoder |
defmodule PowAssent.Phoenix.ViewHelpers do
@moduledoc """
View helpers to render authorization links.
"""
alias PowAssent.Plug
alias Phoenix.{HTML, HTML.Link}
alias PowAssent.Phoenix.AuthorizationController
@doc """
Generates list of authorization links for all configured providers.
The list of pro... | lib/pow_assent/phoenix/views/view_helpers.ex | 0.808521 | 0.408483 | view_helpers.ex | starcoder |
defmodule Nixa.NaiveBayes.Gaussian do
@moduledoc """
Implements the Gaussian Naive Bayes algorithm for continuous feature domains
"""
import Nixa.NaiveBayes.Shared
import Nixa.Stats
import Nx.Defn
defstruct [
class_probs: nil,
means: nil,
stds: nil
]
@doc """
Train a model using the p... | lib/nixa/naive_bayes/gaussian.ex | 0.861989 | 0.626367 | gaussian.ex | starcoder |
defprotocol SimpleStatEx.Query.Stat do
@moduledoc """
Interface to query stats from the configured Repo
"""
@doc """
Insert a new stat or new stats to the means of storage
"""
def insert(stat)
@doc """
Retrieve a stat or set of stats from the means of storage
"""
def retrieve(stat, stat_query)... | lib/query/protocol_stat.ex | 0.824603 | 0.568835 | protocol_stat.ex | starcoder |
defmodule Mix.Shell.Process do
@moduledoc """
This is a Mix shell that uses the current process mailbox
for communication instead of IO.
When a developer calls `info("hello")`, the following
message will be sent to the current process:
{ :mix_shell, :info, ["hello"] }
This is mainly useful in tests... | lib/mix/lib/mix/shell/process.ex | 0.770335 | 0.480662 | process.ex | starcoder |
defmodule Timex.Interval do
@moduledoc """
This module is used for creating and manipulating date/time intervals.
## Examples
iex> use Timex
...> Interval.new(from: ~D[2016-03-03], until: [days: 3])
%#{__MODULE__}{from: ~N[2016-03-03 00:00:00], left_open: false, right_open: true, step: [days: ... | lib/interval/interval.ex | 0.912076 | 0.674091 | interval.ex | starcoder |
use Croma
defmodule RaftFleet.RecentlyRemovedGroups do
alias RaftFleet.NodesPerZone
defmodule NodesMap do
defmodule Pair do
use Croma.SubtypeOfTuple, elem_modules: [Croma.PosInteger, Croma.TypeGen.nilable(Croma.PosInteger)]
end
use Croma.SubtypeOfMap, key_module: Croma.Atom, value_module: Pair
... | lib/raft_fleet/recently_removed_groups.ex | 0.66356 | 0.479808 | recently_removed_groups.ex | starcoder |
defprotocol ExMatch.Match do
@moduledoc false
@fallback_to_any true
@spec diff(t, any, any) :: [any] | {any, any}
def diff(left, right, opts)
@spec escape(t) :: any
def escape(self)
@spec value(t) :: any
def value(self)
end
defimpl ExMatch.Match, for: Any do
@moduledoc false
def diff(left, rig... | lib/exmatch/match.ex | 0.773473 | 0.57678 | match.ex | starcoder |
defmodule Plug.Adapters.Cowboy do
@moduledoc """
Adapter interface to the Cowboy webserver.
## Options
* `:ip` - the ip to bind the server to.
Must be a tuple in the format `{x, y, z, w}`.
* `:port` - the port to run the server.
Defaults to 4000 (http) and 4040 (https).
* `:acceptors` - the numb... | lib/plug/adapters/cowboy.ex | 0.875081 | 0.444685 | cowboy.ex | starcoder |
defmodule Dpos.Tx do
import Dpos.Utils, only: [hexdigest: 1]
alias Salty.Sign.Ed25519
@keys [
:id,
:recipientId,
:senderPublicKey,
:signature,
:signSignature,
:timestamp,
:type,
address_suffix_length: 1,
amount: 0,
asset: %{},
fee: 0
]
@json_keys [
:id,
:... | lib/tx/tx.ex | 0.806396 | 0.616878 | tx.ex | starcoder |
defmodule AWS.DataSync do
@moduledoc """
AWS DataSync
AWS DataSync is a managed data transfer service that makes it simpler for you to
automate moving data between on-premises storage and Amazon Simple Storage
Service (Amazon S3) or Amazon Elastic File System (Amazon EFS).
This API interface reference fo... | lib/aws/generated/data_sync.ex | 0.81283 | 0.520557 | data_sync.ex | starcoder |
defmodule Apoc.RSA.PrivateKey do
@moduledoc """
A Struct and set of functions to represent an RSA private key based
on the underlying erlang representation.
For information on key formats in PKI see [PKI PEM overview](https://gist.github.com/awood/9338235)
or [RFC5912](https://tools.ietf.org/html/rfc5912)
... | lib/apoc/rsa/private_key.ex | 0.796015 | 0.63968 | private_key.ex | starcoder |
defmodule Watchman.Query do
defstruct [:generator, expression: %{}, fields: ["name"]]
end
defmodule Watchman do
@moduledoc """
A file watching service.
Watchman exists to watch files and send messages to your Erlang processes when they change.
This modules uses [`watchman`](https://facebook.github.io/watchma... | lib/watchman.ex | 0.676299 | 0.463262 | watchman.ex | starcoder |
defmodule Typesense.Collections do
@moduledoc """
The `Typesense.Collections` module is the service implementation for Typesense' `Collections` API Resource.
"""
@doc """
Create a Collection.
## Examples
```
schema = %{
name: "companies",
fields: [
%{name: "company_name", type: "string"... | lib/typesense/collections/collections.ex | 0.89605 | 0.85567 | collections.ex | starcoder |
defmodule Ameritrade.Quote.Index do
@moduledoc false
@derive Jason.Encoder
defstruct symbol: nil,
description: nil,
lastPrice: 0,
openPrice: 0,
highPrice: 0,
lowPrice: 0,
closePrice: 0,
netChange: 0,
totalVolume: 0,
... | lib/schema/quote.ex | 0.644449 | 0.606994 | quote.ex | starcoder |
defmodule Calcy do
@moduledoc """
Documentation for Calcy.
"""
@doc """
Runs over input and tokenizes it
"""
def run(input, env) do
tokens = Calcy.Lexer.lex(input)
case length(tokens) do
0 -> {}
_ -> continue(tokens, env)
end
end
@doc """
Gets a list of tokens and parses it... | lib/calcy.ex | 0.578448 | 0.491395 | calcy.ex | starcoder |
defmodule MerkleTree do
@moduledoc """
A hash tree or Merkle tree is a tree in which every non-leaf node is labelled
with the hash of the labels or values (in case of leaves) of its child nodes.
Hash trees are useful because they allow efficient and secure verification of
the contents of large data st... | lib/merkle_tree.ex | 0.863435 | 0.528898 | merkle_tree.ex | starcoder |
defmodule Exbee do
@moduledoc """
Communicate with [XBee](http://en.wikipedia.org/wiki/XBee) wireless radios in Elixir.
This assumes that XBee modules are in API mode. In API mode, XBee modules send and receive
commands via encoded frames. Possible frames include:
* `Exbee.ATCommandFrame`
* `Exbee.ATC... | lib/exbee.ex | 0.902757 | 0.552359 | exbee.ex | starcoder |
defmodule MatrexNumerix.Fft do
@moduledoc """
Computes the discrete Fourier transform (DFT) of the given complex vector.
"""
import Matrex.Guards
alias Matrex.Vector
def dft_freq_and_amplitude(
vector_data(len1, _body1) = x,
vector_data(len2, _body2) = y
) when len1 == len2 do
sa... | lib/fft.ex | 0.919584 | 0.707809 | fft.ex | starcoder |
defmodule Vector do
defstruct x1: 0,
y1: 0,
x2: 0,
y2: 0,
orientation: :point,
slope: 0.0,
covered_points: [],
b: 0.0
@type t(x1, y1, x2, y2, orientation, slope, covered_points, slope) :: %Vector{
x1: x1,
y1: y1... | lib/y_2021/d5/day5.ex | 0.86012 | 0.870377 | day5.ex | starcoder |
defmodule Type.Function do
@moduledoc """
represents a function type.
There are two fields for the struct defined by this module.
- `params` a list of types for the function arguments. Note that the arity
of the function is the length of this list. May also be the atom `:any`
which corresponds to "... | lib/type/function.ex | 0.898182 | 0.970632 | function.ex | starcoder |
defmodule Flex.EngineAdapter.TakagiSugeno do
@moduledoc """
Takagi-Sugeno-Kang fuzzy inference uses singleton output membership functions that are either constant or a linear function of the input values.
The defuzzification process for a Sugeno system is more computationally efficient compared to that of a Mamda... | lib/engine_adapters/takagi_sugeno.ex | 0.840029 | 0.583352 | takagi_sugeno.ex | starcoder |
defmodule Sqlitex.Server do
@moduledoc """
Sqlitex.Server provides a GenServer to wrap a sqlitedb.
This makes it easy to share a sqlite database between multiple processes without worrying about concurrency issues.
You can also register the process with a name so you can query by name later.
## Unsupervised ... | deps/sqlitex/lib/sqlitex/server.ex | 0.839537 | 0.788604 | server.ex | starcoder |
defmodule Xqlite.PragmaUtil do
@moduledoc ~S"""
A module with zero dependencies on the rest of the modules in this library.
Used to reduce boilerplate and slice and dice the pragmas collection (also used in tests).
"""
@type name :: atom()
@type spec :: keyword()
@type arg_type :: :blob | :bool | :int | ... | lib/xqlite/pragma_util.ex | 0.753648 | 0.563678 | pragma_util.ex | starcoder |
defmodule AdaptableCostsEvaluator.Formulas do
@moduledoc """
The Formulas context.
"""
import Ecto.Query, warn: false
alias AdaptableCostsEvaluator.Repo
alias AdaptableCostsEvaluator.Outputs
alias AdaptableCostsEvaluator.Formulas.Formula
alias AdaptableCostsEvaluator.Computations.Computation
@doc "... | lib/adaptable_costs_evaluator/formulas.ex | 0.906234 | 0.514644 | formulas.ex | starcoder |
defmodule Monad.Writer do
@moduledoc """
ML / Ocaml style functor
"""
defmacro functor(opts) do
module_name = Keyword.fetch!(opts, :module)
mempty = Keyword.fetch!(opts, :mempty)
mappend = Keyword.fetch!(opts, :mappend)
quote location: :keep do
defmodule unquote(module_name) do
... | writer_monad_from_first_principle/lib/monad.writer.ex | 0.628749 | 0.472744 | monad.writer.ex | starcoder |
defmodule Phoenix.Tracker do
@moduledoc ~S"""
Provides distributed Presence tracking to processes.
Tracker servers use a heartbeat protocol and CRDT to replicate presence
information across a cluster in an eventually consistent, conflict-free
manner. Under this design, there is no single source of truth or g... | deps/phoenix_pubsub/lib/phoenix/tracker.ex | 0.920994 | 0.65062 | tracker.ex | starcoder |
defmodule Bubblit.BubbleRooms do
@moduledoc """
The BubbleRooms context.
"""
import Ecto.Query, warn: false
alias Bubblit.Repo
alias Bubblit.Accounts.User
alias Bubblit.BubbleRooms.BubbleLog
@doc """
Returns the list of bubble_logs.
## Examples
iex> list_bubble_logs()
[%BubbleLog{},... | bubblit/lib/bubblit/bubble_rooms.ex | 0.859826 | 0.482612 | bubble_rooms.ex | starcoder |
defmodule NimbleTOTP do
@moduledoc ~S"""
NimbleTOTP is a tiny library for Two-factor authentication (2FA) that
allows developers to implement Time-Based One-Time Passwords (TOTP)
for their applications.
## Two-factor authentication (2FA)
The concept of 2FA is quite simple. It's an extra layer of security
... | lib/nimble_totp.ex | 0.81283 | 0.687643 | nimble_totp.ex | starcoder |
defmodule Cepex.CEP do
@moduledoc """
This module provides functions related to the Brazilian postal code (CEP) string
representation.
A valid CEP has eight digits, e.g. `80010180` (check `t:Cepex.CEP.t/0`).
"""
@typedoc """
The Brazilian postal code (CEP) string representation without formatting, e.g. ... | lib/cepex/cep.ex | 0.889915 | 0.587381 | cep.ex | starcoder |
defmodule PokerHands.Hand.Straight do
alias PokerHands.{Hand.HighCard, Utils}
@ace_high %PokerHands.Definitions{}.values_ace_high
@ace_low %PokerHands.Definitions{}.values_ace_low
@doc """
## Examples
iex> PokerHands.Hand.Straight.valid?(
iex> PokerHands.DealtHand.init("2H 3H 4H 5D 6D")
... | lib/poker_hands/hand/straight.ex | 0.644673 | 0.401688 | straight.ex | starcoder |
defmodule ExAeonsEnd.Card do
@moduledoc "
This is a simple structure that represents a card
At first pass, this is just a turn order card. This may eventually be refactored
to either support other types of cards, or be renamed to indicate that it is just
for turn order.
"
defstruct [:id, :name]
@type... | lib/ExAeonsEnd/card.ex | 0.793586 | 0.481454 | card.ex | starcoder |
defmodule Solarex.Moon do
@moduledoc """
Solarex.Moon is module for calculating moon phase for particular date.
This module implements naive approach by calculating the number of days since a known new moon.
See [Wikipedia](https://en.wikipedia.org/wiki/Lunar_phase#Calculating_phase) page for more info.
"""
... | lib/solarex/moon.ex | 0.912207 | 0.647652 | moon.ex | starcoder |
defmodule ForthVM.Words.Stack do
@moduledoc """
Stack words
"""
alias ForthVM.Process
import ForthVM.Utils
# ---------------------------------------------
# Stack operations
# ---------------------------------------------
@doc """
depth: ( -- x ) get stack depth
"""
def depth(tokens, data_st... | lib/forthvm/words/stack.ex | 0.798619 | 0.850965 | stack.ex | starcoder |
defmodule AWS.SWF do
@moduledoc """
Amazon Simple Workflow Service
The Amazon Simple Workflow Service (Amazon SWF) makes it easy to build
applications that use Amazon's cloud to coordinate work across distributed
components. In Amazon SWF, a *task* represents a logical unit of work that
is performed by a ... | lib/aws/swf.ex | 0.9298 | 0.567697 | swf.ex | starcoder |
defmodule Vault.Auth.Generic do
@moduledoc """
A Generic Auth Adapter. An alternative to writing your own adapter.
"""
@type request :: %{
path: String.t(),
method: :post,
body: map()
}
@type response :: %{
token: list(String.t()),
ttl: list(String.t... | lib/vault/auth/generic.ex | 0.858006 | 0.719999 | generic.ex | starcoder |
defmodule Bingo do
@moduledoc """
This is the Bingo Game. The game is a struct, with a value map, a row count map, and a column count map
The value map maps the value to its coordinates. For this game, the coordinates are 1..5
The row count map maps a row number to the count of marked numbers in the row.
The ... | apps/bingo/lib/bingo.ex | 0.800419 | 0.898053 | bingo.ex | starcoder |
defmodule Mastery.Core.Quiz do
alias Mastery.Core.{Template, Question, Response}
defstruct title: nil,
mastery: 3,
templates: %{},
used: [],
current_question: nil,
last_response: nil,
record: %{},
mastered: []
def new(fields) do... | lib/mastery/core/quiz.ex | 0.506591 | 0.460835 | quiz.ex | starcoder |
defmodule Nightcrawler.Parser do
@moduledoc """
Parses multiple things to deliver neat representations of entities
"""
@doc """
Grabs the title and start + end values
## Example
iex> Nightcrawler.Parser.title("Nightcrawler (2011 - 2018)")
%{title: "Nightcrawler", start: 2011, end: 2018}
... | apps/nightcrawler/lib/nightcrawler/parser.ex | 0.82347 | 0.435841 | parser.ex | starcoder |
defmodule Pigeon.Dispatcher do
@moduledoc """
Dispatcher worker for push notifications.
If your push workers are relatively static, it is encouraged to follow the adapter
guides. For other use cases, such as supporting dynamic configurations, dispatchers
can be started and stopped as needed.
## Using Dyna... | lib/pigeon/dispatcher.ex | 0.714429 | 0.571049 | dispatcher.ex | starcoder |
defmodule ReviewAnalysis do
@moduledoc """
Useful functions to analyse reviews contents.
"""
@overly_positive_words [
"awesome",
"best",
"friendly",
"amazing",
"excellent",
"better",
"wonderful",
"dream",
"excellence",
"highest",
"knowledgeable",
"fan",
"grea... | lib/review_analysis.ex | 0.69285 | 0.501404 | review_analysis.ex | starcoder |
defmodule Timber.Exceptions.Translator do
@moduledoc """
This module implements a Logger translator to take advantage of
the richer metadata available from Logger in OTP 21 and Elixir 1.7+.
Including the translator allows for crash reasons and stacktraces to be
included as structured metadata within Timber.
... | lib/timber_exceptions/translator.ex | 0.773772 | 0.810554 | translator.ex | starcoder |
defmodule Yum.Migration do
@moduledoc """
A struct that contains the migration info.
Migration items can optionally contain metadata associated with that
individual transaction.
"""
defstruct [
timestamp: -1,
move: [],
delete: [],
add: [],
update: ... | lib/yum/migration.ex | 0.831383 | 0.531696 | migration.ex | starcoder |
defmodule Membrane.RemoteControlled.Pipeline do
@moduledoc """
`Membrane.RemoteControlled.Pipeline` is a basic `Membrane.Pipeline` implementation that can be
controlled by a controlling process.
The controlling process can request the execution of arbitrary
valid `Membrane.Pipeline.Action`:
```
childre... | lib/membrane/remote_controlled/pipeline.ex | 0.941129 | 0.896523 | pipeline.ex | starcoder |
defmodule LoggerJSON.Ecto do
@moduledoc """
Implements the behaviour of `Ecto.LogEntry` and sends query as string
to Logger with additional metadata:
* result - the query result as an `:ok` or `:error` tuple;
* query_time - the time spent executing the query in microseconds;
* decode_time - the time ... | lib/logger_json/ecto.ex | 0.90485 | 0.585931 | ecto.ex | starcoder |
defmodule Dlex.Node do
@moduledoc """
Simple high level API for accessing graphs
## Usage
defmodule Shared do
use Dlex.Node
shared do
field :id, :string, index: ["term"]
field :name, :string, index: ["term"]
end
end
defmodule User do
use Dlex.Node, depends_o... | lib/dlex/node.ex | 0.771972 | 0.409044 | node.ex | starcoder |
defmodule Kryptiles do
@moduledoc """
"""
use Bitwise
@doc """
Returns a cryptographically strong pseudo-random data string.
Takes a size argument for the length of the string.
## Examples
iex> Kryptiles.random_string(0)
""
iex> Kryptiles.random_string(10)
"do77RukqJobZPG3rSJS... | lib/kryptiles.ex | 0.929664 | 0.490602 | kryptiles.ex | starcoder |
defmodule CouchGears.Database do
@moduledoc """
This module provides CRUD functions for managing either databases or documents.
The main important thing is a `database` module designed to be a 'instance' for certain DB (see examples below).
## Examples:
db = CouchGears.Database.open("db")
db.find(... | lib/couch_gears/database.ex | 0.809012 | 0.418816 | database.ex | starcoder |
defprotocol Digger do
@moduledoc """
Documentation for Digger Protocol
"""
@fallback_to_any true
alias Digger.Types
@doc """
'Atomize' a valid Types.data_type according to the protocol implementation
"""
@spec atomize(Types.data_type(), keyword()) :: Types.valid_return_type()
def atomize(
... | lib/protocols/digger_protocol.ex | 0.872266 | 0.512815 | digger_protocol.ex | starcoder |
defmodule Dingo.CoreUtils do
@moduledoc """
Utility functions for core gameplay
"""
@def_board %{
0 => %{0 => nil, 1 => nil, 2 => nil, 3 => nil, 4 => nil},
1 => %{0 => nil, 1 => nil, 2 => nil, 3 => nil, 4 => nil},
2 => %{0 => nil, 1 => nil, 2 => nil, 3 => nil, 4 => nil},
3 => %{0 => nil, 1 => ni... | lib/dingo/core_utils.ex | 0.749637 | 0.528047 | core_utils.ex | starcoder |
defmodule EpicenterWeb.Test.Pages.CaseInvestigationStartInterview do
import ExUnit.Assertions
import Phoenix.LiveViewTest
alias Epicenter.Cases.CaseInvestigation
alias Epicenter.Test
alias EpicenterWeb.Test.Pages
alias Phoenix.LiveViewTest.View
@form_id "case-investigation-interview-start-form"
def v... | test/support/pages/case_investigation_start_interview.ex | 0.589598 | 0.48987 | case_investigation_start_interview.ex | starcoder |
defmodule Himamo.BaumWelch do
@moduledoc ~S"""
Defines the Baum-Welch algorithm.
See `Himamo.BaumWelch.StepE` and `Himamo.BaumWelch.StepM` for details on its
respective expectation and maximization steps.
"""
defmodule Stats do
@moduledoc ~S"""
Defines the statistical properties of an HMM.
Se... | lib/himamo/baum_welch.ex | 0.793146 | 0.678999 | baum_welch.ex | starcoder |
defmodule P0 do
# Problem 01 - Write a function last : 'a list -> 'a option that returns the last element of a list.
def last([]), do: nil
def last([a]), do: a
def last([ _ | tail ]), do: last(tail)
# Problem 02 - Find the last but one (last and penultimate) elements of a list.
def last_two([]), do... | solutions/1-10.ex | 0.607197 | 0.575588 | 1-10.ex | starcoder |
defmodule Cielo.Transaction do
@moduledoc """
This module makes a transactions calls for credit, debit, bankslips and recurrent payments.
Cielo API reference:
- [Credit](https://developercielo.github.io/manual/cielo-ecommerce#cart%C3%A3o-de-cr%C3%A9dito)
- [Debit](https://developercielo.github.io/manual/ci... | lib/cielo/transaction.ex | 0.732113 | 0.413181 | transaction.ex | starcoder |
defmodule Day3 do
def solve do
config =
prepare_input()
|> Day3.prepare_config()
start = System.monotonic_time(unquote(:milli_seconds))
IO.puts("Part one answer:")
matrices =
config
|> Day3.build_matrices()
matrices
|> Day3.Part1.solve()
|> IO.puts()
time_pa... | elixir/day3/lib/day3.ex | 0.548674 | 0.421343 | day3.ex | starcoder |
defmodule Mbcs do
@moduledoc """
Wrapper for erlang-mbcs.
This module provides functions for character encoding conversion.
See `https://code.google.com/p/erlang-mbcs/` for detail.
## Usage
# Start mbcs server
iex> Mbcs.start
:ok
# Convert UTF-8 to Shift_JIS
iex> Mbcs.encode!(... | lib/mbcs.ex | 0.78609 | 0.430746 | mbcs.ex | starcoder |
defmodule InductiveGraph.Internal do
@moduledoc """
Functions to manage internal representation of inductive graph.
"""
alias InductiveGraph.Utilities
@type value :: InductiveGraph.value
@type edge_value :: InductiveGraph.edge_value
@type vertex_value :: InductiveGraph.vertex_value
@type vertex :: Ind... | lib/inductive_graph/internal.ex | 0.916959 | 0.696433 | internal.ex | starcoder |
defmodule JaSerializer.Serializer do
@moduledoc """
Define a serialization schema.
Provides `has_many/2`, `has_one/2`, `attributes/1` and `location/1` macros
to define how your data (struct or map) will be rendered in the
JSONAPI.org 1.0 format.
Defines `format/1`, `format/2` and `format/3` used to conver... | lib/ja_serializer/serializer.ex | 0.820362 | 0.486027 | serializer.ex | starcoder |
defmodule FDB.Directory do
@moduledoc """
Directory is one of the ways to [manage
namespaces](https://apple.github.io/foundationdb/developer-guide.html#directories).
root = FDB.Directory.new()
dir = FDB.Database.transact(db, fn tr ->
FDB.Directory.create_or_open(root, tr, ["users", "inactive"... | lib/fdb/directory.ex | 0.881456 | 0.4184 | directory.ex | starcoder |
defmodule Brains do
@moduledoc """
`Brains` is a GraphQL client for Elixir on top of `Tesla`.
## Usage
```elixir
connection = Brains.Connection.new("https://example.com/graph")
Brains.query(connection, \"""
{
films {
title
}
}
\"""
)
{:ok,
%Tesla.Env{
... | lib/brains.ex | 0.876509 | 0.701662 | brains.ex | starcoder |
defmodule MediaServer.Watches do
@moduledoc """
The WatchStatuses context.
"""
import Ecto.Query, warn: false
alias MediaServer.Repo
alias MediaServer.Watches.Movie
@doc """
Returns the list of movie_watches.
## Examples
iex> list_movie_watches()
[%Movie{}, ...]
"""
def list_movi... | lib/media_server/watches.ex | 0.866979 | 0.416292 | watches.ex | starcoder |
defmodule Ambry.People do
@moduledoc """
Functions for dealing with People.
"""
import Ambry.FileUtils
import Ecto.Query
alias Ambry.People.{Person, PersonFlat}
alias Ambry.{PubSub, Repo}
@person_direct_assoc_preloads [:authors, :narrators]
@doc """
Returns a limited list of people and whether o... | lib/ambry/people.ex | 0.845289 | 0.45042 | people.ex | starcoder |
defmodule QRCode.FormatVersion do
@moduledoc """
A QR code uses error correction encoding and mask patterns. The QR code's
size is represented by a number, called a version number. To ensure that
a QR code scanner accurately decodes what it scans, the QR code specification
requires that each code include a fo... | lib/qr_code/format_version.ex | 0.530723 | 0.890485 | format_version.ex | starcoder |
defmodule Filtrex.Type.Config do
@moduledoc """
This configuration struct is for passing options at the top-level (e.g. `Filtrex.parse/2`) in a list. See `defconfig/1` for a more specific example.
Struct keys:
* `type`: the corresponding condition module with this type (e.g. :text = Filtrex.Condition.Text)
... | lib/filtrex/config.ex | 0.834036 | 0.458046 | config.ex | starcoder |
defmodule Vox.Model do
@moduledoc """
A voxel model.
"""
@type bounds_error :: :bounds
@type unknown_error :: :unknown
@type error(type) :: { :error, { :model, type } }
@type id :: non_neg_integer
@type axis :: non_neg_integer
@type point :: { axis, axis, axis }
@type t :: %_... | lib/vox/model.ex | 0.939679 | 0.574395 | model.ex | starcoder |
defprotocol RDF.Data do
@moduledoc """
An abstraction over the different data structures for collections of RDF statements.
"""
@doc """
Adds statements to a RDF data structure.
As opposed to the specific `add` functions on the RDF data structures, which
always return the same structure type than the fi... | lib/rdf/data.ex | 0.862308 | 0.961858 | data.ex | starcoder |
defmodule ForgeAbi.CodeInfo do
@moduledoc false
use Protobuf, syntax: :proto3
@type t :: %__MODULE__{
checksum: binary,
binary: binary
}
defstruct [:checksum, :binary]
field :checksum, 1, type: :bytes
field :binary, 2, type: :bytes
end
defmodule ForgeAbi.TypeUrls do
@moduled... | lib/protobuf/gen/tx.pb.ex | 0.788705 | 0.608536 | tx.pb.ex | starcoder |
defmodule DecemberTwo do
@moduledoc """
Second Advent of Code task.
"""
@noun_position 1
@verb_position 2
@part_one_noun 12
@part_one_verb 2
@part_two_target 19_690_720
@part_two_max_val 99
@doc """
Read file and convert the comma separated list to a map with the index as key.
"""
def init_m... | 02/elixir/lib/december_two.ex | 0.748168 | 0.410431 | december_two.ex | starcoder |
defmodule Cards do
@moduledoc """
This module provides many function for interact with an deck
"""
@doc """
Create an deck
## Examples
iex> deck = Cards.create_deck
iex> deck
["Ace of Spades", "Ace of Clubs", "Ace of Hearts", "Ace of Diamonds",
"Two of Spades", "Two of Clubs"... | lib/cards.ex | 0.841923 | 0.76176 | cards.ex | starcoder |
defmodule FarmbotCeleryScript.Scheduler do
@moduledoc """
Handles execution of CeleryScript.
CeleryScript can be `execute`d or `schedule`d. Both have the same API but
slightly different behaviour.
A message will arrive in the callers inbox after either shaped like
{FarmbotCeleryScript.Scheduler, resu... | farmbot_celery_script/lib/farmbot_celery_script/scheduler.ex | 0.816223 | 0.408277 | scheduler.ex | starcoder |
defmodule ESpec.Expect do
@moduledoc """
Defines `expect` and `is_expected` helper functions.
These functions wrap arguments for ESpec.ExpectTo module.
"""
alias ESpec.ExpectTo
@doc false
defmacro __using__(_arg) do
quote do
@doc "The same as `expect(subject)`"
def is_expected do
... | lib/espec/expect.ex | 0.805096 | 0.826116 | expect.ex | starcoder |
defmodule Zstream.Unzip.Extra do
@moduledoc false
use Bitwise
defmodule Unknown do
@type t :: %__MODULE__{
signature: String.t(),
tsize: integer(),
data: iodata()
}
defstruct [:signature, :tsize, :data]
end
defmodule ExtendedTimestamp do
@type t :: ... | lib/zstream/unzip/extra.ex | 0.681409 | 0.430147 | extra.ex | starcoder |
defmodule Floki do
alias Floki.{Finder, FilterOut, HTMLTree}
@moduledoc """
Floki is a simple HTML parser that enables search for nodes using CSS selectors.
## Example
Assuming that you have the following HTML:
```html
<!doctype html>
<html>
<body>
<section id="content">
<p class="headli... | lib/floki.ex | 0.794385 | 0.696042 | floki.ex | starcoder |
defmodule Sippet.Transactions do
@moduledoc """
The `Sippet.Transactions` is responsible to dispatch messages from
`Sippet.Transports` and `Sippet.Core` modules to transactions, creating when
necessary.
"""
import Supervisor.Spec
alias Sippet.Message, as: Message
alias Sippet.Message.RequestLine, as: ... | lib/sippet/transactions.ex | 0.898508 | 0.4133 | transactions.ex | starcoder |
defmodule GenEvent do
@moduledoc """
A behaviour module for implementing event handling functionality.
The event handling model consists of a generic event manager
process with an arbitrary number of event handlers which are
added and deleted dynamically.
An event manager implemented using this module wil... | lib/elixir/lib/gen_event.ex | 0.896092 | 0.614423 | gen_event.ex | starcoder |
defmodule Mix.Tasks.Rustler.New do
use Mix.Task
import Mix.Generator
@shortdoc "Creates a new Rustler project."
@moduledoc """
Generates boilerplate for a new Rustler project.
Usage:
```
mix rustler.new [--module <Module>] [--name <Name>] [--otp-app <OTP App>]
```
"""
@basic [
{:eex, "basi... | rustler_mix/lib/mix/tasks/rustler.new.ex | 0.712732 | 0.543106 | rustler.new.ex | starcoder |
defmodule ZenMonitor.Proxy.Batcher do
@moduledoc """
`ZenMonitor.Proxy.Batcher` is responsible for collecting death_certificates from
`ZenMonitor.Proxy` destined for the Batcher's subscriber (normally the subscriber is a
`ZenMonitor.Local.Connector`)
Periodically it will sweep and send all of the death_certi... | lib/zen_monitor/proxy/batcher.ex | 0.865878 | 0.44071 | batcher.ex | starcoder |
defmodule NewRelic.Sampler.Beam do
use GenServer
@kb 1024
@mb 1024 * 1024
# Takes samples of the state of the BEAM at an interval
@moduledoc false
def start_link(_) do
GenServer.start_link(__MODULE__, :ok, name: __MODULE__)
end
def init(:ok) do
# throw away first value
:cpu_sup.util()
... | lib/new_relic/sampler/beam.ex | 0.771155 | 0.404302 | beam.ex | starcoder |
defmodule Membrane.MP4.MovieBox do
@moduledoc """
A module providing a function assembling an MPEG-4 movie box.
The movie box (`moov`) is a top-level box that contains information about
a presentation as a whole. It consists of:
* exactly one movie header (`mvhd` atom)
The movie header contains med... | lib/membrane_mp4/movie_box.ex | 0.869424 | 0.773687 | movie_box.ex | starcoder |
defmodule Mmo.Player do
alias Mmo.Player
alias Mmo.Player.Controller
alias Mmo.World
@derive Jason.Encoder
defstruct id: "",
name: "",
x: 64,
y: 64,
attack: 10,
max_health: 100,
health: 100,
exp: 0,
required_exp: ... | lib/mmo/player/player.ex | 0.594669 | 0.411879 | player.ex | starcoder |
defmodule Niex.State do
@moduledoc """
The internal state representing a running `Niex.Notebook`.
"""
defstruct(
notebook: %Niex.Notebook{},
selected_cell: nil,
worksheet: 0,
env: [],
bindings: [],
path: nil,
dirty: false
)
def new() do
%Niex.State{
dirty: false,
... | niex/lib/niex/state.ex | 0.628407 | 0.558417 | state.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.824144 | 0.733667 | fashionmnist.ex | starcoder |
defmodule Nostrum.Cache.UserCache do
@default_cache_implementation Nostrum.Cache.UserCache.ETS
@moduledoc """
Cache behaviour & dispatcher for users.
You can call the functions provided by this module independent of which cache
is configured, and it will dispatch to the configured cache implementation.
By... | lib/nostrum/cache/user_cache.ex | 0.866387 | 0.563408 | user_cache.ex | starcoder |
defmodule Neoscan.Explanations do
@moduledoc false
@explanations %{
# blocks
"block_hash" =>
"Hash of all of the info stored in a block, including, but not limited to, the index, time, merkle root, etc...",
"block_index" =>
"Position of this block in the overall chain of blocks forming the '... | apps/neoscan/lib/neoscan/helpers/explanations.ex | 0.613005 | 0.529689 | explanations.ex | starcoder |
defmodule Jsonpatch do
@moduledoc """
A implementation of [RFC 6902](https://tools.ietf.org/html/rfc6902) in pure Elixir.
The patch can be a single change or a list of things that shall be changed. Therefore
a list or a single JSON patch can be provided. Every patch belongs to a certain operation
which influ... | lib/jsonpatch.ex | 0.89783 | 0.520131 | jsonpatch.ex | starcoder |
defmodule Binance.FuturesCoin do
alias Binance.Futures.Coin.Rest.HTTPClient
@type error ::
{:binance_error, %{code: integer(), message: String.t()}}
| {:http_error, any()}
| {:poison_decode_error, any()}
| {:config_missing, String.t()}
# Server
@doc """
Pings Binance... | lib/binance/futures_coin.ex | 0.882301 | 0.573021 | futures_coin.ex | starcoder |
defmodule Exred.Node.Suppress do
@moduledoc """
Suppresses or filters incoming messages for configurable time periods.
###Inputs
`topic :: string`
if message suppression starts when triggered then a message with '_START' topic triggers the suppression
otherwise topic is ignored
`payload :: term... | lib/exred_node_suppress.ex | 0.61682 | 0.403156 | exred_node_suppress.ex | starcoder |
defmodule Mix.Tasks.AzureFunctions.Release do
@moduledoc """
Create files to publish Azure Functions.
Run this task inside Docker image `elixir:1.10.4-slim`.
## How to build
```
$ docker run -d -it --rm --name elx erintheblack/elixir-azure-functions-builder:1.10.4
$ docker cp mix.exs elx:/tmp
$ docke... | lib/mix/tasks/azure_functions/release.ex | 0.673084 | 0.402627 | release.ex | starcoder |
defmodule Game.Effect do
@moduledoc """
Calculate and apply effects from skills/items
"""
alias Data.Effect
alias Data.Stats
alias Game.DamageTypes
@random_effect_range Application.get_env(:ex_venture, :game)[:random_effect_range]
@type continuous_effect :: {Character.t(), Effec.t()}
@doc """
Ca... | lib/game/effect.ex | 0.895625 | 0.611759 | effect.ex | starcoder |
defmodule Descisionex.Helper do
@moduledoc """
Utility functions
"""
@doc """
Normalizes matrix.
## Examples
iex> matrix = [[1, 2], [3, 4], [0, 1]]
iex> size = 3 # matrix rows
iex> Descisionex.Helper.normalize(matrix, size)
[[0.25, 0.286], [0.75, 0.571], [0.0, 0.143]]
"""
@sp... | lib/helper/helper.ex | 0.871639 | 0.73041 | helper.ex | starcoder |
defmodule QRCodeEx.Mask do
@moduledoc false
@doc """
Get the total score for the masked matrix.
"""
@spec score(QRCodeEx.Matrix.matrix()) :: integer
def score(matrix) do
rule1(matrix) + rule2(matrix) + rule3(matrix) + rule4(matrix)
end
@doc """
Check for consecutive blocks.
"""
@spec rule1(Q... | lib/eqrcode/mask.ex | 0.781956 | 0.681661 | mask.ex | starcoder |
defmodule AlchemyVM.HostFunction.API do
alias AlchemyVM.Helpers
use Agent
@moduledoc """
Provides an API for interacting with the VM from within a host function
"""
@doc false
def child_spec(arg), do: child_spec(arg)
@doc false
def start_link(vm), do: Agent.start_link(fn -> vm end)
@doc false
... | lib/execution/host_function_api.ex | 0.894993 | 0.404684 | host_function_api.ex | starcoder |
defmodule Unsafe do
@moduledoc """
Generate unsafe bindings for Elixir functions.
This library aims to simplify the generation of unsafe function
definitions (which here means "functions which can crash"). This
is done by code generation at compile time to lessen the bloat in
the main source tree, and to r... | deps/unsafe/lib/unsafe.ex | 0.814717 | 0.67985 | unsafe.ex | starcoder |
defmodule OMG.Watcher.ExitProcessor.StandardExit do
@moduledoc """
Part of Core to handle SE challenges & invalid exit detection.
Treat as private helper submodule of `OMG.Watcher.ExitProcessor.Core`, test and call via that
"""
defmodule Challenge do
@moduledoc """
Represents a challenge to a stand... | apps/omg_watcher/lib/omg_watcher/exit_processor/standard_exit.ex | 0.676406 | 0.415136 | standard_exit.ex | starcoder |
defmodule AntlUtilsEcto.Query do
@moduledoc """
Set of utils for Ecto.Query
"""
@type status :: :ended | :ongoing | :scheduled
import Ecto.Query, only: [dynamic: 2, from: 2]
@spec where(any, atom, nil | binary | [any] | integer | boolean) :: Ecto.Query.t()
def where(queryable, key, nil) when is_atom(key... | lib/query.ex | 0.797951 | 0.492005 | query.ex | starcoder |
defmodule Memento.Capture.Feed do
@moduledoc """
The `Memento.Capture.Feed` module implements a state machine capable
of periodically fetching and saving new data from a specific source,
optionally with authentication.
A `Memento.Capture.Feed` instance is started with a configuration map (see `t:config/0`
... | lib/memento/capture/feed.ex | 0.85811 | 0.568026 | feed.ex | starcoder |
defmodule Tds.Tokens do
import Tds.BinaryUtils
import Bitwise
require Logger
alias Tds.Types
alias Tds.UCS2
def retval_typ_size(38) do
# 0x26 - SYBINTN - 1
8
end
def retval_typ_size(dec) do
# Undefined
raise Tds.Error,
"Unknown datatype parsed when decoding return value: #{... | lib/tds/tokens.ex | 0.566139 | 0.40987 | tokens.ex | starcoder |
defmodule Courier.Scheduler do
use GenServer
@timeout 5_000
@pool_size 10
@interval 1_000
@moduledoc """
Scheduler adapter
The Scheduler will allow you to schedule when messages can be sent out.
It accomplishes this with four parts
1. The adapter - needs to be set in the opts
2. The poller - def... | lib/courier/scheduler.ex | 0.792504 | 0.432123 | scheduler.ex | starcoder |
defmodule Normalizer do
@moduledoc """
# Normalizer
Normalizes string-keyed maps to atom-keyed maps while converting values
according to a given schema. Particularly useful when working with param maps.
### Usage
schema = %{
user_id: {:number, required: true},
name: :string,
a... | lib/normalizer.ex | 0.909567 | 0.622517 | normalizer.ex | starcoder |
defmodule AdventOfCode.Day12 do
@moduledoc "Day 12"
defmodule PartOneShip, do: defstruct x: 0, y: 0, face: :E
defmodule PartTwoShip, do: defstruct x: 0, y: 0, waypoint_x: 10, waypoint_y: -1
defprotocol Ship do
def turn(ship)
def forward(ship, value)
end
defimpl Ship, for: PartOneShip do
@tur... | lib/advent_of_code/day12.ex | 0.7181 | 0.724481 | day12.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.