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 IntSet do
use Bitwise
@moduledoc """
Efficiently store and index a set of non-negative integers.
A set can be constructed using `IntSet.new/0`:
iex> IntSet.new
#IntSet<[]>
An `IntSet` obeys the same set semantics as `MapSet`, and provides
constant-time operations for insertion, de... | lib/int_set.ex | 0.91204 | 0.709001 | int_set.ex | starcoder |
defmodule Zap.Entry do
@moduledoc false
use Bitwise
@type header :: %{
size: non_neg_integer(),
name: String.t(),
nsize: non_neg_integer()
}
@type entity :: %{
crc: pos_integer(),
size: non_neg_integer(),
usize: non_neg_integer(),
... | lib/zap/entry.ex | 0.771026 | 0.444806 | entry.ex | starcoder |
defmodule DoIt.Option do
@moduledoc false
import DoIt.Helper, only: [validate_list_type: 2]
@option_types [:boolean, :count, :integer, :float, :string]
@type t :: %__MODULE__{
name: atom,
type: atom,
description: String.t(),
alias: atom,
default: String.t() |... | lib/do_it/option.ex | 0.626924 | 0.427994 | option.ex | starcoder |
defmodule ExcellentMigrations.DangersDetector do
@moduledoc """
This module finds potentially dangerous or destructive database operations in a given
migration AST.
"""
alias ExcellentMigrations.{
AstParser,
ConfigCommentsParser,
DangersFilter
}
@type ast :: list | tuple | atom | String.t()
... | lib/dangers_detector.ex | 0.848643 | 0.525856 | dangers_detector.ex | starcoder |
defimpl Timex.Convertable, for: Map do
alias Timex.Convertable
def to_gregorian(map), do: try_convert(map, &Convertable.to_gregorian/1)
def to_julian(map), do: try_convert(map, &Convertable.to_julian/1)
def to_gregorian_seconds(map), do: try_convert(map, &Convertable.to_gregorian_seconds/1)
... | lib/convert/map.ex | 0.632389 | 0.67277 | map.ex | starcoder |
defmodule Timex.Date do
@moduledoc """
This module represents all functions specific to creating/manipulating/comparing Dates (year/month/day)
"""
defstruct calendar: :gregorian, day: 1, month: 1, year: 0
alias __MODULE__
alias Timex.DateTime
alias Timex.TimezoneInfo
alias Timex.Helpers
use Timex.Con... | lib/date/date.ex | 0.906118 | 0.564279 | date.ex | starcoder |
defmodule AdventOfCode.Day14 do
@typep pair :: {byte(), byte()}
@typep pairs :: Map.t(pair(), integer())
@typep rule :: {pair(), {pair(), pair()}}
@typep rules :: Map.t(pair(), {pair(), pair()})
@spec part1([binary()]) :: integer()
@spec part2([binary()]) :: integer()
def part1(args), do: parse_args(args... | lib/advent_of_code/day_14.ex | 0.859487 | 0.417717 | day_14.ex | starcoder |
defmodule Hologram.Template.EmbeddedExpressionParser do
alias Hologram.Compiler.{Context, Transformer}
alias Hologram.Compiler.Parser, as: CompilerParser
alias Hologram.Template.{TokenHTMLEncoder, Tokenizer}
alias Hologram.Template.VDOM.{Expression, TextNode}
@doc """
Splits a string which may contain embe... | lib/hologram/template/embedded_expression_parser.ex | 0.650245 | 0.427516 | embedded_expression_parser.ex | starcoder |
defmodule SimpleCipher do
@alphabet "abcdefghijklmnopqrstuvwxyz" |> String.graphemes()
@alphabet_size @alphabet |> length
for key_char <- @alphabet do
shifted_alphabet =
Stream.cycle(@alphabet)
|> Stream.drop_while(&(&1 != key_char))
|> Enum.take(@alphabet_size)
for {plain, cipher} <- ... | exercises/practice/simple-cipher/.meta/example.ex | 0.853699 | 0.589805 | example.ex | starcoder |
defmodule Component.Builder do
@moduledoc """
Conveniences for building components.
This module can be `use`-d into a module in order to build a component
pipeline:
defmodule MyApp do
use Component.Builder
component Component.Logger, some: :option
component :a_component_function... | lib/component/builder.ex | 0.866429 | 0.589657 | builder.ex | starcoder |
defmodule Markright.Collectors.OgpTwitter do
@moduledoc ~S"""
Collector that basically builds the Open Graph Protocol and Twitter Card.
Typical usage:
```elixir
defmodule Sample do
use Markright.Collector, collectors: Markright.Collectors.OgpTwitter
def on_ast(%Markright.Continuation{ast: {tag, _, ... | lib/markright/collectors/ogp_twitter.ex | 0.86609 | 0.792946 | ogp_twitter.ex | starcoder |
defmodule Zaryn.Crypto.Ed25519 do
@moduledoc false
alias __MODULE__.LibSodiumPort
@doc """
Generate an Ed25519 key pair
"""
@spec generate_keypair(binary()) :: {binary(), binary()}
def generate_keypair(seed) when is_binary(seed) and byte_size(seed) < 32 do
seed = :crypto.hash(:sha256, seed)
do_g... | lib/zaryn/crypto/ed25519.ex | 0.728652 | 0.411879 | ed25519.ex | starcoder |
defmodule APIacAuthMTLS do
@behaviour Plug
@behaviour APIac.Authenticator
@moduledoc """
An `APIac.Authenticator` plug implementing **section 2** of
OAuth 2.0 Mutual-TLS Client Authentication and Certificate-Bound Access Tokens
([RFC8705](https://tools.ietf.org/html/rfc8705))
Using this scheme, authent... | lib/apiac_auth_mtls.ex | 0.925894 | 0.805594 | apiac_auth_mtls.ex | starcoder |
defmodule Crux.Gateway.Registry.Generator do
@moduledoc false
# Generates via_ and lookup_ functions for different types of processes.
# Yes, I am overdoing it.
defmacro __using__(_opts) do
quote do
require unquote(__MODULE__)
import unquote(__MODULE__)
@spec _lookup(atom(), term()) ::... | lib/gateway/registry/generator.ex | 0.818737 | 0.668366 | generator.ex | starcoder |
defmodule GrovePi.Board do
@moduledoc """
Low-level interface for sending raw requests and receiving responses from a
GrovePi hat. Automatically started with GrovePi, allows you to use one of the other GrovePi
modules for interacting with a connected sensor, light, or actuator.
To check that your GrovePi har... | lib/grovepi/board.ex | 0.824885 | 0.693719 | board.ex | starcoder |
defmodule Membrane.VideoCutter do
@moduledoc """
Membrane element that cuts raw video.
The element expects each frame to be received in a separate buffer, so the parser
(`Membrane.Element.RawVideo.Parser`) may be required in a pipeline before
the encoder (e.g. when input is read from `Membrane.File.Source`).... | lib/video_cutter.ex | 0.908161 | 0.57943 | video_cutter.ex | starcoder |
defmodule Day3 do
defmodule Extent do
defstruct start_x: 0, start_y: 0, min_x: 0, min_y: 0, max_x: 0, max_y: 0
end
defmodule Point do
defstruct x: 0, y: 0
end
@no_intersection 9_999_999_999_999_999
@type path() :: [Extent.t()]
@spec points_in(Day3.Extent.t()) :: [Day3.Point.t()]
defp points_i... | lib/day3.ex | 0.798933 | 0.700271 | day3.ex | starcoder |
defmodule Confx do
@moduledoc "README.md"
|> File.read!()
|> String.split("<!-- MDOC !-->")
|> Enum.fetch!(1)
@doc """
Returns the configuration specified in the given file
## Options
The accepted options are:
* `defaults`: If some key could not be found, the def... | lib/confx.ex | 0.795181 | 0.410047 | confx.ex | starcoder |
defmodule Pipe do
@moduledoc """
A [conduit](http://hackage.haskell.org/package/conduit) like pipe system for Elixir.
See the [README](README.html) for high level documentation.
"""
use Monad
@typedoc "A pipe which hasn't started running yet"
@type t :: Source.t | Conduit.t | Sink.t
@typedoc "The re... | lib/pipe.ex | 0.890139 | 0.631253 | pipe.ex | starcoder |
defmodule Cryptopunk do
@moduledoc """
Hierarchical deterministic wallet. It has the following features:
- Generate mnemonic
- Generate seed from mnemonic
- Generate master keys from seed
- Derive private and public keys from the master key
- Various utility functions to work with derivation path, keys, ... | lib/cryptopunk.ex | 0.908529 | 0.568655 | cryptopunk.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
By default, the storage directory is `uploads`. But, it can be customized
in two ways.
### By setting up configuration
Customize... | lib/waffle/definition/storage.ex | 0.853837 | 0.48182 | storage.ex | starcoder |
defmodule Geo do
@moduledoc """
A collection of GIS functions. Handles conversions to and from WKT, WKB, and GeoJSON for the following geometries:
* Point
* PointZ
* LineString
* LineStringZ
* Polygon
* PolygonZ
* MultiPoint
* MultiPointZ
* MulitLineString
* MulitLineStringZ
* MultiPolygon
... | lib/geo.ex | 0.861524 | 0.965771 | geo.ex | starcoder |
defmodule AWS.Ivs do
@moduledoc """
**Introduction**
The Amazon Interactive Video Service (IVS) API is REST compatible, using a
standard HTTP API and an [AWS SNS](http://aws.amazon.com/sns) event stream
for responses. JSON is used for both requests and responses, including
errors.
The API is an AWS reg... | lib/aws/ivs.ex | 0.909513 | 0.588919 | ivs.ex | starcoder |
defmodule Poison.EncodeError do
defexception value: nil, message: nil
def message(%{value: value, message: nil}) do
"unable to encode value: #{inspect value}"
end
def message(%{message: message}) do
message
end
end
defmodule Poison.Encode do
defmacro __using__(_) do
quote do
defp encode... | deps/poison/lib/poison/encoder.ex | 0.51562 | 0.435541 | encoder.ex | starcoder |
defmodule Absinthe.Type.BuiltIns.Scalars do
use Absinthe.Schema.Notation
@moduledoc false
scalar :integer, name: "Int" do
description """
The `Int` scalar type represents non-fractional signed whole numeric values.
Int can represent values between `-(2^53 - 1)` and `2^53 - 1` since it is
represe... | lib/absinthe/type/built_ins/scalars.ex | 0.902403 | 0.734262 | scalars.ex | starcoder |
defmodule GenServer.Behaviour do
@moduledoc """
This module is a convenience for defining GenServer callbacks in Elixir.
A server is responsible for reacting to messages received from a client.
A GenServer is an OTP behaviour that encapsulates common server
functionalities.
## Example
Below is an examp... | lib/elixir/lib/gen_server/behaviour.ex | 0.75274 | 0.484075 | behaviour.ex | starcoder |
defmodule Kernel.Typespec do
@moduledoc """
Provides macros and functions for working with typespecs.
Elixir comes with a notation for declaring types and specifications. Elixir is
dynamically typed, as such typespecs are never used by the compiler to
optimize or modify code. Still, using typespecs is useful... | lib/elixir/lib/kernel/typespec.ex | 0.898828 | 0.74644 | typespec.ex | starcoder |
defmodule Rajska.ObjectScopeAuthorization do
@moduledoc """
Absinthe Phase to perform object scoping.
Authorizes all Absinthe's [objects](https://hexdocs.pm/absinthe/Absinthe.Schema.Notation.html#object/3) requested in a query by checking the value of the field defined in each object meta `scope`.
## Usage
... | lib/middlewares/object_scope_authorization.ex | 0.86771 | 0.850344 | object_scope_authorization.ex | starcoder |
defmodule AWS.StorageGateway do
@moduledoc """
AWS Storage Gateway Service
AWS Storage Gateway is the service that connects an on-premises software
appliance with cloud-based storage to provide seamless and secure
integration between an organization's on-premises IT environment and the
AWS storage infrast... | lib/aws/storage_gateway.ex | 0.898916 | 0.588653 | storage_gateway.ex | starcoder |
defmodule AWS.WorkMail do
@moduledoc """
Amazon WorkMail is a secure, managed business email and calendaring service with
support for existing desktop and mobile email clients.
You can access your email, contacts, and calendars using Microsoft Outlook, your
browser, or other native iOS and Android email app... | lib/aws/generated/work_mail.ex | 0.713332 | 0.406567 | work_mail.ex | starcoder |
defmodule PollutionData do
@moduledoc """
Loading data from file to the pollution server using Enum.
"""
@doc """
Gets lines from CSV file as list.
Returns list.
"""
def import_lines_from_CSV do
lines = File.read!("pollution.csv")
|> String.split("\r\n")
lines
end
@doc """
M... | src/pollution_data.ex | 0.896494 | 0.538194 | pollution_data.ex | starcoder |
defmodule RRulex.Parser do
alias RRulex.Util
@moduledoc """
Parses an RRULE from the (iCalendar RFC-2445)[https://www.ietf.org/rfc/rfc2445.txt] a into RRulex%{}
"""
@frequencies %{
"SECONDLY" => :secondly,
"MINUTELY" => :minutely,
"HOURLY" => :hourly,
"DAILY" => :daily,
"WEEKLY" => :week... | lib/rrulex/parser.ex | 0.695028 | 0.465934 | parser.ex | starcoder |
defmodule DataQuacker.Schema do
@moduledoc ~S"""
Defines macros for creating data schemas
which represents a mapping from the source to the desired output.
> Note: To use the macros you have to put `use DataQuacker.Schema` in the desired module.
A schema can be defined to represent the structure of an arbit... | lib/schema/schema.ex | 0.919154 | 0.987055 | schema.ex | starcoder |
defmodule Grapevine.Gossip.Rumor.State do
@moduledoc """
The rumor mongering message state
"""
defstruct [:state, :rounds, :removed_at]
@type t :: %__MODULE__{
state: atom(),
rounds: integer(),
removed_at: nil | integer()
}
@doc """
Returns a new state
## Example... | lib/grapevine/gossip/rumor/state.ex | 0.809163 | 0.509154 | state.ex | starcoder |
defmodule Geo.Turf.Measure do
@moduledoc """
A collection of measurement related tools
"""
import Geo.Turf.Helpers, only: [bbox: 1, flatten_coords: 1]
alias Geo.Turf.Math
@doc """
Takes a LineString and returns a Point at a specified distance along the line.
Note that this will aproximate location to t... | lib/geo/turf/measure.ex | 0.81335 | 0.790934 | measure.ex | starcoder |
defmodule WeightedRoundRobin do
@moduledoc ~S"""
A local, decentralized and scalable weighted round-robin generator.
It allows developers to generate a sequence, evenly distributed, attending a
predefined set of weights attributed to elements of any type. The `take/2`
function is guaranteed to be atomic and ... | lib/weighted_round_robin.ex | 0.924108 | 0.573977 | weighted_round_robin.ex | starcoder |
defmodule ExPBKDF2 do
@moduledoc """
Rust NIf for [Password-Based Key Derivation Function v2 (PBKDF2)](https://en.wikipedia.org/wiki/PBKDF2). It uses the [pbkdf2](https://github.com/RustCrypto/password-hashes/tree/master/pbkdf2) rust library.
"""
alias ExPBKDF2.Impl
@doc """
Generate a random salt
Exam... | lib/ex_pbkdf2.ex | 0.86891 | 0.567427 | ex_pbkdf2.ex | starcoder |
defmodule Resx.Storer do
@moduledoc """
A storer is an interface to perform some side-effect with a resource.
While this is intended for things such as caching, or saving a resource at
some destination. It may also be used for producing other side-effects such
as logging, delivery/dispatch,... | lib/resx/storer.ex | 0.887835 | 0.414928 | storer.ex | starcoder |
defmodule ROS.Node.Spec do
@moduledoc """
A set of functions for declaring ROS abstractions for your Supervisor setup.
Add ROS abstractions to your `lib/my_project/application.ex` like so:
iex> import ROS.Node.Spec
iex> children = [
...> node(:"/mynode", [
...> publisher(:mypub, "c... | lib/ros/node/spec.ex | 0.908933 | 0.758935 | spec.ex | starcoder |
defmodule ExUnit.ClusteredCase do
@moduledoc """
Helpers for defining clustered test cases.
Use this in place of `ExUnit.Case` when defining test modules where
you will be defining clustered tests. `#{__MODULE__}` extends
`ExUnit.Case` to provide additional helpers for those tests.
Since `#{__MODULE__}` i... | lib/clustered_case.ex | 0.908168 | 0.832985 | clustered_case.ex | starcoder |
alias KidsChain.Util
require Record
defmodule KidsChain.DB do
@moduledoc """
A set of functions for working with user over Mnesia.
"""
Record.defrecord(:user, [:uid, :id, :inviter, :name, :content, :from, :to, :address, :at])
@timeout 5000
# Returns a list of user fields.
defmacrop fields(record) do
... | lib/kids_chain/db.ex | 0.843396 | 0.534673 | db.ex | starcoder |
defmodule Mix.Tasks.GitHooks.Run do
@shortdoc "Runs all the configured mix tasks for a given git hook."
@moduledoc """
Runs all the configured mix tasks for a given git hook.
Any [git hook](https://git-scm.com/docs/githooks) is supported.
## Examples
You can run any hook by running `mix git_hooks.run ho... | lib/mix/tasks/git_hooks/run.ex | 0.83508 | 0.77373 | run.ex | starcoder |
defmodule Sanbase.Twitter.Store do
@moduledoc ~S"""
A module for storing and fetching twitter account data from a time series data store
"""
use Sanbase.Influxdb.Store
alias Sanbase.Influxdb.Measurement
alias Sanbase.Twitter.Store
def all_records_for_measurement(measurement_name, from, to, interval) ... | lib/sanbase/twitter/store.ex | 0.776835 | 0.480418 | store.ex | starcoder |
defmodule Teiserver.Coordinator.CoordinatorLib do
alias Teiserver.Data.Types, as: T
@spec help(T.user(), boolean()) :: String.t()
def help(user, host) do
everybody = """
$whoami
Sends back information about who you are
$joinq
Adds you to the queue to join when a space opens up, you will be automatically add... | lib/teiserver/coordinator/coordinator_lib.ex | 0.523177 | 0.451871 | coordinator_lib.ex | starcoder |
defmodule VintageNetWiFi.WPA2 do
@moduledoc """
WPA2 preshared key calculations
WPA2 doesn't use passphrases directly, but instead hashes them with the
SSID and uses the result for the network key. The algorithm that runs
the hash takes some time so it's useful to compute the PSK from the
passphrase once r... | lib/vintage_net_wifi/wpa2.ex | 0.646683 | 0.55266 | wpa2.ex | starcoder |
defmodule Braintree.PaypalAccount do
@moduledoc """
Find, update and delete Paypal Accounts using PaymentMethod token
"""
use Braintree.Construction
alias Braintree.HTTP
alias Braintree.ErrorResponse, as: Error
@type t :: %__MODULE__{
billing_agreement_id: String.t(),
created_at: St... | lib/paypal_account.ex | 0.890079 | 0.412264 | paypal_account.ex | starcoder |
defmodule TinkoffInvest.HistoricalData do
@moduledoc """
Module for getting historical data for a security.
Useful when testing your algo or just need some insight on past prices
"""
alias TinkoffInvest.Market
alias TinkoffInvest.Model.Candle
require Logger
@intervals [
"1min",
"2min",
"3m... | lib/tinkoff_invest/historical_data.ex | 0.875873 | 0.815857 | historical_data.ex | starcoder |
defmodule Timber.Events.CustomEvent do
@moduledoc ~S"""
The `CustomEvent` represents events that aren't covered elsewhere.
The defined structure of this data can be found in the log event JSON schema:
https://github.com/timberio/log-event-json-schema
Custom events can be used to structure information about ... | lib/timber/events/custom_event.ex | 0.914032 | 0.892843 | custom_event.ex | starcoder |
defmodule Pbuf.Tests.Everything do
@moduledoc false
alias Pbuf.Decoder
@derive {Jason.Encoder, except: [:sfixed64, :sint64]}
defstruct [
choice: nil,
bool: false,
int32: 0,
int64: 0,
uint32: 0,
uint64: 0,
sint32: 0,
sint64: 0,
fixed32: 0,
fixed64: 0,
sfixed32: 0,
... | test/schemas/generated/everything.pb.ex | 0.665302 | 0.678548 | everything.pb.ex | starcoder |
defmodule Omise.Transaction do
@moduledoc ~S"""
Provides Transaction API interfaces.
<https://www.omise.co/transactions-api>
"""
use Omise.HTTPClient, endpoint: "transactions"
defstruct object: "transaction",
id: nil,
location: nil,
type: nil,
source: nil,
... | lib/omise/transaction.ex | 0.898756 | 0.439928 | transaction.ex | starcoder |
defmodule Snitch.Data.Schema.TaxRate do
@moduledoc """
Models a TaxRate
"""
use Snitch.Data.Schema
alias Snitch.Data.Schema.{TaxCategory, Zone}
alias Snitch.Domain.Calculator
@type t :: %__MODULE__{}
schema "snitch_tax_rates" do
# associations
belongs_to(:tax_category, TaxCategory)
belong... | apps/snitch_core/lib/core/data/schema/tax_rate.ex | 0.860355 | 0.410845 | tax_rate.ex | starcoder |
defmodule Eml do
@moduledoc """
Eml makes markup a first class citizen in Elixir. It provides a
flexible and modular toolkit for generating, parsing and
manipulating markup. It's main focus is html, but other markup
languages could be implemented as well.
To start off:
This piece of code
```elixir
u... | lib/eml.ex | 0.830353 | 0.785473 | eml.ex | starcoder |
defmodule ExSDP.ConnectionData do
@moduledoc """
This module represents the Connection Information.
The address can be represented by either:
- IPv4 address
- IPv6 address
- FQDN (Fully Qualified Domain Name)
In the case of IPv4 and IPv6 multicast addresses there can be more than one
parsed from si... | lib/ex_sdp/connection_data.ex | 0.712932 | 0.475727 | connection_data.ex | starcoder |
defmodule Bible.Reader do
@moduledoc """
This module provides services related to what parts of the Bible
have been read over periods of time. for example; the following information can be obtained:
1 - Percent of Bible read during a specific period.
2 - List of readings during a specific time period.
3 - ... | lib/bible/reader.ex | 0.672439 | 0.589864 | reader.ex | starcoder |
defmodule Lanyard.Gateway.Utility do
@spec normalize_atom(atom) :: String.t
def normalize_atom(atom) do
atom |> Atom.to_string |> String.downcase |> String.to_atom
end
@doc "Build a binary payload for discord communication"
@spec payload_build(number, map, number, String.t) :: binary
def payload_build(... | lib/gateway/utility.ex | 0.780077 | 0.419856 | utility.ex | starcoder |
defmodule Solution do
@moduledoc """
A Macro-based approach to working with ok/error tuples
This module exposes two main things:
1. guard-clause macros `is_ok/1`, `is_error/1` and `is_okerror/1` (as well as arity-2 variants of the same), to be used whenever you like.
2. `scase/2` and `swith/2`, replacements... | lib/solution.ex | 0.869341 | 0.746486 | solution.ex | starcoder |
defmodule Cuckoo.Bucket do
@moduledoc """
This module implements a Bucket.
"""
@type t :: :array.array()
@doc """
Creates a new bucket with the given size `n`.
"""
@spec new(pos_integer) :: t
def new(n) do
:array.new([{:default, nil}, n, :fixed])
end
@doc """
Sets the entry `index` to `el... | lib/bucket/bucket.ex | 0.90385 | 0.636424 | bucket.ex | starcoder |
defmodule StatBuffer do
@moduledoc """
Defines a stat buffer.
A stat buffer is an efficient way to maintain a local incrementable count with a
given key that can later be flushed to persistent storage. In fast moving systems,
this provides a scalable way keep track of counts without putting heavy loads
on ... | lib/stat_buffer.ex | 0.901107 | 0.644288 | stat_buffer.ex | starcoder |
defmodule Data.Item do
@moduledoc """
Item Schema
"""
use Data.Schema
alias Data.Effect
alias __MODULE__
alias Data.Item.Instance
alias Data.ItemAspecting
alias Data.NPCItem
alias Data.ShopItem
alias Data.Stats
@type instance :: %Instance{}
@types ["basic", "weapon", "armor","resource", "p... | lib/data/item.ex | 0.768516 | 0.415254 | item.ex | starcoder |
defmodule Meilisearch.Search do
@moduledoc """
Collection of functions used to search for documents matching given query.
[MeiliSearch Documentation - Search](https://docs.meilisearch.com/references/search.html)
"""
alias Meilisearch.HTTP
@doc """
Search for documents matching a specific query in the gi... | lib/meilisearch/search.ex | 0.844072 | 0.684771 | search.ex | starcoder |
defmodule DataConverter do
@accident_statuses ["Accident", "Collision", "Spun off"]
@mecahnical_problem_statuses [
"Clutch", "Electrical", "Engine", "Gearbox",
"Hydraulics", "Transmission", "Suspension", "Brakes",
"Mechanical", "Tyre", "Puncture", "Wheel",
"Heat shield fire", "Oil leak", "Water l... | lib/data_converter.ex | 0.544559 | 0.48182 | data_converter.ex | starcoder |
defmodule ExMicrosoftAzureStorage.Storage.Utilities do
@moduledoc """
Utilities
"""
@doc """
Adds a value to a list, which is a value in a dictionary.
## Examples
iex> %{foo: nil} |> ExMicrosoftAzureStorage.Storage.Utilities.add_to(:foo, :a)
%{foo: [:a]}
iex> %{foo: [:a]} |> ExMicrosof... | lib/storage/utilities.ex | 0.863161 | 0.501953 | utilities.ex | starcoder |
defmodule UrbitEx.API.DM do
alias UrbitEx.{API, Actions, Utils, Resource, GraphStore}
alias UrbitEx.API.{Graph}
@moduledoc """
Client API to interact with `dm-hook`, new implementation of direct messaging
Fetch, send, accept and decline DMs.
"""
@doc """
Fetch new DMs. Takes a Session struct, a targe... | lib/api/gall/dm.ex | 0.707101 | 0.407805 | dm.ex | starcoder |
defmodule PEnum do
@moduledoc """
Parallel `Enum`. This library provides a set of functions similar to the
ones in the [Enum](https://hexdocs.pm/elixir/Enum.html) module except that
the function is executed on each element parallel.
The behavior of each of the functions should be the same as the `Enum` varie... | lib/p_enum.ex | 0.889876 | 0.655818 | p_enum.ex | starcoder |
defmodule Cloudinary.Transformation.Effect do
@moduledoc """
The effect parameter of transformations.
To apply an effect without options, pass an `t:atom/0` as a transformation's effect parameter. To
apply with options, use a `t:tuple/0` instead. For details of each options, see the corresponding
documentati... | lib/cloudinary/transformation/effect.ex | 0.938555 | 0.616301 | effect.ex | starcoder |
defmodule Logi.Channel do
@moduledoc """
Log Message Channels.
A channel (logically) receives log messages from loggers and delivers the messages to installed sinks.
## Examples
```elixir
# CREATE CHANNEL
iex> :ok = Logi.Channel.create :sample_log
iex> Logi.Channel.which_channels
[:sample_log, :log... | lib/logi/channel.ex | 0.85289 | 0.665261 | channel.ex | starcoder |
defmodule V3Api.Stream do
@moduledoc """
A GenStage for connecting to the V3Api's Server-Sent Event Stream
capability. Receives events from the API and parses their data.
Subscribers receive events as `%V3Api.Stream.Event{}` structs, which
include the event name and the data as a `%JsonApi{}` struct.
Requi... | apps/v3_api/lib/stream.ex | 0.810066 | 0.414869 | stream.ex | starcoder |
NimbleCSV.define(CsvParser, [])
defmodule Reports.Easymile.Incidents do
def run(params \\ []) do
data = query(params)
|> Stream.map(fn row -> for {key, val} <- row, into: %{}, do: {String.to_atom(key), val} end)
|> Stream.map(fn row -> Map.update!(row, :last_seen, &date_parse/1) end)
|> Enum.into([])... | lib/easymile/incidents.ex | 0.547464 | 0.418251 | incidents.ex | starcoder |
defmodule Earmark.Internal do
@moduledoc ~S"""
All public functions that are internal to Earmark, so that **only** external API
functions are public in `Earmark`
"""
alias Earmark.{Error, Message, Options, SysInterface, Transform}
import Message, only: [emit_messages: 2]
@doc ~S"""
A wrapper to extra... | lib/earmark/internal.ex | 0.808635 | 0.76399 | internal.ex | starcoder |
defmodule USGovData.Parsers.CandidateMaster do
defstruct([
:address1,
:address2,
:city,
:election_year,
:ici,
:id,
:name,
:office_district,
:office_state,
:party,
:pcc,
:state,
:status,
:type,
:zip_code
])
@type candidate_type :: :house | :senate | :pre... | lib/parsers/candidate_master.ex | 0.727298 | 0.492493 | candidate_master.ex | starcoder |
defmodule Interpreter do
@moduledoc """
Interprets a Brainfark program.
To turn the output into text, pass the final state to
`CmdState.render_output/1` and it will convert it into a string.
"""
@doc """
Interpret a parsed Brainfark program.
"""
def interpret(program), do: interpret(program, "")
... | lib/brainfark/interpreter.ex | 0.659076 | 0.598664 | interpreter.ex | starcoder |
defmodule DateTimeParserTestMacros do
@moduledoc false
alias DateTimeParser
alias DateTimeParserTest.Recorder
def to_iso(%NaiveDateTime{} = datetime), do: NaiveDateTime.to_iso8601(datetime)
def to_iso(%DateTime{} = datetime), do: DateTime.to_iso8601(datetime)
def to_iso(%Date{} = date), do: Date.to_iso8601... | test/support/macros.ex | 0.755096 | 0.7036 | macros.ex | starcoder |
defmodule TreeStorage do
@moduledoc """
Documentation for TreeStorage.
"""
@doc """
## Manage tree-like structure.
"""
@tree :tree
@leaf :leaf
def leaf(name, data), do: {@leaf, name, data}
def tree(name, tree), do: check_tree(tree) && {@tree, name, tree}
def find(tree, condition) when is_functi... | lib/tree_storage.ex | 0.597725 | 0.456773 | tree_storage.ex | starcoder |
defmodule Shmex do
@moduledoc """
This module allows using data placed in POSIX shared memory on POSIX
compliant systems.
Defines a struct representing the actual shared memory object. The struct
should not be modified, and should always be passed around as a whole - see
`t:#{inspect(__MODULE__)}.t/0`
""... | lib/shmex.ex | 0.912021 | 0.706937 | shmex.ex | starcoder |
defmodule AdventOfCode.Solutions.Day08 do
@moduledoc """
Solution for day 8 exercise.
### Exercise
https://adventofcode.com/2021/day/8
"""
require Logger
@entry_separator " | "
def calculate_segments(filename, mode) do
entries =
filename
|> File.read!()
|> parse_entries()
... | lib/advent_of_code/solutions/day08.ex | 0.689828 | 0.459561 | day08.ex | starcoder |
defmodule Advent.Sixteen.Thirteen.State do
alias Advent.Helpers.Utility, as: U
alias Advent.Sixteen.Thirteen.State
@favourite_number 1364
#@favourite_number 10
defstruct [:x, :y]
def to_list(state) do
[state.x, state.y]
end
def valid(state) do
x = state.x
y = state.y
(x >= 0 && y >= ... | lib/2016/13.ex | 0.574156 | 0.584123 | 13.ex | starcoder |
defmodule Regex do
@moduledoc ~S"""
Provides regular expressions for Elixir.
"""
defstruct re_pattern: nil, source: "", opts: "", re_version: ""
@type t :: %__MODULE__{re_pattern: term, source: binary, opts: binary}
defmodule CompileError do
defexception message: "regex could not be compiled"
end
... | samples/Elixir/regex.ex | 0.838746 | 0.436682 | regex.ex | starcoder |
defmodule Himamo.Matrix do
@moduledoc ~S"""
Defines a two- or three-dimensional matrix.
## Examples
iex> matrix = Himamo.Matrix.new({2, 3})
...> matrix = Himamo.Matrix.put(matrix, {1, 0}, 0.1)
...> Himamo.Matrix.get(matrix, {1, 0})
0.1
Implements the `Collectable` protocol.
## Exa... | lib/himamo/matrix.ex | 0.888369 | 0.814238 | matrix.ex | starcoder |
defmodule Cards do
@moduledoc """
Documentation for `Cards` module which is used for:
1. Creating a hand/deck of cards.
2. Shuffling a hand/deck cards.
3. Saving a hand/deck.
4. Loading a hand/deck.
5. Assessing if a hand/deck contains a specific card.
"""
defp create_deck_meh() do
suits = [... | cards/lib/cards.ex | 0.895552 | 0.74637 | cards.ex | starcoder |
defmodule Kiq.Job do
@moduledoc """
Used to construct a Sidekiq compatible job.
The job complies with the [Sidekiq Job Format][1], and contains the following
fields:
* `jid` - A 12 byte random number as a 24 character hex encoded string
* `pid` — Process id of the worker running the job, defaults to the c... | lib/kiq/job.ex | 0.886353 | 0.615319 | job.ex | starcoder |
defmodule Adapter.Compile do
@moduledoc false
@doc false
@spec generate(term, Adapter.Utility.behavior(), Adapter.Utility.config()) :: term
def generate(code, callbacks, config)
def generate(code, callbacks, config) do
%{default: default, error: error, log: log, random: random, validate: validate} = con... | lib/adapter/compile.ex | 0.76947 | 0.501526 | compile.ex | starcoder |
defmodule ExDockerBuild.DockerfileParser do
@comment ~r/^\s*#/
@continuation ~r/^.*\\\s*$/
@instruction ~r/^\s*(\w+)\s+(.*)$/
@spec parse_file!(Path.t()) :: list(String.t()) | no_return()
def parse_file!(path) do
path
|> File.read!()
|> do_parse()
end
@spec parse_content!(String.t()) :: list... | lib/ex_docker_build/dockerfile_parser.ex | 0.642881 | 0.433682 | dockerfile_parser.ex | starcoder |
defmodule SubscriptionsTransportWS.Socket do
@external_resource "README.md"
@moduledoc @external_resource
|> File.read!()
|> String.split("<!-- MDOC !-->")
|> Enum.fetch!(1)
require Logger
alias SubscriptionsTransportWS.OperationMessage
alias __MODULE__
@typedoc """... | lib/subscriptions_transport_ws/socket.ex | 0.871146 | 0.500183 | socket.ex | starcoder |
defmodule Timex.Format.Time.Formatters.Default do
@moduledoc """
Handles formatting timestamp values as ISO 8601 durations as described below.
Durations are represented by the format P[n]Y[n]M[n]DT[n]H[n]M[n]S.
In this representation, the [n] is replaced by the value for each of the
date and time elements th... | lib/format/time/formatters/default.ex | 0.916568 | 0.738645 | default.ex | starcoder |
defmodule GameOfLife do
@moduledoc """
Game Of Life implementation in Elixir.
"""
@doc """
Runs the experiment sequentially.
"""
def run_sequentially do
run(&update_world_sequentially/1)
end
@doc """
Runs the experiment by updating every cell in a separate process.
"""
def run_with_spawn d... | gol_elixir/lib/game_of_life.ex | 0.665411 | 0.771069 | game_of_life.ex | starcoder |
defmodule Rustler do
@moduledoc """
Provides compile-time configuration for a NIF module.
When used, Rustler expects the `:otp_app` as option.
The `:otp_app` should point to the OTP application that
the dynamic library can be loaded from.
For example:
defmodule MyNIF do
use Rustler, otp_app... | rustler_mix/lib/rustler.ex | 0.913571 | 0.475666 | rustler.ex | starcoder |
defmodule ExAws.Utils do
@moduledoc false
def identity(x), do: x
def identity(x, _), do: x
def camelize_keys(opts) do
camelize_keys(opts, deep: false)
end
# This isn't tail recursive. However, given that the structures
# being worked upon are relatively shallow, this is ok.
def camelize_keys(opt... | lib/ex_aws/utils.ex | 0.559651 | 0.495545 | utils.ex | starcoder |
defmodule Elsa.Producer do
require Logger
@moduledoc """
Defines functions to write messages to topics based on either a list of endpoints or a named client.
All produce functions support the following options:
* An existing named client process to handle the request can be specified by the keyword option ... | lib/elsa/producer.ex | 0.85984 | 0.637764 | producer.ex | starcoder |
defmodule Timex.Format.DateTime.Formatters.Default do
@moduledoc """
Date formatting language used by default by the formatting functions in Timex.
This is a novel formatting language introduced with `DateFormat`. Its main
advantage is simplicity and usage of mnemonics that are easy to memorize.
## Directiv... | lib/format/datetime/formatters/default.ex | 0.904022 | 0.875148 | default.ex | starcoder |
defmodule Legion.Identity.Telephony.PhoneNumber do
@moduledoc """
Represents a phone number entry of a user.
## Schema fields
- `:user_id`: The reference of the user that phone number belongs to.
- `:number`: The number of the phone.
- `:type`: The type of the phone, e.g. "home", "work".
- `:ignored?`: ... | apps/legion/lib/identity/telephony/phone_number/phone_number.ex | 0.830663 | 0.557153 | phone_number.ex | starcoder |
defmodule Sentry do
use Application
import Supervisor.Spec
alias Sentry.{Event, Config}
require Logger
@moduledoc """
Provides the basic functionality to submit a `Sentry.Event` to the Sentry Service.
## Configuration
Add the following to your production config
config :sentry, dsn: "https://pu... | lib/sentry.ex | 0.877909 | 0.518241 | sentry.ex | starcoder |
defmodule ExGremlin.Graph do
@moduledoc """
Functions for traversing and mutating the Graph.
Graph operations are stored in a queue which can be created with `g/0`.
Mosts functions return the queue so that they can be chained together
similar to how Gremlin queries work.
Example:
```
g.V(1).values("na... | lib/ex_gremlin/graph/graph.ex | 0.913397 | 0.865508 | graph.ex | starcoder |
if Code.ensure_loaded?(Plug) do
defmodule Uinta.Plug do
@moduledoc """
This plug combines the request and response logs into a single line. This
brings many benefits including:
- Removing the need to visually match up the request and response makes it
easier to read your logs and get a full pictu... | lib/uinta/plug.ex | 0.830834 | 0.82226 | plug.ex | starcoder |
defmodule OMG.Performance.ExtendedPerftest do
@moduledoc """
This performance test allows to send out many transactions to a child chain instance of choice.
See `OMG.Performance` for configuration within the `iex` shell using `Performance.init()`
"""
use OMG.Utils.LoggerExt
alias OMG.TestHelper
alias ... | apps/omg_performance/lib/omg_performance/extended_perftest.ex | 0.931774 | 0.80784 | extended_perftest.ex | starcoder |
defmodule Membrane.MPEG.TS.Demuxer do
@moduledoc """
Demuxes MPEG TS stream.
After transition into playing state, this element will wait for
[Program Association Table](https://en.wikipedia.org/wiki/MPEG_transport_stream#PAT) and
[Program Mapping Table](https://en.wikipedia.org/wiki/MPEG_transport_stream#PMT... | lib/membrane_element_mpegts/demuxer.ex | 0.696887 | 0.827689 | demuxer.ex | starcoder |
defmodule ColognePhoneticEx do
@moduledoc """
**Cologne phonetics** (also Kölner Phonetik, Cologne process) is a phonetic
algorithm which assigns to words a sequence of digits, the phonetic code.
The aim of this procedure is that identical sounding words have the same code
assigned to them. The algorithm c... | lib/cologne_phonetic_ex.ex | 0.704262 | 0.527742 | cologne_phonetic_ex.ex | starcoder |
defmodule Mix.Tasks.AshPostgres.Migrate do
use Mix.Task
import AshPostgres.MixHelpers,
only: [migrations_path: 2, tenant_migrations_path: 2, tenants: 2]
@shortdoc "Runs the repository migrations for all repositories in the provided (or congigured) apis"
@aliases [
n: :step
]
@switches [
all:... | lib/mix/tasks/ash_postgres.migrate.ex | 0.733833 | 0.400515 | ash_postgres.migrate.ex | starcoder |
defmodule Snitch.Data.Schema.Address do
@moduledoc """
Models an Address
An `Address` must contain a reference to `Snitch.Data.Schema.Country` and only if the
country has states a reference to a `Snitch.Data.Schema.State`. This means some
Addresses might not have a State.
"""
use Snitch.Data.Schema
a... | apps/snitch_core/lib/core/data/schema/address.ex | 0.874553 | 0.590573 | address.ex | starcoder |
defmodule ScrapyCloudEx.Endpoints.App.Jobs do
@moduledoc """
Wraps the [Jobs](https://doc.scrapinghub.com/api/jobs.html) endpoint.
The jobs API makes it easy to work with your spider’s jobs and lets you schedule,
stop, update and delete them.
"""
import ScrapyCloudEx.Endpoints.Guards
alias ScrapyCloudE... | lib/endpoints/app/jobs.ex | 0.911224 | 0.782164 | jobs.ex | starcoder |
defmodule Quantum.DateLibrary do
@moduledoc """
This Behaviour offers Date Library Independant integration of helper
functions.
**This behaviour is considered internal. Breaking Changes can occur on every
release.**
Make sure your implementation passes `Quantum.DateLibraryTest`. Otherwise
unexpected beh... | lib/quantum/date_library.ex | 0.927569 | 0.550789 | date_library.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.