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 FDS.ListArray do
defstruct [:ralist, :count]
@type t :: %__MODULE__{ralist: :fds_ralist.ralist(any()), count: non_neg_integer()}
@spec new() :: t
def new() do
%__MODULE__{ralist: :fds_ralist.new(), count: 0}
end
@spec push(t, term()) :: t
def push(%__MODULE__{ralist: ralist, count: count} ... | lib/fds/list_array.ex | 0.719285 | 0.571468 | list_array.ex | starcoder |
defmodule Grizzly.CommandClass.Configuration.BulkGet do
@moduledoc """
Command module for working with the Configuration command class BULK_GET command
Command Options:
* `:start` - the starting number of the configuration params
* `:number` - the number of params to get
* `:seq_number` the sequenc... | lib/grizzly/command_class/configuration/bulk_get.ex | 0.775009 | 0.459258 | bulk_get.ex | starcoder |
defmodule EctoSearcher.Utils.SearchCondition do
@moduledoc """
Builds SearchCondition from params
This module is internal. Use at your own risk.
"""
@enforce_keys [:field, :matcher, :value]
defstruct [:field, :matcher, :value]
@doc """
Builds `%SearchCondition{}` from params
## Usage
```elixir
... | lib/ecto_searcher/utils/search_condition.ex | 0.788013 | 0.741651 | search_condition.ex | starcoder |
defmodule Day03.Path do
@moduledoc """
Functions for working with paths of wires.
"""
@typedoc """
A list of path segments that forms a complete wire path.
"""
@type t :: list(segment)
@typedoc """
A single segment of a path, with a direction and distance.
"""
@type segment :: {direction, intege... | aoc2019_elixir/apps/day03/lib/path.ex | 0.918562 | 0.653293 | path.ex | starcoder |
defmodule EctoMnesia.Record.Context do
@moduledoc """
Context stores `table`, `query` and `match_spec` that can be used for conversions between schemas and Mnesia records.
"""
alias EctoMnesia.Table
alias EctoMnesia.Record.Context
defstruct table: %Context.Table{}, query: %Context.Query{}, match_spec: %Con... | lib/ecto_mnesia/record/context.ex | 0.818302 | 0.488466 | context.ex | starcoder |
defmodule Exhort.SAT.Constraint do
@moduledoc """
A constraint on the model.
The binary constraints are:
```
:< | :<= | :== | :>= | :> | :"abs=="
```
The list constraints are:
```
:"all!=" | :no_overlap
```
The expression must include a boundary: `<`, `<=`, `==`, `>=`, `>`.
```
x < y
`... | lib/exhort/sat/constraint.ex | 0.904252 | 0.989182 | constraint.ex | starcoder |
defmodule Plaid.Item do
@moduledoc """
Functions for Plaid `item` endpoint.
"""
import Plaid, only: [make_request_with_cred: 4, get_cred: 0]
alias Plaid.Utils
@derive Jason.Encoder
defstruct available_products: [], billed_products: [], error: nil,
institution_id: nil, item_id: nil, webhook:... | lib/plaid/item.ex | 0.820721 | 0.625681 | item.ex | starcoder |
defmodule Ppc.Live do
@behaviour Ppc
# ------------------------------------ product --------------------------------------
@impl Ppc
def product_list(opts \\ []) do
Ppc.Product.list(opts)
end
@impl Ppc
def product_details(id, opts \\ []) do
Ppc.Product.details(id, opts)
end
@impl Ppc
def... | lib/ppc_live.ex | 0.61555 | 0.424889 | ppc_live.ex | starcoder |
defmodule JsonApiQueryBuilder.Filter do
@moduledoc """
Filter operations for JsonApiQueryBuilder.
"""
@doc """
Applies filter conditions from a parsed JSON-API request to an `Ecto.Queryable.t`.
Each filter condition will be cause the given callback to be invoked with the query, attribute and value.
## ... | lib/json_api_query_builder/filter.ex | 0.888544 | 0.775052 | filter.ex | starcoder |
defmodule CastParams.Schema do
@moduledoc """
Defines a params schema for a plug.
A params schema is just a keyword list where keys are the parameter name
and the value is either a valid `CastParams.Type` (ending with a `!` to mark the parameter as required).
## Example
CastParams.Schema.init(age: :... | lib/cast_param/schema.ex | 0.892818 | 0.584419 | schema.ex | starcoder |
defmodule NYSETL.Extra.Scrubber do
use Magritte
@moduledoc """
Functions to scrub all PII in ECLRS dump files so that it can be used in development.
Sensitive data is replaced with random strings of the same length and format (letters
for letters, digits for digits and dates for dates). Currently only works... | lib/nys_etl/extra/scrubber.ex | 0.689201 | 0.418281 | scrubber.ex | starcoder |
defmodule Thrash.MacroHelpers do
@moduledoc false
# Functions that are helpful for working with macros
# Thrash internal use only
@type escaped_module_name :: {term, list, [atom]}
@type namespace :: nil | {atom, atom}
@doc """
Determine the caller module name with optional override.
Use with the `__... | lib/thrash/macro_helpers.ex | 0.844024 | 0.444083 | macro_helpers.ex | starcoder |
defmodule Concentrate.MergeFilter do
@moduledoc """
ProducerConsumer which merges the data given to it, filters, and outputs the result.
We manage the demand from producers manually.
* On subscription, we ask for 1 event
* Once we've received an event, schedule a timeout for 1s
* When the timeout happens, ... | lib/concentrate/merge_filter.ex | 0.787196 | 0.566888 | merge_filter.ex | starcoder |
defmodule Site.ResponsivePagination do
@moduledoc """
Represents all the contextual information necessary to render the responsive pagination component.
"""
@desktop_max_length 5
@mobile_max_length 3
@type stats :: %{
offset: integer,
per_page: integer,
total: integer,
... | apps/site/lib/site/responsive_pagination.ex | 0.795857 | 0.444866 | responsive_pagination.ex | starcoder |
defmodule Snitch.Data.Schema.TaxRate do
@moduledoc """
Models a TaxRate.
TaxRate belongs to a zone.
A tax rate basically groups the tax values for different tax classes. These are used
for tax calculation.
### e.g.
```
`ProductTaxClass`: 5%,
`ShippingTaxClass`: 2%
```
A tax rate has a priorit... | apps/snitch_core/lib/core/data/schema/tax/tax_rate.ex | 0.904698 | 0.968974 | tax_rate.ex | starcoder |
defmodule SSHKit.SSH.Connection do
@moduledoc """
Defines a `SSHKit.SSH.Connection` struct representing a host connection.
A connection struct has the following fields:
* `host` - the name or IP of the remote host
* `port` - the port to connect to
* `options` - additional connection options
* `ref` - th... | lib/sshkit/ssh/connection.ex | 0.861596 | 0.5119 | connection.ex | starcoder |
defmodule Cldr.LanguageTag.Parser do
@moduledoc """
Parses a CLDR language tag (also referred to as locale string).
The applicable specification is from [CLDR](http://unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers)
which is similar based upon [RFC5646](https://tools.ietf.org/html/rfc5646) wi... | lib/cldr/language_tag/parser.ex | 0.887476 | 0.702836 | parser.ex | starcoder |
defmodule Wallaby.Selenium do
@moduledoc """
The Selenium driver uses [Selenium Server](https://github.com/SeleniumHQ/selenium) to power many types of browsers (Chrome, Firefox, Edge, etc).
## Usage
Start a Wallaby Session using this driver with the following command:
```
{:ok, session} = Wallaby.start_s... | lib/wallaby/selenium.ex | 0.755907 | 0.779679 | selenium.ex | starcoder |
defmodule Filterable do
@moduledoc """
`Filterable` allows to map incoming parameters to filter functions.
This module contains functions (`apply_filters/3`, `filter_values/2`)
which allow to perform filtering and `filterable` macro which allows
to define available filters using DSL (see `Filterable.DSL`).
... | lib/filterable.ex | 0.79858 | 0.738763 | filterable.ex | starcoder |
defmodule FinanceTS.Adapters.Yahoo do
@moduledoc """
An Adapter for Yahoo Finance
Homepage: https://finance.yahoo.com/
API Docs: (The api is not officially documented)
"""
@behaviour FinanceTS.Adapter
@supported_resolutions [
:minute,
{:minute, 2},
{:minute, 5},
{:minute, 15},
{:minu... | lib/finance_ts/adapters/yahoo.ex | 0.715325 | 0.532425 | yahoo.ex | starcoder |
defmodule Overpex.Parser.JSON do
@moduledoc """
Provides functions to parse JSON response from Overpass API
"""
alias Overpex.Overpass.{Node, Relation, RelationMember, Tag, Way}
alias Overpex.Response
@doc """
Parses JSON response from Overpass API
## Return values
Returns `{:ok, response}`, where... | lib/overpex/parser/json.ex | 0.851722 | 0.448487 | json.ex | starcoder |
defmodule Ash.Filter.Predicate.In do
@moduledoc "A predicate for a value being in a list of provided values"
defstruct [:field, :values]
use Ash.Filter.Predicate
alias Ash.Error.Query.InvalidFilterValue
alias Ash.Filter.Expression
alias Ash.Filter.Predicate
alias Ash.Filter.Predicate.Eq
def new(_reso... | lib/ash/filter/predicate/in.ex | 0.819605 | 0.448064 | in.ex | starcoder |
defmodule Telnyx.Messages do
@moduledoc """
Send a message with `create/2`, and retrieve a message with `retrieve/2`.
"""
alias Telnyx.Client
@doc """
Sends a message.
## Examples
```
api_key = "YOUR_API_KEY"
%{
from: "+18665552368", # Your Telnyx number
to: "+18445552367",
... | lib/telnyx/messages.ex | 0.852782 | 0.787053 | messages.ex | starcoder |
defmodule Instruments.FastCounter do
@moduledoc false
# A Faster than normal counter.
# Builds one ETS table per scheduler in the system and sends increment / decrement writes to the local
# scheduler. Statistics are reported per scheduler once every `fast_counter_report_interval` milliseconds.
@table_pref... | lib/fast_counter.ex | 0.810366 | 0.425725 | fast_counter.ex | starcoder |
defmodule ElixirMock.Matchers do
@moduledoc """
Contains utility functions that allow predicate-based matching against arguments passed to mock function calls.
The `ElixirMock.assert_called/1` and `ElixirMock.refute_called/1` macros can take matchers in place of literal arguments
in function call verifications... | lib/matchers/matchers.ex | 0.943393 | 0.909023 | matchers.ex | starcoder |
defmodule OliWeb.RevisionHistory.ReingoldTilford do
# Reingold-Tilford algorithm for drawing trees
@moduledoc false
@node_height 30
@node_y_separation 10
@total_y_distance @node_height + @node_y_separation
@node_x_separation 50
defmodule Node do
@moduledoc false
defstruct [:x, :y, :label, :child... | lib/oli_web/live/history/reingold_tifford.ex | 0.778228 | 0.571468 | reingold_tifford.ex | starcoder |
defmodule Statistics.Distributions.Chisq do
alias Statistics.Math
alias Statistics.Math.Functions
@moduledoc """
Chi square distribution.
Takes a *degrees of freedom* parameter.
"""
@doc """
The probability density function
## Examples
iex> Statistics.Distributions.Chisq.pdf(1).(2)
0.... | lib/statistics/distributions/chisq.ex | 0.889873 | 0.609146 | chisq.ex | starcoder |
defmodule Md5 do
@moduledoc """
Provides methods for calculating a MD5 hash. This module implements the MD5 hashing algorithm in pure Elixir.
"""
use Bitwise
# Pre-determined constants to shift bits - aproximated to give biggest avalanche
@shift_constants {
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, ... | lib/md5.ex | 0.810479 | 0.466663 | md5.ex | starcoder |
defmodule Explorer.PolarsBackend.Series do
@moduledoc false
import Kernel, except: [length: 1]
import Explorer.Shared, only: [check_types!: 1, cast_numerics: 2]
alias Explorer.DataFrame
alias Explorer.PolarsBackend.Native
alias Explorer.PolarsBackend.Shared
alias Explorer.Series
alias __MODULE__, as: ... | lib/explorer/polars_backend/series.ex | 0.904318 | 0.511656 | series.ex | starcoder |
defmodule AWS.Snowball do
@moduledoc """
AWS Snow Family is a petabyte-scale data transport solution that uses secure
devices to transfer large amounts of data between your on-premises data centers
and Amazon Simple Storage Service (Amazon S3).
The Snow commands described here provide access to the same fun... | lib/aws/generated/snowball.ex | 0.8628 | 0.583263 | snowball.ex | starcoder |
defmodule ExMinimatch do
@moduledoc """
ExMinimatch
===========
Globbing paths without walking the tree! Elixir and Erlang provide `wildcard`
functions in the stdlib. But these will walk the directory tree. If you simply
want to test whether a file path matches a glob, ExMinimatch is for you.
Quick exa... | vendor/ex_minimatch/ex_minimatch.ex | 0.838515 | 0.55658 | ex_minimatch.ex | starcoder |
defmodule Grizzly.Trace.Record do
@moduledoc """
Data structure for a single item in the trace log
"""
alias Grizzly.{Trace, ZWave}
alias Grizzly.ZWave.Command
@type t() :: %__MODULE__{
timestamp: Time.t(),
binary: binary(),
src: Trace.src() | nil,
dest: Trace.src()... | lib/grizzly/trace/record.ex | 0.852721 | 0.470493 | record.ex | starcoder |
defmodule ExState.Execution do
@moduledoc """
`ExState.Execution` executes state transitions with a state chart.
"""
alias ExState.Result
alias ExState.Definition.Chart
alias ExState.Definition.State
alias ExState.Definition.Step
alias ExState.Definition.Transition
@type t :: %__MODULE__{
... | lib/ex_state/execution.ex | 0.877935 | 0.40869 | execution.ex | starcoder |
defmodule AWS.KMS do
@moduledoc """
AWS Key Management Service
AWS Key Management Service (AWS KMS) is an encryption and key management
web service. This guide describes the AWS KMS operations that you can call
programmatically. For general information about AWS KMS, see the [AWS Key
Management Service De... | lib/aws/kms.ex | 0.891617 | 0.463991 | kms.ex | starcoder |
defmodule Circuits.GPIO do
alias Circuits.GPIO.Nif
@moduledoc """
Control GPIOs from Elixir
If you're coming from Elixir/ALE, check out our [porting guide](PORTING.md).
`Circuits.GPIO` works great with LEDs, buttons, many kinds of sensors, and
simple control of motors. In general, if a device requires hi... | lib/gpio.ex | 0.862757 | 0.778313 | gpio.ex | starcoder |
defmodule Custodian.Github.Tentacat.Labels do
@moduledoc """
Provides an implementation of the `Custodian.Github.Labels` behaviour with
the GitHub API.
This module contains convenience methods for listing, adding, and removing
labels from GitHub pull requests via the GitHub v3 API over HTTPS.
"""
@behav... | lib/custodian/github/tentacat/labels.ex | 0.526343 | 0.496033 | labels.ex | starcoder |
defmodule Dust.Requests do
@moduledoc """
Requests provide an API to make fetch pages also it supports
automatic retries with constant backoff the request should fail.
"""
use Retry
alias Dust.Parsers
alias Dust.Requests.{
State,
Proxy,
Result,
Util
}
@type url() :: String.t()
@ty... | lib/dust/requests.ex | 0.82734 | 0.428712 | requests.ex | starcoder |
defmodule SSHKit.SCP.Upload do
@moduledoc false
require Bitwise
alias SSHKit.SCP.Command
alias SSHKit.SSH
defstruct [:source, :target, :state, :handler, options: []]
@doc """
Uploads a local file or directory to a remote host.
## Options
* `:verbose` - let the remote scp process be verbose, defa... | lib/sshkit/scp/upload.ex | 0.86342 | 0.737855 | upload.ex | starcoder |
defmodule Tradehub.Exchange do
@moduledoc """
This module allows developers to interact with the public endpoints mainly focusing on the
exchange information.
"""
import Tradehub.Raising
@doc """
Requests all known tokens on the Tradehub chain.
## Examples
iex> Tradehub.Exchange.tokens
"""
... | lib/tradehub/exchange.ex | 0.910694 | 0.449513 | exchange.ex | starcoder |
Parameters, xscale=1000, xname=$Horizontal\ displacement\ along\ x\ axis\ (mm)$, marksnumber=15, title=$One\ Element\ Torus\ Test$, crop=True
# Temperature curve
temperature, yname=$Temperature\ in\ ^{\circ}C$, legendlocate=bottomright, name=$DynELA\ T$, temperature.plot, name=$Abaqus\ T$, Abaqus/Torus_Temperature.plo... | Samples/Element/Torus/ElQua4NAx/Curves.ex | 0.672117 | 0.642678 | Curves.ex | starcoder |
defmodule CNPJ do
@moduledoc """
CNPJ provides you functions to work with CNPJs.
"""
alias CNPJ.ParsingError
defguardp is_positive_integer(number) when is_integer(number) and number > 0
@v1_weights [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
@v2_weights [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
defstruct [:d... | lib/cnpj/cnpj.ex | 0.897504 | 0.669103 | cnpj.ex | starcoder |
defmodule Kojin.Pod.PodMap do
@moduledoc """
Represents a map keyed by string and some other `Kojin.Pod.PodType`
"""
use TypedStruct
alias Kojin.Pod.{PodMap, PodArray, PodType, PodTypeRef, PodTypes}
@typedoc """
Defines a map keyed by string and value of some other `Kojin.Pod.PodType`
"""
typedstruc... | lib/kojin/pod/pod_map.ex | 0.872266 | 0.547525 | pod_map.ex | starcoder |
defmodule Cepex do
@spec lookup(String.t() | integer(), [keyword()]) ::
{:ok, Cepex.Address.t()}
| {:error, :request_failed}
| {:error, {:invalid_response, Cepex.HTTP.Response.t()}}
| {:error, :invalid_cep}
| {:error, :cep_not_found}
@doc """
Lookups a postal code... | lib/cepex.ex | 0.796253 | 0.420719 | cepex.ex | starcoder |
defmodule Edeliver.Relup.Instructions.SuspendChannels do
@moduledoc """
This upgrade instruction suspends the websocket processes
connected to phoenix channels to avoid that new channel
events will be processed during the code upgrade / downgrade
process. It will be appended to the instructions aft... | lib/edeliver/relup/instructions/suspend_channels.ex | 0.739328 | 0.499939 | suspend_channels.ex | starcoder |
defmodule Memento.Schema do
require Memento.Mnesia
@moduledoc """
Module to interact with the database schema.
For persisting data, Mnesia databases need to be created on disk. This
module provides an interface to create the database on the disk of the
specified nodes. Most of the time that is usually th... | lib/memento/schema.ex | 0.762733 | 0.878783 | schema.ex | starcoder |
defmodule Pascal do
@moduledoc """
# Pascal.addrow([0,1,0])
# 0 | 1 | 0
# 0 | 1 | 1 | 0
# 0 | 1 | 2 | 1 | 0
# 0 | 1 | 3 | 3 | 1 | 0
The pattern is simple to grasp.
This is non-tail stac tracked recursive pattern matching.
[0, 1, 0]
=> [0, 1] | [1, 0]
=> [1, 0] = [1+0] ... | pascal.ex | 0.503906 | 0.716343 | pascal.ex | starcoder |
if elem(Code.ensure_compiled(Plug), 0) != :error do
defmodule Msgpax.PlugParser do
@moduledoc """
A `Plug.Parsers` plug for parsing a MessagePack-encoded body.
Look at the [documentation for
`Plug.Parsers`](http://hexdocs.pm/plug/Plug.Parsers.html) for more
information on how to use `Plug.Parsers... | lib/msgpax/plug_parser.ex | 0.80837 | 0.410609 | plug_parser.ex | starcoder |
defmodule Scidata.IMDBReviews do
@moduledoc """
Module for downloading the [Large Movie Review Dataset](https://ai.stanford.edu/~amaas/data/sentiment/).
"""
@base_url "http://ai.stanford.edu/~amaas/data/sentiment/"
@dataset_file "aclImdb_v1.tar.gz"
alias Scidata.Utils
@type train_sentiment :: :pos | :n... | lib/scidata/imdb_reviews.ex | 0.78316 | 0.776284 | imdb_reviews.ex | starcoder |
defmodule AWS.TimestreamWrite do
@moduledoc """
Amazon Timestream is a fast, scalable, fully managed time series database
service that makes it easy to store and analyze trillions of time series
data points per day. With Timestream, you can easily store and analyze IoT
sensor data to derive insights from you... | lib/aws/generated/timestream_write.ex | 0.87588 | 0.735487 | timestream_write.ex | starcoder |
defmodule T2ServerQuery do
@moduledoc """
Querying a Tribes 2 server actually requires sending 2 different packets to the server where the first byte is denoting the type of information we're asking for. The first is called the `info` packet which doesnt contain much more then the server name. The second is called... | lib/t2_server_query.ex | 0.729134 | 0.573977 | t2_server_query.ex | starcoder |
defmodule Hades do
@moduledoc """
A wrapper for `NMAP` written in Elixir.
Nmap (network mapper), the god of port scanners used for network discovery and the basis for most security enumeration during the initial stages of a penetration test. The tool was written and maintained by Fyodor AKA <NAME>.
Nmap displ... | lib/hades.ex | 0.88512 | 0.654453 | hades.ex | starcoder |
defmodule Ticker.Quote.Processor.Simulate do
use Timex
@historical_hours 2
@ticks_per_minute 4
@behaviour Ticker.Quote.Processor.Behaviour
@initial_quote %Ticker.Quote{c: "0.00", c_fix: "0.00", ccol: "chr", cp: "0.00", cp_fix: "0.00", e: "NASDAQ", id: "99999", l: "120.00", l_cur: "120.00", l_fix: "120.00", ... | lib/ticker/quote/processor/simulate.ex | 0.592195 | 0.469095 | simulate.ex | starcoder |
defmodule Deparam.Type do
@moduledoc """
A behavior that can be used to implement a custom coercer.
"""
alias Deparam.TypeContext
alias Deparam.Types
@doc """
Coerces the given value using the type and additional options specified in the
specified type context.
"""
@callback coerce(value :: any, c... | lib/deparam/type.ex | 0.855474 | 0.482612 | type.ex | starcoder |
defmodule Scenic.Primitive.Arc do
@moduledoc """
Draw an arc on the screen.
An arc is a segment that traces part of the outline of a circle. If you are
looking for something shaped like a piece of pie, then you want a segment.
Arcs are often drawn on top of a segment to get an affect where a piece of pie
... | lib/scenic/primitive/arc.ex | 0.910932 | 0.703333 | arc.ex | starcoder |
defmodule MeteoStick.WeatherStation do
use GenServer
require Logger
defmodule State do
defstruct id: 0,
outdoor_temperature: 0,
indoor_temperature: 0,
humidity: 0,
pressure: 0,
wind: %{
speed: 0,
direction: 0,
gust: 0
},
rain: 0,
uv: 0,
solar: %{
ra... | lib/meteo_stick/weather_station.ex | 0.544559 | 0.574634 | weather_station.ex | starcoder |
defmodule StreamingMetrics.PrometheusMetricCollector do
@moduledoc """
Prometheus backend.
It is the client's responsibility to expose the metrics
to prometheus via a scrape endpoint or the Pushgateway.
This module simply creates and increments the counters.
"""
@behaviour StreamingMetrics.MetricCollecto... | lib/streaming_metrics/prometheus_metric_collector.ex | 0.85115 | 0.520679 | prometheus_metric_collector.ex | starcoder |
defmodule Kaguya.Module do
defmodule Doc do
defstruct command: "", args: [], trailing: "", user: nil
end
@moduledoc """
Module which provides functionality used for creating IRC modules.
When this module is used, it will create wrapper
functions which allow it to be automatically registered
as a mo... | lib/kaguya/module.ex | 0.571169 | 0.402862 | module.ex | starcoder |
defmodule SRP do
@moduledoc """
SRP provides an implementation of the Secure Remote Password Protocol presented on
[The SRP Authentication and Key Exchange System](https://tools.ietf.org/html/rfc2945),
[Using the Secure Remote Password (SRP) Protocol for TLS Authentication](https://tools.ietf.org/html/rfc5054)
... | lib/srp.ex | 0.904457 | 0.946151 | srp.ex | starcoder |
defmodule SanbaseWeb.Graphql.Middlewares.AccessControl do
@moduledoc """
Middleware that is used to restrict the API access in a certain timeframe.
Currently the implemented scheme is like this:
* For users accessing data for slug `santiment` - there is no restriction.
* If the logged in user is subscribed t... | lib/sanbase_web/graphql/middlewares/access_control.ex | 0.90101 | 0.460471 | access_control.ex | starcoder |
defmodule Pbuf.Protoc.Field do
alias Pbuf.Protoc
alias Pbuf.Protoc.Fields
@enforce_keys [:tag, :name, :prefix, :typespec, :encode_fun, :decode_fun, :default]
defstruct @enforce_keys ++ [
hidden: false,
oneof_index: nil,
post_decode: :none,
json?: true,
]
@type t :: %__MODULE__{
tag: po... | lib/protoc/fields/field.ex | 0.658418 | 0.468365 | field.ex | starcoder |
defmodule Expug.Tokenizer do
@moduledoc ~S"""
Tokenizes a Pug template into a list of tokens. The main entry point is
`tokenize/1`.
iex> Expug.Tokenizer.tokenize("title= name")
[
{{1, 8}, :buffered_text, "name"},
{{1, 1}, :element_name, "title"},
{{1, 1}, :indent, 0}
]
... | lib/expug/tokenizer.ex | 0.832543 | 0.864139 | tokenizer.ex | starcoder |
defmodule AdventOfCode2016.NoTimeForATaxiCab do
@north "North"
@south "South"
@east "East"
@west "West"
def distance_to_final_location(instructions) do
{_dir, {x, y}} =
instructions
|> final_location
abs(x) + abs(y)
end
def final_location(instructions) do
instructions
|> par... | lib/day1/no_time_for_a_taxicab.ex | 0.670069 | 0.436442 | no_time_for_a_taxicab.ex | starcoder |
defmodule PinElixir.Refund do
import PinElixir.Utils.RequestOptions
import PinElixir.Utils.Response
@moduledoc """
Responsible for refunding of charges and retreiving refund details
"""
@pin_url Application.get_env(:pin_elixir, :pin_url)
@doc """
Requests a full refund given a charge_token
Returns... | lib/refunds/refund.ex | 0.683842 | 0.699139 | refund.ex | starcoder |
defmodule OnCrash do
@moduledoc """
Convinence module to wrap a monitor and call a function when a process ends. Useful to setp cleanup tasks on process shutdown.
```elixir
worker = spawn(fn ->
OnCrash.call(fn -> cleanup() end)
do_the_work()
end)
```
OnCrash is always called when the process fi... | lib/oncrash.ex | 0.627723 | 0.768081 | oncrash.ex | starcoder |
defmodule Vax.Adapter.Query do
alias Vax.Adapter.Helpers
def query_to_objs(query, params, bucket) do
{source, schema} = query.from.source
primary_key = Helpers.schema_primary_key!(schema)
case query.wheres do
[%{expr: expr}] ->
where_expr_to_key(expr, source, primary_key, bucket, params)... | lib/vax/adapter/query.ex | 0.716516 | 0.4099 | query.ex | starcoder |
defmodule LoadResource.Plug do
@moduledoc """
This plug allows you to specify resources that your app should load and (optionally) validate as part of a request.
## Examples
Load a Book resource using the `id` param on the incoming request:
```
plug LoadResource.Plug, [model: Book, handler: &MyErrorHandl... | lib/load_resource/plug.ex | 0.885495 | 0.839931 | plug.ex | starcoder |
defmodule DarkMatter.Decimals.Variance do
@moduledoc """
Decimal variance functions
"""
@moduledoc since: "1.0.0"
alias DarkMatter.Decimals.Arithmetic
alias DarkMatter.Decimals.Comparison
alias DarkMatter.Decimals.Conversion
@type minmax() :: {DarkMatter.strict_numeric(), DarkMatter.strict_numeric()}
... | lib/dark_matter/decimals/variance.ex | 0.908684 | 0.438966 | variance.ex | starcoder |
defmodule Util.Header do
@moduledoc """
This module defines a structure for interpretting some of the ROM's metadata
"""
use Bitwise
@base_size 0x400
defstruct [
:title,
:rom_makeup,
:rom_type,
:rom_size,
:sram_size,
:license_id,
:version_number,
:checksum,
:checksum_c... | lib/util/header.ex | 0.671686 | 0.528473 | header.ex | starcoder |
defmodule Utils.Feedback do
@moduledoc """
Utils.Feedback defines tests using the `feedback` macro.
Each `feedback` macro creates an associated Utils.feedback function and
ensures that each has a corresponding solution in Utils.Solutions.
## Examples
```elixir
feedback :example do
answer = get_answe... | utils/lib/feedback.ex | 0.882662 | 0.828766 | feedback.ex | starcoder |
defmodule TaggedTuple do
@moduledoc "README.md"
|> File.read!()
|> String.split("[//]: # (Documentation)\n")
|> Enum.at(1)
|> String.trim("\n")
defmacro __using__(_opts) do
quote do
require unquote(__MODULE__)
import unquote(__MODULE__),
... | lib/tagged_tuple.ex | 0.826852 | 0.523968 | tagged_tuple.ex | starcoder |
defmodule ScrollHat.Buttons do
@moduledoc """
Buttons interface for Scroll HAT Mini
Pass a `:handler` option as a pid or {m, f, a} to receive the button events
"""
use GenServer
alias Circuits.GPIO
require Logger
@typedoc """
A name of Scroll HAT Mini button
These are labelled A, B, X, and Y on... | lib/scroll_hat/buttons.ex | 0.850779 | 0.521898 | buttons.ex | starcoder |
defmodule PromEx.Config do
@moduledoc """
This module defines a struct that contains all of the fields necessary to configure
an instance of PromEx.
While this module does not directly access your Application config, PromEx will call the
`PromEx.Config.build/1` function directly with the contents of `Applica... | lib/prom_ex/config.ex | 0.897074 | 0.652324 | config.ex | starcoder |
defmodule Crux.Structs.Emoji do
@moduledoc """
Represents a Discord [Emoji Object](https://discordapp.com/developers/docs/resources/emoji#emoji-object-emoji-structure).
Differences opposed to the Discord API Object:
- `:user` is just the user id
"""
@behaviour Crux.Structs
alias Crux.Structs.{Emoji, ... | lib/structs/emoji.ex | 0.896063 | 0.421284 | emoji.ex | starcoder |
defmodule Nostrum.Permission do
@moduledoc """
Functions that work on permissions.
Some functions return a list of permissions. You can use enumerable functions
to work with permissions:
```Elixir
alias Nostrum.Cache.GuildCache
alias Nostrum.Struct.Guild.Member
guild = GuildCache.get!(279093381723062... | lib/nostrum/permission.ex | 0.895454 | 0.812719 | permission.ex | starcoder |
defmodule WordsWithEnemies.WordAi do
use GenServer
alias WordsWithEnemies.{Letters}
import WordsWithEnemies.WordFinder
# Client
@doc """
Creates an instance of the AI, with a skill
level of `difficulty`.
"""
def start_link(id, difficulty) do
GenServer.start_link(__MODULE__, %{id: id, difficulty:... | lib/words_with_enemies/language/word_ai.ex | 0.748076 | 0.508483 | word_ai.ex | starcoder |
defmodule AdventOfCode.DayNineSolution.Location do
defstruct [:coords, :height]
end
defmodule AdventOfCode.DayNineSolution do
alias AdventOfCode.DayNineSolution.Location, as: Location
defp load_data() do
m =
AdventOfCode.load_data(9, 'data.txt')
|> Enum.map(&String.graphemes/1)
|> Enum.map... | lib/advent_of_code/day-9/solution.ex | 0.566258 | 0.487734 | solution.ex | starcoder |
defmodule Dinero do
alias Dinero.Currency
alias Dinero.Utils
@moduledoc """
`Dinero` is a struct that provides methods for working with currencies
## Examples
iex> d1 = Dinero.new(100, :USD)
%Dinero{amount: 10000, currency: :USD}
iex> d2 = Dinero.new(200, :USD)
%Dinero{amount: 20000... | lib/dinero.ex | 0.88602 | 0.563408 | dinero.ex | starcoder |
defmodule Upstairsbox.WindowCovering do
@moduledoc """
Responsible for managing the state of a window covering
"""
@behaviour HAP.ValueStore
use GenServer
require Logger
# It takes 27s to fully close the blind
@percent_per_second 100 / 27
@closing 0
@opening 1
@stopped 2
@open_pin 22
@clos... | lib/upstairsbox/window_covering.ex | 0.793586 | 0.411702 | window_covering.ex | starcoder |
defmodule Queens do
@board_length 8
@black "B"
@white "W"
@blank "_"
@type t :: %Queens{black: {integer, integer}, white: {integer, integer}}
defstruct black: nil, white: nil
@doc """
Creates a new set of Queens
"""
@spec new() :: Queens.t()
@spec new({integer, integer}, {integer, integer}) :: Q... | elixir/queen-attack/lib/queens.ex | 0.802013 | 0.452475 | queens.ex | starcoder |
defmodule SevenSegment do
import LogicGates
@moduledoc """
SevenSegment decoder that outputs a list of booleans
equivalent to the inputs of a seven segment display
"""
@doc """
outputs a list of booleans representing the segments of a seven segment display
## Parameters
- a: boolean rep... | lib/seven_segment.ex | 0.8067 | 0.778691 | seven_segment.ex | starcoder |
defmodule Ravix.Ecto.Conversions do
@moduledoc false
defmacro is_keyword(doc) do
quote do
unquote(doc) |> hd |> tuple_size == 2
end
end
defmacro is_literal(value) do
quote do
is_atom(unquote(value)) or is_number(unquote(value)) or is_binary(unquote(value))
end
end
def to_ecto(... | lib/ravix_ecto/parsers/conversions.ex | 0.66769 | 0.42937 | conversions.ex | starcoder |
defmodule Zipper do
defstruct focus: nil, trail: []
@doc """
Get a zipper focused on the root node.
"""
@spec from_tree(BinTree.t()) :: Zipper.t()
def from_tree(bin_tree), do: %Zipper{focus: bin_tree}
@doc """
Get the complete tree from a zipper.
"""
@spec to_tree(Zipper.t()) :: BinTree.t()
def ... | elixir/zipper/lib/zipper.ex | 0.863852 | 0.727637 | zipper.ex | starcoder |
defmodule Geocoder.Providers.OpenStreetMaps do
use HTTPoison.Base
use Towel
# url="https://nominatim.openstreetmap.org/reverse?format=json&accept-language={{ language }}&lat={{ latitude }}&lon={{ longitude }}&zoom={{ zoom }}&addressdetails=1"
@endpoint "https://nominatim.openstreetmap.org/"
@endpath_reverse ... | lib/geocoder/providers/open_street_maps.ex | 0.592667 | 0.520253 | open_street_maps.ex | starcoder |
defmodule Sanbase.Alert.Validation.Operation do
import Sanbase.Validation
alias Sanbase.Alert.Operation
@percent_operations Operation.percent_operations()
@absolute_value_operations Operation.absolute_value_operations()
@absolute_change_operations Operation.absolute_change_operations()
@absolute_operation... | lib/sanbase/alerts/trigger/validation/operation_validation.ex | 0.691497 | 0.433082 | operation_validation.ex | starcoder |
defmodule Telegram.Api do
@moduledoc ~S"""
Telegram Bot API request.
The module expose a light layer over the Telegram Bot API HTTP-based interface,
it does not expose any "(data)binding" over the HTTP interface and tries to abstract
away only the boilerplate for building / sending / serializing the API requ... | lib/api.ex | 0.854779 | 0.575051 | api.ex | starcoder |
defmodule Grizzly.ZWave.Commands.MultiChannelAssociationReport do
@moduledoc """
This command is used to advertise the current destinations for a given association group.
Params:
* `:grouping_identifier` - the association grouping identifier (required)
* `:max_nodes_supported` - the maximum number of de... | lib/grizzly/zwave/commands/multi_channel_association_report.ex | 0.913912 | 0.444444 | multi_channel_association_report.ex | starcoder |
defmodule Params do
@moduledoc ~S"""
Functions for processing params and transforming their changesets.
`use Params` provides a `defparams` macro, allowing you to define
functions that process parameters according to some [schema](Params.Schema.html)
## Example
```elixir
defmodule MyApp.SessionContro... | lib/params.ex | 0.885049 | 0.782018 | params.ex | starcoder |
defmodule OliWeb.Api.GlobalStateController do
@moduledoc """
Provides user state service endpoints for extrinsic state.
"""
use OliWeb, :controller
use OpenApiSpex.Controller
alias Oli.Delivery.ExtrinsicState
alias OliWeb.Api.State
alias OpenApiSpex.Schema
@moduledoc tags: ["User State Service: Ext... | lib/oli_web/controllers/api/global_state_controller.ex | 0.871912 | 0.531209 | global_state_controller.ex | starcoder |
defmodule Timex.Ecto.Date do
@moduledoc """
Support for using Timex with :date fields
"""
use Timex
@behaviour Ecto.Type
def type, do: :date
@doc """
Handle casting to Timex.Ecto.Date
"""
def cast(%Date{} = date), do: {:ok, date}
# Support embeds_one/embeds_many
def cast(%{"calendar" => _,
... | lib/types/date.ex | 0.90653 | 0.45181 | date.ex | starcoder |
defmodule UncaloteMe.AppContext do
@moduledoc """
The AppContext context.
"""
import Ecto.Query, warn: false
alias UncaloteMe.Repo
alias UncaloteMe.AppContext.Debtor
@doc """
Returns the list of debtors.
## Examples
iex> list_debtors()
[%Debtor{}, ...]
"""
def list_debtors do
... | lib/uncalote_me/app_context/app_context.ex | 0.768342 | 0.417984 | app_context.ex | starcoder |
defmodule Observables.Reactivity do
alias Observables.Obs
@doc """
* Lifts a unary function and applies it to an observable (essentially a wrapper for the map observable)
"""
def liftapp(obs, fun) do
obs |> Obs.map(fun)
end
@doc """
* Lifts a binary function and applies it to two observables
* Does not co... | lib/reactivity.ex | 0.737914 | 0.781914 | reactivity.ex | starcoder |
defmodule AWS.Client do
@moduledoc """
Provides credentials and connection details for making requests to AWS services.
You can configure `access_key_id` and `secret_access_key` which are the credentials
needed by [IAM](https://aws.amazon.com/iam), and also the `region` for your services.
The list of regions... | lib/aws/client.ex | 0.83025 | 0.403596 | client.ex | starcoder |
defmodule Yatzy.Game do
@moduledoc """
Game module responsible for :
- starting a new game
- delegating player interactions based on game's turn
- finishing a game
"""
use TypedStruct
alias Yatzy.Player
alias Yatzy.Result
alias Yatzy.Roll
typedstruct do
field :players, %{
required(Str... | lib/yatzy/game.ex | 0.804636 | 0.408365 | game.ex | starcoder |
defmodule Speedtest do
@moduledoc """
Speedtest.net client for Elixir.
"""
alias Speedtest.Ping
alias Speedtest.Decoder
alias Speedtest.Result
require Logger
defstruct config: [],
servers: [],
include: nil,
exclude: nil,
threads: nil,
sele... | lib/speedtest.ex | 0.80651 | 0.564459 | speedtest.ex | starcoder |
defmodule ExInsights do
@moduledoc """
Exposes... | lib/ex_insights.ex | 0.861101 | 0.722369 | ex_insights.ex | starcoder |
defmodule ExWire.Message.FindNeighbours do
@moduledoc """
A wrapper for ExWire's `FindNeighbours` message.
"Id of a node. The responding node will send back nodes closest to the target."
"""
@behaviour ExWire.Message
@message_id 0x03
alias ExWire.Util.Timestamp
defstruct target: nil,
tim... | apps/ex_wire/lib/ex_wire/message/find_neighbours.ex | 0.902796 | 0.521471 | find_neighbours.ex | starcoder |
defmodule LineEx.Webhook do
@moduledoc """
A behaviour for implementing LINE webhook. When `LineEx.Webhook.Plug`
receive an event, a plug module will verify the request and forward
event to the webhook.
## Example
Let's build a echo webhook that reply a message that user sent. We would
create a module a... | line_ex_webhook/lib/line_ex/webhook.ex | 0.758376 | 0.426262 | webhook.ex | starcoder |
defmodule Xema.Builder do
@moduledoc """
This module contains some convenience functions to generate schemas.
## Examples
iex> import Xema.Builder
...> schema = Xema.new integer(minimum: 1)
...> Xema.valid?(schema, 6)
true
...> Xema.valid?(schema, 0)
false
"""
alias Xema... | lib/xema/builder.ex | 0.911269 | 0.410815 | builder.ex | starcoder |
defmodule Clickhousex.Codec.Binary do
@moduledoc false
use Bitwise
def encode(:varint, num) when num < 128, do: <<num>>
def encode(:varint, num), do: <<fc00:e968:6179::de52:7100, num::7, encode(:varint, num >>> 7)::binary>>
def encode(:string, str) when is_bitstring(str) do
[encode(:varint, byte_size(s... | lib/clickhousex/codec/binary.ex | 0.577853 | 0.423577 | binary.ex | starcoder |
defmodule Ash.Query.Function do
@moduledoc """
A function is a predicate with an arguments list.
For more information on being a predicate, see `Ash.Filter.Predicate`. Most of the complexities
are there. A function must meet both behaviours.
"""
alias Ash.Query.{BooleanExpression, Call, Not, Ref}
@type... | lib/ash/query/function/function.ex | 0.834576 | 0.425337 | function.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.