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 ExAws.Dynamo.Encoder do
@moduledoc """
Takes an elixir value and converts it into a dynamo style map.
```elixir
MapSet.new [1,2,3] |> #{__MODULE__}.encode
#=> %{"NS" => ["1", "2", "3"]}
MapSet.new ["A","B","C"] |> #{__MODULE__}.encode
#=> %{"SS" => ["A", "B", "C"]}
"bubba" |> ExAws.Dynamo.E... | lib/ex_aws/dynamo/encoder.ex | 0.703142 | 0.735855 | encoder.ex | starcoder |
defmodule HashSet do
@moduledoc """
A set store.
The `HashSet` is implemented using tries, which grows in
space as the number of keys grows, working well with both
small and large set of keys. For more information about the
functions and their APIs, please consult the `Set` module.
"""
@behaviour Set
... | lib/elixir/lib/hash_set.ex | 0.792143 | 0.713394 | hash_set.ex | starcoder |
defmodule Nerves.SSDPServer do
@moduledoc """
Implements a simple subset of the [Simple Service Discovery Protocol](https://en.wikipedia.org/wiki/Simple_Service_Discovery_Protocol).
This does *not* implement the full UPNP specification, but uses the
multicast SSDP protocol in order to provide LAN presence ann... | lib/ssdp_server.ex | 0.842442 | 0.590838 | ssdp_server.ex | starcoder |
defmodule JsonApiClient.Parser do
@moduledoc false
alias JsonApiClient.Parser.{FieldValidation, Schema}
@spec parse(String.t() | map) :: {:ok, JsonApiClient.Document.t() | nil} | {:error, String.t()}
def parse(json) when is_binary(json) do
parse(Poison.decode!(json))
rescue
error in Poison.SyntaxErr... | lib/json_api_client/parser.ex | 0.806014 | 0.400398 | parser.ex | starcoder |
defmodule EQC.Component 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_component.hrl`. For detailed documentation of the
macros, please refer t... | lib/eqc/component.ex | 0.758242 | 0.422117 | component.ex | starcoder |
defmodule Owl.Palette do
@moduledoc """
Poor man's color picker.
"""
@demo_block "ββββ"
@doc """
Returns palette with named codes.
Owl.Palette.named() |> Owl.IO.puts()
Selected color can be used as follows
# print "test" using cyan foreground color
"test" |> Owl.Data.tag(:cyan) |> Ow... | lib/owl/palette.ex | 0.696268 | 0.418222 | palette.ex | starcoder |
defmodule TripPlan.Transfer do
@moduledoc """
Tools for handling logic around transfers between transit legs and modes.
The MBTA allows transfers between services depending on the fare media used
and the amount paid.
This logic may be superseded by the upcoming fares work.
"""
alias TripPlan.{Leg... | apps/trip_plan/lib/trip_plan/transfer.ex | 0.73173 | 0.492554 | transfer.ex | starcoder |
defmodule ThousandIsland.Transports.SSL do
@moduledoc """
Defines a `ThousandIsland.Transport` implementation based on TCP SSL sockets
as provided by Erlang's `:ssl` module. For the most part, users of Thousand
Island will only ever need to deal with this module via `transport_options`
passed to `ThousandIsla... | lib/thousand_island/transports/ssl.ex | 0.879697 | 0.806319 | ssl.ex | starcoder |
defmodule KafkaEx do
@moduledoc """
Kafka API
This module is the main API for users of the KafkaEx library.
Most of these functions either use the default worker (registered as
`:kafka_ex`) by default or can take a registered name or pid via a
`worker_name` option.
```
# create an unnamed worker
{:... | lib/kafka_ex.ex | 0.901741 | 0.599368 | kafka_ex.ex | starcoder |
defmodule ExOauth2Provider.Plug.VerifyHeader do
@moduledoc """
Use this plug to authenticate a token contained in the header.
You should set the value of the Authorization header to:
Authorization: <token>
## Example
plug ExOauth2Provider.Plug.VerifyHeader, otp_app: :my_app
A "realm" can be spec... | lib/ex_oauth2_provider/plug/verify_header.ex | 0.831177 | 0.446857 | verify_header.ex | starcoder |
defmodule DateTimeParser.Parser.DateTime do
@moduledoc """
Tokenizes the string for both date and time formats. This prioritizes the international standard
for representing dates.
"""
@behaviour DateTimeParser.Parser
import NimbleParsec
import DateTimeParser.Combinators.Date
import DateTimeParser.Combi... | lib/parser/date_time.ex | 0.867289 | 0.428114 | date_time.ex | starcoder |
defmodule PingServer do
@moduledoc """
Documentation for PingServer.
A GenServer extension which receives a ping at a regular interval.
## Example usage
```
defmodule UsePing do
use PingServer, interval: 10_000
def start_link(thing) do
# You can start link this way. It will... | lib/ex_ping_server.ex | 0.718397 | 0.700972 | ex_ping_server.ex | starcoder |
defmodule Roulette.Config do
@moduledoc ~S"""
Here is a minimum configuration example,
You must setup `servers` list.
Put your load-balancers' hostname into it.
```elixir
config :my_app, MyApp.PubSub,
servers: [
"gnatsd-cluster1.example.org",
"gnatsd-cluster2.example.org"
]
```
O... | lib/roulette/config.ex | 0.831554 | 0.695312 | config.ex | starcoder |
defmodule Xandra.Cluster do
@moduledoc """
Connection to a Cassandra cluster.
This module is a "proxy" connection with support for connecting to multiple
nodes in a Cassandra cluster and executing queries on such nodes based on a
given *strategy*.
## Usage
This module manages connections to different n... | lib/xandra/cluster.ex | 0.916224 | 0.714304 | cluster.ex | starcoder |
defmodule Cldr.LocaleDisplay.Backend do
@moduledoc false
def define_locale_display_module(config) do
require Cldr
require Cldr.Config
module = inspect(__MODULE__)
backend = config.backend
config = Macro.escape(config)
quote location: :keep, bind_quoted: [module: module, backend: backend, ... | lib/cldr/backend.ex | 0.889138 | 0.484624 | backend.ex | starcoder |
defmodule Blockchain.Chain do
@moduledoc """
Represents the information about a specific chain. This
will either be a current chain (such as homestead), or
a test chain (such as ropsten). Different chains have
different parameters, such as accounts with an initial
balance and when EIPs are implemented.
F... | apps/blockchain/lib/blockchain/chain.ex | 0.835114 | 0.477676 | chain.ex | starcoder |
defmodule ExWire.Packet.BlockHeaders do
@moduledoc """
Eth Wire Packet for getting block headers from a peer.
```
**BlockHeaders** [`+0x04`, `blockHeader_0`, `blockHeader_1`, ...]
Reply to `GetBlockHeaders`. The items in the list (following the message ID) are
block headers in the format described in the ... | apps/ex_wire/lib/ex_wire/packet/block_headers.ex | 0.834373 | 0.790085 | block_headers.ex | starcoder |
defmodule Algae.Free do
@moduledoc """
A "free" structure that converts functors into monads by embedding them in
a special structure with all of the monadic heavy lifting done for you.
Similar to trees and lists, but with the ability to add a struct "tag",
at each level. Often used for DSLs, interpreters, o... | lib/algae/free.ex | 0.892504 | 0.61438 | free.ex | starcoder |
defmodule Indicado.Math do
@moduledoc """
This is the helper module holding common math functions for Indicado.
"""
@doc """
Calculates variance of a given numeric list.
Returns `nil` if list is empty.
## Examples
iex> Indicado.Math.variance([1, 2, 3, 4])
1.25
iex> Indicado.Math.vari... | lib/indicado/math.ex | 0.934268 | 0.727346 | math.ex | starcoder |
defmodule Akin.Metaphone.Double do
@moduledoc """
The original Metaphone algorithm was published in 1990 as an improvement over
the Soundex algorithm. Like Soundex, it was limited to English-only use. The
Metaphone algorithm does not produce phonetic representations of an input word
or name; rather, the outpu... | lib/akin/algorithms/phonetic/double_metaphone.ex | 0.87006 | 0.53048 | double_metaphone.ex | starcoder |
defmodule AWS.RedshiftData do
@moduledoc """
You can use the Amazon Redshift Data API to run queries on Amazon Redshift
tables.
You can run individual SQL statements, which are committed if the statement
succeeds.
For more information about the Amazon Redshift Data API, see [Using the Amazon Redshift Dat... | lib/aws/generated/redshift_data.ex | 0.824921 | 0.548915 | redshift_data.ex | starcoder |
defmodule Rihanna.Config do
@moduledoc """
Global configuration for Rihanna.
Sensible defaults have been chosen for you but if you want, you can optionally
override any of these values in your local configuration.
For example, to change the table name for jobs:
```
config :rihanna, jobs_table_name: "aw... | lib/rihanna/config.ex | 0.91463 | 0.789234 | config.ex | starcoder |
defmodule AshPostgres.DataLayer do
@manage_tenant %Ash.Dsl.Section{
name: :manage_tenant,
describe: """
Configuration for the behavior of a resource that manages a tenant
""",
examples: [
"""
manage_tenant do
template ["organization_", :id]
create? true
update? ... | lib/data_layer.ex | 0.92037 | 0.42316 | data_layer.ex | starcoder |
defmodule Changelog.Post do
use Changelog.Web, :model
alias Changelog.Regexp
schema "posts" do
field :title, :string
field :slug, :string
field :guid, :string
field :tldr, :string
field :body, :string
field :published, :boolean, default: false
field :published_at, Timex.Ecto.DateT... | web/models/post.ex | 0.707101 | 0.412087 | post.ex | starcoder |
defmodule Tox.Date do
@moduledoc """
A set of functions to work with `Date`.
"""
@doc """
Shifts the `date` by the given `duration`.
The `durations` is a keyword list of one or more durations of the type
`Tox.duration` e.g. `[year: 1, month: 5, day: 500]`. All values will be
shifted from the largest ... | lib/tox/date.ex | 0.935346 | 0.698876 | date.ex | starcoder |
defmodule Cog.Commands.Filter do
use Cog.Command.GenCommand.Base, bundle: Cog.Util.Misc.embedded_bundle
@description "Filter elements of a collection"
@long_description """
Filters a collection where the `path` equals the `matches`.
The `path` option is the key that you would like to focus on;
The `matche... | lib/cog/commands/filter.ex | 0.802052 | 0.452475 | filter.ex | starcoder |
defmodule Adap.Joiner do
@doc """
Make a stream wich reduces input elements joining them according to specified key pattern.
The principle is to keep a fixed length queue of elements waiting to
receive joined elements.
This is for stream of elements where order is unknown, but elements to join
are... | lib/joiner.ex | 0.54698 | 0.431225 | joiner.ex | starcoder |
defmodule Day05 do
def part1(file_name \\ "input.txt"), do:
run(file_name, &remove_diagonals/1)
def part2(file_name \\ "input.txt"), do:
run(file_name, &keep_diagonals/1)
def run(file_name, handle_diagonals) do
"priv/" <> file_name
|> parse()
|> handle_diagonals.()
|> lines()
|> coun... | jpcarver+elixir/day05/lib/day05.ex | 0.558086 | 0.42483 | day05.ex | starcoder |
defmodule JSONC.AgentParser do
@moduledoc false
import JSONC.AgentTokenizer
def parse!(content) when is_binary(content) do
case parse(content) do
{:ok, result} ->
result
{:error, reason} ->
raise reason
end
end
def parse(content) when is_binary(content) do
case star... | lib/legacy/agent-parser.ex | 0.698329 | 0.411879 | agent-parser.ex | starcoder |
defmodule StrawHat.Map.Country do
@moduledoc """
A Country entity.
"""
use StrawHat.Map.EctoSchema
alias StrawHat.Map.{Continents, State}
alias StrawHat.Map.Ecto.Types.Regex
@typedoc """
- `iso_two`: Two characters ISO code.
- `iso_three`: Three characters ISO code.
- `iso_numeric`: Numeric ISO co... | lib/straw_hat_map/world/countries/country_entity.ex | 0.872924 | 0.522385 | country_entity.ex | starcoder |
defmodule Game.Actuator do
@moduledoc false
alias Game.{Cell, Coordinate, Grid, Manager, Tile}
# ======================================================================================
# Public
# ======================================================================================
def move(%Grid{} = grid... | lib/game/actuator.ex | 0.793986 | 0.659821 | actuator.ex | starcoder |
defmodule BitstylesPhoenix.Component.Dropdown do
use BitstylesPhoenix.Component
import BitstylesPhoenix.Component.Button
@moduledoc """
The dropdown component without any JS.
"""
@doc """
Renders a dropdown component with a button and a menu.
*In order for this component to work you have to provide ... | lib/bitstyles_phoenix/component/dropdown.ex | 0.762601 | 0.413596 | dropdown.ex | starcoder |
defmodule Asteroid.ObjectStore.AuthorizationCode.Mnesia do
@moduledoc """
Mnesia implementation of the `Asteroid.ObjectStore.AuthorizationCode` behaviour
## Options
The options (`Asteroid.ObjectStore.AuthorizationCode.opts()`) are:
- `:table_name`: an `atom()` for the table name. Defaults to `:asteroid_autho... | lib/asteroid/object_store/authorization_code/mnesia.ex | 0.906793 | 0.893356 | mnesia.ex | starcoder |
require Logger
defmodule ExoSQL.Expr do
@moduledoc """
Expression executor.
Requires a simplified expression from `ExoSQL.Expr.simplify` that converts
columns names to column positions, and then use as:
```
iex> context = %{ row: [1,2,3,4,5] }
iex> expr = {:op, {"*", {:column, 1}, {:column, 2}}}
... | lib/expr.ex | 0.711832 | 0.92164 | expr.ex | starcoder |
defmodule Artemis.Helpers.IBMCloudantSearch do
@doc """
Return a cloudant compatible timestamp
"""
def get_cloudant_timestamp_range(units, duration) do
precision_lookup = [
minutes: 16,
hours: 13,
days: 10,
months: 7,
years: 4
]
precision = Keyword.fetch!(precision_loo... | apps/artemis/lib/artemis/helpers/ibm_cloudant_search.ex | 0.799755 | 0.45532 | ibm_cloudant_search.ex | starcoder |
defprotocol Dynamo.Templates.Finder do
@moduledoc """
Defines the protocol required for finding templates.
"""
@doc """
Returns true if templates require precompilation.
"""
@spec requires_precompilation?(t) :: boolean
def requires_precompilation?(finder)
@doc """
Attempts to find a template given... | lib/dynamo/templates/finder.ex | 0.825906 | 0.410136 | finder.ex | starcoder |
defmodule Livebook.LiveMarkdown.Export do
alias Livebook.Notebook
alias Livebook.Notebook.Cell
alias Livebook.LiveMarkdown.MarkdownHelpers
@doc """
Converts the given notebook into a Markdown document.
"""
@spec notebook_to_markdown(Notebook.t()) :: String.t()
def notebook_to_markdown(notebook) do
... | lib/livebook/live_markdown/export.ex | 0.794185 | 0.764979 | export.ex | starcoder |
defmodule Credo.Check.Warning.NameRedeclarationByCase do
@moduledoc """
Names assigned to choices in a `case` statement should not be the same as
names of functions in the same module or in `Kernel`.
Example:
def handle_something(foo, bar) do
case foo do
nil -> bar
time ->
... | lib/credo/check/warning/name_redeclaration_by_case.ex | 0.679817 | 0.48688 | name_redeclaration_by_case.ex | starcoder |
defmodule Dotenvy do
@moduledoc """
`Dotenvy` is an Elixir implementation of the original [dotenv](https://github.com/bkeepers/dotenv) Ruby gem.
It is designed to help the development of applications following the principles of
the [12-factor app](https://12factor.net/) and its recommendation to store
config... | lib/dotenvy.ex | 0.911351 | 0.637398 | dotenvy.ex | starcoder |
defmodule DBConnection do
@moduledoc """
A behaviour module for implementing efficient database connection
client processes, pools and transactions.
`DBConnection` handles callbacks differently to most behaviours. Some
callbacks will be called in the calling process, with the state
copied to and from the c... | deps/db_connection/lib/db_connection.ex | 0.920352 | 0.57063 | db_connection.ex | starcoder |
defmodule Tailwind do
# https://github.com/tailwindlabs/tailwindcss/releases
@latest_version "3.0.12"
@moduledoc """
Tailwind is an installer and runner for [tailwind](https://tailwind.github.io).
## Profiles
You can define multiple tailwind profiles. By default, there is a
profile called `:default` wh... | lib/tailwind.ex | 0.826957 | 0.477981 | tailwind.ex | starcoder |
defmodule Ash.Api do
@moduledoc """
An Api allows you to interact with your resources, and holds non-resource-specific configuration.
Your Api can also house config that is not resource specific. For example, the json api extension
adds an api extension that lets you toggle authorization on/off for all resourc... | lib/ash/api/api.ex | 0.851243 | 0.595669 | api.ex | starcoder |
defmodule HeartCheck do
@moduledoc """
Define your own checks using this macro:
```elixir
defmodule MyHeart do
use HeartCheck, timeout: 2000 # 3000 is default
add :redis do
# TODO: do some actual checks here
:ok
end
add :cas do
# TODO: do some actual checks here
:tim... | lib/heartcheck.ex | 0.595375 | 0.835886 | heartcheck.ex | starcoder |
defmodule Vex.Validators.Length do
@moduledoc """
Ensure a value's length meets a constraint.
## Options
At least one of the following must be provided:
* `:min`: The value is at least this long
* `:max`: The value is at most this long
* `:in`: The value's length is within this Range
* `:is`: The... | lib/vex/validators/length.ex | 0.93097 | 0.726814 | length.ex | starcoder |
defmodule Poison.SyntaxError do
defexception [:message, :token, :pos]
def exception(opts) do
message = if token = opts[:token] do
"Unexpected token at position #{opts[:pos]}: #{token}"
else
"Unexpected end of input at position #{opts[:pos]}"
end
%Poison.SyntaxError{message: message, to... | lib/poison/parser.ex | 0.637257 | 0.571468 | parser.ex | starcoder |
defmodule AOC.Day10.MonitoringStation do
@moduledoc false
@type point :: {integer, integer}
def read_puzzle_input(path) do
File.read!(path)
end
def part1(input) do
process_input(input)
|> find_best_station_location()
end
def part2(input, origin) do
result =
process_input(input)
... | aoc-2019/lib/aoc/day10/monitoring_station.ex | 0.832747 | 0.527864 | monitoring_station.ex | starcoder |
defmodule GoogleApis.Generator.ElixirGenerator.Type do
@moduledoc """
A type holds information about a property type
"""
@type t :: %__MODULE__{
:name => String.t(),
:struct => String.t(),
:typespec => String.t()
}
defstruct [:name, :struct, :typespec]
alias GoogleA... | lib/google_apis/generator/elixir_generator/type.ex | 0.827584 | 0.445107 | type.ex | starcoder |
defmodule Ecto.Changeset do
@moduledoc """
Changesets allow filtering, casting and validation of model changes.
There is an example of working with changesets in the introductory
documentation in the `Ecto` module.
## The Ecto.Changeset struct
The fields are:
* `valid?` - Stores if the changeset ... | lib/ecto/changeset.ex | 0.935839 | 0.622746 | changeset.ex | starcoder |
defmodule Infer.Doc do
@moduledoc """
Document type matchers based on the [magic number](https://en.wikipedia.org/wiki/Magic_number_(programming))
"""
use Bitwise
@doc """
Takes the binary file contents as arguments. Returns `true` if it's Microsoft Word Open XML Format Document (DOCX) data.
## Example... | lib/matchers/doc.ex | 0.876423 | 0.485905 | doc.ex | starcoder |
defmodule Content.Message.Predictions do
@moduledoc """
A message related to real time predictions. For example:
Mattapan BRD
Mattapan ARR
Mattapan 2 min
The constructor should be used rather than creating a struct
yourself.
"""
require Logger
require Content.Utilities
@max_time Content... | lib/content/message/predictions.ex | 0.790247 | 0.608391 | predictions.ex | starcoder |
defmodule AWS.OpsWorksCM do
@moduledoc """
AWS OpsWorks CM
AWS OpsWorks for configuration management (CM) is a service that runs and
manages configuration management servers.
You can use AWS OpsWorks CM to create and manage AWS OpsWorks for Chef Automate
and AWS OpsWorks for Puppet Enterprise servers, an... | lib/aws/generated/ops_works_c_m.ex | 0.900829 | 0.532547 | ops_works_c_m.ex | starcoder |
defprotocol DeepMerge.Resolver do
@moduledoc """
Protocol defining how conflicts during deep_merge should be resolved.
As part of the DeepMerge library this protocol is already implemented for
`Map` and `List` as well as a fallback to `Any`.
"""
@fallback_to_any true
@doc """
Defines what happens when... | lib/deep_merge/resolver.ex | 0.876733 | 0.868046 | resolver.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/... | lib/phoenix_ecto/sql/sandbox.ex | 0.873754 | 0.551755 | sandbox.ex | starcoder |
defmodule BootstrapForm do
@moduledoc """
Helpers related to producing inputs using Bootstrap classes.
As `BootstrapForm` is built on top of `Phoenix.HTML.Form`, we use as many resources from
`Phoenix.HTML.Form` as possible. Then, when you don't provide a type attribute the
`input/3` is going to guess the ty... | lib/bootstrap_form.ex | 0.765944 | 0.431854 | bootstrap_form.ex | starcoder |
defmodule HeartCheck.Plug do
@moduledoc """
Plug to mount heartcheck in your plug-compatible app
Add to your router:
```elixir
def MyApp.Router
use Plug.Router
# (...)
forward "/monitoring", to: HeartCheck.Plug, heartcheck: MyHeart
end
```
Or phoenix pipeline (note the different syntax)... | lib/heartcheck/plug.ex | 0.808861 | 0.714815 | plug.ex | starcoder |
defmodule CronExpressionParser do
@moduledoc """
Documentation for `CronExpressionParser`. This module handles the logic for expanding each part
of a standard cron string intodetails expressions for each time field and the command to be run.
The printing of the result is handled in the script itself, which can ... | lib/cron_expression_parser.ex | 0.873255 | 0.471588 | cron_expression_parser.ex | starcoder |
defmodule Kino.JS do
@moduledoc ~S'''
Allows for defining custom JavaScript powered kinos.
## Example
Here's how we could define a minimal kino that embeds the given
HTML directly into the page.
defmodule KinoDocs.HTML do
use Kino.JS
def new(html) do
Kino.JS.new(__MODULE__,... | lib/kino/js.ex | 0.912641 | 0.690049 | js.ex | starcoder |
defmodule BMP280 do
use GenServer
alias BMP280.{Calc, Calibration, Comm, Measurement, Transport}
alias Circuits.I2C
@sea_level_pa 100_000
@typedoc """
The type of sensor in use.
"""
@type sensor_type() :: :bmp280 | :bme280 | 0..255
@moduledoc """
Read temperature and pressure measurements from a ... | lib/bmp280.ex | 0.897767 | 0.572992 | bmp280.ex | starcoder |
defmodule Joken.Config do
@moduledoc ~S"""
Main entry point for configuring Joken. This module has two approaches:
## Creating a map of `Joken.Claim` s
If you prefer to avoid using macros, you can create your configuration manually. Joken's
configuration is just a map with keys being binaries (the claim na... | lib/joken/config.ex | 0.910406 | 0.520009 | config.ex | starcoder |
defmodule PhoenixApiToolkit.Ecto.GenericQueries do
@moduledoc """
This entire module is DEPRECATED.
Generic queries are applicable to any named binding in a query. By using
generic queries, it is not necessary to implement standard queries for every Ecto model.
For example, instead of implementing in a User... | lib/ecto/generic_queries.ex | 0.898914 | 0.428831 | generic_queries.ex | starcoder |
defmodule Crutches.Option do
@moduledoc """
Convenience functions for dealing with function option handling.
This provides a mechanism for declaring default options and merging these with
those given by any caller.
# Usage
When you have a function with the following head, the use of this module may
be ... | lib/crutches/option.ex | 0.908729 | 0.6306 | option.ex | starcoder |
defmodule Stripe.CreditNote do
@moduledoc """
Work with Stripe Credit Note objects.
You can:
- Create a credit note
- Retrieve a credit note
- Update a credit note
- Void a credit note
- List credit notes
```
{
"id": "ivory-extended-580",
"object": "plan",
"active": true,
"aggrega... | lib/stripe/subscriptions/credit_note.ex | 0.814201 | 0.724261 | credit_note.ex | starcoder |
defmodule ExKdl.Encoder do
@moduledoc false
alias ExKdl.Chars
alias ExKdl.Node
alias ExKdl.Value
import ExKdl.Chars, only: [is_initial_identifier_char: 1]
import Decimal, only: [is_decimal: 1]
@tab_size 4
@kw_true "true"
@kw_false "false"
@kw_null "null"
@spec encode(list(Node.t())) :: {:ok,... | lib/ex_kdl/encoder.ex | 0.651577 | 0.462959 | encoder.ex | starcoder |
defmodule RDF.Serialization do
@moduledoc """
Functions for working with RDF serializations generically.
Besides some reflection functions regarding available serialization formats,
this module includes the full serialization reader and writer API from the
serialization format modules.
As opposed to callin... | lib/rdf/serialization/serialization.ex | 0.909947 | 0.592431 | serialization.ex | starcoder |
defmodule Commanded.EventStore do
@moduledoc """
Use the event store configured for a Commanded application.
"""
alias Commanded.Application
alias Commanded.Event.Upcast
@type application :: Commanded.Application.t()
@type config :: Keyword.t()
@doc """
Append one or more events to a stream atomica... | lib/commanded/event_store.ex | 0.891321 | 0.540439 | event_store.ex | starcoder |
defmodule AbsintheQuarry.Helpers do
@moduledoc """
Functions to integrate quarry with your absinthe schema
"""
alias AbsintheQuarry.Middleware
@doc """
Returns a resolver function that runs a quarry query.
```elixir
field :posts, list_of(:post), resolve: quarry(Post, Repo)
```
This resolver will... | lib/absinthe_quarry/helpers.ex | 0.811303 | 0.812272 | helpers.ex | starcoder |
defmodule Domo.Raises do
@moduledoc false
alias Domo.TypeEnsurerFactory.Alias
alias Domo.TypeEnsurerFactory.ModuleInspector
@add_domo_compiler_message """
Domo compiler is expected to do a second-pass compilation \
to resolve remote types that are in the project's BEAM files \
and generate TypeEnsurer m... | lib/domo/raises.ex | 0.682679 | 0.459622 | raises.ex | starcoder |
defmodule TextDelta.Attributes do
@moduledoc """
Attributes represent format associated with `t:TextDelta.Operation.insert/0`
or `t:TextDelta.Operation.retain/0` operations. This library uses maps to
represent attributes.
Same as `TextDelta`, attributes are composable and transformable. This library
does n... | lib/text_delta/attributes.ex | 0.926003 | 0.714528 | attributes.ex | starcoder |
defmodule HTTPDate.Parser do
@moduledoc false
defp month_to_integer("Jan" <> unparsed), do: { 1, unparsed }
defp month_to_integer("Feb" <> unparsed), do: { 2, unparsed }
defp month_to_integer("Mar" <> unparsed), do: { 3, unparsed }
defp month_to_integer("Apr" <> unparsed), do: { 4, unparsed }
d... | lib/http_date/parser.ex | 0.600774 | 0.847527 | parser.ex | starcoder |
defmodule AWS.Cognito.IdentityProvider do
@moduledoc """
Using the Amazon Cognito Your User Pools API, you can create a user pool to
manage directories and users. You can authenticate a user to obtain tokens
related to user identity and access policies.
This API reference provides information about user poo... | lib/aws/cognito_identity_provider.ex | 0.738198 | 0.429609 | cognito_identity_provider.ex | starcoder |
defmodule Icon.Schema.Types.Transaction.Result do
@moduledoc """
This module defines a transaction result.
A transaction result has the following keys:
Key | Type | Description
:-------------------- | :----------------------------------------- | :-----... | lib/icon/schema/types/transaction/result.ex | 0.915058 | 0.784938 | result.ex | starcoder |
defmodule ConfigCat.User do
@moduledoc """
Represents a user in your system; used for ConfigCat's Targeting feature.
The User Object is an optional parameter when getting a feature flag or
setting value from ConfigCat. It allows you to pass potential [Targeting
rule](https://configcat.com/docs/advanced/targe... | lib/config_cat/user.ex | 0.89127 | 0.560734 | user.ex | starcoder |
defmodule Interceptor.Queue do
@moduledoc false
alias Interceptor.Coercible
defstruct queue: :queue.new(),
stack: []
@type t :: %__MODULE__{
queue: :queue.queue(),
stack: list
}
@type direction :: :forwards | :backwards
@spec new(list) :: t
def new(items \\ [])... | lib/interceptor/queue.ex | 0.819965 | 0.407157 | queue.ex | starcoder |
defmodule Redix.Telemetry do
@moduledoc """
Telemetry integration for event tracing, metrics, and logging.
Redix connections (both `Redix` and `Redix.PubSub`) execute the
following Telemetry events:
* `[:redix, :connection]` - executed when a Redix connection establishes the
connection to Redis. The... | lib/redix/telemetry.ex | 0.966112 | 0.592224 | telemetry.ex | starcoder |
defmodule Formex.View.Nested do
import Formex.View
@moduledoc """
Helper functions for templating nested form.
See [Type docs](https://hexdocs.pm/formex/Formex.Type.html#module-nested-forms)
for example of use.
"""
@doc false
def formex_nested(form, item_name) do
formex_nested(form, item_name, []... | lib/formex/view_nested.ex | 0.64131 | 0.628963 | view_nested.ex | starcoder |
defmodule Puid.CharSet do
@moduledoc """
Pre-defined `Puid.CharSet`s
Pre-defined `Puid.CharSet`s are specified via an atom `charset` option during `Puid` module
definition.
## Example
defmodule(AlphanumId, do: use(Puid, charset: :alphanum))
## CharSets
### :alpha
Upper/lower case alphabet
... | lib/charset.ex | 0.880637 | 0.888711 | charset.ex | starcoder |
defmodule Waffle.Definition.Storage do
@moduledoc ~S"""
Uploader configuration.
Add `use Waffle.Definition` inside your module to use it as uploader.
## Storage directory
config :waffle,
storage_dir: "my/dir"
The storage directory to place files. Defaults to `uploads`, but can
be overwritt... | lib/waffle/definition/storage.ex | 0.774328 | 0.452294 | storage.ex | starcoder |
defmodule Day19 do
def part1(input) do
machine = Intcode.new(input)
for col <- 0..49, row <- 0..49 do
case in_beam?(col, row, machine) do
true -> [1]
false -> []
end
end
|> List.flatten
|> Enum.sum
end
def part2(input, size) do
machine = Intcode.new(input)
max = size - 1... | day19/lib/day19.ex | 0.588653 | 0.64013 | day19.ex | starcoder |
defimpl Differ.Patchable, for: List do
def revert_op(_, {op, val}) do
case op do
:remove -> {:error, "Operation :remove is not revertable"}
:del -> {:ok, {:ins, val}}
:ins -> {:ok, {:del, val}}
_ -> {:ok, {op, val}}
end
end
def explain(list, op, {res, index}, cb) do
new_acc =
... | lib/implementations/patchable/list.ex | 0.542136 | 0.435902 | list.ex | starcoder |
defmodule RDF.Description do
@moduledoc """
A set of RDF triples about the same subject.
`RDF.Description` implements:
- Elixir's `Access` behaviour
- Elixir's `Enumerable` protocol
- Elixir's `Inspect` protocol
- the `RDF.Data` protocol
"""
@enforce_keys [:subject]
defstruct subject: nil, predic... | lib/rdf/description.ex | 0.894072 | 0.660302 | description.ex | starcoder |
defmodule Crawly.Manager do
@moduledoc """
Crawler manager module
This module is responsible for spawning all processes related to
a given Crawler.
The manager spawns the following processes tree.
ββββββββββββββββββ βββββββββββββββββββββ
β Crawly.Manager βββββββββ> Crawly.ManagerSup β
βββββββββ... | lib/crawly/manager.ex | 0.585338 | 0.511961 | manager.ex | starcoder |
defmodule FLHook.Result do
@moduledoc """
A struct that contains result data and provides helpers to decode the
contained data.
"""
alias FLHook.ParamError
alias FLHook.Params
alias FLHook.Utils
defstruct lines: []
@type t :: %__MODULE__{lines: [String.t()]}
@doc """
Converts the result to a s... | lib/fl_hook/result.ex | 0.837819 | 0.560132 | result.ex | starcoder |
defmodule Stripe.Charge do
@moduledoc """
Work with Stripe charge objects.
You can:
- Capture a charge
- Retrieve a charge
Stripe API reference: https://stripe.com/docs/api#charge
"""
@type t :: %__MODULE__{}
defstruct [
:id, :object,
:amount, :amount_refunded, :application, :application_... | lib/stripe/charge.ex | 0.760117 | 0.700498 | charge.ex | starcoder |
defmodule AdaptableCostsEvaluator.Inputs do
@moduledoc """
The Inputs context.
"""
import Ecto.Query, warn: false
alias AdaptableCostsEvaluator.Repo
alias AdaptableCostsEvaluator.Inputs.Input
alias AdaptableCostsEvaluator.Computations.Computation
@doc """
Returns the list of inputs in the computati... | lib/adaptable_costs_evaluator/inputs.ex | 0.869264 | 0.527621 | inputs.ex | starcoder |
defmodule AWS.Personalize do
@moduledoc """
Amazon Personalize is a machine learning service that makes it easy to add
individualized recommendations to customers.
"""
@doc """
Creates a batch inference job.
The operation can handle up to 50 million records and the input file must be in
JSON format. ... | lib/aws/generated/personalize.ex | 0.888879 | 0.726353 | personalize.ex | starcoder |
defmodule Structex.Modal do
@moduledoc """
Functions related to modal analysis.
"""
@doc """
Returns a tensor where each diagonal element is natural angular frequency and a corresponding
normal mode matrix.
iex> Structex.Modal.normal_modes(
...> Tensorex.from_list([[ 15.3, 0 ],
.... | lib/structex/modal.ex | 0.877687 | 0.516169 | modal.ex | starcoder |
defmodule Rbt.Producer.Sandbox do
@moduledoc """
Provides a Sandbox producer which can be used in tests (the API is
compatible with `Rbt.Producer`.
The sandbox purpose is to provide a in-memory, concurrency-safe way to
produce events and verify their existence.
Each event is stored in a public ets table a... | lib/rbt/producer/sandbox.ex | 0.791418 | 0.505127 | sandbox.ex | starcoder |
defmodule Aecore.Contract.Tx.ContractCreateTx do
@moduledoc """
Contains the transaction structure for creating contracts
and functions associated with those transactions.
"""
use Aecore.Tx.Transaction
alias __MODULE__
alias Aecore.Account.{Account, AccountStateTree}
alias Aecore.Chain.{Identifier, Ch... | apps/aecore/lib/aecore/contract/tx/contract_create_tx.ex | 0.88544 | 0.41253 | contract_create_tx.ex | starcoder |
defmodule Univrse.Alg do
@moduledoc """
Proxy module for calling crypto functions on supported algorithms.
## Supported algorithms
* `A128CBC-HS256`
* `A256CBC-HS512`
* `A128GCM`
* `A256GCM`
* `ECDH-ES+A128GCM`
* `ECDH-ES+A256GCM`
* `ES256K`
* `HS256`
* `HS512`
"""
alias __MODULE__.AES_CBC... | lib/univrse/alg.ex | 0.694924 | 0.437523 | alg.ex | starcoder |
defmodule Delx do
@moduledoc """
An Elixir library to make function delegation testable.
## Usage
Let's say you have the following module.
iex> defmodule Greeter.StringGreeter do
...> def hello(name) do
...> "Hello, \#{name}!"
...> end
...> end
You can delegate functi... | lib/delx.ex | 0.749821 | 0.565479 | delx.ex | starcoder |
defmodule LibLatLon.Info do
@moduledoc """
Main storage struct for holding information about any place/POI/address
in the unified form.
## Example:
LibLatLon.lookup {41.38777777777778, 2.197222222222222}
%LibLatLon.Info{
address: "Avinguda del Litoral, [...] EspaΓ±a",
bounds: %LibL... | lib/lib_lat_lon/data/info.ex | 0.865423 | 0.46035 | info.ex | starcoder |
defmodule Legion.Networking.INET do
@moduledoc """
Provides functions and types for INET data structures.
"""
import CIDR, only: [match!: 2, parse: 1]
alias Legion.Networking.INET
@env Application.get_env(:legion, Legion.Identity.Auth.Concrete)
@allow_local_addresses Keyword.fetch!(@env, :allow_local_ad... | apps/legion/lib/networking/inet/inet.ex | 0.676299 | 0.401131 | inet.ex | starcoder |
defmodule DevAssetProxy.Plug do
@moduledoc """
Phoenix plug to proxy a locally running instance of a dev server.<br />
This plug will only serve assets when the env parameter has the value of `:dev`.<br />
Phoenix will be allowed a chance to resolve any assets not resolved by the dev server.<br />
## Install... | lib/dev_asset_proxy.ex | 0.722625 | 0.756582 | dev_asset_proxy.ex | starcoder |
defmodule PhoenixLiveViewExt.Listilled do
@moduledoc """
Listilled behaviour should be implemented by the modules (e.g. LiveView components) assuming the concern
of their state-to-assigns transformation where such assigns then need to get compared and diffed (listilled)
by the Listiller before getting actually ... | lib/listiller/listilled.ex | 0.88677 | 0.653085 | listilled.ex | starcoder |
defmodule Ecto.Adapters.SQL.Sandbox do
@moduledoc """
Start a pool with a single sandboxed SQL connection.
"""
defmodule Query do
defstruct [:request]
end
defmodule Result do
defstruct [:value]
end
@behaviour DBConnection
@behaviour DBConnection.Pool
defstruct [:mod, :state, :status, :ad... | deps/ecto/lib/ecto/adapters/sql/sandbox.ex | 0.651798 | 0.535463 | sandbox.ex | starcoder |
defmodule SmartCity.Registry.Organization do
@moduledoc """
Struct defining an organization definition and functions for reading and writing organization definitions to Redis.
```javascript
const Organization = {
"id": "", // uuid
"orgTitle": "", // user friendly
"orgName": "", // s... | lib/smart_city/registry/organization.ex | 0.835383 | 0.695945 | organization.ex | starcoder |
defmodule Mix.Tasks.Aoc.Get do
@moduledoc """
Fetch the input and example input of the AOC challenge for a given day / year.
This mix task fetches the input and example input for the advent of code challenge of a specific
day. The day and year of the challenge can be passed as command-line arguments or be set ... | lib/mix/tasks/aoc.get.ex | 0.890002 | 0.934035 | aoc.get.ex | starcoder |
defmodule DataLogger do
@moduledoc """
A `DataLogger` can log any data to any configured destination.
A destination can be configured using the the application configuration:
config :data_logger,
destinations: [
{DestinationImplementation, %{option_one: value_one, option_two: value_two}}... | lib/data_logger.ex | 0.91116 | 0.851459 | data_logger.ex | starcoder |
defmodule Plymio.Vekil.Forom.Term do
@moduledoc ~S"""
The module implements the `Plymio.Vekil.Forom` protocol and produces
a valid term transparently ("passthru").
See `Plymio.Vekil.Forom` for the definitions of the protocol functions.
See `Plymio.Vekil` for an explanation of the test environment.
## Mod... | lib/vekil/concrete/forom/term.ex | 0.847321 | 0.569015 | term.ex | starcoder |
defmodule Rampart.Authorize do
@moduledoc """
The Authorize module defines the plug that handles
the actual authorization of a request.
### Configuration
On initialisation, the Authorize plug requires two
options:
- `resource` - The resource that is being authorized, either a module or a struct in most... | lib/rampart/authorize.ex | 0.690142 | 0.498291 | authorize.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.