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 VintageNetDirect do
@moduledoc """
Support for directly connected Ethernet configurations
Direct Ethernet connections are those where the network connects only two
devices. Examples include a virtual Ethernet interface being run over a USB
cable. This is a popular Nerves configuration for developme... | lib/vintage_net_direct.ex | 0.784608 | 0.770724 | vintage_net_direct.ex | starcoder |
if Code.ensure_loaded?(Decorator.Define) do
defmodule Nebulex.Caching do
@moduledoc ~S"""
Declarative annotation-based caching via function
[decorators](https://github.com/arjan/decorator).
For caching declaration, the abstraction provides three Elixir function
decorators: `cacheable `, `cache_ev... | lib/nebulex/caching.ex | 0.881526 | 0.717148 | caching.ex | starcoder |
defmodule LexOffice do
@moduledoc """
Documentation for `LexOffice` which provides an API for lexoffice.de.
## Installation
This package can be installed by adding `lexoffice` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:lexoffice, "~> 0.1"}
]
end
```
## Confi... | lib/lexoffice.ex | 0.84375 | 0.660118 | lexoffice.ex | starcoder |
defmodule PoxTool.Poxel do
defstruct [
front: [],
back: [],
left: [],
right: [],
bottom: [],
top: []
]
@type colour :: { red :: float, green :: float, blue :: float, alpha :: float }
@type material :: atom
@type depth_range :: { non_neg_integer, pos_i... | lib/pox_tool/poxel.ex | 0.876654 | 0.495178 | poxel.ex | starcoder |
defmodule Level.DailyDigest do
@moduledoc """
Functions for generating the daily digest email.
"""
import Ecto.Query
alias Level.Digests
alias Level.Digests.FeedSection
alias Level.Digests.InboxSection
alias Level.Digests.Options
alias Level.Repo
alias Level.Schemas.Digest
alias Level.Schemas.Du... | lib/level/daily_digest.ex | 0.736495 | 0.438845 | daily_digest.ex | starcoder |
defmodule Dpos.Utils do
alias Salty.Sign.Ed25519
@doc """
Signs a message using the wallet private key.
"""
@type keypair() :: {binary(), binary()}
@spec generate_keypair(String.t()) :: keypair()
def generate_keypair(secret) when is_binary(secret) do
{:ok, pk, sk} =
:sha256
|> :crypto.has... | lib/utils.ex | 0.860017 | 0.408247 | utils.ex | starcoder |
defmodule Ockam.Messaging.Ordering.Strict.IndexPipe do
@moduledoc """
Strictly ordered pipe using indexing to enforce ordering
See `Ockam.Messaging.Ordering.IndexPipe.Sender` and
`Ockam.Messaging.Ordering.Strict.IndexPipe.Receiver`
"""
@behaviour Ockam.Messaging.Pipe
@doc "Get sender module"
def send... | implementations/elixir/ockam/ockam/lib/ockam/messaging/ordering/strict/index_pipe.ex | 0.801042 | 0.515864 | index_pipe.ex | starcoder |
defmodule Golos.SocialNetworkApi do
@moduledoc """
Contains all functions to call Golos database_api methods
"""
def call(method, params) do
Golos.call(["social_network", method, params])
end
# CONTENT
@doc """
Returns content data, accepts author and permlink.
Example response:
```
%{"m... | lib/apis/social_network_api.ex | 0.619701 | 0.647213 | social_network_api.ex | starcoder |
defmodule APIDoc.APIDocumenter do
@moduledoc ~S"""
API Documenter.
Documents the main entry of the API.
The following annotations can be set:
- `@api` (string) name of the API.
- `@vsn` (string) version of the API.
- `@moduledoc` (string) API description. Supports markdown.
- `@contact` (stri... | lib/documenter/api.ex | 0.833257 | 0.672688 | api.ex | starcoder |
defmodule ETag.Plug.Options do
@moduledoc """
Applies defaults and validates the given options for the plug. Allowed options are:
- `generator`
- `methods`
- `status_codes`
For details on their usage, values and defaults take a look at the `ETag.Plug` module.
"""
@defaults %{
generator: ETag.Gener... | lib/etag/plug/options.ex | 0.828592 | 0.463323 | options.ex | starcoder |
defmodule FastXlsxExporter do
@moduledoc """
# Fast XLSX Exporter
## Installation
Add `fast_xlsx_exporter` to your mix.ex deps:
```elixir
def deps do
[
{:fast_xlsx_exporter, "~> 0.2.2"}
]
end
```
## Explanation
[Elixlsx](https://github.com/xou/elixlsx) was fine, until really huge ... | lib/fast_xlsx_exporter.ex | 0.852966 | 0.886224 | fast_xlsx_exporter.ex | starcoder |
defmodule Discogs.Models.Record do
@moduledoc """
Ecto model representing a record belonging to a Discogs release.
This is not a first-class object in Discogs's data model. What this allows us
to do is to join over from `User` -> `Release` -> `Record` and pick out a
sampling of _specific records_ in a user's... | lib/discogs/models/record.ex | 0.766643 | 0.514949 | record.ex | starcoder |
defmodule Comet.TabWorker do
@moduledoc """
Worker macro module for use in your application.
This module will manage the life cycle and interactions with a browser
tab worker being managed by `:poolboy`.
This module cannot be used directly, it should be `use`d in your app:
## Example
defmodule MyA... | lib/comet/tab_worker.ex | 0.802246 | 0.478102 | tab_worker.ex | starcoder |
defmodule CashAddr do
use Bitwise
@moduledoc ~S"""
Encode and decode the CashAddr format, with checksums.
"""
# Encoding character set. Maps data value -> char
for {encoding, value} <- Enum.with_index('qpzry9x8gf2tvdw0s3jn54khce6mua7l') do
defp do_encode32(unquote(value)), do: unquote(encoding)
de... | lib/cashaddr.ex | 0.705582 | 0.52476 | cashaddr.ex | starcoder |
defprotocol Jason.Encoder do
@moduledoc """
Protocol controlling how a value is encoded to JSON.
## Deriving
The protocol allows leveraging the Elixir's `@derive` feature
to simplify protocol implementation in trivial cases. Accepted
options are:
* `:only` - encodes only values of specified keys.
... | lib/encoder.ex | 0.935883 | 0.755118 | encoder.ex | starcoder |
defmodule DateTime do
@moduledoc """
A datetime implementation with a time zone.
This datetime can be seen as an ephemeral snapshot
of a datetime at a given time zone. For such purposes,
it also includes both UTC and Standard offsets, as
well as the zone abbreviation field used exclusively
for formatting... | lib/elixir/lib/calendar/datetime.ex | 0.947113 | 0.650592 | datetime.ex | starcoder |
defmodule PolicrMini.Logger do
@moduledoc """
查询和记录日志。
"""
require Logger
defmodule Record do
@moduledoc false
use PolicrMini.Mnesia
@enforce_keys [:level, :message, :timestamp]
defstruct [:level, :message, :timestamp]
@type t :: %__MODULE__{
level: atom,
messa... | lib/policr_mini/logger.ex | 0.702632 | 0.453988 | logger.ex | starcoder |
defmodule Mix.Tasks.Hex.Registry do
use Mix.Task
@behaviour Hex.Mix.TaskDescription
@switches [
name: :string,
private_key: :string
]
@shortdoc "Manages local Hex registries"
@moduledoc """
Manages local Hex registries.
## Build a local registry
mix hex.registry build PUBLIC_DIR
To... | lib/mix/tasks/hex.registry.ex | 0.795221 | 0.731197 | hex.registry.ex | starcoder |
defmodule Ash.Query.Function do
@moduledoc """
A function is a predicate with an arguments list.
For more information on being a predicate, see `Ash.Filter.Predicate`. Most of the complexities
are there. A function must meet both behaviours.
"""
@callback new(list(term)) :: {:ok, term}
@type arg :: :re... | lib/ash/query/function/function.ex | 0.851027 | 0.563498 | function.ex | starcoder |
defmodule ExWire.Message do
@moduledoc """
Defines a behavior for messages so that they can be easily encoded and
decoded for transfer from and to the wire.
"""
alias ExthCrypto.Key
alias ExWire.Crypto
alias ExWire.Message.{FindNeighbours, Neighbours, Ping, Pong}
alias ExWire.Struct.Endpoint
defmodu... | apps/ex_wire/lib/ex_wire/message.ex | 0.880451 | 0.410254 | message.ex | starcoder |
defmodule Snitch.Domain.Order do
@moduledoc """
Order helpers.
"""
@editable_states ~w(cart address delivery payment)a
use Snitch.Domain
import Ecto.Changeset
import Ecto.Query
alias Snitch.Data.Schema.{Order, Package, Payment}
alias Snitch.Data.Model.{Product, Image}
alias Snitch.Data.Model.Gene... | apps/snitch_core/lib/core/domain/order/order.ex | 0.781539 | 0.445831 | order.ex | starcoder |
defmodule Mix.Tasks.NervesHub.Device do
use Mix.Task
import Mix.NervesHubCLI.Utils
alias Mix.NervesHubCLI.Shell
@shortdoc "Manages your NervesHub devices"
@moduledoc """
Manage your NervesHub devices.
## create
Create a new NervesHub device. The shell will prompt for information about the
device... | lib/mix/tasks/nerves_hub.device.ex | 0.835618 | 0.427217 | nerves_hub.device.ex | starcoder |
defmodule Serex.Matcher do
@moduledoc """
This module provides functions used to match regular expressions against text.
"""
@doc """
Searches for a regular expression match in supplied text and returns true if found.
"""
def match(regex, text) when is_binary(regex) and is_binary(text) do
tokens = Se... | lib/matcher.ex | 0.656218 | 0.586168 | matcher.ex | starcoder |
defimpl Charts.StackedColumnChart, for: Charts.BaseChart do
alias Charts.BaseChart
alias Charts.StackedColumnChart.{MultiColumn, Rectangle}
alias Charts.ColumnChart.Dataset
def columns(%BaseChart{dataset: nil}), do: []
def columns(%BaseChart{dataset: dataset}), do: columns(dataset)
def columns(%Dataset{dat... | charts/lib/charts/stacked_column_chart/base_chart_impl.ex | 0.828766 | 0.429938 | base_chart_impl.ex | starcoder |
defmodule Confispex.Schema do
@moduledoc """
## Example
defmodule MyApp.RuntimeConfigSchema do
import Confispex.Schema
@behaviour Confispex.Schema
alias Confispex.Type
defvariables(%{
"RUNTIME_CONFIG_REPORT" => %{
cast: {Type.Enum, values: ["disabled", "... | lib/confispex/schema.ex | 0.791176 | 0.492981 | schema.ex | starcoder |
defmodule MssqlexV3 do
@moduledoc """
Interface for interacting with MS SQL Server via an ODBC driver for Elixir.
It implements `DBConnection` behaviour, using `:odbc` to connect to the
system's ODBC driver. Requires MS SQL Server ODBC driver, see
[README](readme.html) for installation instructions.
"""
... | lib/mssqlex_v3.ex | 0.94419 | 0.627523 | mssqlex_v3.ex | starcoder |
defmodule Recurly.AddOn do
@moduledoc """
Module for handling plan addons in Recurly.
See the [developer docs on plan addons](https://dev.recurly.com/docs/plan-add-ons-object)
for more details
"""
use Recurly.Resource
alias Recurly.{Resource,AddOn,Money,Plan}
@endpoint "/plans/<%= plan_code %>/add_ons"... | lib/recurly/add_on.ex | 0.772917 | 0.57332 | add_on.ex | starcoder |
defmodule Cldr.Interval.Backend do
@moduledoc false
def define_interval_module(config) do
backend = config.backend
config = Macro.escape(config)
quote location: :keep, bind_quoted: [config: config, backend: backend] do
defmodule Interval do
@moduledoc """
Interval formats allow f... | lib/cldr/backend/interval.ex | 0.938287 | 0.674164 | interval.ex | starcoder |
defmodule Blockchain.TransactionIO do
@moduledoc """
Implementation of blockchain transaction input/output (IO)
"""
alias Blockchain.Hash
alias Blockchain.Wallet
@enforce_keys [:transaction_hash, :value, :owner, :timestamp]
defstruct @enforce_keys
@typedoc """
Represents transaction IO
"""
@typ... | lib/blockchain/transaction_io.ex | 0.884831 | 0.462655 | transaction_io.ex | starcoder |
defmodule Logger.Backends.Console do
@moduledoc ~S"""
A logger backend that logs messages by printing them to the console.
## Options
* `:level` - the level to be logged by this backend.
Note that messages are filtered by the general
`:level` configuration for the `:logger` application first.
... | lib/logger/lib/logger/backends/console.ex | 0.819569 | 0.61086 | console.ex | starcoder |
defmodule Stache do
@moduledoc """
Mustache templates for Elixir.
`Stache` is a templating engine for compiling mustache templates into native Elixir
functions. It fully supports the features of the Mustache spec, allowing you to
easily use the logic-less mustache templates you know and love.
The API mirr... | lib/stache.ex | 0.855926 | 0.454109 | stache.ex | starcoder |
defmodule Elixlsx do
@moduledoc ~S"""
Elixlsx is a writer for the MS Excel OpenXML format (.xlsx).
# Quick Overview
The `write_to` function takes a `Elixlsx.Workbook` object
and a filename. A Workbook is a collection of `Elixlsx.Sheet`s with
(currently only) a *creation date*.
See the example.exs file ... | lib/elixlsx.ex | 0.823328 | 0.582254 | elixlsx.ex | starcoder |
defmodule KantanCluster.NodeConnector do
@moduledoc false
# When a server is unneeded, we want to stop it immediately.
use GenServer, restart: :transient
require Logger
@polling_interval_ms :timer.seconds(5)
## API
@doc """
Connects to a specified node and start monitoring it.
"""
@spec start_l... | lib/kantan_cluster/node_connector.ex | 0.697094 | 0.441974 | node_connector.ex | starcoder |
defmodule Andy.Profiles.Rover.GMDefs.AvoidingObstacle do
@moduledoc "The GM definition for :avoiding_obstacle"
alias Andy.GM.{GenerativeModelDef, Conjecture, Prediction}
import Andy.GM.Utils
def gm_def() do
%GenerativeModelDef{
name: :avoiding_obstacle,
conjectures: [
conjecture(:obsta... | lib/andy/profiles/rover/gm_defs/avoiding_obstacle.ex | 0.712732 | 0.455986 | avoiding_obstacle.ex | starcoder |
defmodule AdventOfCode.Day09 do
@spec problem1 :: number
def problem1 do
{width, height} = _shape = Nx.shape(input())
padded = Nx.pad(input(), 99, [{0, 0, 0}, {1, 1, 0}])
shifted = Nx.slice_axis(padded, 0, height, :x)
x1 = Nx.less(input(), shifted)
shifted = Nx.slice_axis(padded, 2, height, :x)... | 2021/lib/aoc09.ex | 0.689515 | 0.684554 | aoc09.ex | starcoder |
defmodule Combinatorics do
# === product ===
@doc ~S"""
Cartesian Product of 2 Enumerables.
(At least 2nd Enumerable should be finite)
## Examples
iex> Combinatorics.product([1, 2, 3], 1..3) |> Enum.to_list
[{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}]
iex> Stre... | lib/combinatorics.ex | 0.807081 | 0.704583 | combinatorics.ex | starcoder |
defmodule Gnat.ConsumerSupervisor do
use GenServer
require Logger
@moduledoc """
A process that can supervise consumers for you (EXPERIMENTAL)
> Note: This module is experimental and may be removed in the 1.0 release depending on what we find as we experiment with other forms of highly available connections... | lib/gnat/consumer_supervisor.ex | 0.778018 | 0.703091 | consumer_supervisor.ex | starcoder |
defmodule Credo.Check.Consistency.Helper do
@moduledoc """
This module contains functions that are used by several
consistency checks.
# On properties and property lists
Imagine a test that checks files for whether they use soft-tabs or hard-tabs
for indentation.
property_values in this case might be :... | lib/credo/check/consistency/helper.ex | 0.753829 | 0.545104 | helper.ex | starcoder |
defmodule GameApp.Round do
@moduledoc """
`GameApp.Round` defines a struct that encapsulates Round state as well as
functions that update the round state.
"""
alias __MODULE__, as: Round
alias GameApp.Player
@enforce_keys [:number]
defstruct number: nil,
prompt: nil,
winner: ni... | apps/game/lib/game/state/round.ex | 0.885369 | 0.47171 | round.ex | starcoder |
defmodule Spandex.Datadog.Span do
@moduledoc """
In charge of holding the datadog span attributes, and for starting/ending
spans. This also handles serialization via `to_map/1`, and span inheritance
via `child_of/3`
"""
alias __MODULE__, as: Span
alias Spandex.Datadog.Utils
defstruct [
:id, :trace... | lib/datadog/span.ex | 0.751329 | 0.414069 | span.ex | starcoder |
defmodule GeoPotion.Vector do
alias :math, as: Math
alias GeoPotion.Distance
alias GeoPotion.Angle
alias __MODULE__
@type position_map :: %{
latitude: number,
longitude: number
}
@type t :: %__MODULE__{
azimuth: Angle.t,
distance: Distance.t
}
defstruct azimuth: Angle.new, distance: ... | lib/geopotion/vector.ex | 0.802052 | 0.688711 | vector.ex | starcoder |
defmodule FastEIP55 do
@moduledoc """
Github link: https://github.com/gregors/fast_eip_55
Rust-powered Keccak version of EIP-55
Provides EIP-55 encoding and validation functions.
"""
@doc """
Encodes an Ethereum address into an EIP-55 checksummed address.
## Examples
iex> alias FastEIP55, as: EIP... | lib/fast_eip55.ex | 0.698844 | 0.428532 | fast_eip55.ex | starcoder |
defmodule Prelude.Type do
defstruct [:type]
types = [
:atom,
:binary,
:bitstring,
:boolean,
:float,
:function,
:integer,
:list,
:map,
:nil,
:nonempty_list,
:number,
:pid,
:port,
:reference,
:tuple
]
for type <- types do
def unquote(type)() do... | lib/prelude/type.ex | 0.599837 | 0.756807 | type.ex | starcoder |
defmodule Commanded.Middleware.Pipeline do
@moduledoc """
Pipeline is a struct used as an argument in the callback functions of modules
implementing the `Commanded.Middleware` behaviour.
This struct must be returned by each function to be used in the next
middleware based on the configured middleware chain.
... | lib/commanded/middleware/pipeline.ex | 0.912378 | 0.861363 | pipeline.ex | starcoder |
defmodule Tesla.Middleware.ConsulWatch do
@moduledoc """
Fills the request so it results in a Consul blocking query.
## Example usage
```
defmodule Myclient do
use Tesla
plug Tesla.Middleware.ConsulWatch, wait: 60_000
end
```
"""
@behaviour Tesla.Middleware
use GenServer
@default_wait... | lib/tesla/middleware/consul_watch.ex | 0.836388 | 0.7586 | consul_watch.ex | starcoder |
defmodule RDF.XSD.Utils.Regex do
@moduledoc !"""
XSD-flavoured regex matching.
This is not intended to be used directly.
Use `c:RDF.XSD.Datatype.matches?/3` implementations on the datatypes or
`RDF.Literal.matches?/3` instead.
"""
@doc """
Matches... | lib/rdf/xsd/utils/regex.ex | 0.847716 | 0.6612 | regex.ex | starcoder |
defmodule Liaison.NodeHelper do
@moduledoc """
NodeHelper aims to make converting between node representations
into FQDN nodenames
### Auto Localhost Calculation
Ever tried to connect to another local node but your machine name
is not fun to enter? Now all you need to do is enter a name for the
nod... | lib/node_helper.ex | 0.663015 | 0.603114 | node_helper.ex | starcoder |
defmodule Andi.InputSchemas.DatasetInput do
@moduledoc """
Module for validating Ecto.Changesets on flattened dataset input.
"""
import Ecto.Changeset
alias Andi.DatasetCache
alias Andi.InputSchemas.DatasetSchemaValidator
alias Andi.InputSchemas.Options
alias Andi.InputSchemas.KeyValue
@business_fie... | apps/andi/lib/andi/input_schemas/dataset_input.ex | 0.69285 | 0.425546 | dataset_input.ex | starcoder |
defmodule MangoPay.Hook do
@moduledoc """
Functions for MangoPay [hook](https://docs.mangopay.com/endpoints/v2.01/hooks#e246_the-hook-object).
"""
use MangoPay.Query.Base
set_path "hooks"
@doc """
Get a hook.
## Examples
{:ok, hook} = MangoPay.Hook.get(id)
"""
def get id do
_get id
en... | lib/mango_pay/hook.ex | 0.746509 | 0.420332 | hook.ex | starcoder |
defmodule Qex do
@moduledoc ~S"""
A `:queue` wrapper with improvements in API and addition of Protocol implementations
## Protocols
`Inspect`, `Collectable` and `Enumerable` are implemented
iex> inspect Qex.new
"#Qex<[]>"
iex> Enum.count Qex.new(1..5)
5
iex> Enum.empty? Qex.n... | lib/qex.ex | 0.880855 | 0.551211 | qex.ex | starcoder |
defmodule Stargate.Receiver.Dispatcher do
@moduledoc """
Defines the `Stargate.Receiver.Dispatcher` GenStage process
that functions as the producer in the pipeline, receiving messages
pushed from the reader or consumer socket and dispatching to the
rest of the pipeline.
"""
use GenStage
import Stargate.... | lib/stargate/receiver/dispatcher.ex | 0.842604 | 0.486758 | dispatcher.ex | starcoder |
defmodule Kayrock.Convenience do
@moduledoc """
Convenience functions for working with Kayrock / Kafka API data
"""
alias Kayrock.ErrorCode
def topic_exists?(pid, topic) when is_pid(pid) do
{:ok, [topic]} = Kayrock.topics_metadata(pid, [topic])
topic[:error_code] != ErrorCode.unknown_topic()
end
... | lib/kayrock/convenience.ex | 0.757166 | 0.428293 | convenience.ex | starcoder |
defmodule AwsExRay.Config do
@moduledoc """
Config Accessor Module
## Configuration
```elixir
config :aws_ex_ray,
sampling_rate: 0.1,
default_annotation: %{foo: "bar"},
default_metadata: %{bar: "buz"}
```
|key|default|description|
|:--|:--|:--|
|sampling_rate|0.1|set number between 0.0... | lib/aws_ex_ray/config.ex | 0.836154 | 0.707329 | config.ex | starcoder |
defmodule Authoritex.Mock do
@moduledoc """
Mock Authority for testing Authoritex consumers
Examples:
```
# In test.exs:
# config :authoritex, authorities: [Authoritex.Mock]
# In test_helper.exs:
# Authoritex.Mock.init()
# In test case:
iex> Authoritex.Mock.set_data([
%{id: "m... | lib/authoritex/mock.ex | 0.826677 | 0.855187 | mock.ex | starcoder |
defmodule GGity.Scale.Linetype.Discrete do
@moduledoc false
alias GGity.{Draw, Labels}
alias GGity.Scale.Linetype
# solid: "",
# dashed: "4",
# dotted: "1",
# longdash: "6 2",
# dotdash: "1 2 3 2",
# twodash: "2 2 6 2"
@palette_values [
"",
"4",
"1",
"6 2",
"1 2 3 2",
... | lib/ggity/scale/linetype_discrete.ex | 0.784443 | 0.435061 | linetype_discrete.ex | starcoder |
defmodule SanbaseWeb.Graphql.Resolvers.HistoricalBalanceResolver do
import Sanbase.Utils.ErrorHandling,
only: [maybe_handle_graphql_error: 2, handle_graphql_error: 3, handle_graphql_error: 4]
import SanbaseWeb.Graphql.Helpers.Utils, only: [calibrate_interval: 7]
alias Sanbase.Clickhouse.HistoricalBalance
... | lib/sanbase_web/graphql/resolvers/historical_balance_resolver.ex | 0.799364 | 0.402979 | historical_balance_resolver.ex | starcoder |
defmodule Listerine.Channels do
@moduledoc """
This module provides functions to create and remove private channels.
"""
use Coxir
# Reads the channels from the config.json file.
defp get_courses() do
case File.read("config.json") do
{:ok, ""} -> nil
{:ok, body} -> Poison.decode!(body)["co... | lib/Listerine/channels.ex | 0.84039 | 0.505859 | channels.ex | starcoder |
defmodule Tradehub.Stream do
@moduledoc ~S"""
This module enables the power to interact with the Tradehub Demex socket.
Behinds the scene, this module requires two dependencies to communicate with the socket server, and broadcasting
the received messages to listeners: WebSockex, and Phoenix PubSub.
To subsc... | lib/tradehub/stream.ex | 0.897434 | 0.805785 | stream.ex | starcoder |
defmodule FaultTree.Parser.XML do
@moduledoc """
Parse an XML document into a FaultTree.
The XML schema expected is mostly for opsa-mef, defined at:
[https://github.com/rakhimov/scram/blob/master/share/input.rng](https://github.com/rakhimov/scram/blob/master/share/input.rng)
"""
import SweetXml
alias Fau... | lib/fault_tree/parser/xml.ex | 0.868102 | 0.67298 | xml.ex | starcoder |
defmodule Day22 do
use Bitwise
def read_file(path) do
File.stream!(path)
|> Enum.to_list
|> parse_input
end
def parse_input(rows) do
map = rows
|> Enum.reverse
|> Enum.with_index
|> Enum.map(&parse_row/1)
|> Enum.reduce(%{}, &Map.merge/2)
size = rows |> Enum.count
tran... | lib/day22.ex | 0.540196 | 0.647359 | day22.ex | starcoder |
defmodule Forma.Parser do
def parse!(input, parsers, {:struct, name, fields}) do
case input do
input when is_map(input) -> map_exact_fields!(input, parsers, struct(name), fields)
_ -> raise "not a map #{inspect input}"
end
end
def parse!(input, parsers, {:exact_map, fields}) do
case input... | lib/forma/parser.ex | 0.662906 | 0.65474 | parser.ex | starcoder |
defmodule Elixir99.Lists2 do
def encode_modified(list, current \\ nil, acc \\ [], counter \\ 0) do
new_acc = case counter do
0 -> acc
1 -> acc ++ [current]
_ -> acc ++ [{counter, current}]
end
case list do
[] -> new_acc
[head | tail] ->
if head == current do
... | lib/elixir99_lists2.ex | 0.603231 | 0.606964 | elixir99_lists2.ex | starcoder |
defmodule Rayray.Renderings.Stl do
alias Rayray.Camera
alias Rayray.Canvas
alias Rayray.Lights
alias Rayray.Material
alias Rayray.Matrix
alias Rayray.Plane
alias Rayray.Transformations
alias Rayray.Tuple
alias Rayray.World
def do_it() do
floor = Plane.new()
floor_material = Material.new()
... | lib/rayray/renderings/stl.ex | 0.71403 | 0.525491 | stl.ex | starcoder |
defmodule ChoreRunner.Input do
@valid_types ~w(string int float file bool)a
@type input_type :: :string | :int | :float | :file | :bool
@type reason :: atom() | String.t()
@type validator_function ::
(term() -> {:ok, term()} | :ok | true | {:error, reason} | nil | false)
@type input_options :: [
... | lib/chore_runner/input.ex | 0.770422 | 0.463748 | input.ex | starcoder |
defmodule Solana.CompactArray do
@moduledoc false
use Bitwise, skip_operators: true
# https://docs.solana.com/developing/programming-model/transactions#compact-array-format
@spec to_iolist(arr :: iolist | nil) :: iolist
def to_iolist(nil), do: []
def to_iolist(arr) when is_list(arr) do
[encode_length(... | lib/solana/compact_array.ex | 0.769687 | 0.460228 | compact_array.ex | starcoder |
% Licensed under the Apache License, Version 2.0 (the "License"); you may not
% use this file except in compliance with the License. You may obtain a copy of
% the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the ... | src/rexi/src/rexi_utils.erl | 0.639286 | 0.410166 | rexi_utils.erl | starcoder |
%%
%% Copyright (c) 2018 <NAME>
%% All rights reserved.
%% Distributed under the terms of the MIT License. See the LICENSE file.
%%
%% SIP qvalue
%% (used in Accept and Contact headers)
%%
-module(ersip_qvalue).
-export([make/1,
parse/1,
assemble/1
]).
-export_type([qvalue/0]).
%%%========... | src/ersip_qvalue.erl | 0.529263 | 0.455441 | ersip_qvalue.erl | starcoder |
-module(math_functions).
-export([even/1, odd/1, filter/2, split1/1, split2/1]).
even(Number) ->
% Use `rem` to check if the remainder is 0
% if it is return true, otherwise false
0 =:= Number rem 2.
odd(Number) ->
% Use `rem` to check if the remainder is 1
% if it is return true, otherwise false... | chapter_4/exercise_7/math_functions.erl | 0.58522 | 0.61231 | math_functions.erl | starcoder |
%%%------------------------------------------------------------------------
%% Copyright 2017, OpenCensus Authors
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/... | src/ocp.erl | 0.530236 | 0.442034 | ocp.erl | starcoder |
%%%-------------------------------------------------------------------
%%% Copyright 2014 The RySim Authors. All rights reserved.
%%%
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
%%% You may obtain a copy of the License at
%%%
%... | erlang/rysim_des/src/event_queue.erl | 0.593609 | 0.404802 | event_queue.erl | starcoder |
% The Computer Language Benchmarks Game
% https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
% contributed by <NAME>
%% erlc spectralnorm.erl
%% erl -smp enable -noshell -run spectralnorm main 5500
-module(spectralnorm).
-export([main/1]).
-compile( [ inline, { inline_size, 1000 } ] ).
main([Arg]) ->
... | bench/spectralnorm.erl | 0.626353 | 0.527134 | spectralnorm.erl | starcoder |
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1996-2020. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
... | lib/stdlib/src/erl_pp.erl | 0.50415 | 0.410993 | erl_pp.erl | starcoder |
%%
%% @doc <NAME>'s 5-card Poker hand evaluator, ported to Erlang.
%%
-module(poker).
-export([hand_rank/1, sort_hands/1, winners/1]).
%% Return a list of the ranks, sorted with higher first.
%% Hand is a list of 2-char strings, i.e. ["6H","3D","AS","TH","JC"].
card_ranks(Hand) ->
Ranks = [string:str("-23456789TJQ... | lib/examples/src/poker.erl | 0.580233 | 0.588416 | poker.erl | starcoder |
% ==============================================================================
% Uniform distribution
% ==============================================================================
-module(uniform).
-export([pdf/3, cdf/3, invcdf/3, rnd/3]).
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-endif.
% -----... | src/uniform.erl | 0.513181 | 0.521288 | uniform.erl | starcoder |
%% -------------------------------------------------------------------
%% luwak_mr: utilities for map/reducing on Luwak data
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the L... | mapreduce/erlang/luwak_mr.erl | 0.676299 | 0.787686 | luwak_mr.erl | starcoder |
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2002-2009. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public Lice... | dependencies/otp/r15b03-1/lib/kernel/src/packages.erl | 0.549761 | 0.525795 | packages.erl | starcoder |
% Licensed under the Apache License, Version 2.0 (the "License"); you may not
% use this file except in compliance with the License. You may obtain a copy of
% the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the ... | vtree/src/vtree_choose.erl | 0.76291 | 0.598811 | vtree_choose.erl | starcoder |
%%% @author <NAME> <<EMAIL>>
%%% @copyright (C) 2021, <NAME>
%%% @doc
%%% A particle for a minimizing particle swarm optimization problem.
%%% @end
%%% Created : 25 Apr 2021 by <NAME> <<EMAIL>>
-module(particle).
-export([new/3, new/5, step/2, position/1, value/1, state/1]).
-export_type([particle/0, position/0, vel... | src/particle.erl | 0.722331 | 0.584745 | particle.erl | starcoder |
%%======================================================================
%%
%% Leo Commons
%%
%% Copyright (c) 2012-2015 Rakuten, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a cop... | deps/leo_commons/src/leo_misc.erl | 0.738386 | 0.411347 | leo_misc.erl | starcoder |
%% Copyright Ericsson AB 1996-2020. All Rights Reserved.
%% Copyright (c) 2020 Facebook, Inc. and its affiliates.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apac... | erltc/src/erlt_shape.erl | 0.668447 | 0.416797 | erlt_shape.erl | starcoder |
% @doc API for the
% <a href="https://reference.digilentinc.com/reference/pmod/pmodhygro/start">
% PmodHYGRO
% </a>.
%
% Start the driver with
% ```
% 1> grisp:add_device(i2c, pmod_hygro).
% '''
% @end
-module(pmod_hygro).
-behaviour(gen_server).
% API
-export([start_link/2]).
-export([temp/0]).
-export([humid/0]).
-e... | src/pmod_hygro.erl | 0.612541 | 0.427994 | pmod_hygro.erl | starcoder |
-module(day3).
-behaviour(aoc).
-include_lib("eunit/include/eunit.hrl").
-export([input_type/0, parse_input/1, p1/1, p2/1]).
input_type() -> lines.
parse_input(Lines) ->
lists:map(fun binary_to_list/1, Lines).
%% @doc
%% The submarine has been making some odd creaking noises, so you ask it to produce
%% a diag... | src/day3.erl | 0.508544 | 0.852537 | day3.erl | starcoder |
%% Helper module for binaries/bitstrings
-module(gradualizer_bin).
-export([compute_type/1]).
-include("gradualizer.hrl").
%% Computes the type of a bitstring expression or pattern based on the sizes
%% of the elements. The returned type is a normalized bitstring type.
-spec compute_type(ExprOrPat) -> gradualizer_ty... | src/gradualizer_bin.erl | 0.526343 | 0.520314 | gradualizer_bin.erl | starcoder |
-module(sv).
-export([timestamp/0, new/1, new/2, destroy/1, ask/2, done/3]).
-export([run/2]).
%% Internal API
-export([report/2]).
%% @doc Creates a new queue
%% @end
-spec new(Conf) -> {ok, pid()}
when
Conf :: proplists:proplist().
new(Conf) ->
new(undefined, Conf).
-spec new(Queue, Conf) -> {ok, pid()... | src/sv.erl | 0.688364 | 0.449393 | sv.erl | starcoder |
%%% vim:ts=2:sw=2:et
%%%-----------------------------------------------------------------------------
%%% @doc Erlang map-reduce parse transform
%%%
%%% This transform introduces two modifications of the list comprehension syntax
%%% that allow to perform a fold and mapfold on a list.
%%%
%%% ==== Indexed List Comprehe... | src/listcomp.erl | 0.591133 | 0.623635 | listcomp.erl | starcoder |
%% -------------------------------------------------------------------
%%
%% riak_kv_mapper: Executes map functions on input batches
%%
%% Copyright (c) 2007-2010 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use t... | deps/riak_kv/src/riak_kv_mapred_filters.erl | 0.512449 | 0.474692 | riak_kv_mapred_filters.erl | starcoder |
%% @author jstypka <<EMAIL>>
%% @version 1.0
%% @doc This module handles the logic of a single island in hybrid model
-module(mas_hybrid_island).
-export([start/2, close/1, sendAgent/2]).
-include ("mas.hrl").
-type agent() :: mas:agent().
-type sim_params() :: mas:sim_params().
%% =================================... | src/hybrid/mas_hybrid_island.erl | 0.510985 | 0.446133 | mas_hybrid_island.erl | starcoder |
% %
%% Copyright (c) 2015-2016 <NAME>. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
... | src/state_lwwregister.erl | 0.677901 | 0.444022 | state_lwwregister.erl | starcoder |
%% -------------------------------------------------------------------
%%
%% Copyright (c) 2013, 2014 Basho Technologies, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the... | src/clique_table.erl | 0.545528 | 0.417628 | clique_table.erl | starcoder |
-module(day8).
-export([solve_part1/1, solve_part2/1]).
% for tests
-export([parse/1, detect_loop/1, fix/1]).
%%% solution
solve_part1(Text) ->
Instructions = parse(Text),
{loops, Acc} = detect_loop(Instructions),
Acc.
solve_part2(Text) ->
Instructions = parse(Text),
fix(Instructions).
%%% int... | src/day8.erl | 0.523664 | 0.50177 | day8.erl | starcoder |
%%%-------------------------------------------------------------------
%%% @doc A static cache storage for Erlang.
%%% Currently consists of two compilers:
%%% ASM - Used for large lists as value. Read the module docs
%%% for more info.
%%%
%%% Syntax - Used for all other cases.
%%%
%... | src/haki.erl | 0.510252 | 0.515498 | haki.erl | starcoder |
%% Copyright (c) 2011-2013 <NAME>
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to... | src/lfe_bits.erl | 0.603581 | 0.484136 | lfe_bits.erl | starcoder |
-module(graph_traversal).
-include("records.hrl").
%% API
-export([traverse/2, temp_traverse/2]).
%% @doc
%% traverse/2 represents the main line of looking for a match - the one that was spawned first in a given file
%% part and will try to find match starting with each text character as the first character of the p... | apps/grepper/src/graph_traversal.erl | 0.545528 | 0.637877 | graph_traversal.erl | starcoder |
%%%-------------------------------------------------------------------
%%% @author <NAME> <<EMAIL>>
%%% @copyright (c) WhatsApp Inc. and its affiliates. All rights reserved.
%%% @doc
%%% Implements Erlang interpreter via eval/3 function.
%%%
%%% Allows to `call' functions that are not exported by interpreting
%%% funct... | src/power_shell.erl | 0.540681 | 0.414543 | power_shell.erl | starcoder |
%% -----------------------------------------------------------------------------
%%
%% The MIT License (MIT)
%%
%% Copyright (c) 2015 <NAME>
%%
%% Permission is hereby granted, free of charge, to any person obtaining a copy
%% of this software and associated documentation files (the "Software"), to deal
%% in the Softw... | src/list_digraph.erl | 0.615435 | 0.436742 | list_digraph.erl | starcoder |
% Licensed under the Apache License, Version 2.0 (the "License"); you may not
% use this file except in compliance with the License. You may obtain a copy of
% the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the ... | src/couch_replicator/src/couch_replicator_rate_limiter.erl | 0.859266 | 0.572484 | couch_replicator_rate_limiter.erl | starcoder |
%%--------------------------------------------------------------------
%% Copyright (c) 2020-2021 DGIOT Technologies Co., Ltd. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the Li... | apps/dgiot/src/otp/dgiot_logger.erl | 0.592902 | 0.522507 | dgiot_logger.erl | starcoder |
%% -------------------------------------------------------------------
%%
%% riak_kv_bucket: bucket validation functions
%%
%% Copyright (c) 2007-2011 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% ... | deps/riak_kv/src/riak_kv_bucket.erl | 0.700075 | 0.479138 | riak_kv_bucket.erl | starcoder |
%% Copyright 2019, JobTeaser
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in w... | src/hotp.erl | 0.707203 | 0.551393 | hotp.erl | starcoder |
%%%-------------------------------------------------------------------
%% @author <NAME> <<EMAIL>>
%% @copyright (C) 2017, <NAME>
%% @doc erl_naive_bayes.erl
%% Naive Bayes means that the simplifying assumption that the value of
%% a particular feature is independent of the values of other features.
%% Learning in Naiv... | erl_naive_bayes/erl_naive_bayes.erl | 0.67854 | 0.750027 | erl_naive_bayes.erl | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.