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 Date.Range do
@moduledoc """
Returns an inclusive range between dates.
Ranges must be created with the `Date.range/2` function.
The following fields are public:
* `:first` - the initial date on the range
* `:last` - the last date on the range
The remaining fields are private and should n... | lib/elixir/lib/calendar/date_range.ex | 0.860296 | 0.762114 | date_range.ex | starcoder |
defmodule Sneex.CpuHelper do
@moduledoc "This module defines helper functions for checking CPU flags."
use Bitwise
@doc "
This function will determine new values for several of the CPU flags.
## Examples
iex> 0 |> Sneex.CpuHelper.check_flags_for_value(:bit8)
%{carry: false, negative: false, overflow: ... | lib/sneex/cpu_helper.ex | 0.876641 | 0.531331 | cpu_helper.ex | starcoder |
defmodule ExOwm do
require Logger
@moduledoc """
ExOwm, OpenWeatherMap API Elixir client.
This module contains main public interface of the application.
"""
@typedoc """
Current weather data API request.
"""
@type request ::
%{city: String.t()}
| %{city: String.t(), country_code:... | lib/ex_owm.ex | 0.890945 | 0.466785 | ex_owm.ex | starcoder |
defmodule RayTracer.Canvas do
@moduledoc """
This module defines methods for drawing pixels
"""
alias RayTracer.Color
alias RayTracer.Matrix
@type t :: %__MODULE__{
width: integer,
height: integer,
pixels: Matrix.matrix
}
@ppm_magic_number "P3"
@ppm_max_color_value 255
@ppm_max_line_l... | lib/canvas.ex | 0.878158 | 0.512449 | canvas.ex | starcoder |
defmodule Ash.DataLayer do
@moduledoc """
The interface for being an ash data layer.
This is a large behaviour, and this capability is not complete, but the idea
is to have a large amount of optional callbacks, and use the `can?/2` callback
to ensure that the engine only ever tries to interact with the data ... | lib/ash/data_layer/data_layer.ex | 0.860486 | 0.513668 | data_layer.ex | starcoder |
defmodule OffBroadway.Kafka do
@moduledoc ~S"""
Defines a macro to easily define a Kafka Broadway pipeline in your
application, configuring Broadway and Kafka via callbacks.
It starts a Broadway pipeline for each topic and partition for increased
concurrency processing events, receiving partition assignments... | lib/off_broadway/kafka.ex | 0.847621 | 0.836688 | kafka.ex | starcoder |
defmodule XGPS.Ports do
use Supervisor
@doc """
Open one port to be consumed. Needs to have one GPS attached to the port to work.
To simulate, give port_name = :simulate
"""
def start_port(port_name) do
Supervisor.start_child(__MODULE__, [{port_name}])
end
def start_simulator(file_name) do
Sup... | lib/xgps/ports.ex | 0.62395 | 0.469399 | ports.ex | starcoder |
defmodule PlugSessionMnesia do
@moduledoc """
An application for storing and managing Plug sessions with Mnesia.
This application provides a `Plug.Session.Store` using Mnesia as back-end, and
a session cleaner for automatically deleting inactive sessions. It also
provide helpers for creating the Mnesia table... | lib/plug_session_mnesia.ex | 0.78968 | 0.418697 | plug_session_mnesia.ex | starcoder |
defmodule Modbux.Rtu.Slave do
@moduledoc """
API for a Modbus RTU Slave device.
"""
use GenServer, restart: :transient
alias Modbux.Model.Shared
alias Modbux.Rtu.{Slave, Framer}
alias Modbux.Rtu
alias Circuits.UART
require Logger
@timeout 1000
@speed 115_200
defstruct model_pid: nil,
... | lib/rtu/slave.ex | 0.893527 | 0.758085 | slave.ex | starcoder |
defmodule Desktop.Menu do
@moduledoc """
Menu module used to create and handle menus in Desktop
Menues are defined similiar to Live View using a callback module an XML:
```
defmodule ExampleMenuBar do
use Desktop.Menu
@impl true
def mount(menu) do
menu = assign(menu, items: Exam... | lib/desktop/menu.ex | 0.694924 | 0.54819 | menu.ex | starcoder |
defmodule Advent.Day17 do
defmodule Conway3D do
def new(input) do
for {line, y} <- Enum.with_index(String.split(input, "\n", trim: true)),
{char, x} <- Enum.with_index(String.codepoints(line)),
char == "#",
into: MapSet.new(),
do: {x, y, 0}
end
defp active?(a... | shritesh+elixir/lib/advent/day_17.ex | 0.550124 | 0.602646 | day_17.ex | starcoder |
defmodule ExCell.Adapters.CellJS do
@moduledoc """
The CellJS adapter can be used to output the cells as HTML compatible with
[cells-js](https://github.com/DefactoSoftware/cells-js). CellsJS was written
with ExCell in mind.
Tags are automatically closed when they are part of the
[void elements](https://sta... | lib/ex_cell/adapters/cell_js.ex | 0.797714 | 0.688468 | cell_js.ex | starcoder |
defmodule ExthCrypto.Math do
@moduledoc """
Helpers for basic math functions.
"""
@doc """
Simple function to compute modulo function to work on integers of any sign.
## Examples
iex> ExthCrypto.Math.mod(5, 2)
1
iex> ExthCrypto.Math.mod(-5, 1337)
1332
iex> ExthCrypto.Math.... | apps/exth_crypto/lib/math/math.ex | 0.837686 | 0.530541 | math.ex | starcoder |
defmodule AttributeRepositoryRiak do
@moduledoc """
## Initializing a bucket type for attribute repository
```sh
$ sudo riak-admin bucket-type create attr_rep '{"props":{"datatype":"map", "backend":"leveldb_mult"}}'
attr_rep created
$ sudo riak-admin bucket-type activate attr_rep
attr_rep has been acti... | lib/attribute_repository_riak.ex | 0.630344 | 0.418578 | attribute_repository_riak.ex | starcoder |
defmodule Zaryn.OracleChain.Summary do
@moduledoc false
alias Zaryn.Crypto
alias Zaryn.TransactionChain.Transaction
alias Zaryn.TransactionChain.Transaction.ValidationStamp
alias Zaryn.TransactionChain.TransactionData
defstruct [:transactions, :previous_date, :date, :aggregated]
@type t :: %__MODULE__... | lib/zaryn/oracle_chain/summary.ex | 0.87672 | 0.423756 | summary.ex | starcoder |
defmodule StepFlow.WorkflowDefinitionController do
use StepFlow, :controller
use BlueBird.Controller
import Plug.Conn
alias StepFlow.Controller.Helpers
alias StepFlow.WorkflowDefinitions
alias StepFlow.WorkflowDefinitions.WorkflowDefinition
require Logger
action_fallback(StepFlow.FallbackController)
... | lib/step_flow/controllers/workflow_definition_controller.ex | 0.504883 | 0.441312 | workflow_definition_controller.ex | starcoder |
defmodule Mix.Tasks.Stats do
@moduledoc false
use Mix.Task
def get_datum(module, learn_val, args) do
to_train = module.new(args)
role_model = module.new(args)
{_, info} = NeuralNet.Tester.test_training(to_train, role_model, 100, 10, learn_val, 2, 0, false)
{info.eval_time, info.iterations}
end
... | lib/mix/tasks/stats.ex | 0.512693 | 0.498718 | stats.ex | starcoder |
defmodule SSTable do
@moduledoc """
# Specification of Sorted String Table files
A Sorted String Table contains zero or more _gzipped key/value chunks_.
## GZipped key/value chunks
A _gzip key/value chunk_ follows this binary specification:
1. Four bytes: length of the gzipped chunk
2. Variable length... | lib/august_db/sstable/sstable.ex | 0.886994 | 0.873323 | sstable.ex | starcoder |
defmodule Is do
@moduledoc ~S"""
Fast, extensible and easy to use data structure validation with nested structures support.
"""
alias Is.{AliasType, Validator, Validators}
@validators_map Validator.to_map(
Application.get_env(:is, :validators, Validators.get_default())
)
@doc ~S"""
Validate data ... | lib/is.ex | 0.900696 | 0.658843 | is.ex | starcoder |
defmodule Firmata.Board do
use GenServer
use Firmata.Protocol.Mixin
require Logger
alias Firmata.Protocol.State, as: ProtocolState
@initial_state %{
pins: [],
outbox: [],
processor_pid: nil,
parser: {},
firmware_name: "",
interface: nil,
serial: nil
}
def start_link(port, opt... | lib/firmata/board.ex | 0.547948 | 0.409339 | board.ex | starcoder |
defmodule Cased.Sensitive.String do
@moduledoc """
Used to mask sensitive string values.
"""
@enforce_keys [:data, :label]
defstruct [
:data,
:label
]
@type t :: %__MODULE__{
data: String.t(),
label: nil | atom() | String.t()
}
@type new_opts :: [new_opt()]
@type... | lib/cased/sensitive/string.ex | 0.915879 | 0.829492 | string.ex | starcoder |
defmodule Eml.Compiler do
@moduledoc """
Various helper functions for implementing an Eml compiler.
"""
@type chunk :: String.t | { :safe, String.t } | Macro.t
# Options helper
@default_opts [escape: true,
transform: nil,
fragment: false,
compiler: Eml.H... | lib/eml/compiler.ex | 0.768299 | 0.472623 | compiler.ex | starcoder |
defmodule Periodic do
@moduledoc """
Periodic job execution.
## Quick start
It is recommended (but not required) to implement the job in a dedicated module. For example:
defmodule SomeCleanup do
def child_spec(_arg) do
Periodic.child_spec(
id: __MODULE__,
run: ... | lib/periodic.ex | 0.895517 | 0.745375 | periodic.ex | starcoder |
defmodule LogiStd.Sink.File do
@moduledoc """
A sink which writes log messages to a file.
## Note
The sink has no overload protections,
so it is recommended to use it together with (for example) `Logi.Sink.Flowlimiter`
in a production environment.
(See also `LogiStd.Sink.Ha`)
## Examples
```
iex... | lib/logi_std/sink/file.ex | 0.743727 | 0.670864 | file.ex | starcoder |
defmodule Xxo.State do
@moduledoc """
This module is used to track game state and declare when a user has won/lost.
"""
require Logger
# alias Xxo.Game
@doc """
Checks if there are 3 symbols in a row
"""
def winner?(symbol, state) do
won(symbol, state.board)
end
### Top row win
defp won(... | lib/xxo/state.ex | 0.586523 | 0.616719 | state.ex | starcoder |
defmodule Kademlia do
@moduledoc """
Kademlia.ex is in fact a K* implementation. K* star is a modified version of Kademlia
using the same KBuckets scheme to keep track of which nodes to remember. But instead of
using the XOR metric it is using geometric distance on a ring as node value distance.
Node ... | lib/kademlia.ex | 0.839767 | 0.437763 | kademlia.ex | starcoder |
defmodule Zaryn.BeaconChain.Subset do
@moduledoc """
Represents a beacon slot running inside a process
waiting to receive transactions to register in a beacon slot
"""
alias Zaryn.BeaconChain.Slot
alias Zaryn.BeaconChain.Slot.EndOfNodeSync
alias Zaryn.BeaconChain.Slot.TransactionSummary
alias Zaryn.Bea... | lib/zaryn/beacon_chain/subset.ex | 0.864139 | 0.418905 | subset.ex | starcoder |
defmodule Day25 do
@moduledoc """
Assembunny code interpreter, with output command
"""
@clk_count_enough 10000
defmodule State do
defstruct pc: 0, a: 0, init_a: 0, b: 0, c: 1, d: 0, clk_last: 1, clk_count: 0, clk_error: false
end
def evaluate_file(path, state \\ %State{}) do
path
|> File.re... | day25/lib/day25.ex | 0.527073 | 0.558086 | day25.ex | starcoder |
defmodule RDF.XSD.Decimal do
@moduledoc """
`RDF.XSD.Datatype` for XSD decimals.
"""
@type valid_value :: Decimal.t()
use RDF.XSD.Datatype.Primitive,
name: "decimal",
id: RDF.Utils.Bootstrapping.xsd_iri("decimal")
alias RDF.XSD
alias Elixir.Decimal, as: D
def_applicable_facet XSD.Facets.MinI... | lib/rdf/xsd/datatypes/decimal.ex | 0.886211 | 0.594963 | decimal.ex | starcoder |
defmodule WaveshareHat.SMS do
@moduledoc """
Includes helper functions for sending and receiving SMS.
"""
import WaveshareHat.Utils
@doc """
Set the number from which SMS message are sent.
"""
def set_local_number(pid, number), do: write(pid, "AT+CSCA=\"#{number}\"")
@doc """
Set the format of SM... | lib/waveshare/sms.ex | 0.792906 | 0.5144 | sms.ex | starcoder |
defmodule Ockam.Session.Handshake do
@moduledoc """
Session handshake behaviour.
Used in `Ockam.Session.Pluggable` and `Ockam.Session.Separate` modules
"""
@type message() :: Ockam.Message.t()
@typedoc """
State passed to the callbacks, can be modified, but following fields are required:
`init_route... | implementations/elixir/ockam/ockam/lib/ockam/session/handshake.ex | 0.773901 | 0.452173 | handshake.ex | starcoder |
defmodule BNO055 do
use BNO055.SensorInterface
@moduledoc """
This module is used to create commands for interacting with a Bosch BNO055 sensor. This
module is intended to be an unopinionated collection of functions to created data for
communicating with the sensor, but does not handle actual communication.
... | lib/bno055.ex | 0.928384 | 0.872836 | bno055.ex | starcoder |
defmodule CSSEx.RGBA do
@moduledoc """
Struct and helper functions for generating RGBA values.
"""
@colors CSSEx.Helpers.Colors.colors_tuples()
alias CSSEx.Unit
defstruct r: 0, g: 0, b: 0, a: 1
@type t() :: %CSSEx.RGBA{
r: non_neg_integer,
g: non_neg_integer,
b: non_neg_in... | lib/structs/rgba.ex | 0.84241 | 0.502502 | rgba.ex | starcoder |
defmodule Advent.Y2021.D11 do
@moduledoc """
https://adventofcode.com/2021/day/11
"""
@typep point :: {non_neg_integer(), non_neg_integer()}
@typep grid :: %{point => non_neg_integer()}
@doc """
Given the starting energy levels of the dumbo octopuses in your cavern,
simulate 100 steps. How many total ... | lib/advent/y2021/d11.ex | 0.82994 | 0.660662 | d11.ex | starcoder |
defmodule GingerbreadShop.Service.Store.Model do
use Ecto.Schema
import Ecto
import Ecto.Changeset
import Protecto
@moduledoc """
A model representing a store.
##Fields
###:id
Is the unique reference to the store entry. Is an `integer`.
###:entity
Is the entity... | apps/gingerbread_shop_service/lib/gingerbread_shop.service/store/model.ex | 0.831793 | 0.604807 | model.ex | starcoder |
defmodule Google.Protobuf.Compiler.Version do
@moduledoc false
alias Pbuf.Decoder
import Bitwise, only: [bsr: 2, band: 2]
@derive Jason.Encoder
defstruct [
major: nil,
minor: nil,
patch: nil,
suffix: nil
]
@type t :: %__MODULE__{
major: integer,
minor: integer,
patch: integer,... | lib/protoc/google/protobuf/compiler/plugin.pb.ex | 0.794704 | 0.522872 | plugin.pb.ex | starcoder |
defmodule Sippet.Proxy do
@moduledoc """
Defines very basic operations commonly used in SIP Proxies.
"""
alias Sippet.Message, as: Message
alias Sippet.Message.RequestLine, as: RequestLine
alias Sippet.Message.StatusLine, as: StatusLine
alias Sippet.URI, as: URI
alias Sippet.Transactions, as: Transacti... | lib/sippet/proxy.ex | 0.869853 | 0.400749 | proxy.ex | starcoder |
defmodule Dion.Lexers.RST.Inline do
@moduledoc """
Provides function used to perform lexical analysis, searching for
inline reStructuredText (RST) elements.
"""
@moduledoc since: "0.1.0"
@doc """
Performs inline lexical analysis on the provided text.
The `lineno` argument is set on the return element... | lib/dion/lexers/rst/inline.ex | 0.725649 | 0.498779 | inline.ex | starcoder |
defmodule Samples do
def extract(contents, type) do
contents
|> extract_table_parts
|> (fn {vars, _type, keyword_lists} -> {vars, type, keyword_lists} end).()
|> process_table_parts
end
def extract(contents) do
contents
|> extract_table_parts
|> process_table_parts
end
defp extra... | lib/samples.ex | 0.581065 | 0.458349 | samples.ex | starcoder |
defmodule GitGud.OAuth2.Provider do
@moduledoc """
OAuth2.0 provider schema and helper functions.
"""
use Ecto.Schema
alias GitGud.DB
alias GitGud.Account
import Ecto.Changeset
schema "oauth2_providers" do
belongs_to :account, Account
field :provider, :string
field :provider_id, :integer... | apps/gitgud/lib/gitgud/schemas/oauth2_provider.ex | 0.839405 | 0.695015 | oauth2_provider.ex | starcoder |
defmodule TelemetryMetricsPrometheus.Core do
@moduledoc """
Prometheus Reporter for [`Telemetry.Metrics`](https://github.com/beam-telemetry/telemetry_metrics) definitions.
Provide a list of metric definitions to the `child_spec/1` function. It's recommended to
add this to your supervision tree.
def star... | lib/core.ex | 0.935236 | 0.632716 | core.ex | starcoder |
defmodule ToyRobot.Api do
@moduledoc """
The Api module contains the common higher level functions
that are called from the Command Line `ToyRobot.Cli`
and File Driven `ToyRobot.FromFile` interfaces.
This includes functions to:
- start and stop the `ToyRobot.Server`
- run commands
- get server state
... | lib/toy_robot/api.ex | 0.726329 | 0.568566 | api.ex | starcoder |
defmodule Kalevala.Character.Controller do
@moduledoc ~S"""
A `Kalevala.Character.Controller` is the largest building block of handling
texting. When starting the foreman, an initial controller is given. This
controller is initialized and used from then on. The callbacks required will
be called at the appro... | lib/kalevala/character/controller.ex | 0.889156 | 0.836955 | controller.ex | starcoder |
defmodule Pixie.Monitor do
use Timex
@moduledoc """
Allows you to monitor various events within Pixie.
Internally Pixie.Monitor is implemented using GenEvent, so you're free to
bypass using the Pixie.Monitor behaviour and use your own GenEvent if the
need arises.
Usage example:
```elixir
defmodule ... | lib/pixie/monitor.ex | 0.839537 | 0.506103 | monitor.ex | starcoder |
defmodule Dirwalk do
@moduledoc """
A simple-to-use module to help traverse directories. Interface inspired by Python's `os.walk`.
`Dirwalk` enables you to walk directories lazily or greedily. Lazy traversal means that the minimum
amount of work is needed to get the next result, and each next step has to be do... | lib/dirwalk.ex | 0.921313 | 0.589716 | dirwalk.ex | starcoder |
defmodule Mix.Tasks.Format do
use Mix.Task
@shortdoc "Formats the given files/patterns"
@moduledoc """
Formats the given files and patterns.
mix format mix.exs "lib/**/*.{ex,exs}" "test/**/*.{ex,exs}"
Formatting is done with the `Code.format_string/2` function.
## Options
* `--check-formatte... | lib/mix/lib/mix/tasks/format.ex | 0.804598 | 0.445288 | format.ex | starcoder |
defmodule JID do
@moduledoc """
Jabber Identifiers (JIDs) uniquely identify individual entities in an XMPP
network.
A JID often resembles an email address with a user@host form, but there's
a bit more to it. JIDs consist of three main parts:
A JID can be composed of a local part, a server part, and a reso... | lib/jid.ex | 0.864982 | 0.61315 | jid.ex | starcoder |
defmodule Sanity.Components.PortableText do
@moduledoc ~S'''
For rending [Sanity CMS portable text](https://www.sanity.io/docs/presenting-block-text).
## Examples
### Basic example
use Phoenix.Component
# ...
assigns = %{
portable_text: [
%{
_key: "f71173c80e... | lib/sanity/components/portable_text.ex | 0.754915 | 0.506897 | portable_text.ex | starcoder |
defmodule CRUDimentary.Absinthe.Generator.Endpoint do
@moduledoc """
This module defines generators for Absinthe GraphQL CRUD fields.
By calling one of macros you can generate multiple queries or mutations with generic resolver callbacks, middleware and error handlers.
"""
import CRUDimentary.Absinthe.Generat... | lib/crudimentary/absinthe/generators/endpoint.ex | 0.728941 | 0.612339 | endpoint.ex | starcoder |
defmodule Plymio.Fontais.Option do
@moduledoc ~S"""
Functions for Managing Keyword Options ("opts")
See `Plymio.Fontais` for overview and other documentation terms.
## Documentation Terms
### *key*
A *key* is an `Atom`.
### *key list*
A *key list* is a list of *key*s.
### *key spec*
A *key s... | lib/fontais/option/option.ex | 0.889996 | 0.641338 | option.ex | starcoder |
defmodule Blake2 do
import Bitwise
@moduledoc """
BLAKE2 hash functions
Implementing "Blake2b" and "Blake2s" as described in [RFC7693](https://tools.ietf.org/html/rfc7693)
Note that, at present, this only supports full message hashing and no OPTIONAL features
of BLAKE2.
"""
defp modulo(n, 64), do: n... | lib/blake2.ex | 0.746509 | 0.627666 | blake2.ex | starcoder |
defmodule Talan.Counter do
@moduledoc """
Linear probabilistic counter implementation with **concurrent accessibility**,
powered by [:atomics](http://erlang.org/doc/man/atomics.html) module for cardinality estimation.
Cardinality is the count of unique elements.
For more info about linear probabilistic coun... | lib/talan/counter.ex | 0.927256 | 0.689619 | counter.ex | starcoder |
defmodule Grapex.Model.Logicenn do
import Grapex.TupleUtils
# alias Grapex.IOutils, as: IO_
require Axon
defp relation_embeddings(%Axon{output_shape: parent_shape} = x, n_relations, opts \\ []) do
n_hidden_units = last(parent_shape) - 1
output_shape = parent_shape
|> delete_last
... | lib/grapex/models/logicenn.ex | 0.75274 | 0.589126 | logicenn.ex | starcoder |
defmodule Affine do
@moduledoc """
This library performs affine transforms for multiple dimensions. The
implementation is simple in this initial version allowing for translation,
scaling, shear and rotation.
This library uses the Matrix library available on Hex. It is automatically included when using this l... | lib/affine.ex | 0.942109 | 0.898633 | affine.ex | starcoder |
defmodule Advent.Y2021.D10 do
@moduledoc """
https://adventofcode.com/2021/day/10
"""
@doc """
Find the first illegal character in each corrupted line of the navigation
subsystem. What is the total syntax error score for those errors?
"""
@spec part_one(Enumerable.t()) :: non_neg_integer()
def part_o... | lib/advent/y2021/d10.ex | 0.755457 | 0.565959 | d10.ex | starcoder |
defmodule Dune.Parser do
@moduledoc false
alias Dune.{AtomMapping, Success, Failure, Opts}
alias Dune.Parser.{CompileEnv, StringParser, Sanitizer, SafeAst, UnsafeAst}
@typep previous_session :: %{
atom_mapping: AtomMapping.t(),
compile_env: Dune.Parser.CompileEnv.t()
}
@spec ... | lib/dune/parser.ex | 0.741861 | 0.421641 | parser.ex | starcoder |
defmodule LineBot.Message.Imagemap do
use LineBot.Message
@moduledoc """
Represents an [Imagemap message](https://developers.line.biz/en/reference/messaging-api/#imagemap-message).
"""
@type t :: %__MODULE__{
baseUrl: String.t(),
altText: String.t(),
baseSize: %{width: integer()... | lib/line_bot/message/image_map.ex | 0.880733 | 0.430656 | image_map.ex | starcoder |
defmodule Day22 do
def part1(input, moves \\ 10000) do
grid = parse(input)
|> Map.new
state = {{0, 0}, 0, 0, grid}
res = Stream.iterate(state, &next_state_part1/1)
|> Stream.drop(moves)
|> Enum.take(1)
|> hd
{_, _, infections, _} = res
infections
end
def part2(input, moves \... | day22/lib/day22.ex | 0.654343 | 0.622832 | day22.ex | starcoder |
defmodule MetarMap do
@moduledoc """
MetarMap keeps the contexts that define your domain
and business logic.
Contexts are also responsible for managing your data, regardless
if it comes from the database, an external API or others.
"""
alias MetarMap.Display.Color
@doc """
Naively blends two colors... | lib/metar_map.ex | 0.858704 | 0.555194 | metar_map.ex | starcoder |
defmodule Bolt.Sips.Internals.PackStream.EncoderV1 do
@moduledoc false
alias Bolt.Sips.Internals.PackStream.EncoderHelper
use Bolt.Sips.Internals.PackStream.Markers
@doc """
Encode an atom into Bolt binary format.
Encoding:
`Marker`
with
| Value | Marker |
| ------- | -------- |
| nil | `0xC0... | lib/bolt_sips/internals/pack_stream/encoder_v1.ex | 0.847936 | 0.659193 | encoder_v1.ex | starcoder |
defmodule EtsQuery do
@moduledoc """
EtsQuery gives you convinient function to work with ets tables
"""
alias :ets, as: Ets
import Ets
@doc """
looks up every row in the given ets table.
Type indicates whether the traversal should start from the start or the last row of the table.
It would m... | lib/ets_query.ex | 0.657758 | 0.706861 | ets_query.ex | starcoder |
defmodule Rambla.Amqp do
@moduledoc """
Default connection implementation for 🐰 Rabbit.
`publish/2` accepts the following options:
- `exchange` [`binary()`, **mandatory**] the exchange to publish to
- `queue` [`binary()`, **optional**] if passed, the queue will be created
and bound to the exchange; it’... | lib/rambla/connections/amqp.ex | 0.881596 | 0.820685 | amqp.ex | starcoder |
defmodule AfterGlow.ColumnValueController do
use AfterGlow.Web, :controller
alias AfterGlow.ColumnValue
alias JaSerializer.Params
alias AfterGlow.Plugs.Authorization
plug Authorization
plug :authorize!, ColumnValue
plug :scrub_params, "data" when action in [:create, :update]
plug :verify_authorized
... | web/controllers/column_values_controller.ex | 0.536556 | 0.415166 | column_values_controller.ex | starcoder |
defmodule Logger.ErrorHandler do
@moduledoc false
use GenEvent
require Logger
def init({otp?, sasl?, threshold}) do
# We store the logger PID in the state because when we are shutting
# down the Logger application, the Logger process may be terminated
# and then trying to reach it will lead to cr... | lib/logger/lib/logger/error_handler.ex | 0.562898 | 0.448245 | error_handler.ex | starcoder |
defmodule Slipstream.Socket do
@moduledoc """
A data structure representing a potential websocket client connection
This structure closely resembles `t:Phoenix.Socket.t/0`, but is not
compatible with its functions. All documented functions from this module
are imported by `use Slipstream`.
"""
import Ke... | lib/slipstream/socket.ex | 0.902734 | 0.483405 | socket.ex | starcoder |
defmodule ShEx.ShapeMap.Decoder do
@moduledoc !"""
Decoder for standard representation format for ShapeMaps specified in <https://shexspec.github.io/shape-map/>.
"""
import ShEx.Utils
alias RDF.{IRI, BlankNode, Literal}
def decode(content, opts \\ []) do
with {:ok, tokens, _} <-... | lib/shex/shape_map/decoder.ex | 0.773559 | 0.564038 | decoder.ex | starcoder |
defmodule Poison.SyntaxError do
defexception [:message, :token]
def exception(opts) do
message = if token = opts[:token] do
"Unexpected token: #{token}"
else
"Unexpected end of input"
end
%Poison.SyntaxError{message: message, token: token}
end
end
defmodule Poison.Parser do
@modul... | issues/deps/poison/lib/poison/parser.ex | 0.648689 | 0.517449 | parser.ex | starcoder |
defmodule OpenIDConnect do
@moduledoc """
Handles a majority of the life-cycle concerns with [OpenID Connect](http://openid.net/connect/)
"""
@typedoc """
URI as a string
"""
@type uri :: String.t()
@typedoc """
JSON Web Token
See: https://jwt.io/introduction/
"""
@type jwt :: String.t()
@... | lib/openid_connect.ex | 0.897558 | 0.495484 | openid_connect.ex | starcoder |
defmodule Sentix.Cache do
@moduledoc """
This module just provides a cache interface which can back multiple Sentix
watchers, to make sure that we have some form of persistence (rather than
relying on the developer to remember to reconnect on crashes).
Currently the only provided functions are based around s... | lib/sentix/cache.ex | 0.774583 | 0.503418 | cache.ex | starcoder |
defmodule Timber.Plug.Event do
@moduledoc """
Automatically logs metadata information about HTTP requests
and responses in Plug-based frameworks like Phoenix.
Whether you use Plug by itself or as part of a framework like Phoenix,
adding this plug to your pipeline will automatically create events
for incomi... | lib/timber_plug/event.ex | 0.906978 | 0.74382 | event.ex | starcoder |
defmodule AWS.Kinesis do
@moduledoc """
Amazon Kinesis Streams Service API Reference
Amazon Kinesis Streams is a managed service that scales elastically for
real time processing of streaming big data.
"""
@doc """
Adds or updates tags for the specified Amazon Kinesis stream. Each stream
can have up t... | lib/aws/kinesis.ex | 0.934724 | 0.775817 | kinesis.ex | starcoder |
defmodule Valet.Error.TypeMismatch do
@enforce_keys [:trail, :value, :expected]
defstruct @enforce_keys
def new(trail, value, expected),
do: %__MODULE__{trail: trail, value: value, expected: expected}
end
defmodule Valet.Error.NotInSet do
@enforce_keys [:trail, :value, :valid]
defstruct @enforce_keys
... | lib/errors.ex | 0.782912 | 0.743401 | errors.ex | starcoder |
defmodule AisFront.Units.ROT do
alias __MODULE__
alias AisFront.Protocols.Convertible
defstruct value: %Decimal{}, unit: :ms
@si_unit :rad_sec
@unit_si_ratio %{
rad_sec: 1,
deg_sec: :math.pi |> Decimal.cast |> Decimal.div(180),
deg_min: :math.pi |> Decimal.cast |> Decimal.div(180*60)
}
@poss... | lib/ais_front/units/rot.ex | 0.643217 | 0.681899 | rot.ex | starcoder |
defmodule Guardian.Plug.Backdoor do
@moduledoc """
This plug allows you to bypass authentication in acceptance tests by passing
the token needed to load the current resource directly to your Guardian module
via a query string parameter.
## Installation
Add the following to your Phoenix router before other... | lib/guardian/plug/backdoor.ex | 0.698432 | 0.76769 | backdoor.ex | starcoder |
defmodule Redix.Protocol do
@moduledoc """
This module provides functions to work with the [Redis binary
protocol](http://redis.io/topics/protocol).
"""
defmodule ParseError do
@moduledoc """
Error in parsing data according to the
[RESP](http://redis.io/topics/protocol) protocol.
"""
def... | lib/redix/protocol.ex | 0.888124 | 0.564639 | protocol.ex | starcoder |
import Kernel, except: [to_string: 1]
defmodule Macro do
@moduledoc """
Conveniences for working with macros.
"""
@typedoc "Abstract Syntax Tree (AST)"
@type t :: expr | { t, t } | atom | number | binary | pid | fun | [t]
@typedoc "Expr node (remaining ones are literals)"
@type expr :: { expr | atom, K... | lib/elixir/lib/macro.ex | 0.7413 | 0.538923 | macro.ex | starcoder |
defmodule Extatus.Metric.Histogram do
@moduledoc """
This module defines a wrapper over `Prometheus.Metric.Histogram` functions to
be compatible with `Extatus` way of handling metrics.
"""
alias Extatus.Settings
@metric Settings.extatus_histogram_mod()
@doc """
Creates a histogram using the `name` of ... | lib/extatus/metric/histogram.ex | 0.896 | 0.655164 | histogram.ex | starcoder |
defmodule Snitch.Data.Model.Promotion.Applicability do
@moduledoc """
Exposes functions related to promotion level checks.
"""
use Snitch.Data.Model
alias Snitch.Data.Schema.Promotion
@errors %{
not_found: "promotion not found",
inactive: "promotion is not active",
expired: "promotion has expi... | apps/snitch_core/lib/core/data/model/promotion/promotion_applicability.ex | 0.828106 | 0.414247 | promotion_applicability.ex | starcoder |
defmodule Vow.Pat do
@moduledoc """
This module provides a vow for wrapping a pattern and the `Vow.Pat.pat/1`
macro for conveniently wrapping the pattern and packaging it in `Vow.Pat.t`.
# Note
Installation of the `Expat` package is recommended if using this module as
`Expat` provides excellent utilities ... | lib/vow/pat.ex | 0.905706 | 0.835953 | pat.ex | starcoder |
defmodule AtomTweaks.Tweaks.Tweak do
@moduledoc """
Represents a tweak.
## Fields
* `code` - Source code of the tweak
* `description` - Markdown description of what the tweak does
* `title` - Title of the tweak
* `type` - The type of the tweak
### Associations
Must be preloaded before they can be ... | lib/atom_tweaks/tweaks/tweak.ex | 0.79854 | 0.514095 | tweak.ex | starcoder |
defmodule ExStoneOpenbank.TeslaHelper do
@moduledoc """
Group of functions that helps in the utilization of Mox in Tesla Adapters
"""
import Mox
import Tesla.Mock, only: [json: 2]
import ExUnit.Assertions
alias ExStoneOpenbank.TeslaMock
defmodule RequestMatchError do
defexception [:message]
de... | test/support/tesla_helper.ex | 0.736401 | 0.438785 | tesla_helper.ex | starcoder |
defmodule BowlingGame do
defstruct scores: List.duplicate([0, 0], 12),
current_frame: 1,
roll_in_frame: 1
end
defmodule Bowling do
def start do
%BowlingGame{}
end
def roll(_, score) when score < 0 do
{:error, "Negative roll is invalid"}
end
def roll(_, score) when score > ... | exercises/practice/bowling/.meta/example.ex | 0.695131 | 0.610424 | example.ex | starcoder |
defmodule ExWire.Message do
@moduledoc """
Defines a behavior for messages so that they can be
easily encoded and decoded.
"""
defmodule UnknownMessageError do
defexception [:message]
end
@type t ::
ExWire.Message.Ping.t()
| ExWire.Message.Pong.t()
| ExWire.Message.Find... | apps/ex_wire/lib/ex_wire/message.ex | 0.860838 | 0.408247 | message.ex | starcoder |
defmodule Membrane.Element.Base do
@moduledoc """
Module defining behaviour common to all elements.
When used declares behaviour implementation, provides default callback definitions
and imports macros.
# Elements
Elements are units that produce, process or consume data. They can be linked
with `Membra... | lib/membrane/element/base.ex | 0.922787 | 0.653182 | base.ex | starcoder |
defmodule ExDoc.Markdown do
@moduledoc """
Transform a given document in Markdown to HTML
ExDoc supports the following Markdown parsers:
* [Hoedown][]
* [Earmark][]
* [Cmark][]
If you don't specify a parser in `config/config.exs`, ExDoc will try to
find one of the Markdown parsers from the list... | lib/ex_doc/markdown.ex | 0.765856 | 0.662669 | markdown.ex | starcoder |
defmodule HL7.Composite.Default.XCN do
@moduledoc """
2.9.52 XCN - extended composite ID number and name for persons
Components:
- `id_number` (ST)
- `family_name` (FN)
- `given_name` (ST)
- `second_name` (ST)
- `suffix` (ST)
- `prefix` (ST)
- `degree` (IS)
- `source_table` (IS)
... | lib/ex_hl7/composite/default/xcn.ex | 0.800458 | 0.619788 | xcn.ex | starcoder |
defmodule AWS.SSM do
@moduledoc """
Amazon Web Services Systems Manager is a collection of capabilities that helps
you automate management tasks such as collecting system inventory, applying
operating system (OS) patches, automating the creation of Amazon Machine Images
(AMIs), and configuring operating syst... | lib/aws/generated/ssm.ex | 0.902295 | 0.557905 | ssm.ex | starcoder |
defmodule CyberSourceSDK.Helper do
@moduledoc """
Small utility functions
"""
@doc """
Convert a Map that have the keys as strings to atoms
## Examples
iex> CyberSourceSDK.Helper.convert_map_to_key_atom(%{"a" => 3, "b" => 5})
%{a: 3, b: 5}
"""
def convert_map_to_key_atom(string_key_map) ... | lib/cybersource-sdk/helper.ex | 0.771843 | 0.517144 | helper.ex | starcoder |
defmodule Trifolium.Genus do
@moduledoc """
Module to be used to interact with Trefle [Genus](https://docs.trefle.io/reference/#tag/Genus) related endpoints.
"""
alias Trifolium.Config
alias Trifolium.API
@endpoint_path "api/v1/genus/"
@http_client Config.http_client()
@doc """
List every possi... | lib/trifolium/endpoints/genus.ex | 0.833968 | 0.696139 | genus.ex | starcoder |
defmodule SanbaseWeb.Graphql.Helpers.Utils do
import Sanbase.DateTimeUtils, only: [round_datetime: 2, str_to_sec: 1]
def selector_args_to_opts(args) when is_map(args) do
opts = [aggregation: Map.get(args, :aggregation, nil)]
selector = args[:selector]
opts =
if is_map(selector) do
opts
... | lib/sanbase_web/graphql/helpers/utils.ex | 0.732592 | 0.460228 | utils.ex | starcoder |
defmodule Strava.Deserializer do
@moduledoc """
Helper functions for deserializing responses into models.
"""
@doc """
Update the provided model with a deserialization of a nested value.
"""
@spec deserialize(
struct(),
atom(),
:list | :struct | :map | :date | :datetime,
... | lib/strava/deserializer.ex | 0.795261 | 0.439086 | deserializer.ex | starcoder |
defmodule OliWeb.Common.Table.SortableTableModel do
@moduledoc """
The model for the sortable table LiveComponent.
The model consists of the `rows` that the table will display. This must be in the form of an enumeration of
either maps or structs.
The `column_specs` are the specifications the columns that t... | lib/oli_web/live/common/table/sortable_table_model.ex | 0.861305 | 0.798854 | sortable_table_model.ex | starcoder |
defmodule PersistentVector do
@moduledoc """
`PersistentVector` is an array-like collection of values indexed by contiguous `0`-based integer index
and optimized for growing/shrinking at the end.
`PersistentVector` optimizes the following operations:
* Get element count
* Lookup element by index
* Update... | lib/PersistentVector.ex | 0.926935 | 0.846133 | PersistentVector.ex | starcoder |
defmodule SortedSet do
alias RedBlackTree
@moduledoc """
A Set implementation that always remains sorted.
SortedSet guarantees that no element appears more than once and that
enumerating over members happens in their sorted order.
"""
@behaviour Set
@default_comparator &RedBlackTree.compare_ter... | lib/sorted_set.ex | 0.878822 | 0.542015 | sorted_set.ex | starcoder |
defmodule SanbaseWeb.Graphql.Helpers.Utils do
alias Sanbase.DateTimeUtils
def calibrate_interval(
module,
measurement,
from,
to,
interval,
min_interval_seconds \\ 300,
data_points_count \\ 500
)
def calibrate_interval(
module,
measure... | lib/sanbase_web/graphql/helpers/utils.ex | 0.828523 | 0.409988 | utils.ex | starcoder |
defmodule ServerUtils.SentryLogger do
@moduledoc """
Logger wrapper that handles `warn` and `error` logging and sends a Sentry report. Both logging and Sentry calls will be executed asynchronously.
Sentry will need to be configured in the project that uses this dependency.
The integration with Sentry ca... | lib/logger/logger.ex | 0.885055 | 0.484868 | logger.ex | starcoder |
defmodule Rihanna.Migration do
@max_32_bit_signed_integer (:math.pow(2, 31) |> round) - 1
@moduledoc """
A set of tools for creating the Rihanna jobs table.
Rihanna stores jobs in a table in your database. The default table name is
"rihanna_jobs". The name is configurable by either passing it as an argument... | lib/rihanna/migration.ex | 0.869396 | 0.72189 | migration.ex | starcoder |
defmodule Ivy.Package do
alias Ivy.{Constraint, Logical, LSubst, LVar, Unifyable}
@behaviour Access
defstruct [s: %{}, d: %{}, c: [], vs: nil, oc: true, meta: %{}]
@type t :: %__MODULE__{
s: %{LVar.t => LSubst.t | LVar.t},
d: %{LVar.t => Domain.t},
c: [Constraint.t],
vs: [LVar.t] | nil,
oc... | archive/ivy/query/package.ex | 0.734786 | 0.456107 | package.ex | starcoder |
defmodule Calcinator.Resources.Sort do
@moduledoc """
Sort in `Calcinator.Resources.query_options`
"""
alias Alembic.{Document, Error, Fetch.Includes, Source}
alias Calcinator.Resources
import Resources, only: [attribute_to_field: 2]
# Struct
defstruct field: nil,
direction: :ascending,
... | lib/calcinator/resources/sort.ex | 0.903655 | 0.497559 | sort.ex | starcoder |
defmodule Pointers.Mixin do
@moduledoc """
If a Pointer represents an object, mixins represent data about the object. Mixins collate optional
additional information about an object. Different types of object will typically make use of
different mixins. You can see these as aspects of the data if you like.
A ... | lib/mixin.ex | 0.892621 | 0.875361 | mixin.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.