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 ExBin.Formatter do
@doc """
Pretty print a given `binary`. By default this will output
in the same format as `hexdump -C <file>` from BSD general commands.
This function returns a string, so you aren't bound to any certain
I/O mechanism (i.e. you may not want to print this to stdout, so `IO.puts/1` ... | lib/ex_bin/formatter.ex | 0.805211 | 0.720368 | formatter.ex | starcoder |
defmodule Wallaby do
@moduledoc """
A concurrent feature testing library.
## Configuration
Wallaby supports the following options:
* `:pool_size` - Maximum amount of phantoms to run. The default is `:erlang.system_info(:schedulers_online) * 2`.
* `:screenshot_dir` - The directory to store screenshots.
... | lib/wallaby.ex | 0.819352 | 0.695235 | wallaby.ex | starcoder |
defmodule Tds do
@moduledoc """
Microsoft SQL Server driver for Elixir.
Tds is partial implementation of the Micorosoft SQL Server
[MS-TDS](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-tds)
Tabular Data Stream Protocol.
A Tds query is performed in separate server-side prepare and execut... | lib/tds.ex | 0.839109 | 0.40248 | tds.ex | starcoder |
defmodule Phoenix.Ecto.SQL.Sandbox do
@moduledoc """
A plug to allow concurrent, transactional acceptance tests with [`Ecto.Adapters.SQL.Sandbox`]
(https://hexdocs.pm/ecto_sql/Ecto.Adapters.SQL.Sandbox.html).
## Example
This plug should only be used during tests. First, set a flag to
enable it in `config/... | deps/phoenix_ecto/lib/phoenix_ecto/sql/sandbox.ex | 0.914295 | 0.531574 | sandbox.ex | starcoder |
defmodule Zig.Parser.Nif do
@moduledoc """
This datastructure represents structured information about a single nif
inside of a `Zig.sigil_Z/2` block. This is used to generate the
`exported_nifs` variable which is an array of `ErlNifFunc` structs. The
following keys are implemented:
- name: (`t:atom/0`) ... | lib/zig/parser/nif.ex | 0.773216 | 0.560132 | nif.ex | starcoder |
defmodule StrongMigrations.Parser do
@moduledoc """
The module responsible for reading an ASTand generating a bucket of the information of migration's content
"""
alias StrongMigrations.Migration
@doc """
Parses given migrations into a struct with information about the content
"""
@spec parse([StrongM... | lib/strong_migrations/parser.ex | 0.804483 | 0.47792 | parser.ex | starcoder |
defmodule Cldr.Calendar.Coptic do
@moduledoc """
Implementation of the Coptic calendar.
"""
import Cldr.Math, only: [mod: 2]
import Cldr.Macros
@behaviour Calendar
@behaviour Cldr.Calendar
@type year :: -9999..-1 | 1..9999
@type month :: 1..12
@type day :: 1..31
@months_in_year 13
@days_in_w... | lib/cldr/calendar/coptic.ex | 0.927929 | 0.728797 | coptic.ex | starcoder |
defmodule CforumWeb.Views.ViewHelpers.RelativeTime do
@moduledoc """
Provides functions to convert a time period to a relative text, e.g. „a year ago“
"""
import CforumWeb.Gettext
@doc """
Generates a relative time text, e.g. "less than 5 seconds" or "about an hour".
`time` may be a `%DateTime{}` or the... | lib/cforum_web/views/view_helpers/relative_time.ex | 0.752468 | 0.466846 | relative_time.ex | starcoder |
defmodule GGity.Geom.Boxplot do
@moduledoc false
alias GGity.{Draw, Geom, Plot, Shapes}
@type t() :: %__MODULE__{}
@type record() :: map()
@type mapping() :: map()
defstruct data: nil,
mapping: nil,
stat: :boxplot,
position: :dodge,
key_glyph: :boxplot,
... | lib/ggity/geom/boxplot.ex | 0.924492 | 0.631822 | boxplot.ex | starcoder |
defmodule ConCache.Item do
@moduledoc """
This struct can be used in place of naked values to set per-item TTL values.
"""
defstruct value: nil, ttl: :infinity
@type t :: %ConCache.Item{
value: ConCache.value(),
ttl: pos_integer | :infinity | :renew | :no_update
}
end
defmodule C... | lib/con_cache.ex | 0.916407 | 0.628721 | con_cache.ex | starcoder |
defmodule Brando.MigrationTest.Project do
use Brando.Blueprint,
application: "Brando",
domain: "Projects",
schema: "Project",
singular: "project",
plural: "projects"
trait(Brando.Trait.Creator)
trait(Brando.Trait.SoftDelete)
trait(Brando.Trait.Sequenced)
trait(Brando.Trait.Timestamped)
... | test/support/blueprints/migration_schemas.ex | 0.576542 | 0.422386 | migration_schemas.ex | starcoder |
defmodule Commanded.Aggregate.Multi.BankAccount do
defstruct [
account_number: nil,
balance: 0,
state: nil,
]
alias Commanded.Aggregate.Multi
alias Commanded.Aggregate.Multi.BankAccount
defmodule Commands do
defmodule OpenAccount, do: defstruct [:account_number, :initial_balance]
... | test/aggregates/support/multi_bank_account.ex | 0.576304 | 0.549338 | multi_bank_account.ex | starcoder |
defmodule Appsignal.Span do
alias Appsignal.{Config, Nif, Span}
defstruct [:reference, :pid]
@nif Application.get_env(:appsignal, :appsignal_tracer_nif, Appsignal.Nif)
def create_root(namespace, pid) do
if Config.active?() do
{:ok, reference} = @nif.create_root_span(namespace)
%Span{reference:... | lib/appsignal/span.ex | 0.528047 | 0.40116 | span.ex | starcoder |
defmodule Kayrock.MessageSet do
@moduledoc """
Represents a set of messages with the v0 or v1 format
This is the old format that KafkaEx supported
See https://kafka.apache.org/documentation/#recordbatch
"""
defmodule Message do
@moduledoc """
Represents a single message with the v0 or v1 format
... | lib/kayrock/message_set.ex | 0.804675 | 0.460532 | message_set.ex | starcoder |
defmodule BinFormat.FieldType.IpAddr do
defstruct name: nil, default: nil, options: []
@moduledoc """
:inet style IP address field type for defformat.
"""
@doc """
Add an IP address field to the format structure in defformat.
This field type decodes IP addresses represented as 32 bit integers in
bin... | lib/bin_format/field_type/ip_addr.ex | 0.744099 | 0.537891 | ip_addr.ex | starcoder |
defmodule Twitter.Clock do
@moduledoc """
Helper functions to deal with time
"""
@type t :: :calendar.datetime
@type time :: :calendar.time
@doc """
Returns the current local time
"""
@spec now :: t
def now do
:calendar.local_time
end
@doc """
Returns the current local time of yesterda... | lib/clock.ex | 0.703651 | 0.419737 | clock.ex | starcoder |
defmodule Unleash.Strategy do
@moduledoc """
Used to extend the client and create custom strategies. To do so, `use` this
module within your custom strategy and implmenent `c:enabled?/2`. Provide a
name that is human-readable, as it is logged.
```elixir
defmodule MyApp.CustomStrategy
use Unleash.Strate... | lib/unleash/strategy.ex | 0.882212 | 0.70005 | strategy.ex | starcoder |
defmodule TimeZoneInfo.ExternalTermFormat do
@moduledoc false
# Encodes and decodes the `TimeZoneInfo.data`.
@doc """
Encodes `TimeZoneInfo.data` to binary.
"""
@spec encode(TimeZoneInfo.data()) :: {:ok, binary()} | {:error, atom()}
def encode(term) do
with {:ok, term} <- validate(term) do
bin... | lib/time_zone_info/external_term_format.ex | 0.884558 | 0.598752 | external_term_format.ex | starcoder |
defmodule Nixa.Shared do
@moduledoc """
Utility functions
"""
import Nx.Defn
@empty_mapset MapSet.new()
@doc """
Provide function guard to check for empty MapSet
"""
defguard empty_mapset?(some_map_set) when some_map_set == @empty_mapset
@doc """
Provide simple log2 function
"""
defn log2(... | lib/nixa/shared.ex | 0.748995 | 0.549701 | shared.ex | starcoder |
defmodule JaNestedParams do
@moduledoc """
Parse `Json Api v1.0` parameters. Additionally, deviate from the specification
by allowing the building of nested parameters, just like those consumed by
Ecto's changeset at initialization.
Make use of the `included` array of the Json Api specification. This does n... | lib/ja_nested_params.ex | 0.574156 | 0.451447 | ja_nested_params.ex | starcoder |
defmodule ElixirScript.FFI do
@moduledoc """
The Foreign Function Interface (FFI) for interacting with JavaScript
To define a foreign module, make a new module and add `use ElixirScript.FFI` to it.
To define external functions, use the `defexternal` macro.
Here is an example of a foreign module for a JSON m... | lib/elixir_script/ffi.ex | 0.878471 | 0.848847 | ffi.ex | starcoder |
defmodule ExClearbit.Model.Person do
@moduledoc """
The struct for the Person data returned from Clearbit
"""
@derive [Poison.Encoder]
defstruct [
:aboutme,
:angellist,
:avatar,
:bio,
:email_provider,
:employment,
:facebook,
:fuzzy,
:gender,
:geo,
:github,
:go... | lib/ex_clearbit/model.ex | 0.685107 | 0.492798 | model.ex | starcoder |
defmodule ExCmd.Process do
@moduledoc """
Server to interact with external process
`ExCmd.stream!` should be preferred over this. Use this only if you need more control over the life-cycle of IO streams and OS process.
"""
defmodule Error do
defexception [:message]
end
@default [log: false]
@doc... | lib/ex_cmd/process.ex | 0.800107 | 0.445107 | process.ex | starcoder |
defmodule MuonTrap.Daemon do
use GenServer
require Logger
@moduledoc """
Wrap an OS process in a GenServer so that it can be supervised.
For example, in your children list add MuonTrap.Daemon like this:
```elixir
children = [
{MuonTrap.Daemon, ["my_server", ["--options", "foo")], [cd: "/some_direc... | lib/muontrap/daemon.ex | 0.829975 | 0.748536 | daemon.ex | starcoder |
defmodule Stream.Reducers do
# Collection of reducers and utilities shared by Enum and Stream.
@moduledoc false
def chunk_every(chunk_by, enumerable, count, step, leftover) do
limit = :erlang.max(count, step)
chunk_fun = fn entry, {acc_buffer, acc_count} ->
acc_buffer = [entry | acc_buffer]
... | lib/elixir/lib/stream/reducers.ex | 0.575349 | 0.407628 | reducers.ex | starcoder |
defmodule MapArray do
@moduledoc """
Documentation for MapArray.
"""
defguard is_index(i) when is_integer(i) and i >= 0
@type index :: non_neg_integer()
@type t :: %{non_neg_integer() => any()}
@spec append(t(), any) :: t()
def append(map, item) do
Map.put(map, map_size(map), item)
end
@doc ... | lib/map_array.ex | 0.776369 | 0.501709 | map_array.ex | starcoder |
defmodule Sanbase.EventBus do
@moduledoc """
The Event Bus is a mechanism that allows different components to communicate
with each other without knowing about eachother.
The Event Bus allows to decouple the creation of an event from the processing
of that same event. A component sends events to the Event Bu... | lib/sanbase/event_bus/event_bus.ex | 0.732879 | 0.637757 | event_bus.ex | starcoder |
defmodule Float do
@moduledoc """
Functions for working with floating point numbers.
"""
@doc """
Parses a binary into a float.
If successful, returns a tuple of the form `{ float, remainder_of_binary }`.
Otherwise `:error`.
## Examples
iex> Float.parse("34")
{34.0,""}
iex> Floa... | lib/elixir/lib/float.ex | 0.931088 | 0.468061 | float.ex | starcoder |
defmodule AdventOfCode.Day07 do
@moduledoc ~S"""
[Advent Of Code day 7](https://adventofcode.com/2018/day/7).
iex> input = [
...> "Step C must be finished before step A can begin.",
...> "Step C must be finished before step F can begin.",
...> "Step A must be finished before step B can begin.",
... | lib/advent_of_code/day_07.ex | 0.566139 | 0.622947 | day_07.ex | starcoder |
defmodule Engine.DB.Transaction.PaymentV1.Validator.Amount do
@moduledoc """
Contains validation logic for amounts, see validate/3 for more details.
"""
alias Engine.DB.Transaction.PaymentV1.Type
alias Engine.Fee.FeeClaim
@type validation_result_t() ::
:ok
| {:error, {:inputs, :amounts... | apps/engine/lib/engine/db/transaction/payment_v1/validators/amount.ex | 0.890972 | 0.608885 | amount.ex | starcoder |
defmodule Finance.CashFlow do
@moduledoc """
An annuity of n regular payments or receipts occurring at evenly spaced periods
can be represented by the cash flow:
```
[c0, c1, c2, c3, ....., cn]
```
Where the outgoings are represented by negative values, and income by positive values.
Calculates the net... | lib/finance/cashflow.ex | 0.882181 | 0.961461 | cashflow.ex | starcoder |
defmodule Bargad do
@moduledoc """
### Overview
Bargad is a service which implements the concepts and data strucutures described in the **Certificate Transparency** whitepaper [RFC6962](https://tools.ietf.org/html/rfc6962) and the [**Compact Sparse Merkle tree**](https://osf.io/8mcnh/download) whitepaper.
T... | lib/bargad.ex | 0.832407 | 0.96225 | bargad.ex | starcoder |
defmodule DartSass do
@moduledoc """
DartSass is a installer and runner for [Sass](https://sass-lang.com/dart-sass).
## Profiles
You can define multiple configuration profiles. By default, there is a
profile called `:default` which you can configure its args, current
directory and environment:
conf... | lib/dart_sass.ex | 0.753467 | 0.586464 | dart_sass.ex | starcoder |
defmodule AWS.Backup do
@moduledoc """
AWS Backup
AWS Backup is a unified backup service designed to protect AWS services and
their associated data.
AWS Backup simplifies the creation, migration, restoration, and deletion of
backups, while also providing reporting and auditing.
"""
@doc """
Create... | lib/aws/generated/backup.ex | 0.882105 | 0.477371 | backup.ex | starcoder |
defmodule Mix.Tasks.Vessel.Compile do
# mix task
use Mix.Task
# different Vessel build phases
@phases [ :mapper, :combiner, :reducer ]
# information for the mix command line
@shortdoc "Compiles any designated Vessel binaries"
@recursive true
@moduledoc """
Compiles a set of Vessel binaries.
The... | lib/mix/tasks/vessel.compile.ex | 0.882054 | 0.527438 | vessel.compile.ex | starcoder |
defmodule ETS.Bag do
@moduledoc """
Module for creating and interacting with :ets tables of the type `:bag` and `:duplicate_bag`.
Bags contain "records" which are tuples. Bags are configured with a key position via the `keypos: integer` option.
If not specified, the default key position is 1. The element of th... | lib/ets/bag.ex | 0.932361 | 0.858955 | bag.ex | starcoder |
defmodule EQC.Cluster do
@copyright "Quviq AB, 2014-2016"
@moduledoc """
This module contains macros to be used with [Quviq
QuickCheck](http://www.quviq.com). It defines Elixir versions of the Erlang
macros found in `eqc/include/eqc_cluster.hrl`. For detailed documentation of the
macros, please refer to th... | lib/eqc/cluster.ex | 0.772359 | 0.463141 | cluster.ex | starcoder |
defmodule Asteroid.Token.RefreshToken do
import Asteroid.Utils
alias Asteroid.Context
alias Asteroid.Client
alias Asteroid.Token
@moduledoc """
Refresh token structure
## Field naming
The `data` field holds the token data. The following field names are standard and are used
by Asteroid:
- `"exp"`... | lib/asteroid/token/refresh_token.ex | 0.888879 | 0.563438 | refresh_token.ex | starcoder |
defmodule Bacen.STA.Protocol do
@moduledoc """
The protocol message schema for Sisbacen's server.
This message is responsible to create a new protocol
into Sisbacen's server to allow the application to send
one of the ACCS/CCS messages for given protocol.
It has the following XML examples:
```xml
<Pa... | lib/bacen/sta/protocol.ex | 0.851968 | 0.752559 | protocol.ex | starcoder |
defmodule Training.DoorLock do
use GenStateMachine, callback_mode: :state_functions
# This allows our graphviz directed graph to be rendered
# as an image in the documentation
import Training.Util.Graphviz
require Logger
@fsm_diagram """
digraph {
rankdir=LR;
node [shape=doublecircle]
locke... | lib/training/door_lock.ex | 0.528047 | 0.478285 | door_lock.ex | starcoder |
defmodule PeertubeIndex.StatusStorage do
@moduledoc false
@doc """
Create an empty status storage for testing
"""
@callback empty() :: :ok
@doc """
Create a status storage with given statuses for testing
"""
@callback with_statuses([tuple()]) :: :ok
@doc """
Returns the list of all statuses
"... | lib/peertube_index/status_storage.ex | 0.803444 | 0.404213 | status_storage.ex | starcoder |
defmodule Finance.Simple do
@moduledoc """
For the simplified case series of regular payments the relationship between the present value (pv),
future value (fv), payment (pmt) and rate (i) over a period of (n) time periods is given by:
```
pmt(1+i)
pv(1+i)^n + ------------ + fv = 0
... | lib/finance/simple.ex | 0.854278 | 0.918077 | simple.ex | starcoder |
defmodule Surgex.Parser.SortParser do
@moduledoc """
Parses the JSON API's sort parameter according to the
[JSON API spec](http://jsonapi.org/format/#fetching-sorting).
Produces a `{direction, column}` tuple, in which `direction` is either `:asc` or `:desc` and
`column` is a safely atomized and underscored c... | lib/surgex/parser/parsers/sort_parser.ex | 0.896142 | 0.675765 | sort_parser.ex | starcoder |
defmodule Cog.V1.PermissionGrantController do
use Cog.Web, :controller
alias Cog.Models.Permission
alias Cog.Models.Role
plug Cog.Plug.Authentication
plug Cog.Plug.Authorization, [permission: "#{Cog.Util.Misc.embedded_bundle}:manage_roles"] when action == :manage_role_permissions
plug :put_view, Cog.V1.... | web/controllers/v1/permission_grant_controller.ex | 0.760028 | 0.428951 | permission_grant_controller.ex | starcoder |
defmodule PlymioAstVormHelper do
alias Plymio.Ast.Vorm, as: PAV
use Plymio.Ast.Vorm.Attribute
use PlymioAstEvalAttributeHelper
import PlymioAstEvalHelper, only: [
helper_ast_eval: 2,
helper_ast_eval_normalise_error: 1,
helper_ast_eval_compare: 3,
helper_ast_eval_opts_canon_keys!: 1,
]
@... | test/helper/vorm.ex | 0.675122 | 0.477311 | vorm.ex | starcoder |
defmodule Hub do
@moduledoc """
Pub-sub hub
Subscription is done with a pattern.
Example:
```
Hub.subscribe("global", %{count: count} when count > 42)
Hub.publish("global", %{count: 45, message: "You rock!"})
```
"""
alias Hub.Channel
alias Hub.ChannelRegistry
alias Hub.ChannelSupervisor
a... | lib/hub.ex | 0.89174 | 0.856332 | hub.ex | starcoder |
defmodule Reactivity.Quality.Context do
@moduledoc false
alias Observables.Obs
require Logger
def combine(_, nil), do: nil
@doc """
combines a list of contexts in the case of enforcing time synchronization
Takes a mixed list of tuples {oldest_timestamp, newest_timestamp} and timestamps ti
Returns a tuple cont... | lib/reactivity/quality/context.ex | 0.612078 | 0.559049 | context.ex | starcoder |
defmodule Wasmex.Instance do
@moduledoc """
Instantiates a WebAssembly module represented by bytes and allows calling exported functions on it.
```elixir
# Get the Wasm module as bytes.
{:ok, bytes } = File.read("wasmex_test.wasm")
# Instantiates the Wasm module.
{:ok, instance } = Wasmex.Instance.from_... | lib/wasmex/instance.ex | 0.897256 | 0.886076 | instance.ex | starcoder |
defmodule Sippet.Transports do
@moduledoc """
The `Sippet.Transports` is responsible for the actual transmission of requests
and responses over network transports.
Network transport protocols are implemented following the
`Sippet.Transports.Plug` behavior, and they are configured as:
config :sippet, S... | lib/sippet/transports.ex | 0.829871 | 0.47457 | transports.ex | starcoder |
defmodule Hornet.Scheduler do
@moduledoc false
use GenServer
require Logger
alias Hornet.DynamicSupervisor, as: HornetDynamicSupervisor
alias Hornet.RateCounter
alias Hornet.ParamsValidator
alias Hornet.Worker.WorkerSupervisor
@spec start_link(Keyword.t()) :: GenServer.on_start()
def start_link(par... | lib/hornet/scheduler.ex | 0.831656 | 0.438545 | scheduler.ex | starcoder |
defmodule CredoContrib.Check.FunctionBlockSyntax do
@moduledoc """
`def …, do:` syntax should not be mixed with multiple `def … do … end`-style definitions.
https://github.com/christopheradams/elixir_style_guide#multiple-function-defs
"""
@explanation [
check: @moduledoc,
params: [
allow_singl... | lib/check/function_block_syntax.ex | 0.688468 | 0.468061 | function_block_syntax.ex | starcoder |
defmodule TextBasedFPS.GameMap.Matrix do
alias TextBasedFPS.{Direction, GameMap}
alias TextBasedFPS.GameMap.{Coordinates, Objects}
@type t :: list(list(item_t))
@type item_t :: :" " | :"#" | GameMap.Object.t()
@spec set(t, Coordinates.t(), item_t) :: t
def set(matrix, {x, y}, value) do
updated_row = E... | lib/text_based_fps/game_map/matrix.ex | 0.847416 | 0.801703 | matrix.ex | starcoder |
defmodule Scribe do
@moduledoc """
Pretty-print tables of structs and maps
"""
alias Scribe.Table
@type data ::
[]
| [...]
| term
@typedoc ~S"""
Options for configuring table output.
- `:colorize` - When `false`, disables colored output. Defaults to `true`
- `:data` -... | lib/scribe.ex | 0.845321 | 0.600364 | scribe.ex | starcoder |
defmodule Moeda do
@moduledoc """
[](https://travis-ci.org/ramondelemos/ex_dinheiro?branch=master)
[](https://coveralls.io/github/... | lib/moeda.ex | 0.922133 | 0.641113 | moeda.ex | starcoder |
defmodule Cluster.Strategy.GoogleAppEngine do
@moduledoc """
Clustering strategy for Google App Engine.
This strategy checks for the list of app versions that are currently receiving HTTP.
For each version that is listed, the list of instances running for that version are fetched.
Once all of the instances h... | lib/google_app_engine.ex | 0.851181 | 0.79158 | google_app_engine.ex | starcoder |
defmodule Calamity do
@moduledoc """
Documentation for `Calamity`.
"""
alias Calamity.Command
alias Calamity.Stack
alias Calamity.AggregateStore
alias Calamity.ProcessManagerStore
alias Calamity.VersionStore
require Logger
@doc """
Executes a command, and return the updated aggregates, process... | lib/calamity.ex | 0.780035 | 0.524273 | calamity.ex | starcoder |
defmodule Rihanna.Migration.Upgrade do
@moduledoc """
A set of tools for upgrading an existing Rihanna jobs table.
Rihanna stores jobs in a table in your database. The default table name is
"rihanna_jobs". The name is configurable by either passing it as an argument
to the functions below or setting `:jobs_t... | lib/rihanna/migration/upgrade.ex | 0.889132 | 0.668688 | upgrade.ex | starcoder |
defmodule PeopleSorter.Person do
@moduledoc """
A Person is a struct that contains fields that describe a Person.
"""
alias PeopleSorter.Person
@derive {Phoenix.Param, key: :email}
@type t :: %__MODULE__{
last_name: String.t(),
first_name: String.t(),
email: String.t(),
... | lib/people_sorter/person.ex | 0.672762 | 0.451145 | person.ex | starcoder |
defmodule Blockchain.Transaction do
@moduledoc """
Represents one transaction within the chain.
There is a special "reward" transaction which has a fixed amount in it, and
is sent from a special address. Those are set in the @reward and @rewarder
constants.
The transactions are signed by the sender using ... | apps/blockchain/lib/blockchain/transaction.ex | 0.910473 | 0.601242 | transaction.ex | starcoder |
defmodule BMP280.Calc do
alias BMP280.{Calibration, Measurement}
@moduledoc false
@doc """
Convert raw sensor reports to temperature, pressure and altitude measurements
"""
@spec raw_to_measurement(Calibration.t(), number(), map()) :: Measurement.t()
def raw_to_measurement(%Calibration{} = cal, sea_level... | lib/bmp280/calc.ex | 0.761272 | 0.539347 | calc.ex | starcoder |
defmodule Gradient.ElixirChecker do
@moduledoc ~s"""
Provide checks specific to Elixir that complement type checking delivered by Gradient.
Options:
- {`ex_check`, boolean()}: whether to use checks specific only to Elixir.
"""
@spec check([:erl_parse.abstract_form()], keyword()) :: [{:file.filename(), any... | lib/gradient/elixir_checker.ex | 0.824815 | 0.870487 | elixir_checker.ex | starcoder |
defmodule HLDSRcon do
@moduledoc """
A library for creating Half-Life Dedicated Server (a.k.a "HLDS") remote connections (a.k.a "rcon") and executing commands.
Uses a `DynamicSupervisor` for connecting clients. If you want to manage the rcon client supervision
yourself you can use the `HLDSRcon.RconClient` mod... | lib/hlds_rcon.ex | 0.883412 | 0.755952 | hlds_rcon.ex | starcoder |
defmodule Bitcoinex.Secp256k1 do
@moduledoc """
ECDSA Secp256k1 curve operations.
libsecp256k1: https://github.com/bitcoin-core/secp256k1
Currently supports ECDSA public key recovery.
In the future, we will NIF for critical operations. However, it is more portable to have a native elixir version.
"""
us... | lib/secp256k1/secp256k1.ex | 0.900898 | 0.473901 | secp256k1.ex | starcoder |
defmodule Ed25519 do
use Bitwise
@moduledoc """
Ed25519 signature functions
This is mostly suitable as part of a pure Elixir solution.
## Configuration
*No configuration is needed* in most cases. However, if needed, a custom hash
function can be configured. As per the specification - `sha512` is the d... | lib/ed25519.ex | 0.867275 | 0.503113 | ed25519.ex | starcoder |
defmodule Realtime.VehiclePositions do
@moduledoc """
Main entrypoint for realtime vehicle positions
"""
use GenServer
require Logger
alias Realtime.Messages.FeedMessage
alias Realtime.{VehiclePositionFinder, VehiclePositionsSource}
@behaviour VehiclePositionsSource
def child_spec(args) do
%{... | apps/realtime/lib/realtime/vehicle_positions.ex | 0.748904 | 0.432183 | vehicle_positions.ex | starcoder |
defmodule Scrub.CIP.Type do
import Scrub.BinaryUtils, warn: false
alias Scrub.CIP.Symbol
def decode(<<0xA0, 0x02, _crc::uint, data::binary>>, %{members: members} = structure) do
IO.puts("Template: #{structure.template_name}")
IO.inspect(structure)
Enum.reduce(members, [], fn
%{name: <<"ZZZZZZ... | lib/scrub/cip/type.ex | 0.632616 | 0.415581 | type.ex | starcoder |
defmodule GGity.Geom.Rect do
@moduledoc false
alias GGity.{Draw, Geom, Plot}
@type t() :: %__MODULE__{}
@type plot() :: %Plot{}
@type record() :: map()
@type mapping() :: map()
defstruct data: nil,
mapping: nil,
stat: :identity,
position: :identity,
key_g... | lib/ggity/geom/rect.ex | 0.891298 | 0.646983 | rect.ex | starcoder |
defmodule Protobuf.Verifier do
@moduledoc """
Checks whether the values used when instantiating a new protobuf struct are valid.
"""
import Protobuf.WireTypes
alias Protobuf.{MessageProps, FieldProps, FieldOptionsProcessor}
@doc """
Returns `:ok` or a tuple `{:error, <list-of-issues>}`
"""
@spec ver... | lib/protobuf/verifier.ex | 0.835349 | 0.456168 | verifier.ex | starcoder |
defmodule BeepBop do
@moduledoc """
Manages the state machine of an `Ecto.Schema`.
"""
alias Ecto.Multi
alias BeepBop.{Utils, Context}
@doc """
Configures `BeepBop` to work with your `Ecto.Repo`.
Expected keyword arguments:
* `:ecto_repo` -- Since BeepBop does the routine persisting of "state", it
... | lib/beepbop.ex | 0.873255 | 0.617686 | beepbop.ex | starcoder |
defmodule Vow.Function do
@moduledoc """
This module contains utilities for conforming the arguments and return
values of functions.
"""
alias Vow.ConformError
@typedoc """
The options for `Vow.conform_function/1`.
* `:args` - a vow for the function arguments as they were a list to be passed to `appl... | lib/vow/function.ex | 0.839997 | 0.638356 | function.ex | starcoder |
defmodule Exvalidate.Rules.Type do
@moduledoc """
This validation check the type of variable. The checked types are the next:
- :string => "name", "address", "language",
- :list => ["name", "address", "language"],
- :map => %{name: "Vegeta", address: "Vegeta planet"},
- :tuple => {:name, "Vegeta"},
-... | lib/workflow/rules/type.ex | 0.849488 | 0.92597 | type.ex | starcoder |
defmodule Mix.Tasks.Bench.Cmp do
use Mix.Task
@shortdoc "Compare benchmark snapshots"
@moduledoc """
## Usage
mix bench.cmp [options] <snapshot>...
A snapshot is the output of a single run of `mix bench`.
If no arguments are given, bench.cmp will try to read one or two latest
snapshots from the... | lib/mix/tasks/bench_cmp.ex | 0.752922 | 0.423995 | bench_cmp.ex | starcoder |
defmodule BloomList do
@moduledoc """
A behaviour for implementing bloomfilter module.
The `BloomList` behaviour is a implementation of the `GenServer` behaviour which
will keep the bloomfilter in state of `GenServer`. Support some bloomfilter operations:
* initialize: initial bloomfilter through call `in... | lib/bloom_list.ex | 0.858763 | 0.622832 | bloom_list.ex | starcoder |
defmodule LetterLinesElixir.BoardState do
@moduledoc false
alias LetterLinesElixir.BoardState
alias LetterLinesElixir.BoardWord
defstruct [:width, :height, :words]
# Guard to check for adjacent characters
defguard off_by_one(n1, n2) when (n1 - n2) in [-1, 1]
@type t :: %BoardState{
width: int... | lib/letter_lines_elixir/board_state.ex | 0.572962 | 0.412353 | board_state.ex | starcoder |
defmodule ExInterval.Interval do
@moduledoc """
It implements the interval type and range operations on the type, using
directed roundings intervals, recognize the input as strings and performs
operations between intervals.
"""
defstruct inf: nil, sup: nil
@type interval :: %__MODULE__{inf: Float, sup: ... | lib/ex_interval/interval.ex | 0.939874 | 0.607896 | interval.ex | starcoder |
defmodule Day18 do
def part_one(input) do
input
|> sum_input()
|> magnitude()
end
def part_two(input) do
18
|> input.contents_of(:stream)
|> Enum.map(&String.trim/1)
|> Enum.map(&parse/1)
|> permutations()
|> Enum.map(fn [a, b] -> add(a, b) end)
|> Enum.map(&magnitude/1)
... | year_2021/lib/day_18.ex | 0.655887 | 0.505981 | day_18.ex | starcoder |
defmodule Livebook.Notebook.Explore do
@moduledoc false
defmodule NotFoundError do
@moduledoc false
defexception [:slug, plug_status: 404]
def message(%{slug: slug}) do
"could not find an example notebook matching #{inspect(slug)}"
end
end
@type notebook_info :: %{
slug: Stri... | lib/livebook/notebook/explore.ex | 0.811041 | 0.580738 | explore.ex | starcoder |
defmodule Ockam.SecureChannel.KeyEstablishmentProtocol.XX.Protocol do
@moduledoc false
alias Ockam.Vault
defstruct [
# handle to a vault
:vault,
# identity keypair, reference in vault
:s,
# ephemeral keypair, reference in vault
:e,
# remote peer's identity public key
:rs,
# r... | implementations/elixir/ockam/ockam/lib/ockam/secure_channel/key_establishment_protocol/xx/protocol.ex | 0.692122 | 0.430925 | protocol.ex | starcoder |
defmodule RethinkDB.Connection do
@moduledoc """
A module for managing connections.
A `Connection` object is a process that can be started in various ways.
It is recommended to start it as part of a supervision tree with a name:
worker(RethinkDB.Connection, [[port: 28015, host: 'localhost', name: :ret... | lib/rethinkdb/connection.ex | 0.848329 | 0.531027 | connection.ex | starcoder |
defmodule AWS.KinesisAnalytics do
@moduledoc """
Amazon Kinesis Analytics
## Overview
This documentation is for version 1 of the Amazon Kinesis Data Analytics API,
which only supports SQL applications.
Version 2 of the API supports SQL and Java applications. For more information
about version 2, see [... | lib/aws/generated/kinesis_analytics.ex | 0.864439 | 0.650918 | kinesis_analytics.ex | starcoder |
defmodule AWS.DatabaseMigration do
@moduledoc """
Database Migration Service
Database Migration Service (DMS) can migrate your data to and from the most
widely used commercial and open-source databases such as Oracle, PostgreSQL,
Microsoft SQL Server, Amazon Redshift, MariaDB, Amazon Aurora, MySQL, and SAP
... | lib/aws/generated/database_migration.ex | 0.874037 | 0.432303 | database_migration.ex | starcoder |
defmodule WebDriver.Mouse do
@moduledoc """
Mouse driver event.
"""
@doc """
Move the mouse to the specified element.
Parameters:
element: The element to move the mouse to.
offsetx: X offset to the element coordinates
offsety: Y offset to the element coordinates
https://code.g... | lib/webdriver/mouse.ex | 0.753194 | 0.410756 | mouse.ex | starcoder |
defmodule OK do
@moduledoc """
The `OK` module enables clean and expressive error handling when coding with
idiomatic `:ok`/`:error` tuples. We've included many examples in the function
docs here, but you can also check out the
[README](https://github.com/CrowdHailer/OK/blob/master/README.md) for more
detai... | lib/ok.ex | 0.907114 | 0.907926 | ok.ex | starcoder |
defmodule Ecto.LogEntry do
@moduledoc """
Struct used for logging entries.
It is composed of the following fields:
* query - the query as string or a function that when invoked resolves to string;
* source - the query data source;
* params - the query parameters;
* result - the query result as a... | deps/ecto/lib/ecto/log_entry.ex | 0.83346 | 0.602091 | log_entry.ex | starcoder |
defmodule Alchemy.Events do
@moduledoc """
This module provides raw Event hooks into the various events supplied by
the gateway.
To use the macros in this module, it must be `used`. This also defines
a `__using__` macro for that module, which will then allow those hooks
to be loaded in the main application... | lib/events.ex | 0.886297 | 0.762645 | events.ex | starcoder |
defmodule ChallengeGov.GovDelivery.Implementation do
@moduledoc """
Implementation details for GovDelivery
We never actually care about the return values
Everything is best effort to maintain the GovDelivery state
"""
@behaviour ChallengeGov.GovDelivery
import SweetXml
import Phoenix.View
alias C... | lib/challenge_gov/gov_delivery/implementation.ex | 0.584271 | 0.416559 | implementation.ex | starcoder |
defmodule WechatPay.App do
@moduledoc """
The **App** payment method.
[Official document](https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_1)
## Example
Set up a client:
```elixir
{:ok, client} = WechatPay.Client.new(
app_id: "the-app_id",
mch_id: "the-mch-id",
api_key: "the-ap... | lib/wechat_pay/payment_methods/app.ex | 0.755005 | 0.602354 | app.ex | starcoder |
defmodule UrbitEx.Terminal do
alias UrbitEx.{Utils, API, Actions}
## error messages in dojo can be accessed through a completely separate SSE pipeline
## at GET "/~_~/slog"
## which inputs plaintext errors
@moduledoc """
Module with functions to interact with `herm`, the Urbit virtual terminal.
Subsc... | lib/api/gall/herm.ex | 0.824037 | 0.541348 | herm.ex | starcoder |
defmodule Asteroid.OAuth2.Scope do
@moduledoc """
Scope helper functions and default callbacks
"""
alias OAuth2Utils.Scope
alias Asteroid.Context
alias Asteroid.OAuth2
import Asteroid.Utils
defmodule UnknownRequestedScopeError do
@moduledoc """
Error return when an unknown scope has been reuq... | lib/asteroid/oauth2/scope.ex | 0.872646 | 0.489992 | scope.ex | starcoder |
defmodule Plausible.Stats do
use Plausible.Repo
alias Plausible.Stats.Query
def compare_pageviews_and_visitors(site, query, {pageviews, visitors}) do
query = Query.shift_back(query)
{old_pageviews, old_visitors} = pageviews_and_visitors(site, query)
cond do
old_pageviews == 0 and pageviews > 0... | lib/plausible/stats/stats.ex | 0.644673 | 0.423458 | stats.ex | starcoder |
defmodule AWS.SecurityHub do
@moduledoc """
Security Hub provides you with a comprehensive view of the security state
of your AWS environment and resources. It also provides you with the
readiness status of your environment based on controls from supported
security standards. Security Hub collects security d... | lib/aws/security_hub.ex | 0.872741 | 0.764276 | security_hub.ex | starcoder |
defmodule CSSEx.HSLA do
alias CSSEx.Unit
@moduledoc """
Struct and helper functions for generating HSLA values.
"""
defstruct h: %Unit{value: 0, unit: nil},
s: %Unit{value: 0, unit: "%"},
l: %Unit{value: 0, unit: "%"},
a: 1
@type t() :: %CSSEx.HSLA{
h: non_neg... | lib/structs/hsla.ex | 0.870308 | 0.453746 | hsla.ex | starcoder |
defmodule OMG.Watcher.ExitProcessor.Canonicity do
@moduledoc """
Encapsulates managing and executing the behaviors related to treating exits by the child chain and watchers
Keeps a state of exits that are in progress, updates it with news from the root chain, compares to the
state of the ledger (`OMG.Watcher.S... | apps/omg_watcher/lib/omg_watcher/exit_processor/canonicity.ex | 0.810966 | 0.541712 | canonicity.ex | starcoder |
defmodule Kayrock.Compression do
@moduledoc """
Handles compression/decompression of messages.
NOTE this is a copy of KafkaEx.Compression:
https://github.com/kafkaex/kafka_ex/blob/master/lib/kafka_ex/compression.ex
It is duplicated here to avoid creating a circular dependency.
See https://cwiki.apache.or... | lib/kayrock/compression.ex | 0.837387 | 0.631665 | compression.ex | starcoder |
defmodule MeshxRpc.Client.Pool do
require Logger
alias MeshxRpc.App.{C, T}
alias MeshxRpc.Common.{Options, Structs.Data}
@error_prefix :error_rpc
@error_prefix_remote :error_rpc_remote
@request_retries_statem 5
@opts [
idle_reconnect: [
type: :timeout,
default: 600_000,
doc: """
... | lib/client/pool.ex | 0.837587 | 0.554651 | pool.ex | starcoder |
defmodule Stripe.Entity do
@moduledoc """
A behaviour implemented by modules which represent Stripe objects.
Intended for internal use within the library.
A Stripe Entity is just a struct, optionally containing some logic for
transforming a raw result from the Stripe API into a final struct. This is
achie... | lib/stripe/entity.ex | 0.930205 | 0.89607 | entity.ex | starcoder |
defmodule JSON.LD.LoadingDocumentFailedError do
@moduledoc """
The document could not be loaded or parsed as JSON.
"""
defexception code: "loading document failed", message: nil
end
defmodule JSON.LD.ListOfListsError do
@moduledoc """
A list of lists was detected. List of lists are not supported in this ve... | lib/json/ld/exceptions.ex | 0.841988 | 0.404096 | exceptions.ex | starcoder |
defmodule MongoEx do
defguard is_field(literal) when is_atom(literal)
defguard is_value(literal) when not is_atom(literal)
def dumpers(_primitive, type), do: [type]
def all(query, params) do
normalized = %{}
sources = []
normalized |> from(query) |> filter(query, sources, params) |> projection(que... | lib/mongo_ex.ex | 0.614163 | 0.501465 | mongo_ex.ex | starcoder |
defmodule Network do
@moduledoc"""
Create a simple neural network to train across relatively simple tasks.
"""
@doc"""
The primary function of a neural net is to learn to produce the right output from
a given input (learning). The train call receives the scape and size and creates
accordingly.
ex: Net... | lib/network.ex | 0.742422 | 0.766119 | network.ex | starcoder |
defmodule Theater.Demo.Order do
@moduledoc """
A more complex demonstration Actor.
This is a simple actor for demonstrating how implementing an Actor works. It
represents an order and goes through several stages like a state machine. It
can also interact with other Actors.
Items can be added to an order a... | lib/theater/demo/order.ex | 0.747432 | 0.592961 | order.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.