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 ExType.Type do
@moduledoc false
alias ExType.Assert
@type t ::
ExType.Type.Any.t()
| ExType.Type.None.t()
| ExType.Type.Union.t()
| ExType.Type.Intersection.t()
| ExType.Type.Protocol.t()
| ExType.Type.GenericProtocol.t()
| ExType.T... | lib/ex_type/type.ex | 0.713531 | 0.714504 | type.ex | starcoder |
defmodule Cizen.EffectHandler do
@moduledoc """
Handles effects.
"""
alias Cizen.Effect
alias Cizen.Event
alias Cizen.Request.Response
alias Cizen.SagaID
@type state :: %{
handler: SagaID.t(),
effect: Effect.t() | nil,
effect_state: term,
event_buffer: list(Even... | lib/cizen/effect_handler.ex | 0.823541 | 0.446193 | effect_handler.ex | starcoder |
defmodule Crawly do
@moduledoc """
Crawly is a fast high-level web crawling & scraping framework for Elixir.
"""
@doc """
Fetches a given url. This function is mainly used for the spiders development
when you need to get individual pages and parse them.
The fetched URL is being converted to a request, a... | lib/crawly.ex | 0.848737 | 0.50891 | crawly.ex | starcoder |
defmodule Artour.Admin do
@moduledoc """
The Admin context.
"""
import Ecto.Query, warn: false
alias Artour.Repo
alias Artour.Post
alias Artour.PostTag
alias Artour.Format
# alias Artour.Category
alias Artour.Image
# alias Artour.PostImage
@doc """
Returns the list of posts.
"""
def lis... | apps/artour/lib/artour/admin/admin.ex | 0.729134 | 0.416945 | admin.ex | starcoder |
defmodule Identicon do
@moduledoc """
Converts a string into an identicon
This module uses md5 encoding to convert string into a binary
We save the binary into a list
we select the first 3 elements in the list to select the color for identicon
The full list will be match to first 3 x 5 grids from identicon... | identicon/lib/identicon.ex | 0.868381 | 0.649155 | identicon.ex | starcoder |
require Utils
require Program
defmodule D11 do
@moduledoc """
--- Day 11: Space Police ---
On the way to Jupiter, you're pulled over by the Space Police.
"Attention, unmarked spacecraft! You are in violation of Space Law! All spacecraft must have a clearly visible registration identifier! You have 24 hours to... | lib/days/11.ex | 0.742235 | 0.695454 | 11.ex | starcoder |
defmodule Sanbase.Utils.Transform do
def to_bang(result) do
case result do
{:ok, result} -> result
{:error, error} -> raise error
end
end
@doc ~s"""
Combine all the MapSets from the mapsets_list either by
taking their intersection or their union. The decision is
made based on the `:comb... | lib/sanbase/utils/transform.ex | 0.877503 | 0.641478 | transform.ex | starcoder |
defmodule EWallet.Web.Paginator do
@moduledoc """
The Paginator allows querying of records by page. It takes in a query, break the query down,
then selectively query only records that are within the given page's scope.
"""
import Ecto.Query
alias EWalletDB.Repo
@default_per_page 10
@default_max_per_pag... | apps/ewallet/lib/ewallet/web/paginator.ex | 0.827793 | 0.418905 | paginator.ex | starcoder |
defmodule NewRelic.Util.AttrStore do
# This is an abstraction around an ETS table that lets us store efficently
# store and access arbitrary key->value pairs for all Transactions we are tracking
@moduledoc false
def new(table) do
:ets.new(table, [
:named_table,
:duplicate_bag,
:public,
... | lib/new_relic/util/attr_store.ex | 0.599954 | 0.595404 | attr_store.ex | starcoder |
defmodule GGityDemoWeb.ScatterLive do
use GGityDemoWeb, :live_view
alias GGity.Plot
import GGity.Element.{Line, Rect, Text}
@mtcars_data GGity.Examples.mtcars()
|> Enum.map(fn record ->
Enum.map(record, fn {key, value} -> {to_string(key), value} end)
|> Enum.in... | lib/ggity_demo_web/live/scatter_live.ex | 0.709221 | 0.450843 | scatter_live.ex | starcoder |
defrecord EEx.State, engine: EEx.SmartEngine, dict: [], file: 'nofile', line: 1, start_line: 1
defmodule EEx.Compiler do
@moduledoc false
@doc """
This is the compilation entry point. It glues the tokenizer
and the engine together by handling the tokens and invoking
the engine every time a full expression o... | lib/eex/lib/eex/compiler.ex | 0.709623 | 0.575409 | compiler.ex | starcoder |
defmodule ExDgraph.Expr.Uid do
@moduledoc """
Helper functions to deal with uids. Not in use yet. Intended for query builder.
https://docs.dgraph.io/query-language/#uid
## Syntax Examples:
q(func: uid(<uid>))
predicate @filter(uid(<uid1>, ..., <uidn>))
predicate @filter(uid(a)) for variable... | lib/exdgraph/expr/uid.ex | 0.786869 | 0.562717 | uid.ex | starcoder |
import TypeClass
defclass Witchcraft.Ord do
@moduledoc ~S"""
`Ord` describes how to order elements of a data type.
This is a total order, so all elements are either `:equal`, `:greater`, or `:lesser`
than each other.
## Type Class
An instance of `Witchcraft.Ord` must also implement `Witchcraft.Setoid`,
... | lib/witchcraft/ord.ex | 0.896109 | 0.669454 | ord.ex | starcoder |
defmodule CloudEvents.Event do
@moduledoc """
Module that defines a struct and functions for handling CloudEvents.
Currently implements the 1.0 specversion of CloudEvents.
https://github.com/cloudevents/spec/blob/v1.0/spec.md
"""
@specversion "1.0"
defstruct [
:id,
:source,
:type,
:data... | lib/cloudevents/event.ex | 0.92361 | 0.420064 | event.ex | starcoder |
defmodule Extractly.Xtra do
alias Extractly.Messages, as: M
alias Extractly.Toc.Options
@moduledoc """
This wraps `Extractly's` API by putting all messages to be logged to the
`Extractly.Messages` module.
Its primarty use case is for `Mix.Tasks.Xtra` which will pass this module
as a param into the `EEx`... | lib/extractly/xtra.ex | 0.78838 | 0.782455 | xtra.ex | starcoder |
defmodule Eunomo.Formatter.AlphabeticalExpressionSorter do
@moduledoc false
# This module is only meant to be used for alias & import expressions!
alias Eunomo.LineMap
defmodule LineModificationConflict do
@moduledoc false
defexception message: """
Please report a bug.
... | lib/eunomo/formatter/alphabetical_expression_sorter.ex | 0.817392 | 0.509642 | alphabetical_expression_sorter.ex | starcoder |
defmodule Adventofcode.Day19Tubes do
defstruct grid: nil,
width: 0,
height: 0,
seen: [],
steps: 0,
position: {0, 0},
direction: {0, 1}
def what_letters(input) do
input
|> new()
|> travel()
|> seen_letters()
end
def how_man... | lib/day_19_tubes.ex | 0.64131 | 0.627923 | day_19_tubes.ex | starcoder |
defmodule ExAudit.Repo do
@moduledoc """
Adds ExAudit version tracking to your Ecto.Repo actions. The following functions are
extended to detect if the given struct or changeset is in the list of :tracked_schemas
given in :ex_audit config:
insert: 2,
update: 2,
insert_or_update: 2,
delete: 2,
... | lib/repo/repo.ex | 0.827932 | 0.716529 | repo.ex | starcoder |
defmodule ExTwilio.Notify.Binding do
@moduledoc """
Represents a Binding resource in the Twilio Notify.
- [Twilio docs](https://www.twilio.com/docs/notify/api/bindings)
- identity The Identity to which this Binding belongs to. Identity is defined
by your application. Up to 20 Bindings can be created for the... | lib/ex_twilio/resources/notify/binding.ex | 0.729134 | 0.447158 | binding.ex | starcoder |
defmodule Bricks.Socket do
@moduledoc """
A Socket represents a *connected* Socket - that is it is
manufactured *after* a connection has been established.
As in Erlang/OTP, a Socket is owned by a single process, the
owner. No other process may interact with the Socket, but the owner
can hand off ownership... | bricks/lib/socket.ex | 0.911017 | 0.503906 | socket.ex | starcoder |
defprotocol Flop.Schema do
@moduledoc """
This protocol allows you to set query options in your Ecto schemas.
## Usage
Derive `Flop.Schema` in your Ecto schema and set the filterable and sortable
fields.
defmodule Flop.Pet do
use Ecto.Schema
@derive {Flop.Schema,
fil... | lib/flop/schema.ex | 0.881155 | 0.546012 | schema.ex | starcoder |
defmodule Tenantex.Repo do
import Application, only: [get_env: 2]
import Tenantex.Prefix
import Mix.Tenantex
defmacro __using__(opts) do
quote bind_quoted: [opts: opts] do
@behaviour Ecto.Repo
alias Tenantex.TenantMissingError
@repo Keyword.fetch!(opts, :repo)
@untenanted [Ecto.Mig... | lib/tenantex/repo.ex | 0.594904 | 0.539347 | repo.ex | starcoder |
defmodule Witai do
alias Witai.Client, as: Client
@base_url "https://api.wit.ai"
@version "20201023"
def message("") do
{:noreply, %{}}
end
@spec message(binary) :: {atom, %{}}
def message(term) when is_binary(term) do
%{
"entities" => entities,
"... | lib/witai.ex | 0.722233 | 0.562927 | witai.ex | starcoder |
defmodule Cuid do
@moduledoc """
Collision-resistant ids.
Usage:
```elixir
Cuid.generate()
``
"""
@opaque state :: {binary(), :ets.tid()}
@base 36
@discrete_values @base * @base * @base * @base
@max_discrete_value @discrete_values - 1
@two_discrete_values @discrete_values * @discrete_values
... | lib/cuid.ex | 0.750187 | 0.775775 | cuid.ex | starcoder |
defmodule KB do
import Utils
#---- Knowledge base
@doc """
Initializes an empty knowledge base.
"""
def init(), do: []
@doc """
Returns all facts in the knowledge base.
"""
def facts(kb), do: Enum.filter(kb, fn thing -> elem(thing, 0) == :fact end)
@doc """
Returns all rules in the knowledge... | lib/kb.ex | 0.671686 | 0.477493 | kb.ex | starcoder |
defmodule Dicon do
@moduledoc """
Simple release deliverer for Elixir.
Dicon gets most of the information needed to deploy and manage releases from
the configuration of the `:dicon` application. For example, in your
application's configuration (`my_app/config/config.exs`):
config :dicon,
targe... | lib/dicon.ex | 0.880855 | 0.515559 | dicon.ex | starcoder |
defmodule Dicon.Executor do
@moduledoc """
Behaviour for executors.
This behaviour specifies the callbacks that executors must implement. Look at
the documentation for the `Dicon` module for more information about executors.
"""
alias Dicon.SecureShell
@type conn :: identifier | struct
@type t :: %_... | lib/dicon/executor.ex | 0.880508 | 0.489137 | executor.ex | starcoder |
defmodule EctoTemp.Factory do
@doc """
Inserts values into a temporary table.
## Params:
* struct (optional) - a struct defined the schema used by the data migration.
* table_name
* attrs (optional) - a keyword list of attributes to insert
## Notes:
* If not given a struct, and the temporary... | lib/ecto_temp/factory.ex | 0.747063 | 0.640369 | factory.ex | starcoder |
defmodule Harnais.Form do
@moduledoc ~S"""
Functions for Testing Quoted Forms
## Documentation Terms
In the documentation these terms, usually in *italics*, are used to mean the same thing.
### *form* and *forms*
A *form* is a quoted form (`Macro.t`). A *forms* is a list of zero, one or more *form*s
... | lib/form.ex | 0.88397 | 0.565779 | form.ex | starcoder |
defmodule Primer.Elements do
@moduledoc """
Functions for displaying common elements that are present on GitHub-authored sites.
"""
use Phoenix.HTML
defmodule MissingConfigurationError do
defexception [:missing_keys]
def exception(key) when is_atom(key), do: exception([key])
def exception(keys)... | lib/primer/elements.ex | 0.838993 | 0.84228 | elements.ex | starcoder |
defmodule NewtonIteration do
@moduledoc """
The NewtonIteration module implements the computation of roots of
real functions using Newton's method.
"""
@doc ~S"""
Runs Newton's iteration
`f` is an anonymous function of one real variable and `fp` is the
derivative of `f`.
`start_value` is the fir... | lib/newton_iteration.ex | 0.946324 | 0.951639 | newton_iteration.ex | starcoder |
defmodule TtrCore.Mechanics do
@moduledoc """
Game play mechanics, rules and state transformer.
"""
@type cost :: integer
@type count :: integer
alias TtrCore.{
Board,
Cards,
Players
}
alias TtrCore.Mechanics.{
Context,
OtherPlayer,
Score,
State
}
alias TtrCore.Player... | lib/ttr_core/mechanics.ex | 0.914477 | 0.512022 | mechanics.ex | starcoder |
defmodule Exhort.SAT.Constraint do
@moduledoc """
A constraint on the model.
> #### Suggestion {: .warning}
>
> Consider using `Exhort.SAT.Expr` instead of using this module directly.
The binary constraints are:
```
:< | :<= | :== | :>= | :> | :"abs=="
```
The list constraints are:
```
:"al... | lib/exhort/sat/constraint.ex | 0.889942 | 0.960287 | constraint.ex | starcoder |
defmodule CImg.Builder do
@moduledoc """
Build and excecute image processing sequence.
** under construction **
"""
alias __MODULE__
alias CImg.NIF
# builder object
# :handle - work image.
# :src - source image.
# :script - image operations
defstruct handle: nil, src: nil, script: []
... | lib/cimg/builder.ex | 0.879283 | 0.762778 | builder.ex | starcoder |
defmodule Noegle.Schema do
@moduledoc """
Add authentication support to your User schema module.
Example:
```elixir
defmodule MyApp.User do
use MyApp.Web, :model
use Noegle.Schema
```
The following functions are available:
* `hash_password/1` - hashes a password string using `Comeonin.... | lib/noegle/schema.ex | 0.884984 | 0.622459 | schema.ex | starcoder |
defmodule Esolix.Langs.Brainfuck do
@moduledoc """
Documentation for the Brainfuck Module.
"""
# > Move the pointer to the right
# < Move the pointer to the left
# + Increment the memory cell at the pointer
# - Decrement the memory cell at the pointer
# . Output the character signified by the cell at t... | lib/langs/brainfuck.ex | 0.639286 | 0.514583 | brainfuck.ex | starcoder |
defmodule Blockchain.Extensions.SmartContracts do
@moduledoc """
Smart contracts
"""
alias Blockchain.Transaction
alias Blockchain.Wallet
@typedoc """
Represents the possible operators that can be used in a contract
"""
@type operator :: :+ | :* | :- | :== | :> | :< | :and | :or
@typedoc """
Re... | lib/blockchain/extensions/smart_contracts.ex | 0.758242 | 0.575051 | smart_contracts.ex | starcoder |
defmodule Droll do
@moduledoc """
Simple implementation of standard dice notation
See [The Wikipedia Page](https://en.wikipedia.org/wiki/Dice_notation) for
more information.
"""
alias Droll.{Result, Formula}
@doc """
Parse a standard dice notation formula
Examples:
iex> Droll.parse("d20")
... | lib/droll.ex | 0.857037 | 0.615521 | droll.ex | starcoder |
defmodule TimeZoneInfo.DataPersistence.FileSystem do
@moduledoc """
An implementation for the behaviour `TimeZoneInfo.DataPersistence` to persist
data in the file system.
"""
@behaviour TimeZoneInfo.DataPersistence
alias File.Stat
alias TimeZoneInfo.ExternalTermFormat
@impl true
def put(data) do
... | lib/time_zone_info/data_persistence/file_system.ex | 0.76999 | 0.435421 | file_system.ex | starcoder |
defmodule OpenGraph do
defstruct [
# Basic Metadata
:title,
:type,
:image,
:url,
# Optional Metadata
:audio,
:description,
:determiner,
:locale,
:site_name,
:video
]
@type value() :: String.t() | nil
@type t() :: %__MODULE__{
title: value(),
... | lib/open_graph.ex | 0.895573 | 0.481941 | open_graph.ex | starcoder |
defmodule SharedSettings do
@moduledoc ~S"""
SharedSettings is a library for fetching and updating settings at runtime.
The goal of this is to provide a simple, language-agnostic storage interface
as well as an accompanying Ruby gem (TODO) and UI. This is not intended
to be a fully-fledged feature flagging ... | lib/shared_settings.ex | 0.807081 | 0.522202 | shared_settings.ex | starcoder |
defmodule Geometry.WKT.Parser do
@moduledoc false
import Geometry.WKT.Parsers
@spec parse(Geometry.wkt()) ::
{:ok, Geometry.t() | {Geometry.t(), Geometry.srid()}} | Geometry.wkt_error()
def parse(string) do
with {:ok, [info], rest, _context, line, byte_offset} <- geometry(string),
{:ok,... | lib/geometry/wkt/parser.ex | 0.787237 | 0.57093 | parser.ex | starcoder |
defmodule Mix do
@moduledoc ~S"""
Mix is a build tool that provides tasks for creating, compiling,
and testing Elixir projects, managing its dependencies, and more.
## Mix.Project
The foundation of Mix is a project. A project can be defined by using
`Mix.Project` in a module, usually placed in a file name... | lib/mix/lib/mix.ex | 0.880348 | 0.642853 | mix.ex | starcoder |
defmodule CoursePlanner.Classes.Summaries do
@moduledoc """
Provides helper functions for the summary page
"""
import Ecto.Query
alias CoursePlanner.{Repo, Terms.Term, Courses.OfferedCourse, Tasks.Task, Settings}
alias Ecto.DateTime
def get_term_offered_course_for_user(user) do
get_term_offered_co... | lib/course_planner/classes/summaries.ex | 0.568775 | 0.512937 | summaries.ex | starcoder |
defmodule BPXE.Engine.PrecedenceGateway do
@moduledoc """
*Note: This gateway is not described in BPMN 2.0. However, it's available through
BPXE's extension schema.*
This gateway will only process the first model of a received token
(tracked by token_id) and send it out to a corresponding output. The
corre... | lib/bpxe/engine/precedence_gateway.ex | 0.73914 | 0.408395 | precedence_gateway.ex | starcoder |
defmodule Geocalc.Calculator do
@moduledoc false
alias Geocalc.Point
@earth_radius 6_371_000
@pi :math.pi()
@epsilon 2.220446049250313e-16
@intersection_not_found "No intersection point found"
def distance_between(point_1, point_2, radius \\ @earth_radius) do
fo_1 = degrees_to_radians(Point.latitud... | lib/geocalc/calculator.ex | 0.865594 | 0.875893 | calculator.ex | starcoder |
defmodule ShEx.TripleConstraint do
@moduledoc false
defstruct [
# tripleExprLabel?
:id,
# shapeExpr?
:value_expr,
# IRIREF
:predicate,
# BOOL?
:inverse,
# INTEGER?
:min,
# INTEGER?
:max,
# [SemAct+]?
:sem_acts,
# [Annotation+]?
:annotations
]
... | lib/shex/shape_expressions/triple_constraint.ex | 0.558568 | 0.405272 | triple_constraint.ex | starcoder |
defmodule AWS.Lightsail do
@moduledoc """
Amazon Lightsail is the easiest way to get started with AWS for developers
who just need virtual private servers. Lightsail includes everything you
need to launch your project quickly - a virtual machine, SSD-based storage,
data transfer, DNS management, and a static... | lib/aws/lightsail.ex | 0.810291 | 0.588948 | lightsail.ex | starcoder |
defmodule Braintree.PaymentMethod do
@moduledoc """
Create, update, find and delete payment methods. Payment methods
may be a `CreditCard` or a `PaypalAccount`.
"""
alias Braintree.{AndroidPayCard, ApplePayCard, CreditCard, HTTP, PaypalAccount}
alias Braintree.ErrorResponse, as: Error
@doc """
Create ... | lib/payment_method.ex | 0.882228 | 0.428532 | payment_method.ex | starcoder |
defmodule Advent.D7 do
@steps_keywords ["Step ", " must be finished before step ", " can begin."]
def instructions() do
steps =
"inputs/d7.txt"
|> file_to_steps
steps
|> order_steps([])
|> Enum.reverse()
|> Enum.join()
end
def order_steps(steps, order) do
next = next_step(... | lib/advent/d7.ex | 0.525612 | 0.541227 | d7.ex | starcoder |
defmodule Blockchain.Block.HolisticValidity do
@moduledoc """
This module is responsible for holistic validity check, as defined in Eq.(31),
section 4.3.2, of the Yellow Paper - Byzantium Version e94ebda.
"""
alias Blockchain.{Block, Chain, Genesis}
alias MerklePatriciaTree.TrieStorage
@doc """
Determ... | apps/blockchain/lib/blockchain/block/holistic_validity.ex | 0.810629 | 0.435481 | holistic_validity.ex | starcoder |
defmodule GraphQL.Type.Interface do
alias GraphQL.Type.AbstractType
@type t :: %GraphQL.Type.Interface{
name: binary,
description: binary | nil,
fields: Map.t | function,
resolver: (any -> GraphQL.Type.ObjectType.t) | nil
}
defstruct name: "", description: "", fields: %{}, resolver: nil
def... | lib/graphql/type/interface.ex | 0.671363 | 0.458773 | interface.ex | starcoder |
defmodule Sobelow.Misc.FilePath do
@moduledoc ~S"""
# Insecure use of `File` and `Path`
In Elixir, `File` methods are null-terminated, while `Path`
functions are not. This may cause security issues in certain
situations. For example:
```
user_input = "/var/www/secret.txt\0/name"
path = Path.dirname(u... | lib/sobelow/misc/file_path.ex | 0.717012 | 0.694821 | file_path.ex | starcoder |
defmodule Cizen.Filter do
@moduledoc """
Creates a filter.
## Basic
Filter.new(
fn %Event{body: %SomeEvent{field: value}} ->
value == :a
end
)
Filter.new(
fn %Event{body: %SomeEvent{field: :a}} -> true end
)
value = :a
Filter.new(
f... | lib/cizen/filter.ex | 0.726911 | 0.537709 | filter.ex | starcoder |
require Pedro.Helpers, as: H
defmodule Pedro.Db.Repo do
@moduledoc """
Helpers to interact with Mnesia in single node mode.
"""
@tables [Pedro.Db.EntryQueue, Pedro.Db.Messages, Pedro.Db.Throttles]
@doc """
create_schema and then start Mnesia in single node mode
Returns `:ok` or `{:error, reason}`
... | lib/pedro/db/repo.ex | 0.691602 | 0.412708 | repo.ex | starcoder |
defmodule Pbkdf2 do
@moduledoc """
Pbkdf2 password hashing library main module.
For a lower-level API, see Pbkdf2.Base.
## Pbkdf2
Pbkdf2 is a password-based key derivation function
that uses a password, a variable-length salt and an iteration
count and applies a pseudorandom function to these to
prod... | deps/pbkdf2_elixir/lib/pbkdf2.ex | 0.911839 | 0.483953 | pbkdf2.ex | starcoder |
defmodule Mix.Tasks.Firmware.Unpack do
use Mix.Task
import Mix.Nerves.Utils
alias Mix.Nerves.Preflight
@shortdoc "Unpack a firmware bundle for inspection"
@moduledoc """
Unpack the firmware so that its contents can be inspected locally.
## Usage
mix firmware.unpack [--output output directory] [-... | lib/mix/tasks/firmware.unpack.ex | 0.795817 | 0.402803 | firmware.unpack.ex | starcoder |
defmodule TreeSet do
defstruct set: nil
@behaviour Set
@implementation :gb_sets
def delete(set, el) do
%{set | :set => @implementation.del_element(el, set.set)}
end
def difference(set1, set2) do
%{set1 | :set => @implementation.difference(set1.set, set2.set)}
end
def disjoint?(set1, set2) do... | lib/structurez/tree_set.ex | 0.625095 | 0.455986 | tree_set.ex | starcoder |
defmodule Membrane.Core.Child.PadsSpecs do
@moduledoc false
# Functions parsing element and bin pads specifications, generating functions and docs
# based on them.
use Bunch
alias Membrane.Caps
alias Membrane.Core.OptionsSpecs
alias Membrane.Pad
require Pad
@spec def_pads([{Pad.name_t(), raw_spec :... | lib/membrane/core/child/pads_specs.ex | 0.847684 | 0.560253 | pads_specs.ex | starcoder |
defmodule Phone do
@moduledoc ~S"""
Phone is a real telephone number parser, that will help you get useful information from numbers.
## How to use
Very simple to use:
iex> Phone.parse("555132345678")
{:ok, %{a2: "BR", a3: "BRA", country: "Brazil", international_code: "55", area_code: "51", number:... | lib/phone.ex | 0.78609 | 0.906901 | phone.ex | starcoder |
defmodule Snap.Bulk do
@moduledoc """
Supports streaming bulk operations against a `Snap.Cluster`.
"""
@default_page_size 5000
@default_page_wait 15_000
alias Snap.Bulk.Actions
@doc """
Performs a bulk operation.
Takes an `Enumerable` of action structs, where each struct is one of:
* `Snap.Bulk... | lib/snap/bulk/bulk.ex | 0.855941 | 0.912436 | bulk.ex | starcoder |
defmodule Euler do
@moduledoc """
This module defines general-purpose functions used in solving Project Euler challenges.
"""
defmacro divides?(d, n) do
quote do
rem(unquote(n), unquote(d)) == 0
end
end
@doc """
Calculates the sum of all natural numbers less than max which have any of th... | lib/euler.ex | 0.695338 | 0.623148 | euler.ex | starcoder |
defmodule Hologram.Compiler.IR do
# TYPES
defmodule AnonymousFunctionType do
defstruct arity: nil, params: [], bindings: [], body: nil
end
defmodule AtomType do
defstruct value: nil
end
defmodule BinaryType do
defstruct parts: []
end
defmodule BooleanType do
defstruct value: nil
en... | lib/hologram/compiler/ir.ex | 0.518059 | 0.839537 | ir.ex | starcoder |
defmodule Evaluation.Adaptations.CombineWithGuaranteesEval do
@moduledoc false
use Observables.GenObservable
alias Reactivity.Processing.Matching
require Logger
def init([imap, tmap, gmap, rtype]) do
Logger.debug("CombineWithGuaranteesEval: #{inspect(self())}")
{:ok, {:buffer, imap, :types, tmap, :g... | lib/evaluation/adaptations/combine_with_guarantees_eval.ex | 0.646125 | 0.417093 | combine_with_guarantees_eval.ex | starcoder |
defmodule Hive.MQ.NodeAgent do
use Agent
require Logger
@moduledoc """
This agent is responsible to keep track of all nodes that are connected
to the network.
"""
@doc """
Starts the agent with an empty map
"""
def start_link(opts \\ []) do
Agent.start_link(fn -> %{} end, opts)
end
@doc "... | lib/hive/mq/node_agent.ex | 0.64579 | 0.442456 | node_agent.ex | starcoder |
defmodule AWS.CognitoIdentity do
@moduledoc """
Amazon Cognito Federated Identities
Amazon Cognito Federated Identities is a web service that delivers scoped
temporary credentials to mobile devices and other untrusted environments.
It uniquely identifies a device and supplies the user with a consistent ide... | lib/aws/generated/cognito_identity.ex | 0.89742 | 0.474753 | cognito_identity.ex | starcoder |
defmodule TypeCheck.Builtin.Map do
defstruct [:key_type, :value_type]
use TypeCheck
@opaque! t :: %__MODULE__{key_type: TypeCheck.Type.t(), value_type: TypeCheck.Type.t()}
@type! problem_tuple ::
{t(), :not_a_map, %{}, any()}
| {t(), :key_error,
%{problem: lazy(TypeCheck.TypeErro... | lib/type_check/builtin/map.ex | 0.643889 | 0.482673 | map.ex | starcoder |
defmodule Tz.PeriodsBuilder do
@moduledoc false
def build_periods(zone_lines, rule_records, mode \\ :compilation, prev_period \\ nil, periods \\ [])
def build_periods([], _rule_records, _mode, _prev_period, periods), do: Enum.reverse(periods)
def build_periods([zone_line | rest_zone_lines], rule_records, mod... | lib/periods_builder.ex | 0.644673 | 0.588002 | periods_builder.ex | starcoder |
defmodule Shake do
@moduledoc """
A Plug-like middleware optimized for search.
Full-text search is build on layers of dependencies:
results <- query <- index <- catalog <- params
The data-processing requirements resembles 'make' - where you assemble
results out of intermediate parts.
At every step... | lib/shake.ex | 0.858719 | 0.660125 | shake.ex | starcoder |
if Code.ensure_loaded?(:fuse) do
defmodule JsonApiClient.Middleware.Fuse do
@moduledoc """
Circuit Breaker middleware using [fuse](https://github.com/jlouis/fuse). In order to use this middleware the
fuse package must be added to your mix project and the `fuse` and `sasl` applications must be started. e.g... | lib/json_api_client/middleware/fuse.ex | 0.860457 | 0.708893 | fuse.ex | starcoder |
defmodule ValidatorsRo.CIF do
@moduledoc """
See `ValidatorsRo`
"""
import ValidatorsRo.Utils, only: [control_sum: 2]
defmacro __using__(_opts) do
quote location: :keep do
@cif_test_key 753217532
|> Integer.digits
|> Enum.reverse
@doc """
Provides validation of Romanian CI... | lib/cif/cif.ex | 0.876112 | 0.77907 | cif.ex | starcoder |
defmodule ElixirRigidPhysics.Geometry.Hull do
@moduledoc """
Hull geometry module.
Hulls are lists of coplanar faces wound CCW (to find normal, follow right-hand rule).
Their center is assumed to be at the origin, but in the absence of a frame that doesn't matter.
"""
alias Graphmath.Vec3
require Recor... | lib/geometry/hull.ex | 0.845209 | 0.560253 | hull.ex | starcoder |
defmodule SwotEx.AcademicTlds do
@moduledoc """
List of tlds that belong to educational institutes.
"""
@academic_tlds ~w(
ac.ae
ac.at
ac.bd
ac.be
ac.cn
ac.cr
ac.cy
ac.fj
ac.gg
ac.gn
ac.id
ac.il
ac.in
ac.ir
ac.jp
ac.ke
ac.kr
ac.ma
ac.m... | lib/swotex/academic_tlds.ex | 0.527073 | 0.560433 | academic_tlds.ex | starcoder |
defmodule Data.NPC do
@moduledoc """
NPC Schema
"""
use Data.Schema
alias Data.Script
alias Data.Event
alias Data.Stats
alias Data.NPCItem
alias Data.NPCSpawner
@fields [
:level,
:name,
:tags,
:status_line,
:status_listen,
:description,
:experience_points,
:currenc... | lib/data/npc.ex | 0.721841 | 0.453806 | npc.ex | starcoder |
defmodule AWS.ElastiCache do
@moduledoc """
Amazon ElastiCache
Amazon ElastiCache is a web service that makes it easier to set up,
operate, and scale a distributed cache in the cloud.
With ElastiCache, customers get all of the benefits of a high-performance,
in-memory cache with less of the administrativ... | lib/aws/generated/elasticache.ex | 0.775775 | 0.606673 | elasticache.ex | starcoder |
defmodule EllipticCurve.PublicKey do
@moduledoc """
Used to convert public keys between struct and .der or .pem formats.
Functions:
- toPem()
- toDer()
- fromPem()
- fromPem!()
- fromDer()
- fromDer!()
"""
alias EllipticCurve.Utils.{Der, BinaryAscii, Point}
alias EllipticCurve.{Curve}
alias ... | lib/publicKey/publicKey.ex | 0.925361 | 0.522019 | publicKey.ex | starcoder |
defmodule EdgehogWeb.Schema.AstarteTypes do
use Absinthe.Schema.Notation
use Absinthe.Relay.Schema.Notation, :modern
alias EdgehogWeb.Middleware
alias EdgehogWeb.Resolvers
@desc """
Describes a set of filters to apply when fetching a list of devices.
When multiple filters are specified, they are appli... | backend/lib/edgehog_web/schema/astarte_types.ex | 0.843283 | 0.632091 | astarte_types.ex | starcoder |
defmodule Exonerate.Filter.Items do
@moduledoc false
@behaviour Exonerate.Filter
@derive Exonerate.Compiler
@derive {Inspect, except: [:context]}
alias Exonerate.Validator
import Validator, only: [fun: 2]
defstruct [:context, :schema, :additional_items, :prefix_size]
def parse(artifact = %{context:... | lib/exonerate/filter/items.ex | 0.731442 | 0.443661 | items.ex | starcoder |
defmodule ForthVM.Words.Math do
@moduledoc """
Math words
"""
alias ForthVM.Process
# ---------------------------------------------
# Basic math operations
# ---------------------------------------------
@doc """
+: ( y x -- n ) sums y to x
"""
def plus(tokens, [y, x | data_stack], return_stack... | lib/forthvm/words/math.ex | 0.813127 | 0.905322 | math.ex | starcoder |
defmodule KiteConnect do
@moduledoc """
Elixir module for the Zerodha Kite Connect API
## Installation
Add `kite_connect` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:kite_connect, "~> 0.1"}
]
end
```
## Setup
Your project should be an OTP application. In your ... | lib/kite_connect.ex | 0.72331 | 0.61832 | kite_connect.ex | starcoder |
defmodule Pokerap.Ez do
@moduledoc """
Helper functions to make pokemon searching more intuitve
"get what I mean" instead of the almost firehose-esk data from the API
"""
alias Pokerap.Env, as: Env
#cleaner to move this out to its own funtion
defp parse_evo(chain) do
[chain["species"]["name"]|Enum.m... | lib/Pokerap/Ez.ex | 0.752831 | 0.562837 | Ez.ex | starcoder |
if Appsignal.live_view?() do
defmodule Appsignal.Phoenix.LiveView do
alias Appsignal.{ErrorHandler, Stacktrace, Transaction, TransactionRegistry, Utils.MapFilter}
import Appsignal.Utils
require Appsignal.Stacktrace
@transaction Application.get_env(:appsignal, :appsignal_transaction, Transaction)
... | lib/appsignal/phoenix/live_view.ex | 0.698946 | 0.458288 | live_view.ex | starcoder |
defmodule TeslaMate.Vehicles.Vehicle.Summary do
import TeslaMate.Convert, only: [miles_to_km: 2, mph_to_kmh: 1]
alias TeslaApi.Vehicle.State.{Drive, Charge}
alias TeslaApi.Vehicle
defstruct [
:display_name,
:state,
:since,
:healthy,
:latitude,
:longitude,
:battery_level,
:ideal... | lib/teslamate/vehicles/vehicle/summary.ex | 0.689828 | 0.561004 | summary.ex | starcoder |
defmodule Contentful.Delivery.Assets do
@moduledoc """
Deals with the loading of assets from a given `Contentful.Space`
See https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/assets.end
## Simple asset calls
A `Contentful.Asset` can be retrieved by its `asset_id`:
i... | lib/contentful_delivery/assets.ex | 0.855731 | 0.445409 | assets.ex | starcoder |
defmodule Explorer.Series do
@moduledoc """
The Series struct and API.
A series can be of the following data types:
* `:float` - 64-bit floating point number
* `:integer` - 64-bit signed integer
* `:boolean` - Boolean
* `:string` - UTF-8 encoded binary
* `:date` - Date type that unwraps to `... | lib/explorer/series.ex | 0.939116 | 0.777785 | series.ex | starcoder |
defmodule BitcoinRpc.Transactions do
@moduledoc """
BitcoinRpc.Transactions allows you to stay connected to an bitcoin wallet and be notified of incomming
or outgoing transactions that affect that wallet.
## Examples
Connect to the bitcoin node using the configured BitcoinRpc connection and listen for new t... | lib/bitcoin_rpc/transactions.ex | 0.84626 | 0.519399 | transactions.ex | starcoder |
defmodule Day21 do
use Tensor
def read_file(path) do
File.stream!(path)
|> parse_input
end
def parse_input(rows) do
rows
|> Enum.map(&parse_rule/1)
|> Enum.reduce([], fn {from, to}, acc -> acc ++ (variations(from) |> Enum.map(&({&1, to}))) end)
|> Map.new
end
def parse_rule(row) d... | lib/day21.ex | 0.620392 | 0.610105 | day21.ex | starcoder |
defmodule Cldr.Calendar.Compiler.Week do
@moduledoc false
defmacro __before_compile__(env) do
config =
Module.get_attribute(env.module, :options)
|> Keyword.put(:calendar, env.module)
|> Cldr.Calendar.Config.extract_options()
|> Cldr.Calendar.Config.validate_config!(:week)
Module.p... | lib/cldr/calendar/backend/week_compiler.ex | 0.868771 | 0.434641 | week_compiler.ex | starcoder |
defmodule Statifier.Schema do
@moduledoc """
A compiled and parsed state chart definition
The Schema Struct:
The fields of a Schema should not be adjusted manually but are publicly
available to read. They are as follows:
* `initial_configuration` - the initial configuration of the machine (root)
* `sta... | impl/ex/lib/schema/schema.ex | 0.884825 | 0.726547 | schema.ex | starcoder |
defmodule Penelope.ML.Vector do
@moduledoc """
This is a the vector library used by the ML modules. It provides an
interface to an efficient binary representation of 32-bit floating point
values. Math is done via the BLAS interface, wrapped in a NIF module.
"""
alias Penelope.NIF, as: NIF
@type t :: bin... | lib/penelope/ml/vector.ex | 0.82347 | 0.689384 | vector.ex | starcoder |
defmodule Numbers.Protocols do
@moduledoc """
A set of protocols that can be implemented for your data structure, to add `Numbers`-support to it.
In older versions of `Numbers`, structures were required to follow a single, very strict, behaviour.
But because there are many different kind of structures that b... | lib/numbers/protocols.ex | 0.894775 | 0.789599 | protocols.ex | starcoder |
defmodule ExCmd do
@moduledoc """
ExCmd is an Elixir library to run and communicate with external programs with back-pressure.
"""
@doc """
Runs the given command with arguments and return an Enumerable to read command output.
First parameter must be a list containing command with arguments. example: `["c... | lib/ex_cmd.ex | 0.868255 | 0.858955 | ex_cmd.ex | starcoder |
defmodule Grizzly.ZWave.Commands.NodeAddStatus do
@moduledoc """
Command for NODE_ADD_STATUS
This command is normally the report from adding a node to the Z-Wave network
Params:
* `:seq_number` - the sequence number of the inclusion command
* `:status` - the status of the inclusion
* `:node_id` -... | lib/grizzly/zwave/commands/node_add_status.ex | 0.732209 | 0.45302 | node_add_status.ex | starcoder |
defmodule GoogleMaps.MapData do
alias GoogleMaps.MapData.Path
alias GoogleMaps.MapData.Marker
alias GoogleMaps.MapData.Layers
defmodule Point do
defstruct x: 0, y: 0
@type t :: %__MODULE__{
x: integer,
y: integer
}
end
defmodule Padding do
defstruct left: 0, ... | apps/google_maps/lib/google_maps/map_data.ex | 0.911839 | 0.501282 | map_data.ex | starcoder |
defmodule XQLite3 do
@moduledoc """
SQLite3 driver for Elixir.
"""
alias XQLite3.{Query, Result, Error}
@doc """
Start the connection process and connect to the database.
## Options
* `:path` - the path to the database. If no database exists at that
path, one will be created there. For in-me... | lib/xqlite3.ex | 0.830697 | 0.405302 | xqlite3.ex | starcoder |
# <NAME>
# https://github.com/boone
# https://twitter.com/boonedocks
# Trying to learn Elixir by modeling an Enigma machine, inspired by the Ruby
# code written by @albert_still in:
# http://red-badger.com/blog/2015/02/23/understanding-the-enigma-machine-with-30-lines-of-ruby-star-of-the-2014-film-the-imitation-game
... | lib/enigma.ex | 0.685739 | 0.485478 | enigma.ex | starcoder |
defmodule Vaultag do
@moduledoc """
Vault agent.
A wrapper around `libvault` library.
## Configuration
* `vault` - `libvault` options;
* `ets_table_options` - options for ETS table;
* `token_renewal_time_shift` - a time in seconds;
* `:vault` - `libvault` configuration. See the options for `... | lib/vaultag.ex | 0.780035 | 0.47993 | vaultag.ex | starcoder |
defmodule BMP280.BME680Sensor do
@moduledoc false
alias BMP280.{BME680Calibration, BME680Comm, Calc, Comm, Measurement}
@behaviour BMP280.Sensor
@type raw_samples() :: %{
raw_pressure: non_neg_integer(),
raw_temperature: non_neg_integer(),
raw_humidity: non_neg_integer(),
... | lib/bmp280/sensor/bme680_sensor.ex | 0.824427 | 0.547464 | bme680_sensor.ex | starcoder |
defmodule RlStudy.DP.PolicyIterationPlanner do
alias RlStudy.DP.PolicyIterationPlanner
alias RlStudy.DP.Planner
alias RlStudy.MDP.Environment
require Logger
@type t :: %RlStudy.DP.PolicyIterationPlanner{
env: Environment.t(),
log: [] | [binary()],
policy: [any()]
}
def... | lib/dp/policy_iteration_planner.ex | 0.778607 | 0.665963 | policy_iteration_planner.ex | starcoder |
defmodule Chisel.Renderer do
@moduledoc """
The renderer is capable of draw the text on any target using for that
a function that receives the x, y coordinates of the pixel to be painted.
"""
alias Chisel.Font
alias Chisel.Font.Glyph
@draw_default_opts [
size_x: 1,
size_y: 1
]
@type acc :: ... | lib/chisel/renderer.ex | 0.870501 | 0.560253 | renderer.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.