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 Ecto.Rut do
@moduledoc """
Provides simple, sane and terse shortcuts for Ecto models.
Ecto.Rut is a wrapper around `Ecto.Repo` methods that usually require you to pass
the module as the subject and sometimes even require you do extra work before hand,
(as in the case of `Repo.insert/3`) to perform ... | lib/ecto_rut.ex | 0.847684 | 0.768027 | ecto_rut.ex | starcoder |
defmodule Vivid.RGBA do
alias __MODULE__
import :math, only: [pow: 2]
defstruct ~w(red green blue alpha a_red a_green a_blue)a
@ascii_luminance_map {" ", ".", ":", "-", "=", "+", "*", "#", "%", "@"}
@ascii_luminance_map_length 10
@moduledoc """
Defines a colour in RGBA colour space.
The three colour c... | lib/vivid/rgba.ex | 0.916236 | 0.798776 | rgba.ex | starcoder |
defmodule Fxnk.Flow do
@moduledoc """
`Fxnk.Flow` functions are used for control flow.
"""
import Fxnk.Functions, only: [curry: 1]
import Fxnk.List, only: [reduce_right: 3]
@doc """
`and_then/2` allows you to chain together `{:ok, _}` functions. Stops processing on the first `{:error, _}` and returns the... | lib/fxnk/flow.ex | 0.870163 | 0.668988 | flow.ex | starcoder |
defmodule Bamboo.Mailer do
@moduledoc """
Functions for delivering emails using adapters and delivery strategies.
Adds `deliver_now/1`, `deliver_now!/1`, `deliver_later/1` and
`deliver_later!/1` functions to the mailer module in which it is used.
Bamboo [ships with several adapters][available-adapters]. It ... | lib/bamboo/mailer.ex | 0.73782 | 0.447038 | mailer.ex | starcoder |
defmodule Tortoise.Events do
@moduledoc """
A PubSub exposing various system events from a Tortoise
connection. This allows the user to integrate with custom metrics
and logging solutions.
Please read the documentation for `Tortoise.Events.register/2` for
information on how to subscribe to events, and
`T... | lib/tortoise/events.ex | 0.776369 | 0.475666 | events.ex | starcoder |
defmodule Mix.Tasks.Db.Cleanup do
use Mix.Task
import Mix.Ecto
@shortdoc "Performs database cleanup by deleting older rows in a specified table"
@moduledoc """
The db.cleanup task deletes old rows from a table.
By default, it deletes data from events that are older than 7 days.
## Examples
mix d... | lib/mix/tasks/db.cleanup.ex | 0.760917 | 0.44065 | db.cleanup.ex | starcoder |
defmodule Axon.Layers do
@moduledoc ~S"""
Functional implementations of common neural network layer
operations.
Layers are the building blocks of neural networks. These
functional implementations can be used to express higher-level
constructs using fundamental building blocks. Neural network
layers are s... | lib/axon/layers.ex | 0.954287 | 0.917598 | layers.ex | starcoder |
defmodule Stripe.Charges do
@moduledoc """
To charge a credit or a debit card, you create a new charge object. You can
retrieve and refund individual charges as well as list all charges. Charges
are identified by a unique random ID.
"""
@endpoint "charges"
@doc """
To charge a credit card, you create ... | lib/stripe/charges.ex | 0.826467 | 0.627423 | charges.ex | starcoder |
defmodule GCloud.SpeechAPI.Streaming.Client do
@moduledoc """
A client process for Streaming API.
Once a client is started, it establishes a connection to the Streaming API,
gets ready to send requests to the API and forwards incoming responses to a set process.
## Requests
The requests can be sent using... | lib/gcloud/speech_api/streaming_client.ex | 0.901207 | 0.411584 | streaming_client.ex | starcoder |
defmodule Snitch.Data.Schema.Package do
@moduledoc """
Models a Package which is composed of many `PackageItem`s.
"""
use Snitch.Data.Schema
alias Ecto.Nanoid
alias Snitch.Data.Schema.Embedded.ShippingMethod, as: EmbeddedShippingMethod
alias Snitch.Data.Schema.{Order, PackageItem, ShippingCategory, Shipp... | apps/snitch_core/lib/core/data/schema/package.ex | 0.890996 | 0.879665 | package.ex | starcoder |
defmodule Ecto.Query.Builder.Select do
@moduledoc false
alias Ecto.Query.Builder
@doc """
Escapes a select.
It allows tuples, lists and variables at the top level or a
single `assoc(x, y)` expression.
## Examples
iex> escape({1, 2}, [])
{{:{}, [], [:{}, [], [1, 2]]}, %{}}
iex> esca... | lib/ecto/query/builder/select.ex | 0.807688 | 0.482673 | select.ex | starcoder |
defmodule NervesHubLink.ConsoleChannel do
use GenServer
require Logger
@moduledoc """
Starts an IEx shell in process to allow remote console interaction
The remote console ability is disabled by default and requires the
`remote_iex` key to be enabled in the config:
```
config :nerves_hub_link, remote_... | lib/nerves_hub_link/console_channel.ex | 0.797202 | 0.714752 | console_channel.ex | starcoder |
defmodule DistilleryPackager.Debian.Config do
@moduledoc """
This module is used to capture the configuration of the debian package build.
The module also includes validation functionality which is used to ensure that
the data is in the correct format.
"""
defstruct name: nil, version: nil, arch: nil, desc... | lib/distillery_packager/debian/config.ex | 0.673621 | 0.424501 | config.ex | starcoder |
defmodule SafeURL do
@moduledoc """
`SafeURL` is library for mitigating Server Side Request
Forgery vulnerabilities in Elixir. Private/reserved IP
addresses are blocked by default, and users can add
additional CIDR ranges to the blocklist, or alternatively
allow specific CIDR ranges to which the application... | lib/safeurl/safeurl.ex | 0.877477 | 0.408041 | safeurl.ex | starcoder |
defmodule Advent20.LobbyLayout do
@moduledoc """
Day 24: Lobby Layout
Reference for hex coordinate systems:
https://www.redblobgames.com/grids/hexagons
I'm using axial coordinates (q, r)
"""
@directions %{
e: {1, 0},
se: {0, 1},
sw: {-1, 1},
w: {-1, 0},
nw: {0, -1},
ne: {1, -1}
... | lib/advent20/24_lobby_layout.ex | 0.854095 | 0.720786 | 24_lobby_layout.ex | starcoder |
defmodule CQEx.Query do
@moduledoc false
require Record
import CQEx, only: :macros
defmacro __using__(_opts) do
quote do
import CQEx.Query.Sigil
alias CQEx.Query, as: Q
end
end
@default_consistency 1
@type valid_query :: iodata() | CQEx.cql_query() | CQEx.cql_query_batch() | CQEx.... | lib/cqex/query.ex | 0.784236 | 0.402216 | query.ex | starcoder |
defmodule Db.Dets do
@moduledoc """
An implementor of Db that provides a dets table as a backend.
This currently provides a means to lookup a key, delete a value associated with a key,
and insert values associated with keys. Values can be keyspaced by the keyspace argument,
but by default are available every... | lib/dets.ex | 0.664867 | 0.654063 | dets.ex | starcoder |
defprotocol Cat.MonadError do
@moduledoc """
MonadError defines
* `raise(t(any), error) :: t(none)`
* `recover(t(a), (error -> t(a))) :: t(a)`
* `lift_ok_or_error(t(any), ok_or_error(a)) :: t(a)`
* `attempt(t(a)) :: t(ok_or_error(a))`
**It must also be `Monad`, `Applicative` and `Functor`.**
D... | lib/cat/protocols/monad_error.ex | 0.912407 | 0.44059 | monad_error.ex | starcoder |
defmodule Mail.Proplist do
@moduledoc """
A hybrid of erlang's proplists and lists keystores.
It acts as a Set for key-value pairs, but stil maintains it's order like a
List.
"""
@type t :: [{term, term} | term]
@doc """
Retrieves all keys from the key value pairs present in the list,
unlike :propl... | lib/mail/proplist.ex | 0.791942 | 0.544014 | proplist.ex | starcoder |
defmodule ArtemisLog.Helpers do
@doc """
Detect if value is truthy
"""
def present?(nil), do: false
def present?(""), do: false
def present?(0), do: false
def present?(_value), do: true
@doc """
Converts an atom or string to an integer
"""
def to_integer(value) when is_float(value), do: Kernel.tr... | apps/artemis_log/lib/artemis_log/helpers.ex | 0.82887 | 0.654736 | helpers.ex | starcoder |
defmodule UeberauthToken.Plug do
@moduledoc """
An implementation of Ueberauth token validation in a plug pipeline
In order for there to be successful authentication, the `Plug.Conn`
should have a request header in the following format:
%Plug.Conn{req_headers: [%{"authorization" => "Bearer <token>"}]}
... | lib/ueberauth_token/plug.ex | 0.874527 | 0.638004 | plug.ex | starcoder |
defmodule X3m.System.Router do
@moduledoc """
Registers system wide services.
Each `service/2` macro registers system-wide service and function with
documentation in module that `uses` this module.
`servicep/2` is considered as private service and is not introduced to other nodes
in the cluster.
Servic... | lib/router.ex | 0.860208 | 0.436082 | router.ex | starcoder |
defmodule GN.Orchestration do
import GN.Gluon
import GN.Evolution, only: [spawn_offspring: 1, build_layer: 2]
import GN.MNIST
alias GN.Network, as: Network
import GN.Python
import GN.Selection, only: [select: 1]
use Export.Python
def start_and_spawn({_level, net}) do
seed_layers = net.layers
la... | lib/galapagos_nao/orchestration.ex | 0.623721 | 0.510619 | orchestration.ex | starcoder |
defmodule Say do
@doc """
Translate a positive integer into English.
"""
@spec in_english(integer) :: {atom, String.t()}
def in_english(number) when number in 0..999_999_999_999, do: {:ok, say(number)}
def in_english(_number), do: {:error, "number is out of range"}
defp say(number), do: say(number, 0) |>... | say/lib/say.ex | 0.651798 | 0.535341 | say.ex | starcoder |
defmodule Inquisitor.JsonApi.Filter do
@moduledoc """
Inquisitor query handlers for JSON API filters
[JSON API Spec](http://jsonapi.org/format/#fetching-filtering)
#### Usage
`use` the module *after* the `Inquisitor` module:
defmodule MyApp do
use Inquisitor
use Inquisitor.JsonApi.Fi... | lib/inquisitor/jsonapi/filter.ex | 0.819207 | 0.472501 | filter.ex | starcoder |
defmodule GoodTimes do
@vsn "1.1.2"
@doc false
def version, do: @vsn
@moduledoc """
Convenient and expressive functions dealing with dates and times.
This is the core module of the `GoodTimes` library. For other modules and
their functionality, see _Associated modules_ below.
Unless explicitly stated... | lib/good_times.ex | 0.926711 | 0.744517 | good_times.ex | starcoder |
defmodule Fuzzyurl.Strings do
@moduledoc ~S"""
Functions to parse a string URL into a Fuzzyurl, and vice versa.
"""
## this regex matches URLs like this:
## [protocol ://] [username [: password] @] [hostname] [: port] [/ path] [? query] [# fragment]
@regex ~r"""
^
(?: (?<protocol> \* | [a-zA-Z][A-Z... | lib/fuzzyurl/strings.ex | 0.63341 | 0.428831 | strings.ex | starcoder |
defmodule VintageNetMobile.CellMonitor do
@moduledoc """
Monitor cell network information
This monitor queries the modem for cell network information and posts it to
VintageNet properties.
The following properties are reported:
| Property | Values | Description |
| ------... | lib/vintage_net_mobile/cell_monitor.ex | 0.843186 | 0.524212 | cell_monitor.ex | starcoder |
defmodule Octo.Repo do
@moduledoc """
Split read/write operations across multiple Ecto repos.
Forwards all write operations to the `master_repo` and all read operations to the `replica_repos`
"""
defmacro __using__(opts) do
quote bind_quoted: [opts: opts] do
master_repo = Keyword.get(opts, :master... | lib/octo/repo.ex | 0.700178 | 0.510192 | repo.ex | starcoder |
defmodule Goth.TokenStore do
@moduledoc """
The `Goth.TokenStore` is a simple `GenServer` that manages storage and retrieval
of tokens `Goth.Token`. When adding to the token store, it also queues tokens
for a refresh before they expire: ten seconds before the token is set to expire,
the `TokenStore` will call... | lib/goth/token_store.ex | 0.819929 | 0.5835 | token_store.ex | starcoder |
defmodule Feedex do
@moduledoc """
Feedex is a simple elixir feed (atom/rss) parser.
## Examples
```elixir
iex> {:ok, feed} = Feedex.fetch_and_parse "http://9gagrss.com/feed/"
...
iex> {:ok, feed} = Feedex.parse "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\" ..."
...... | lib/feedex.ex | 0.823328 | 0.679438 | feedex.ex | starcoder |
defmodule Money.ExchangeRates.Supervisor do
@moduledoc """
Functions to manage the starting, stopping,
deleting and restarting of the Exchange
Rates Retriever.
"""
use Supervisor
alias Money.ExchangeRates
@child_name ExchangeRates.Retriever
@doc """
Starts the Exchange Rates supervisor and
opti... | lib/money/exchange_rates/exchange_rates_supervisor.ex | 0.86196 | 0.764232 | exchange_rates_supervisor.ex | starcoder |
defmodule Plaid.Auth do
@moduledoc """
[Plaid Auth API](https://plaid.com/docs/api/products/#auth) calls and schema.
"""
defmodule GetResponse do
@moduledoc """
[Plaid API /auth/get response schema.](https://plaid.com/docs/api/products/#auth).
"""
@behaviour Plaid.Castable
alias Plaid.Acc... | lib/plaid/auth.ex | 0.863002 | 0.41256 | auth.ex | starcoder |
defmodule Hitbtc.Http.Account do
alias Hitbtc.Util.Api
@moduledoc """
Set of account related action
This set of methods requires auth information.
You could configure it into `config.exs` file of your application
"""
@doc """
Load list of your balance
## Example:
```elixir
iex(1)> Hitbtc.Acco... | lib/hitbtc/http/account.ex | 0.916517 | 0.689129 | account.ex | starcoder |
defmodule Ehee.Gists do
import Ehee
alias Ehee.Credential
@moduledoc """
The Gist Webhooks API
"""
@doc """
List authenticated users gists
## Example
Ehee.Gists.list(credential)
More info at: https://developer.github.com/v3/gists/#list-a-users-gists
"""
@spec list(Credential.t) :: Ehee.re... | lib/ehee/gists.ex | 0.783077 | 0.479077 | gists.ex | starcoder |
defmodule Norm.Core.Collection do
@moduledoc false
defstruct spec: nil, opts: []
def new(spec, opts) do
%__MODULE__{spec: spec, opts: opts}
end
defimpl Norm.Conformer.Conformable do
alias Norm.Conformer
alias Norm.Conformer.Conformable
def conform(%{spec: spec, opts: opts}, input, path) do... | lib/norm/core/collection.ex | 0.672654 | 0.457137 | collection.ex | starcoder |
defmodule RedisGraph.QueryResult do
@moduledoc """
A QueryResult containing returned fields and query metadata.
The resulting struct contains the result set header and records,
statistics about the query executed, and referential lists of entity
identifiers, specifically labels, property keys, and relationsh... | lib/redis_graph/query_result.ex | 0.880528 | 0.844985 | query_result.ex | starcoder |
module OrderedDict
% Generates a new OrderedDict from a list of tuples
%
% ## Examples
%
% { 'a: 1, 'b: 2 } = OrderedDict.from_list(['a/1, 'b/2])
%
def from_list(list)
{ 'elixir_orddict__, Erlang.orddict.from_list(list) }
end
% Return a new Elixir OrderedDict.
def new()
{ 'elixir_orddic... | lib/ordered_dict.ex | 0.6137 | 0.437403 | ordered_dict.ex | starcoder |
defmodule Farmbot.Firmware.Gcode.Parser do
@moduledoc """
Parses [farmbot-arduino-firmware](https://github.com/farmbot/farmbot-arduino-firmware) G-Codes.
"""
import Farmbot.Firmware.Gcode.Param
@spec parse_code(binary) :: {binary, tuple}
# Status codes.
@doc "Parse a code to an Elixir consumable messag... | lib/farmbot/firmware/gcode/parser.ex | 0.713232 | 0.428771 | parser.ex | starcoder |
defmodule Bolt.Cogs.USW.Set do
@moduledoc false
@behaviour Nosedrum.Command
alias Bolt.ErrorFormatters
alias Bolt.Helpers
alias Bolt.Humanizer
alias Bolt.ModLog
alias Bolt.Repo
alias Bolt.Schema.USWRuleConfig
alias Nosedrum.Predicates
alias Nostrum.Api
@impl true
def usage, do: ["usw set <rul... | lib/bolt/cogs/usw/set.ex | 0.859943 | 0.541409 | set.ex | starcoder |
defmodule Site.TripPlan.Location do
alias Phoenix.HTML
alias Site.TripPlan.Query
alias TripPlan.NamedPosition
@spec validate(Query.t(), map) :: Query.t()
def validate(
%Query{} = query,
%{
"to_latitude" => <<_::binary>>,
"to_longitude" => <<_::binary>>,
"to" => _... | apps/site/lib/site/trip_plan/location.ex | 0.808672 | 0.401189 | location.ex | starcoder |
defmodule PS2.API.QueryBuilder do
@moduledoc """
A module for creating Census API queries in a clean manner via pipelines.
### Example
iex> import PS2.API.QueryBuilder
PS2.API.QueryBuilder
iex> alias PS2.API.Query
PS2.API.Query
iex> query = Query.new(collection: "character")
...> |> term("chara... | lib/ps2/api/query_builder.ex | 0.897319 | 0.679724 | query_builder.ex | starcoder |
defmodule Movielist.Reports do
@moduledoc """
The Reports context.
"""
import Ecto.Query, warn: false
alias Movielist.Repo
alias Movielist.Admin
# alias Movielist.Admin.Genre
alias Movielist.Admin.Movie
alias Movielist.Admin.Rating
@doc """
Returns map with count of movies for genre id and thei... | lib/movielist/admin/reports.ex | 0.636353 | 0.478773 | reports.ex | starcoder |
defmodule TwelveDays do
@doc """
Given a `number`, return the song's verse for that specific day, including
all gifts for previous days in the same line.
"""
@days_and_gifts [
{1, "first", "a Partridge in a Pear Tree."},
{2, "second", "two Turtle Doves"},
{3, "third", "three French Hens"},
{4,... | elixir/twelve-days/lib/twelve_days.ex | 0.728459 | 0.433022 | twelve_days.ex | starcoder |
defmodule BlockchainAPI.Geocoder do
@max_retries 5
require Logger
alias BlockchainAPI.Util
def reverse_geocode(loc) do
reverse_geocode(loc, @max_retries)
end
def reverse_geocode(loc, 0) do
Logger.error("Exceeded google maps lookup for #{inspect(loc)}")
{:error, :retries_exceeded}
end
def... | lib/blockchain_api/geocoder.ex | 0.582729 | 0.430746 | geocoder.ex | starcoder |
defmodule Liquex do
@moduledoc """
Liquid template renderer for Elixir with a goal of 100% compatibility with the
[Liquid](https://shopify.github.io/liquid/) gem by [Shopify](https://www.shopify.com/).
## Basic Usage
iex> {:ok, template_ast} = Liquex.parse("Hello {{ name }}!")
iex> context = Lique... | lib/liquex.ex | 0.765593 | 0.610802 | liquex.ex | starcoder |
defmodule Traktor do
@moduledoc """
`Traktor` is a library to execute actions in a traceable manner by applying a two-phase-commit pattern.
It is mainly defined by two behaviours:
- `Traktor.Action` for the business logic;
- `Traktor.Store` for the persistance layer.
### Entity
An action or a group of a... | lib/traktor.ex | 0.913295 | 0.737371 | traktor.ex | starcoder |
defmodule Lab42.F.Parser do
use Lab42.F.Types
import Lab42.F.Time, only: [make_time: 1]
@moduledoc """
```elixir
defstruct wildcard: "*",
type: nil, # e.g. "vid", "elixir", ...
mgt: nil, # date modification date greater than
mlt: nil, # date modification date less than
sgt: nil, # size greate... | lib/lab42/f/parser.ex | 0.761893 | 0.801392 | parser.ex | starcoder |
defmodule Aoc1 do
@moduledoc """
Advent of Code 2018, Day 1
"""
@doc """
Parse an integer from a string, defaulting to 0
## Examples
iex> Aoc1.parse_int "-5"
-5
iex> Aoc1.parse_int "+8"
8
iex> Aoc1.parse_int "15"
15
iex> Aoc1.parse_int "3.14159"
3
Unp... | 01/lib/aoc1.ex | 0.824709 | 0.451568 | aoc1.ex | starcoder |
defmodule PersistentEts do
@external_resource "README.md"
@moduledoc File.read!("README.md")
|> String.split(~r/<!-- MDOC !-->/)
|> Enum.fetch!(1)
@type tab :: :ets.tab()
# :ets.type() is private for some reason
@type type :: :set | :ordered_set | :bag | :duplicate_bag
@type acces... | lib/persistent_ets.ex | 0.830937 | 0.48121 | persistent_ets.ex | starcoder |
defmodule EpicenterWeb.Test.LiveViewAssertions do
import Euclid.Test.Extra.Assertions
import ExUnit.Assertions
import Phoenix.LiveViewTest
alias Epicenter.Test
alias Euclid.Extra
def assert_attribute(view, selector, attribute, expected) do
rendered = view |> element(selector) |> render()
if rende... | test/support/live_view_assertions.ex | 0.61659 | 0.563948 | live_view_assertions.ex | starcoder |
defmodule EctoVista do
@moduledoc """
Provides the macros and functions to define and manage
PostgreSQL views with Ecto.
## Using EctoVista
To use `EctoVista`, you need to add `use EctoVista` to your Elixir
files. This gives you access to the functions and macros defined
in the module.
exampl... | lib/ecto_vista.ex | 0.767429 | 0.423816 | ecto_vista.ex | starcoder |
defprotocol StathamLogger.Loggable do
@moduledoc """
Implement this protocol for structs, that require custom sanitization.
1. Implement `StathamLogger.Loggable` protocol. Most flexible approach.
```elixir
defimpl StathamLogger.Loggable, for: YourStruct do
@impl true
def sanitize(struct, opts) do
... | lib/loggable.ex | 0.859369 | 0.681859 | loggable.ex | starcoder |
defmodule Erl2ex.Cli do
@moduledoc """
This module provides the command line interface for the erl2ex binary and
the mix erl2ex task.
"""
alias Erl2ex.Results
@doc """
Runs the erl2ex binary, given a set of command line arguments.
Returns the OS result code, which is 0 for success or nonzero for f... | lib/erl2ex/cli.ex | 0.576423 | 0.442637 | cli.ex | starcoder |
defmodule Rex2048.Board do
@doc """
iex> Rex2048.Board.can_move?([2, 4, 2, 8])
true
iex> Rex2048.Board.can_move?([2, 4, 8, 16])
false
"""
def can_move?(board) do
[:left, :right, :up, :down]
|> Enum.map(&({board, push(board, &1)}))
|> Enum.any?(fn {b1, b2} -> b1 != b2 end)
e... | lib/rex2048/board.ex | 0.603581 | 0.504761 | board.ex | starcoder |
defmodule Hades.Arguments.HostDiscovery do
@moduledoc """
One of the very first steps in any network reconnaissance mission is to reduce a (sometimes huge) set of IP ranges into a list of active or interesting hosts. Scanning every port of every single IP address is slow and usually unnecessary. Of course what make... | lib/arguments/host_discovery.ex | 0.768081 | 0.662531 | host_discovery.ex | starcoder |
defmodule Gim.Index do
@moduledoc """
Internal helper module to handle indexes.
"""
@type id :: pos_integer()
@type index :: list(id)
@doc """
Turns a given list into an index
iex> new([10, 13, 6, 60, 2])
[60, 13, 10, 6, 2]
iex> new([2, 2, 2, 3])
[3, 2]
"""
@spec new(list ::... | lib/gim/index.ex | 0.787646 | 0.458409 | index.ex | starcoder |
defmodule HomeBot.EnergyStream.Watercooker.WatercookerDetector do
use GenStage
alias HomeBot.EnergyStream.Watercooker.State
def start_link(_) do
GenStage.start_link(__MODULE__, :ok)
end
@impl GenStage
def init(:ok) do
# Starts a permanent subscription to the broadcaster
# which will automatic... | lib/home_bot/energy_stream/watercooker/watercooker_detector.ex | 0.851305 | 0.469034 | watercooker_detector.ex | starcoder |
defmodule Astro.Math do
@moduledoc false
import Kernel, except: [min: 2, max: 2, ceil: 1, floor: 1]
alias Astro.Time
@radians_to_degrees 180.0 / :math.pi()
@au_to_km 149_597_870.7
@au_to_m 149_597_870.7 * 1_000
defmacro to_degrees(radians) do
radians_to_degrees = @radians_to_degrees
quote do
... | lib/astro/math.ex | 0.894525 | 0.737513 | math.ex | starcoder |
defmodule DiscUnion.Utils.Constructors do
@moduledoc false
require DiscUnion.Utils.Case
alias DiscUnion.Utils
alias DiscUnion.Utils.{Constructors, Case}
defmacro build_constructor_functions(mod, cases) do
from_constructors = build_from_constructors(cases, mod)
c_constructors = build_c_constructors(... | lib/utils/constructors.ex | 0.778355 | 0.494324 | constructors.ex | starcoder |
defmodule VendingMachine.MakeItemStock do
@item %{
A1: %{name: "Coke", display: "🍹", department: "Soft Drink", price: 1.0, quantity: 20},
A2: %{name: "Sprite", display: "🍹", department: "Soft Drink", price: 0.5, quantity: 20},
A3: %{name: "Pepsi", display: "🍹", department: "Soft Drink", price: 0.65, qu... | lib/vending_machine/stock/make_item_stock.ex | 0.648132 | 0.695829 | make_item_stock.ex | starcoder |
defmodule InterceptConfig do
@config %{
################# `Interceptor.intercept do ... end` tests
# on before tests
{InterceptedOnBefore1, :to_intercept, 0} => [before: {Before.Callback, :before, 1}],
{InterceptedOnBefore2, :to_intercept, 0} => [before: {Before.Callback, :before, 1}],
{Intercept... | test/intercepted_modules/intercept_config.ex | 0.665628 | 0.733285 | intercept_config.ex | starcoder |
defmodule Surface.AST do
@type t ::
Surface.AST.Text.t()
| Surface.AST.Interpolation.t()
| Surface.AST.Expr.t()
| Surface.AST.Tag.t()
| Surface.AST.Template.t()
| Surface.AST.Slot.t()
| Surface.AST.If.t()
| Surface.AST.For.t()
|... | lib/surface/ast.ex | 0.903166 | 0.61144 | ast.ex | starcoder |
defmodule Phoenix.Socket.Transport do
@moduledoc """
API for building transports.
This module describes what is required to build a Phoenix transport.
The transport sits between the socket and channels, forwarding client
messages to channels and vice-versa.
A transport is responsible for:
* Implement... | lib/phoenix/socket/transport.ex | 0.90777 | 0.623148 | transport.ex | starcoder |
require Logger
use Timex
defmodule PonyFactor do
@moduledoc """
Calculates the [Pony Factor](https://ke4qqq.wordpress.com/2015/02/08/pony-factor-math/) of a GitHub
repository.
The Pony Factor of a repository is the smallest number of contributors that, when totalling the
number of commits for each contribut... | lib/pony_factor.ex | 0.794544 | 0.70156 | pony_factor.ex | starcoder |
defmodule Still.Compiler.PassThroughCopy do
@moduledoc """
Copies a file from the input path to the output directory without changing it.
## Matching parameters
You can configure matching parameters by setting
config :still,
pass_through_copy: ["img/logo.png"]
In the example above, the file ... | lib/still/compiler/pass_through_copy.ex | 0.7324 | 0.602734 | pass_through_copy.ex | starcoder |
defmodule Stackdelivery do
@moduledoc """
Main Stackdelivery entry point.
This app starts a bunch of stacks as building blocks and can be joined any which way transferring ejectile between two stacks.
The Stacks act as sources to a one or more sinks in numerous ways.
The main operations these stacks can do ... | stackdelivery/lib/stackdelivery.ex | 0.688992 | 0.682448 | stackdelivery.ex | starcoder |
defmodule Zaryn.TransactionChain.MemTables.PendingLedger do
@moduledoc """
Represents a memory table for all the transaction which are in pending state
awaiting some signatures to be counter-validated
"""
@table_name :zaryn_pending_ledger
use GenServer
require Logger
@doc """
Initialize the memory... | lib/zaryn/transaction_chain/mem_tables/pending_ledger.ex | 0.808181 | 0.410727 | pending_ledger.ex | starcoder |
defmodule Riffed.Server do
@moduledoc ~S"""
Provides a server and datastructure mappings to help you build thrift servers in Elixir. Macros
dutifully work behind the scenes to give you near-seamless access to Thrift structures.
*Riffed: Bridging the divide between Thrift and Elixir.*
## Usage
The Thrift ... | lib/riffed/server.ex | 0.629547 | 0.442034 | server.ex | starcoder |
defmodule Krihelinator.ImportExport do
@moduledoc """
Tools to export all of the data from the DB into a single json, and
to populate the DB from an existing one.
"""
alias Krihelinator.Github, as: GH
@models [GH.Language, GH.Repo, Krihelinator.History.Language]
@doc """
Populate the DB with data from... | www/lib/krihelinator/import_export.ex | 0.524395 | 0.460471 | import_export.ex | starcoder |
defmodule Sentry.Logger do
require Logger
@moduledoc """
This is based on the Erlang [error_logger](http://erlang.org/doc/man/error_logger.html).
To set this up, add `:ok = :error_logger.add_report_handler(Sentry.Logger)` to your application's start function. Example:
```elixir
def start(_type, _opts) do... | lib/sentry/logger.ex | 0.7586 | 0.793426 | logger.ex | starcoder |
defmodule Braintree.SettlementBatchSummary do
@moduledoc """
The settlement batch summary displays the total sales and credits for each
batch for a particular date. The transactions can be grouped by a single
custom field's values.
https://developers.braintreepayments.com/reference/request/settlement-batch-s... | lib/settlement_batch_summary.ex | 0.920245 | 0.587825 | settlement_batch_summary.ex | starcoder |
defmodule DoubleCheck do
@moduledoc """
A module for distributing assignments to assignees.
Originally designed to distribute exams to graders, the goals were these:
* Have every exam graded twice, by two different graders.
* Have every grader grade at least one exam in common with every other grader,
so... | lib/double_check.ex | 0.883393 | 0.951997 | double_check.ex | starcoder |
defmodule Makeup.Lexer.Combinators do
import NimbleParsec
@doc """
Wraps the given combinator into a token of the given `ttype`.
Instead of a combinator, the first argument can also be a string literal.
"""
def token(literal, token_type) when is_binary(literal) do
replace(string(literal), {token_type,... | lib/makeup/lexer/combinators.ex | 0.812459 | 0.507141 | combinators.ex | starcoder |
defmodule Wargaming.Warships.Encyclopedia do
@moduledoc """
Encyclopedia provides functions for interacting with the WarGaming.net World of Warships Encyclopedia API.
"""
use Wargaming.ApiEndpoint, api: Wargaming.Warships
@encyclopedia_info "/encyclopedia/info/"
@encyclopedia_ships "/encyclopedia/ships/"
... | lib/wargaming/warships/encyclopedia.ex | 0.862685 | 0.641303 | encyclopedia.ex | starcoder |
defmodule ELA.Vector do
alias :math, as: Math
@moduledoc"""
Contains operations for working with vectors.
"""
@doc"""
Returns a vector with zeroes with provided dimension.
## Examples
iex> Vector.new(3)
[0, 0, 0]
"""
@spec new(number) :: [number]
def new(n) when not is_num... | lib/vector.ex | 0.895353 | 0.722086 | vector.ex | starcoder |
defmodule Workflows.Workflow do
@moduledoc false
alias Workflows.Activity
alias Workflows.Command
alias Workflows.Event
alias Workflows.State
@type activities :: %{Activity.name() => Activity.t()}
@type t :: %__MODULE__{
start_at: Activity.name(),
activities: activities()
}
... | lib/workflows/workflow.ex | 0.760428 | 0.460713 | workflow.ex | starcoder |
defmodule ExChangeRate.Utils.Currency do
@moduledoc """
Functions for calculation, casting, conversion and formatting of currencies
"""
@doc """
Creates a new currency representation
"""
def new(value, currency), do: Money.new(value, currency)
@doc """
Extracts the value from a currency representati... | lib/ex_change_rate/utils/currency.ex | 0.862887 | 0.632247 | currency.ex | starcoder |
defmodule Mix.Tasks.Xref do
use Mix.Task
alias Mix.Tasks.Compile.Elixir, as: E
import Mix.Compilers.Elixir, only: [read_manifest: 2, source: 1, source: 2, module: 1]
@shortdoc "Performs cross reference checks"
@recursive true
@moduledoc """
Performs cross reference checks between modules.
## Xref mo... | lib/mix/lib/mix/tasks/xref.ex | 0.837952 | 0.544741 | xref.ex | starcoder |
defmodule BrazilianUtils.Phone do
@moduledoc false
alias BrazilianUtils.Helper
@spec is_valid?(String.t()) :: boolean()
def is_valid?(phone) when is_binary(phone) do
digits = Helper.only_numbers(phone)
is_valid_phone_length?(digits) and is_valid_first_number?(digits) and is_valid_ddd?(digits)
end
... | lib/brazilian_utils/phone.ex | 0.759493 | 0.413921 | phone.ex | starcoder |
defmodule Mix.Tasks.Liberator.Chart do
@shortdoc "Generates source text for a chart of Liberator's decision tree"
@moduledoc """
Generates source text for a decision tree chart for a Liberator resource.
The chart is compatible with the [Graphviz](https://graphviz.org/) graph visualization software.
```sh
... | lib/mix/tasks/liberator.chart.ex | 0.830147 | 0.814754 | liberator.chart.ex | starcoder |
defmodule ExAdvent.Day01 do
@moduledoc """
# Day 1: Chronal Calibration
"We've detected some temporal anomalies," one of Santa's Elves at the Temporal Anomaly Research and Detection Instrument Station tells you. She sounded pretty worried when she called you down here. "At 500-year intervals into the past, someo... | lib/ex_advent/day_01.ex | 0.844168 | 0.78968 | day_01.ex | starcoder |
defmodule EctoMnesia.Table do
@moduledoc """
This module provides interface to perform CRUD and select operations on a Mnesia table.
"""
alias :mnesia, as: Mnesia
@doc """
Insert a record into Mnesia table.
"""
def insert(table, record, _opts \\ []) when is_tuple(record) do
table = get_name(table)
... | lib/ecto_mnesia/table.ex | 0.771413 | 0.612136 | table.ex | starcoder |
defmodule DataLogger.Destination.Supervisor do
@moduledoc """
Supervisor of a group of `DataLogger.Destination.Controller` workers for given `topic`.
For every configured destination, there will be a worker (unless prefixes are used).
For example if we configured a NoSQL destination and a relational destinatio... | lib/data_logger/destination/supervisor.ex | 0.835484 | 0.648828 | supervisor.ex | starcoder |
defmodule APIDoc.Doc.Schema do
@moduledoc ~S"""
A schema definition for use as in and output type.
"""
require Logger
@typedoc ~S"""
The schema type.
"""
@type type ::
:integer
| :string
| :object
| :array
@typedoc ~S"""
The format for types that have differ... | lib/doc/schema.ex | 0.892445 | 0.457985 | schema.ex | starcoder |
defmodule Andi.InputSchemas.InputConverter do
@moduledoc """
Used to convert between SmartCity.Datasets, form data (defined by Andi.InputSchemas.DatasetInput), and Ecto.Changesets.
"""
alias SmartCity.Dataset
alias Andi.InputSchemas.DatasetInput
@type dataset :: map() | Dataset.t()
@spec changeset_from... | apps/andi/lib/andi/input_schemas/input_converter.ex | 0.681621 | 0.405184 | input_converter.ex | starcoder |
defmodule Onnx.AttributeProto do
@moduledoc """
A named attribute containing either singular float, integer, string
and tensor values, or repeated float, integer, string and tensor values.
An AttributeProto MUST contain the name field, and *only one* of the
following content fields, effectively enforcing a C/... | lib/onnx.pb.ex | 0.894528 | 0.574216 | onnx.pb.ex | starcoder |
defmodule Cryppo.EncryptedDataWithDerivedKey do
@moduledoc """
A struct for a derived key and data encrypted with this derived key
"""
import Cryppo.Base64
import Cryppo.Strategies, only: [find_key_derivation_strategy: 1]
alias Cryppo.{DerivedKey, EncryptedData, EncryptedDataWithDerivedKey, Serialization}
... | lib/cryppo/encrypted_data_with_derived_key.ex | 0.877227 | 0.45175 | encrypted_data_with_derived_key.ex | starcoder |
defmodule AOC.Day5.Intcode do
@moduledoc false
@type memory :: %{
integer => integer,
pointer: integer,
inputs: list(integer),
outputs: list(integer)
}
def part1(path, user_inputs) do
stream_puzzle_input(path)
|> puzzle_input_to_map(user_inputs)
|> com... | aoc-2019/lib/aoc/day5/intcode.ex | 0.848722 | 0.452052 | intcode.ex | starcoder |
defmodule Mix.Tasks.Dialyze do
@moduledoc """
Analyses the current Mix project using success typing.
## Examples
# Build or check a PLT and use it to analysis a project
mix dialyze
# Use the existing PLT to analysis a project
mix dialyze --no-check
# Build or check the PLT for cu... | lib/mix/tasks/dialyze.ex | 0.781831 | 0.579757 | dialyze.ex | starcoder |
defmodule RulEx.Fixtures.Value do
def test_cases do
[
%{
expr: [:val, "number", 10],
db: %{},
expected: {:ok, 10},
message: "yields stored value correctly if typing is correct"
},
%{
expr: [:val, "string", ""],
db: %{},
expected: {:ok, ""},... | test/fixtures/value.ex | 0.76145 | 0.506774 | value.ex | starcoder |
defmodule AWS.AutoScaling do
@moduledoc """
With Application Auto Scaling, you can configure automatic scaling for your
scalable resources. You can use Application Auto Scaling to accomplish the
following tasks:
<ul> <li> Define scaling policies to automatically scale your AWS or custom
resources
</li>... | lib/aws/autoscaling.ex | 0.916568 | 0.596874 | autoscaling.ex | starcoder |
defmodule CoursePlanner.Courses.OfferedCourses do
@moduledoc false
alias CoursePlanner.{Courses.OfferedCourse, Repo, Attendances, Notifications.Notifier,
Notifications, Accounts.Students, Accounts.Teachers, Settings}
import Ecto.Query
alias Ecto.Changeset
@notifier Application.get_env... | lib/course_planner/courses/offered_courses.ex | 0.610686 | 0.42668 | offered_courses.ex | starcoder |
defmodule Mox do
@moduledoc """
Mox is a library for defining concurrent mocks in Elixir.
The library follows the principles outlined in
["Mocks and explicit contracts"](http://blog.plataformatec.com.br/2015/10/mocks-and-explicit-contracts/),
summarized below:
1. No ad-hoc mocks. You can only create moc... | lib/mox.ex | 0.865096 | 0.656588 | mox.ex | starcoder |
defmodule Guardian.Token.Verify do
@moduledoc """
Interface for verifying tokens.
This is intended to be used primarily by token modules
but allows for a custom verification module to be created
if the one that ships with your TokenModule is not quite what you want.
"""
@doc """
Verify a single claim
... | lib/guardian/token/verify.ex | 0.818592 | 0.756403 | verify.ex | starcoder |
defmodule MLLP.Envelope do
@moduledoc """
Helper functions encoding and decoding MLLP-framed messages.
Below is an example of an MLLP-framed HL7 payload. Note the <SB>, <CR>, and <EB> characters.
<SB>
MSH|^~\\\\&|MegaReg|XYZHospC|SuperOE|XYZImgCtr|20060529090131-0500||ADT^A01^ADT_A01|01052901|P|... | lib/mllp/envelope.ex | 0.872755 | 0.584123 | envelope.ex | starcoder |
defmodule HTS221.Calibration do
@moduledoc """
The calibration for the HTS221
Each HTS221 is calibrated at the factory and has an unique calibration. The
calibration is used to calculate the temperature and humidity values that are
stored in the registers as those values are raw ADC values.
"""
import B... | lib/hts221/calibration.ex | 0.817902 | 0.676617 | calibration.ex | starcoder |
defmodule Tai.Markets.Quote do
@moduledoc """
Represents the inside bid & ask price point within the order book
"""
alias __MODULE__
alias Tai.Markets.PricePoint
@type price_point :: PricePoint.t()
@type venue_id :: Tai.Venue.id()
@type product_symbol :: Tai.Venues.Product.symbol()
@type t :: %Quote... | apps/tai/lib/tai/markets/quote.ex | 0.848424 | 0.422594 | quote.ex | starcoder |
defmodule Mix.Tasks.Pix.ReadBrcode do
@moduledoc """
Reads a BRCode decoding and validating it.
It accepts the raw BRCode. Beware of valid spaces in its values! When using the command line,
wrap it with single quotes. Example:
mix pix.read_br_code '00020126580014br.gov.bcb.pix0136123e4567-e12b-12d1-a456... | lib/mix/tasks/read.brcode.ex | 0.825062 | 0.421641 | read.brcode.ex | starcoder |
defmodule TypeCheck.TypeError do
@moduledoc """
Exception to be returned or raised when a value is not of the expected type.
This exception has two fields:
- `:raw`, which will contain the problem tuple of the type check failure.
- `:message`, which will contain a the humanly-readable representation of the ... | lib/type_check/type_error.ex | 0.751375 | 0.749615 | type_error.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.