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 Stripe.Card do
@moduledoc """
Work with Stripe card objects.
You can:
- Create a card
- Retrieve a card
- Update a card
- Delete a card
All requests require `owner_type` and `owner_id` parameters to be specified.
`owner_type` must be one of the following:
* `:customer`,
* `:recip... | lib/stripe/card.ex | 0.815747 | 0.539469 | card.ex | starcoder |
defmodule HeBroker.RouteMap do
@moduledoc """
This module implements a method of mapping consumer services to their
subscribed topics so publishers can properly broadcast messages
Each route is composed by a topic (the string that will be used to define which
_services_ you want to send your message to. eg: ... | lib/he_broker/route_map.ex | 0.849815 | 0.55911 | route_map.ex | starcoder |
defmodule AWS.Route53Domains do
@moduledoc """
Amazon Route 53 API actions let you register domain names and perform
related operations.
"""
@doc """
Accepts the transfer of a domain from another AWS account to the current
AWS account. You initiate a transfer between AWS accounts using
[TransferDomain... | lib/aws/generated/route53_domains.ex | 0.895933 | 0.463748 | route53_domains.ex | starcoder |
defmodule Momento.Add do
import Momento.Guards
import Momento.Helpers
@moduledoc """
This module holds all the various `add/3` methods.
"""
@doc """
Add a specified amount of time. Available atoms are `:years`, `:months`, `:days`, `:hours`, `:minutes`, `:seconds`,
`:milliseconds` and `:microseconds`.
... | lib/add.ex | 0.734786 | 0.656204 | add.ex | starcoder |
defprotocol Timex.Comparable do
@moduledoc """
This protocol is used for comparing and diffing different date/time representations
"""
alias Timex.Types
@type granularity ::
:year
| :years
| :month
| :months
| :week
| :weeks
| :calendar_we... | lib/comparable/comparable.ex | 0.93619 | 0.701726 | comparable.ex | starcoder |
defmodule Mutation.Mutations do
# Transverses all the mutations
def each_mutation(code_transverse_function) do
Enum.flat_map all_mutations, fn(mutation_map) ->
Enum.reduce mutation_map.functions, [], fn({mutation_function, mutation_reason}, acc) ->
result = code_transverse_function.(mutation_map.... | lib/mutation/mutations.ex | 0.542136 | 0.663557 | mutations.ex | starcoder |
defmodule Membrane.Element.Pcap.Source do
@moduledoc """
Element that reads subsequent packets from `pcap` file and sends them
as buffers through the output pad.
"""
use Membrane.Source
use Bunch
alias Membrane.Buffer
alias Membrane.Element.Pcap.Parser
alias ExPcap.Packet
@next_packet &Parser.next... | lib/pcap/source.ex | 0.90939 | 0.401453 | source.ex | starcoder |
defmodule VintageNet.IP.DnsdConfig do
@moduledoc """
This is a helper module for VintageNet.Technology implementations that use
the Busybox DNS server.
DNS functionality is only supported for IPv4 configurations using static IP
addresses.
DNS server parameters are:
* `:port` - The port to use (defaults... | lib/vintage_net/ip/dnsd_config.ex | 0.863348 | 0.820182 | dnsd_config.ex | starcoder |
defmodule Mix.Tasks.Docs do
use Mix.Task
@shortdoc "Generate documentation for the project"
@moduledoc """
Uses ExDoc to generate a static web page from the project documentation.
## Command line options
* `--canonical`, `-n` - Indicate the preferred URL with
rel="canonical" link element, defaul... | lib/mix/tasks/docs.ex | 0.817429 | 0.477554 | docs.ex | starcoder |
defmodule Schocken.Game.Player do
@moduledoc false
alias __MODULE__
alias Schocken.Game.Ranking
defstruct(
name: "",
current_toss: %{dices: nil,
dices_out: nil,
one_toss: nil,
promote: :zero,
tries: 0,
... | lib/schocken/game/player.ex | 0.789437 | 0.416559 | player.ex | starcoder |
defmodule Patch.Listener do
use GenServer
@default_capture_replies true
@default_timeout 5000
@typedoc """
Listeners are started with a tag so the listening process can differentiate
between multiple listeners.
"""
@type tag :: atom()
@typedoc """
Listeners listen to a target.
"""
@type targe... | lib/patch/listener.ex | 0.775647 | 0.41567 | listener.ex | starcoder |
defmodule Day13 do
@moduledoc """
Documentation for Day13.
"""
def part1 do
{start, buses} = read_data("input.txt")
{departure_time, departing_buses} =
next_departure(start, buses |> Enum.filter(fn bus -> bus != -1 end))
IO.puts("Next departure time: #{departure_time} buses #{Enum.join(depa... | day13/lib/day13.ex | 0.575946 | 0.421016 | day13.ex | starcoder |
defmodule Day4 do
def solve do
input = prepare_input()
start = System.monotonic_time(unquote(:milli_seconds))
IO.puts("Part one answer:")
input
|> Day4.Part1.solve()
|> IO.inspect()
time_part_one = System.monotonic_time(unquote(:milli_seconds)) - start
IO.puts("Part one took #{time_... | elixir/day4/lib/day4.ex | 0.553023 | 0.519826 | day4.ex | starcoder |
defmodule Kitt.Message.BSM do
@moduledoc """
Defines the structure and instantiation function
for creating a J2735-compliant BasicSafetyMessage
A `BSM` defines the basic interchange of presence data
between DSRC-capable vehicles and infrastructure
"""
defmodule CoreData do
@moduledoc """
Defines... | lib/kitt/message/bsm.ex | 0.823293 | 0.671065 | bsm.ex | starcoder |
defmodule BubbleMatch.Token do
@moduledoc """
A token is a single word or a part of the sentence. A sentence is a sequence of tokens.
Each token contains information and metadata that is used to match
sentences on, and to extract information from.
"""
@typedoc """
Tokens contain the following fields:
... | lib/bubble_match/token.ex | 0.877424 | 0.763528 | token.ex | starcoder |
defmodule Noizu.DomainObject do
@doc """
Setup Base Domain Object, this struct will in turn hold Entity, Repo, Index, etc.
## See
- `Noizu.AdvancedScaffolding.Internal.Core.Base.Behaviour`
- `Noizu.AdvancedScaffolding.Internal.Persistence.Base.Behaviour`
- `Noizu.AdvancedScaffolding.Internal.EntityIndex.... | lib/scaffolding/domain_object.ex | 0.682997 | 0.663399 | domain_object.ex | starcoder |
defmodule Scrivener.Headers do
@moduledoc """
Helpers for paginating API responses with [Scrivener](https://github.com/drewolson/scrivener) and HTTP headers. Implements [RFC-5988](https://mnot.github.io/I-D/rfc5988bis/), the proposed standard for Web linking.
Use `paginate/2` to set the pagination headers:
... | lib/scrivener/headers.ex | 0.816443 | 0.416559 | headers.ex | starcoder |
defmodule Schedules.RepoCondensed do
@moduledoc """
An alternate way to fetch schedules that is more light weight and easier to cache.
This uses a longer than usual timeout for initial caching as sometime (especially in dev)
it may take a long time to warm the cache.
"""
import Kernel, except: [to_string... | apps/schedules/lib/repo_condensed.ex | 0.730866 | 0.416589 | repo_condensed.ex | starcoder |
defmodule Clova.SkillPlug do
@behaviour Plug
@moduledoc """
This plug provides the necessary middlewear to handle a request from the Clova server, call your
`Clova` implementation, and build the HTTP response.
This plug is a convenience wrapper of four other plugs: `Plug.Parsers`, `Clova.ValidatorPlug`,
`... | lib/clova/skill_plug.ex | 0.864639 | 0.829492 | skill_plug.ex | starcoder |
defmodule Quadquizaminos.Hints do
def tldr(:intro) do
"""
<p>Click "How to Play" for instructions.</p>
<p>Fill all blocks in a row to clear the row.</p>
<p>Right/left arrows move quads right/left.</p>
<p>Up arrow rotates falling quad.</p>
<p>Down arrow drops falling quad.</p>
<p>Space bar ... | lib/quadquizaminos/hints.ex | 0.52683 | 0.709397 | hints.ex | starcoder |
defmodule HL7.Examples do
@moduledoc """
Functions to provide sample HL7 data which can be used to explore the API.
"""
@doc """
Returns a sample HL7 string from [Wikipedia's HL7 article](https://en.wikipedia.org/wiki/Health_Level_7#Version_2_messaging).
The HL7 version of the message defaults to 2.5, but... | lib/hl7/examples.ex | 0.751785 | 0.668001 | examples.ex | starcoder |
defmodule OddJob.Job do
@moduledoc """
The `OddJob.Job` struct holds all of the useful information about a job.
"""
@moduledoc since: "0.1.0"
@spec __struct__ :: OddJob.Job.t()
defstruct [:ref, :owner, :function, :results, :proxy, async: false]
@typedoc """
The `OddJob.Job` struct is the datatype that... | lib/odd_job/job.ex | 0.841923 | 0.60826 | job.ex | starcoder |
defmodule Chopsticks.Learn.Generator do
@moduledoc """
GenServer for generating and remembering moves.
"""
use GenServer
alias Chopsticks.Engine
alias Chopsticks.Random
# Client
def start_link do
GenServer.start_link(__MODULE__, %{1 => [], 2 => []})
end
def take_turn(pid, player_number, play... | lib/chopsticks/learn.ex | 0.792745 | 0.584153 | learn.ex | starcoder |
defmodule Parseus do
@moduledoc """
Legendary Elixir parser to tame all your input enumerables for good.
## Usage
Here's a basic usage:
input = %{
"name" => "Mike",
"email" => "<EMAIL>"
"age" => "21",
"license-agreement" => "1",
"notes" => "Please don't send me e... | lib/parseus.ex | 0.651798 | 0.438124 | parseus.ex | starcoder |
defmodule TypedStruct do
@moduledoc """
TypedStruct is a library for defining structs with a type without writing
boilerplate code.
## Rationale
To define a struct in Elixir, you probably want to define three things:
* the struct itself, with default values,
* the list of enforced keys,
* its a... | lib/typed_struct.ex | 0.853989 | 0.553445 | typed_struct.ex | starcoder |
defmodule Riptide.Store.Riptide do
@moduledoc """
This store forwards all mutations and queries to another Riptide instance. This is useful if you have multiple Riptide instances but want all of them to write and read from a primary node. This is comparable to web applications that write to a centralized Postgres d... | packages/elixir/lib/riptide/store/store_riptide.ex | 0.891876 | 0.797675 | store_riptide.ex | starcoder |
defmodule Mix.Tasks.Dialyzer do
@shortdoc "Runs dialyzer with default or project-defined flags."
@moduledoc """
This task compiles the mix project, creates a PLT with dependencies if needed and runs `dialyzer`. Much of its behavior can be managed in configuration as described below.
If executed outside of a m... | deps/dialyxir/lib/mix/tasks/dialyzer.ex | 0.81468 | 0.795777 | dialyzer.ex | starcoder |
defmodule Square.Devices do
@moduledoc """
Documentation for `Square.Devices`.
"""
@doc """
Lists all DeviceCodes associated with the merchant.
```
def list_device_codes(client, [
cursor: nil,
location_id: nil,
product_type: nil
])
```
### Parameters
| Parameter | Type | Tags | Des... | lib/api/devices_api.ex | 0.92761 | 0.810028 | devices_api.ex | starcoder |
defmodule Hextille.HexGrid do
require Integer
alias Hextille.Offset
alias Hextille.Cube
@moduledoc """
Module for creating HexGrids
"""
@doc ~S"""
Returns a MapSet containing grid of `row` rows and `col` columns of
hexagon tiles in Cube coordinates.
Top left corner of the grid is at %Cube{q: 0, r:... | lib/hexgrid.ex | 0.727589 | 0.598342 | hexgrid.ex | starcoder |
defmodule APIac.Authenticator do
@moduledoc """
Specification for authenticator plug
An authenticator is in charge of extracting and validating credentials. It can
also returns an error indicating how to authenticate, giving information such as
authentication scheme to use, etc.
"""
@type opts :: any()
... | lib/apiac/authenticator.ex | 0.921101 | 0.5 | authenticator.ex | starcoder |
defmodule Protobuf.Wire do
@moduledoc """
Utilities to convert data from wire format to protobuf and back.
"""
alias Protobuf.Wire.{Varint, Zigzag}
require Logger
@type proto_type ::
:int32
| :int64
| :fixed32
| :fixed64
| :uint32
| :uint64
... | lib/protobuf/wire.ex | 0.815012 | 0.456107 | wire.ex | starcoder |
defmodule Livebook.Runtime.Dependencies do
@moduledoc false
@doc """
Finds or adds a `Mix.install/2` call to `code` and modifies it to
include the given Mix deps.
"""
@spec add_mix_deps(String.t(), list(tuple())) :: {:ok, String.t()} | {:error, String.t()}
def add_mix_deps(code, deps) do
with {:ok, a... | lib/livebook/runtime/dependencies.ex | 0.83363 | 0.439807 | dependencies.ex | starcoder |
defmodule Grizzly.CommandClass.TimeParameters.Set do
@moduledoc """
Command module for working with TIME_PARAMETERS SET command
command options:
* `:year` - Year in the usual Gregorian calendar
* `:month` - Month of the year between 01 (January) and 12 (December)
* `:day` - Day of the month between... | lib/grizzly/command_class/time_parameters/set.ex | 0.888463 | 0.595787 | set.ex | starcoder |
defmodule TryNx do
@moduledoc """
Documentation for `TryNx`.
"""
@doc """
Train model using MSE and SGD
Reference: https://jovian.ai/aakashns/02-linear-regression (pytorch version)
## Examples
iex> TryNx.now()
:ok
"""
require Logger
import Nx.Defn
@max_epoch 10000
@max_loss 0.... | lib/try_nx.ex | 0.937854 | 0.701662 | try_nx.ex | starcoder |
defmodule Helios.Router.InvalidSpecError do
defexception message: "invalid route specification"
end
defmodule Helios.Router.Utils do
@moduledoc false
@doc """
Generates a representation that will only match routes
according to the given `spec`.
If a non-binary spec is given, it is assumed to be
custom... | lib/helios/router/utils.ex | 0.862033 | 0.417301 | utils.ex | starcoder |
defmodule Surface.Catalogue.Example do
@moduledoc """
Experimental LiveView to create examples for catalogue tools.
## Options
Besides the buit-in options provided by the LiveView itself, an Example also
provides the following options:
* `subject` - Required. The target component of the Example.
*... | lib/surface/catalogue/example.ex | 0.909561 | 0.793986 | example.ex | starcoder |
defmodule SFTPToolkit.Download do
@moduledoc """
Module containing functions that ease downloading data from the SFTP server.
"""
use Bunch
@default_operation_timeout 5000
@default_chunk_size 32768
@default_remote_mode [:read, :binary]
@default_local_mode [:write, :binary]
@doc """
Downloads a si... | lib/sftp_toolkit/download.ex | 0.7641 | 0.542984 | download.ex | starcoder |
defmodule Day11 do
@moduledoc """
Advent of Code 2019
Day 11: Space Police
"""
alias Day11.{Part1, Part2}
def get_program() do
Path.join(__DIR__, "inputs/day11.txt")
|> File.read!()
|> String.trim()
|> String.split(",")
|> Enum.map(&String.to_integer/1)
end
def execute() do
pr... | lib/day11.ex | 0.636918 | 0.458591 | day11.ex | starcoder |
defmodule BroadwayCloudPubSub.Producer do
@moduledoc """
A GenStage producer that continuously receives messages from a Google Cloud Pub/Sub
topic and acknowledges them after being successfully processed.
By default this producer uses `BroadwayCloudPubSub.GoogleApiClient` to talk to Cloud
Pub/Sub, but you ca... | lib/broadway_cloud_pub_sub/producer.ex | 0.922032 | 0.412619 | producer.ex | starcoder |
defmodule Militerm.Services.MML do
@moduledoc """
Manages the rendering handlers for MML tags for different device contexts.
"""
def start_link() do
GenServer.start_link(__MODULE__, [], name: __MODULE__)
end
def child_spec(opts \\ []) do
%{
id: {:global, __MODULE__},
start: {__MODULE__... | lib/militerm/services/mml.ex | 0.761893 | 0.419826 | mml.ex | starcoder |
defmodule ExKpl do
@moduledoc """
Elixir implementation of the Kinesis Producer Library record aggregator.
This is a port of the Erlang implementation included in [adroll/erlmld](https://github.com/AdRoll/erlmld)
## Basic usage:
iex> {_, aggregator} = ExKpl.add(ExKpl.new(), {"partition_key", "data"})
... | lib/ex_kpl.ex | 0.716913 | 0.505066 | ex_kpl.ex | starcoder |
defmodule ExWire.Packet.Capability.Par.SnapshotData do
@moduledoc """
Respond to a GetSnapshotData message with either an empty RLP list or a
1-item RLP list containing the raw chunk data requested.
```
`SnapshotData` [`0x14`, `chunk_data` or nothing]
```
"""
alias ExthCrypto.Hash.Keccak
alias ExWire... | apps/ex_wire/lib/ex_wire/packet/capability/par/snapshot_data.ex | 0.862294 | 0.742515 | snapshot_data.ex | starcoder |
defmodule Bio.Interaction do
alias Bio.{Cell, Pellet, Physic, Sequence, Virus}
# No interaction
defp possible?(%Pellet{}, %Pellet{}), do: false
defp possible?(%Pellet{}, %Virus{}), do: false
defp possible?(%Virus{}, %Pellet{}), do: false
defp possible?(%Virus{}, %Virus{}), do: false
defp possible?(%{cel... | lib/bio/interaction.ex | 0.581184 | 0.627709 | interaction.ex | starcoder |
defmodule YtPotion.Channel do
import YtPotion.Base
@moduledoc """
Provides methods to interact with the YouTube Channels API
"""
@doc """
Returns the YouTube API response
## Examples
```elixir
iex > YtPotion.Channel.list(%{id: "UC0PEAMcRK7Mnn2G1bCBXOWQ,UCyMafjsLsswLvsd4u_ilprQ", part: "statist... | lib/yt_potion/yt_potion_channel.ex | 0.799638 | 0.445469 | yt_potion_channel.ex | starcoder |
defmodule PigLatin do
@doc """
Given a `phrase`, translate it a word at a time to Pig Latin.
Words beginning with consonants should have the consonant moved to the end of
the word, followed by "ay".
Words beginning with vowels (aeiou) should have "ay" added to the end of the
word.
Some groups of letter... | elixir/pig-latin/lib/pig_latin.ex | 0.697197 | 0.469581 | pig_latin.ex | starcoder |
defmodule RSA do
@moduledoc """
Documentation for RSA.
"""
defp big_num(s) do
Enum.reduce(1..s+1, fn _, y -> y * 2 end)
end
defp big_pow_mod_res(_, b, _, ans) when b <= 0, do: ans
defp big_pow_mod_res(a, b, c, ans) do
ans = if rem(b, 2) == 1, do: rem((ans * a), c), else: ans
b = b/2 |> trun... | lib/rsa.ex | 0.548553 | 0.512205 | rsa.ex | starcoder |
defmodule PhoenixETag do
@moduledoc """
Conditional request (ETag & modified-since) support for Phoenix.
## Usage
The library provides a replacement function for `Phoenix.Controller.render/1-4`
called `PhoenixETag.render_if_stale/1-4` accepting exactly the same arguments.
When called the function expects ... | lib/phoenix_etag.ex | 0.862207 | 0.636692 | phoenix_etag.ex | starcoder |
defmodule Broker.Supervisor.Collector do
@moduledoc """
This the Collector supervisor which supervise the whole
collector engine per topic.
"""
use Supervisor
alias Broker.Collector
@spec start_link(list) :: tuple
def start_link(args) do
Supervisor.start_link(__MODULE__, args, name: args[:name... | apps/broker/lib/broker/supervisor/collector.ex | 0.564219 | 0.444806 | collector.ex | starcoder |
defmodule CPF do
@moduledoc """
CPF mobulde provides functions to verify if a CPF is valid.
"""
@typedoc """
A custom CPF type that can be a number or string
"""
@type t :: integer | String.t()
@doc """
Returns `true` the given `cpf` is valid, otherwise `false`.
## Examples
iex> CPF.valid?... | lib/cpf.ex | 0.861931 | 0.475605 | cpf.ex | starcoder |
defmodule Day13 do
def from_file(path) do
File.read!(path)
|> String.split(",")
|> Enum.map(&Integer.parse/1)
|> Enum.map(&(elem(&1, 0)))
end
def game(program) do
game_execute(Intcode.execute(Intcode.initial_state(program, [])))
end
def game_with_freeplay(program) do
game_execute(In... | lib/day13.ex | 0.510496 | 0.416886 | day13.ex | starcoder |
defmodule OneDialer do
@moduledoc """
Click to call implementation for OneChat.
An interface for external PBX or calling service for handling calling
phone numbers using a third party phone calling service like a PBX or
web service.
This module requires an adapter implementation which is configured with
... | plugins/one_dialer/lib/one_dialer.ex | 0.864425 | 0.623004 | one_dialer.ex | starcoder |
defmodule Bf do
use Bitwise
@moduledoc """
Interprets brainfuck programs.
## Examples
Bf.Parser.parse("--[>--->->->++>-<<<<<-------]>--.>---------.>--..+++.")
|> Bf.run()
Hello
"""
@typedoc """
The state returned by the interpreter.
It is the current cell index and the memory.
"... | lib/bf.ex | 0.569972 | 0.456228 | bf.ex | starcoder |
defmodule Brando.Tag do
@moduledoc """
Helpers for tagging schema data.
Adds a `tags` field to your schema.
## Example/Usage
Controller:
use Brando.Tag,
[:controller, [schema: Brando.Post]]
View:
use Brando.Tag, :view
Schema:
use Brando.Tag, :schema
schema "my_sche... | lib/brando/tag.ex | 0.87401 | 0.510435 | tag.ex | starcoder |
defmodule Guardian.Plug.EnsurePermissions do
@moduledoc """
Use this plug to ensure that there are the
correct permissions set in the claims found on the connection.
### Example
alias Guardian.Plug.EnsurePermissions
# read and write permissions for the admin set
plug EnsurePermissions, admi... | lib/guardian/plug/ensure_permissions.ex | 0.674908 | 0.40987 | ensure_permissions.ex | starcoder |
defmodule Patch do
@moduledoc """
Patch - Ergonomic Mocking for Elixir
Patch makes it easy to mock one or more functions in a module returning a value or executing
custom logic. Patches and Spies allow tests to assert or refute that function calls have been
made.
Using Patch is as easy as adding a single... | lib/patch.ex | 0.861494 | 0.869936 | patch.ex | starcoder |
defmodule Millisecond do
@moduledoc """
A tiny library to parse human readable formats into milliseconds.
"""
@doc """
A tiny library to parse human readable formats into milliseconds to
make configurations easier.
## Examples
iex> Millisecond.ms("100")
{:ok, 100}
iex> Millisecond.ms... | lib/ex_ms.ex | 0.928449 | 0.400456 | ex_ms.ex | starcoder |
defmodule Lapin.Connection do
@moduledoc """
RabbitMQ connection handler
This module handles the RabbitMQ connection. It also provides a behaviour for
worker module implementation. The worker module should use the `Lapin.Connection`
behaviour and implement the callbacks it needs.
When using the `Lapin.Con... | lib/lapin/connection.ex | 0.890705 | 0.435061 | connection.ex | starcoder |
defmodule Ecto.Migration do
@moduledoc """
Migrations are used to modify your database schema over time.
This module provides many helpers for migrating the database,
allowing developers to use Elixir to alter their storage in
a way that is database independent.
Here is an example:
defmodule MyRepo... | deps/ecto/lib/ecto/migration.ex | 0.869715 | 0.565599 | migration.ex | starcoder |
defmodule RfidLatachz.Attendances do
@moduledoc """
The Attendances context.
"""
import Ecto.Query, warn: false
alias RfidLatachz.Repo
alias RfidLatachz.Attendances.Attendance
alias RfidLatachz.Users
alias Phoenix.PubSub
import Ecto
@doc """
Returns the list of attendances.
## Examples
... | web/lib/rfid_latachz/attendances.ex | 0.781497 | 0.442396 | attendances.ex | starcoder |
defmodule LayoutOMatic.Dropdown do
# Checkbox size based on :button_font_size with 20 being the default; width/height override
@default_font_size 20
@default_font :roboto
@default_drop_direction :down
@spec translate(%{
component: map,
starting_xy: {number, number},
grid_xy: {nu... | lib/layouts/components/dropdown.ex | 0.742795 | 0.423577 | dropdown.ex | starcoder |
defmodule Stripe.Token do
@moduledoc """
Work with Stripe token objects.
You can:
- Create a token for a Connect customer with a card
- Create a token with all options - Only for Unit Tests with Stripe
- Retrieve a token
Stripe API reference: https://stripe.com/docs/api/tokens
"""
use Stripe.Enti... | lib/stripe/core_resources/token.ex | 0.84729 | 0.411081 | token.ex | starcoder |
defmodule RemoteIp.Options do
@headers ~w[forwarded x-forwarded-for x-client-ip x-real-ip]
@parsers %{"forwarded" => RemoteIp.Parsers.Forwarded}
@proxies []
@clients []
@moduledoc """
The keyword options given to `RemoteIp.init/1` or `RemoteIp.from/2`.
You shouldn't need to use this module directly. Its... | lib/remote_ip/options.ex | 0.889006 | 0.835953 | options.ex | starcoder |
defmodule Exvalidate do
@moduledoc """
Enter point for validate data structure.
If you want to validate a data set you first have to take into account
the following important points:
1 - This dependence is based on a schema-data system in which two data
structures are received, one called schema and ano... | lib/exvalidate.ex | 0.862366 | 0.993436 | exvalidate.ex | starcoder |
defmodule Exnoops.Drumbot do
@moduledoc """
Module to interact with Github's Noop: Drumbot
See the [official `noop` documentation](https://noopschallenge.com/challenges/drumbot)
"""
require Logger
import Exnoops.API
@noop "drumbot"
@doc """
Query Drumbot for patterns
## Examples
iex> Exn... | lib/exnoops/drumbot.ex | 0.573798 | 0.507507 | drumbot.ex | starcoder |
defmodule AWS.RDSData do
@moduledoc """
Amazon RDS Data Service
Amazon RDS provides an HTTP endpoint to run SQL statements on an Amazon Aurora
Serverless DB cluster.
To run these statements, you work with the Data Service API.
For more information about the Data Service API, see [Using the Data API for ... | lib/aws/generated/rds_data.ex | 0.828211 | 0.457197 | rds_data.ex | starcoder |
defmodule AWS.SNS do
@moduledoc """
Amazon Simple Notification Service
Amazon Simple Notification Service (Amazon SNS) is a web service that enables
you to build distributed web-enabled applications.
Applications can use Amazon SNS to easily push real-time notification messages
to interested subscribers ... | lib/aws/generated/sns.ex | 0.863679 | 0.572902 | sns.ex | starcoder |
defmodule CodeCorps.Tasks.Query do
@moduledoc ~S"""
Holds queries used to retrieve a list of, or a single `Task` record from the
database, using a provided map of parameters/filters.
"""
import Ecto.Query
import ScoutApm.Tracing
alias CodeCorps.{Helpers, Project, Task, Repo}
alias Ecto.Queryable
@d... | lib/code_corps/tasks/query.ex | 0.811041 | 0.417331 | query.ex | starcoder |
defmodule ETLSystem.Workflow do
@moduledoc """
Contains the necessary information to define a workflow
"""
@typedoc """
Defines the structure of a workflow.
"""
@type t :: %__MODULE__{
id: binary() | atom(),
next: list(),
args: any(),
previous: any(),
run... | lib/etl_system/workflow.ex | 0.86521 | 0.562958 | workflow.ex | starcoder |
defmodule AbsintheErrorPayload.ChangesetParser do
@moduledoc """
Converts an ecto changeset into a list of validation errors structs.
Currently *does not* support nested errors
"""
import Ecto.Changeset, only: [traverse_errors: 2]
alias AbsintheErrorPayload.ValidationMessage
@doc "Generate a list of `Ab... | lib/absinthe_error_payload/changeset_parser.ex | 0.89371 | 0.560854 | changeset_parser.ex | starcoder |
defmodule LinkNode do
defstruct value: nil,
next: nil
@type t :: %__MODULE__{
value: integer(),
next: __MODULE__.t()
}
def new(value) when is_integer(value) do
struct!(__MODULE__, value: value, next: nil)
end
def new(value, %__MODULE__{} = next) do
struct!(__... | lib/linked_list.ex | 0.835752 | 0.406626 | linked_list.ex | starcoder |
defmodule WordsWithEnemies.WordFinder do
@moduledoc """
Uses the Stream API to efficiently search a wordlist
for words based on certain criteria. Each function takes
and returns a stream, allowing for easy chaining. When the
chain is complete, a function in the `Enum` module must be
used to retrieve the wor... | lib/words_with_enemies/language/word_finder.ex | 0.915432 | 0.63775 | word_finder.ex | starcoder |
defmodule Loom.MVRegister do
@moduledoc """
A causally consistent multi-value register.
A bit more causally rigorous than LWWRegister, MVRegister will replace
observed values when they are set, but concurrent additions will co-occur,
and a list will be returned for the value.
This is good if you have some... | lib/loom/mvregister.ex | 0.839191 | 0.579936 | mvregister.ex | starcoder |
defmodule Plymio.Codi.Pattern.Delegate do
@moduledoc ~S"""
The *delegate* patterns build `Kernel.defdelegate/2` call(s).
Delegated functions can be built with, optionally, with a `@doc`,
`@since` and/or `@spec`.
See `Plymio.Codi` for an overview and documentation terms
Note the delegated mfa: `{module, f... | lib/codi/pattern/delegate/delegate.ex | 0.89769 | 0.671349 | delegate.ex | starcoder |
defmodule Cluster.Strategy.Consul do
@moduledoc """
This clustering strategy is specific to the Consul service networking
solution. It works by querying the platform's metadata API for containers
belonging to a given service name and attempts to connect them
(see: https://www.consul.io/api/catalog.html).
T... | lib/strategy/consul.ex | 0.847385 | 0.498413 | consul.ex | starcoder |
defmodule Estated.Property.Structure do
@moduledoc "Information about the building(s) on the parcel."
@moduledoc since: "0.2.0"
alias Estated.Property.Structure.OtherArea
alias Estated.Property.Structure.OtherFeature
alias Estated.Property.Structure.OtherImprovement
defstruct year_built: nil,
... | lib/estated/property/structure.ex | 0.865651 | 0.487673 | structure.ex | starcoder |
defmodule EctoSearcher.Mapping do
@moduledoc """
Behaviour for search query, matcher and field mappings
## Usage
Either adopt `EctoSearcher.Mapping` behaviour and implement callbacks or `use EctoSearcher.Mapping`, which provides defaults.
```elixir
defmodule CustomMapping do
use EctoSearcher.Mapping
... | lib/ecto_searcher/mapping.ex | 0.888638 | 0.783947 | mapping.ex | starcoder |
defmodule Hammer.Backend.ETS do
@moduledoc """
An ETS backend for Hammer
The public API of this module is used by Hammer to store information about rate-limit 'buckets'.
A bucket is identified by a `key`, which is a tuple `{bucket_number, id}`.
The essential schema of a bucket is: `{key, count, created_at, u... | lib/hammer/backend/ets.ex | 0.832066 | 0.5144 | ets.ex | starcoder |
defmodule Astro.Earth do
@moduledoc """
Constants and astronomical calculations
related to the earth.
"""
alias Astro.Time
import Astro.Math, only: [to_radians: 1, to_degrees: 1, poly: 2, deg: 1, sin: 1]
@geometric_solar_elevation 90.0
@refraction 34.0 / 60.0
@solar_radius 16.0 / 60.0
@meters_per... | lib/astro/earth.ex | 0.933764 | 0.902867 | earth.ex | starcoder |
defmodule Adventofcode.Day13PacketScanners do
alias Scanner
@enforce_keys [:scanners, :max_depth]
defstruct scanners: nil, max_depth: nil, depth: -1, caught_at_depth: [], delay: 0
def severity(input) do
input
|> parse()
|> new()
|> tick_repeatedly()
|> do_severity()
end
def minimum_de... | lib/day_13_packet_scanners.ex | 0.648132 | 0.634147 | day_13_packet_scanners.ex | starcoder |
% In Elixir, strings are represented as binaries. A binary is a bit
% string where its size is a multiple of eight. A BitString created
% conforming to this condition will be automatically mapped as String:
%
% <<72, 73, 74>>.__parent__ % => String
%
% ## `to_char_list`, `to_bin`, `to_s` and `to_str`
%
% There are ... | lib/string.ex | 0.715821 | 0.728658 | string.ex | starcoder |
defmodule AWS.Fis do
@moduledoc """
Fault Injection Simulator is a managed service that enables you to perform fault
injection experiments on your Amazon Web Services workloads.
For more information, see the [Fault Injection Simulator User Guide](https://docs.aws.amazon.com/fis/latest/userguide/).
"""
al... | lib/aws/generated/fis.ex | 0.757615 | 0.438364 | fis.ex | starcoder |
defmodule OliWeb.Qa.Utils do
use Phoenix.HTML
def warning_icon(type) do
case type do
"accessibility" -> {"not_accessible", "#ffd868"}
"content" -> {"image_not_supported", "#ffa351ff"}
"pedagogy" -> {"batch_prediction", "#ffbe7bff"}
_ -> {"warning", "#eed971ff"}
end
|> icon()
... | lib/oli_web/live/qa/utils.ex | 0.63023 | 0.427367 | utils.ex | starcoder |
defmodule Absinthe.Traversal do
# Graph traversal utilities for dealing with ASTs and schemas using the
# `Absinthe.Traversal.Node` protocol.
# Note this really only exists to handle some Schema rules stuff and is generally
# considered legacy code. See `Absinthe.Blueprint.Transform` for information
# on how ... | lib/absinthe/traversal.ex | 0.878621 | 0.613425 | traversal.ex | starcoder |
defmodule Braintree.Subscription do
@moduledoc """
Manage customer subscriptions to recurring billing plans.
For additional reference see:
https://developers.braintreepayments.com/reference/request/subscription/create/ruby
"""
use Braintree.Construction
alias Braintree.{HTTP, Transaction, AddOn, Search... | lib/subscription.ex | 0.906117 | 0.411318 | subscription.ex | starcoder |
defmodule CLL do
@moduledoc """
This module can be used to represent a data structure with similar behavior
as circular Doubly-Linked-List.
"But wait, aren't all Lists in Erlang Linked Lists?" Well yes, but they
are immutable, which makes things like removing elements while iterating
through the list very... | lib/cll.ex | 0.876218 | 0.599866 | cll.ex | starcoder |
defmodule Plymio.Fontais do
@moduledoc ~S"""
`Plymio.Fontais` is a foundation / support package for the `Plymio` and `Harnais` package families.
## Documentation Terms
In the documentation these terms, usually in *italics*, are used to mean the same thing (e.g. *opts*).
### *opts* and *opzioni*
*opts* i... | lib/fontais/fontais.ex | 0.878731 | 0.744912 | fontais.ex | starcoder |
defmodule Logi.Sink do
@moduledoc """
Sinks.
A sink has the specification of a sink process (see `Logi.SinkProc`).
A sink process manages a sink writer (See `Logi.SinkWriter`).
See the documentations of `Logi.BuiltIn.Sink.*` modules for usage examples.
"""
@typedoc "A sink"
@opaque sink :: :logi_sink... | lib/logi/sink.ex | 0.843992 | 0.460956 | sink.ex | starcoder |
defmodule Oli.Delivery.ExtrinsicState do
@moduledoc """
Enables arbitrary key-value pair storage that is extrinsic to any specific activity attempt.
Extrinsic state exists either truly global for a user, or scoped to a course section for
a user. Leveraging this, activities can be built that share state across ... | lib/oli/delivery/extrinsic_state.ex | 0.887021 | 0.53206 | extrinsic_state.ex | starcoder |
defmodule P2 do
@moduledoc """
## Examples
"""
use Bitwise, only_operators: true
defmodule Factorization do
defstruct value: 2
def next(factor \\ %__MODULE__{value: 2})
def next(%__MODULE__{value: 2}), do: %__MODULE__{value: 3}
def next(%__MODULE__{value: n}) do
if is_prime(n + 2) do
... | lib/100/p2.ex | 0.648466 | 0.564819 | p2.ex | starcoder |
defmodule HomeBot.DataStore.TemperatureStore do
@moduledoc "The datastore for weather data"
alias HomeBot.DataStore.InfluxConnection
def create_database_if_not_exists do
InfluxConnection.query(
"CREATE DATABASE energy",
method: :post
)
end
def write_temperature_data(data) do
datapoi... | lib/home_bot/data_store/temperature_store.ex | 0.801431 | 0.547706 | temperature_store.ex | starcoder |
defmodule Oban.Peer do
@moduledoc """
The `Peer` module maintains leadership for a particular Oban instance within a cluster.
Leadership is used by plugins, primarily, to prevent duplicate work accross nodes. For example,
only the leader's `Cron` plugin will insert new jobs. You can use peer leadership to exte... | lib/oban/peer.ex | 0.894679 | 0.579847 | peer.ex | starcoder |
defmodule Engine.Predictions do
@moduledoc """
Maintains an up-to-date internal state of the realtime predictions of vehicles
in the system. Fetches from the GTFS-rt enhanced JSON file about once per
second.
Offers a `for_stop/1` public interface to get a list of Predictions.Prediction's
for a given GTFS s... | lib/engine/predictions.ex | 0.748214 | 0.535341 | predictions.ex | starcoder |
module Atom
% Returns true if an atom representation of the given string exists.
def exists?(string)
try
Erlang.binary_to_existing_atom(string.to_bin, 'utf8)
true
catch 'error: 'badarg
false
end
end
def from_char_list(list)
Erlang.list_to_atom(list)
end
module Behavior
... | lib/atom.ex | 0.605682 | 0.658051 | atom.ex | starcoder |
defmodule Zachaeus.License do
@moduledoc """
A Zachaeus license contains all relevant data which is essential for a simple licensing system.
Due to the nature of this license, it can be used without a database, if you simply want to verify the validity of a license.
"""
alias Zachaeus.Error
## -- MODULE AT... | lib/zachaeus/license.ex | 0.856122 | 0.520862 | license.ex | starcoder |
defmodule Contex.SVG.Sanitize do
@moduledoc false
#Basically a copy/paste of Plug.HTML. Copied here to avoid a substantial dependency
#License:
#Copyright (c) 2013 Plataformatec.
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the Licen... | lib/chart/svg_sanitize.ex | 0.592077 | 0.493103 | svg_sanitize.ex | starcoder |
defmodule Ambry.Series do
@moduledoc """
Functions for dealing with Series.
"""
import Ambry.SearchUtils
import Ecto.Query
alias Ambry.Repo
alias Ambry.Series.{Series, SeriesBook}
@doc """
Returns a limited list of series and whether or not there are more.
By default, it will limit to the first ... | lib/ambry/series.ex | 0.886162 | 0.584153 | series.ex | starcoder |
defmodule ExAequo.Enum do
alias ExAequo.Error
@moduledoc """
## ExAequo.Enum offers some extension functions for Elixir's Enum module
### Grouped Accumulation
Groupes accumulated values of an Enum according to a function that
indicates if two consequent items are of the same kind and if so
how to ac... | lib/ex_aequo/enum.ex | 0.714528 | 0.668915 | enum.ex | starcoder |
defmodule Animals do
@moduledoc """
Documentation for Animals.
"""
@doc """
Hello world.
## Examples
iex> Animals.hello
:world
"""
def hello do
:world
end
@doc """
create_zoo returns a list of zoo animals
## Examples
iex> Animals.create_zoo
["lion", "tiger", "goril... | elixir/animals/lib/animals.ex | 0.826362 | 0.53959 | animals.ex | starcoder |
defmodule ExCubicIngestion.ProcessIncoming do
@moduledoc """
ProcessIncoming server.
Every @wait_interval_ms, scans the Incoming bucket for table prefixes. If a
prefix is present here and has a record in CubicTable, the prefix is
scanned for files, which are inserted as CubicLoad records to be processed
in... | ex_cubic_ingestion/lib/ex_cubic_ingestion/process_incoming.ex | 0.748076 | 0.424531 | process_incoming.ex | starcoder |
defmodule Tracex.Trace do
@moduledoc """
Collection of helpers to extract data from compiler traces
Compiler traces encapsulate events happening in certain environment.
The module originating an event is considered an *outbound* module,
the module on the receiving end is considered an *inbound* module.
F... | lib/tracex/trace.ex | 0.894778 | 0.523664 | trace.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.