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 Instream.Connection do
@moduledoc """
Defines a connection to an InfluxDB instance.
## Connection Definition
defmodule MyConnection do
use Instream.Connection, otp_app: :my_app
end
This connection will fetch it's configuration from the application environment
as defined by `:o... | lib/instream/connection.ex | 0.892756 | 0.455441 | connection.ex | starcoder |
defmodule Rlp do
@type rlp() :: binary() | [rlp()]
@spec encode!(nil | binary() | maybe_improper_list() | non_neg_integer() | tuple()) :: binary()
def encode!(<<x>>) when x < 0x80, do: <<x>>
def encode!(x) when is_binary(x) do
with_length!(0x80, x)
end
def encode!(list) when is_list(list) do
with... | lib/rlp.ex | 0.733547 | 0.535341 | rlp.ex | starcoder |
defmodule YelpEx.Client do
@moduledoc """
Client to interact with Yelp's Fusion API.
"""
use YelpEx.Client.Base
@doc """
Issues a GET request to the `/businesses/search` endpoint.
GET https://api.yelp.com/v3/businesses/search
This endpoint performs a search of businesses
based on the options s... | lib/yelp_ex/client.ex | 0.881749 | 0.42922 | client.ex | starcoder |
defmodule Kalevala.Event.ItemDrop do
@moduledoc """
Events to drop an item in a room
In order to drop an item, send an `ItemDrop.Request` event with the
item instance. The room will call the `item_request_drop` callback
on the room module.
Depending on the response, an `Abort` or `Commit` event will be se... | lib/kalevala/event/item.ex | 0.807726 | 0.40754 | item.ex | starcoder |
defmodule Score.Server do
@moduledoc """
Score.Server is a GenServer that have 2 elements as state:
`max_number` (random number between 0..100) and a timestamp
(defaults to `nil` for the first query))
This GenServer run every minute and when it runs:
- Should update every user's points in the database
... | lib/score/server.ex | 0.892517 | 0.675678 | server.ex | starcoder |
defmodule SimpleSecrets.Primatives do
def nonce() do
:crypto.strong_rand_bytes(16)
end
def derive(master, role) do
:crypto.hash(:sha256, [master, role])
end
def derive_sender_hmac(master) do
derive(master, "simple-crypto/sender-hmac-key")
end
def derive_sender_key(master) do
derive(mast... | lib/simple_secrets/primatives.ex | 0.584745 | 0.561395 | primatives.ex | starcoder |
defmodule SanbaseWeb.Graphql.AbsintheBeforeSend do
@moduledoc ~s"""
Cache & Persist API Call Data right before sending the response.
This module is responsible for persisting the API Call data and
cache the whole result of some queries right before it is send to the client.
All queries that did not raise ex... | lib/sanbase_web/graphql/absinthe_before_send.ex | 0.773943 | 0.441492 | absinthe_before_send.ex | starcoder |
defmodule Aoc2021.Day8 do
@moduledoc """
See https://adventofcode.com/2021/day/8
"""
@spec solve_part1() :: non_neg_integer()
@spec solve_part1(Path.t()) :: non_neg_integer()
def solve_part1(path \\ "priv/day8/input.txt") do
path
|> read_input()
|> Stream.map(fn {_, v} -> v end)
|> Stream.m... | lib/aoc2021/day8.ex | 0.773772 | 0.553626 | day8.ex | starcoder |
defmodule Phoenix.HTML.SimplifiedHelpers.TimeAgoInWords do
import Phoenix.HTML.SimplifiedHelpers.Gettext
@minutes_in_year 525_600
@minutes_in_quarter_year 131_400
@minutes_in_three_quarters_year 394_200
def time_ago_in_words(from_time),
do: distance_of_time_in_words(from_time, :os.system_time(:seconds))... | lib/phoenix_html_simplified_helpers/time_ago_in_words.ex | 0.624294 | 0.477006 | time_ago_in_words.ex | starcoder |
defmodule Throttlex.Bucket.Counter do
@moduledoc """
This module defines a gen_server that owns a named public ETS table.
The table contains counters aggregated by time slots of in seconds).
These counters allow counting/tracking the rate for errors, requests,
and any other variable we are interested in.
P... | lib/throttlex/bucket/counter.ex | 0.932745 | 0.482185 | counter.ex | starcoder |
defmodule Postgrex.Interval do
@moduledoc """
Struct for Postgres interval.
## Fields
* `months`
* `days`
* `secs`
"""
@type t :: %__MODULE__{months: integer, days: integer, secs: integer}
defstruct months: 0, days: 0, secs: 0
end
defmodule Postgrex.Range do
@moduledoc """
Struct for P... | lib/postgrex/builtins.ex | 0.911888 | 0.618608 | builtins.ex | starcoder |
defmodule InflexDB do
@moduledoc """
Client for [InfluxDB](https://www.influxdata.com/products/influxdb-overview/)
Checkout `InflexDB.Client` on how to instantiate and configure a client.
"""
alias InflexDB.{
Authentication,
Client,
Point,
HTTPRequest,
HTTPResponse,
HTTPClient,
L... | lib/inflex_db.ex | 0.870336 | 0.577436 | inflex_db.ex | starcoder |
defmodule FalconPlusApi.Api.Strategy do
alias Maxwell.Conn
alias FalconPlusApi.{Util, Sig, Api}
@doc """
* [Session](#/authentication) Required
### Request
```{
"tpl_id": 221,
"tags": "",
"run_end": "24:00",
"run_begin": "00:00",
"right_value": "1",
"prior... | lib/falcon_plus_api/api/strategy.ex | 0.595375 | 0.748145 | strategy.ex | starcoder |
defimpl ExPlasma.TypedData, for: ExPlasma.Transaction do
import ExPlasma.Encoding, only: [to_binary: 1, keccak_hash: 1]
import ABI.TypeEncoder, only: [encode_raw: 2]
alias ExPlasma.Configuration
alias ExPlasma.Output
alias ExPlasma.TypedData
# Prefix and version byte motivated by http://eips.ethereum.org/... | lib/ex_plasma/typed_data/transaction.ex | 0.67854 | 0.456168 | transaction.ex | starcoder |
defmodule Geometry.LineString do
@moduledoc """
A line-string struct, representing a 2D line.
A none empty line-string requires at least two points.
"""
alias Geometry.{GeoJson, LineString, Point, WKB, WKT}
defstruct points: []
@type t :: %LineString{points: Geometry.coordinates()}
@doc """
Creat... | lib/geometry/line_string.ex | 0.957387 | 0.523481 | line_string.ex | starcoder |
defmodule MafiaEngine.Players do
@moduledoc """
This module defines the type for a player list and functions to handle it.
## Examples
iex> p = MafiaEngine.Players.new()
[]
iex> {:ok, p} = MafiaEngine.Players.add(p, "Abed")
{:ok, [%MafiaEngine.Player{alive: true, name: "Abed", role: :unknown}]}
i... | lib/mafia_engine/players.ex | 0.723895 | 0.417925 | players.ex | starcoder |
defmodule AWS.CloudFront do
@moduledoc """
Amazon CloudFront
This is the *Amazon CloudFront API Reference*. This guide is for developers
who need detailed information about CloudFront API actions, data types, and
errors. For detailed information about CloudFront features, see the *Amazon
CloudFront Develo... | lib/aws/generated/cloud_front.ex | 0.874185 | 0.503967 | cloud_front.ex | starcoder |
defmodule Rampart.Controller do
@moduledoc ~S"""
The Controller module provides functions that are
to be used by controllers in your application. These
may not strictly be controllers, but they are for
the part of your application that will handle the
request, and trigger the authorisation.
"""
@typedo... | lib/rampart/controller.ex | 0.682679 | 0.400632 | controller.ex | starcoder |
defmodule AwsCredentials do
@moduledoc """
GenServer that catches the fetched credendials and re-fetches them when they expire
Usage:
```
# Start the application with env provider
{:ok, _pid} = AwsCredentials.start_link(provider: AwsCredentials.Providers.Environment)
# Or start the application w... | lib/aws_credentials.ex | 0.805211 | 0.66737 | aws_credentials.ex | starcoder |
defmodule Chaperon.Action do
@moduledoc """
Helper functions to be used with `Chaperon.Actionable`.
"""
@doc """
Retries `action` within `session` by calling `Chaperon.Actionable.abort/2`
followed by `Chaperon.Actionable.run/2`.
"""
def retry(action, session) do
with {:ok, action, session} <- Chape... | lib/chaperon/action.ex | 0.898309 | 0.611672 | action.ex | starcoder |
defmodule P1.Parser do
use Combine
import Combine.Parsers.Base
import Combine.Parsers.Text
alias P1.Channel, as: Channel
alias P1.Tags, as: Tags
@moduledoc """
Understands the P1 format of Smartmeters and translates them to elixir types
As the specification says that all lines wih obis codes are op... | lib/p1/parser.ex | 0.599837 | 0.455683 | parser.ex | starcoder |
defmodule NimblePool do
@external_resource "README.md"
@moduledoc "README.md"
|> File.read!()
|> String.split("<!-- MDOC !-->")
|> Enum.fetch!(1)
use GenServer
require Logger
@type from :: {pid, reference}
@type init_arg :: term
@type pool_state :: term
@type wor... | lib/nimble_pool.ex | 0.885452 | 0.486149 | nimble_pool.ex | starcoder |
defmodule ResxJSON.Partial do
@moduledoc """
Functions that can be used to build partials for a partial stream will be
processed by `ResxJSON.Encoder`.
"""
defstruct [literal: "", separator: "", element: true, prefix: "", suffix: "", end: false]
@doc """
Create part of a JSON string ... | lib/resx_json/partial.ex | 0.807499 | 0.538498 | partial.ex | starcoder |
defmodule Ash.Filter do
@moduledoc """
The representation of a filter in Ash.
Ash filters are stored as nested `Ash.Filter.Expression{}` and `%Ash.Filter.Not{}` structs,
terminating in a `%Ash.Filter.Predicate{}` struct. An expression is simply a boolean operator
and the left and right hand side of that oper... | lib/ash/filter/filter.ex | 0.88758 | 0.668691 | filter.ex | starcoder |
defmodule ExCell.LiveView do
@moduledoc """
Cell helpers used to render the live view cells in both Views and Cells
"""
@view_adapter ExCell.config(:view_adapter, Phoenix.LiveView)
@doc """
Renders a cell in the view.
### Examples
iex(0)> safe_to_string(AppWeb.AvatarView.live_cell(AvatarLive... | lib/ex_cell/live_view.ex | 0.719285 | 0.549641 | live_view.ex | starcoder |
defmodule Mmo.Collision do
alias Mmo.{World, Player}
def check(%{x: x, y: y}, %World{width: width, height: height})
when x < 0 or y < 0 or x >= width or y >= height do
{:collision, :static_object}
end
def check(%Player{} = player, %World{} = world) do
if collision_check(player, world) do
{... | lib/mmo/collision.ex | 0.556882 | 0.535827 | collision.ex | starcoder |
defprotocol Dict do
@only [Record]
@moduledoc """
This module provides the Dict protocol
with the goal of being a common API
to work with dictionaries.
"""
@doc """
Returns a list containing all dict's keys.
The keys are not guaranteed to be sorted, unless
the underlying dict implementation define... | lib/elixir/lib/dict.ex | 0.885554 | 0.773772 | dict.ex | starcoder |
defmodule Faker.Cat.En do
import Faker, only: [sampler: 2]
@moduledoc """
Functions for Cat names, breeds and registries in English
"""
@doc """
Returns a Cat name string
## Examples
iex> Faker.Cat.En.name()
"Daisy"
iex> Faker.Cat.En.name()
"Lily"
iex> Faker.Cat.En.name()... | lib/faker/cat/en.ex | 0.696784 | 0.472501 | en.ex | starcoder |
defmodule Site.TripPlan.ItineraryRowList do
@moduledoc """
Information about an Itinerary that's used for rendering.
An optional to and from name can be passed in.
"""
alias Site.TripPlan.ItineraryRow
alias TripPlan.Itinerary
alias Stops.Stop
@typep destination :: {String.t(), Stop.id_t(), DateTime.t(... | apps/site/lib/site/trip_plan/itinerary_row_list.ex | 0.727201 | 0.428951 | itinerary_row_list.ex | starcoder |
defmodule Hocon do
@moduledoc"""
This module pareses and decodes a [hocon](https://github.com/lightbend/config/blob/master/HOCON.md) configuration string.
## Example
iex(1)> conf = ~s(animal { favorite : "dog" }, key : \"\"\"${animal.favorite} is my favorite animal\"\"\")
iex(2)> Hocon.decode(conf)... | lib/hocon.ex | 0.904622 | 0.467028 | hocon.ex | starcoder |
defmodule TeslaOAuth2ClientAuth.ClientSecretJWT do
@moduledoc """
Tesla middleware that implements the `"client_secret_jwt"` authentication scheme for
[https://openid.net/specs/openid-connect-core-1_0.html#ClientAuthentication](OpenID Connect clients)
The client configuration must contain a `"client_secret"` m... | lib/tesla_oauth2_client_auth/client_secret_jwt.ex | 0.858348 | 0.420034 | client_secret_jwt.ex | starcoder |
defmodule Mix.Tasks.Materialize.Install do
@moduledoc """
Install materialize package
```shell
$ mix materialize.install
```
Comment out or delete the contents of the file **assets/css/phoenix.css**
If you are using a brunch, change the file **assets/brunch-config.js**:
```Elixir
#{Materialize.if_use_... | lib/mix/tasks/install.ex | 0.614972 | 0.611237 | install.ex | starcoder |
defmodule ReIntegrations.Orulo.Mapper do
@moduledoc """
Module to map external structures into persistable internal structures.
"""
alias ReIntegrations.{
Orulo.BuildingPayload
}
@development_attributes ~w(name description developer number_of_floors apts_per_floor status id)
def building_payload_into... | apps/re_integrations/lib/orulo/mapper.ex | 0.682679 | 0.478407 | mapper.ex | starcoder |
defmodule Resonator.Helpers do
@moduledoc """
require Resonator.Helpers, as: H # the cool way
"""
@doc """
Convenience to get environment bits. Avoid all that repetitive
`Application.get_env( :myapp, :blah, :blah)` noise.
Use it as `H.env(:anyapp, :key, default)`
You can add the default ap... | lib/resonator/helpers.ex | 0.706292 | 0.731107 | helpers.ex | starcoder |
defmodule Vtc.Source do
@moduledoc """
Protocols for source values that can be used to construct a timecode.
"""
use Ratio
@typedoc """
Result type of `Vtc.Source.Seconds.seconds/2`.
"""
@type seconds_result :: {:ok, Ratio.t() | integer} | {:error, Vtc.Timecode.ParseError.t()}
defprotocol Seconds d... | lib/sources.ex | 0.928198 | 0.612136 | sources.ex | starcoder |
defmodule Nx.Defn.Grad do
@moduledoc false
alias Nx.Defn.{Expr, Tree}
alias Nx.Tensor, as: T
def transform(to_grad, expr) do
expr = validate_expr!(expr)
initial = Expr.tensor(1.0)
{graded, _} =
Tree.composite(to_grad, %{}, fn to_grad, shared ->
id = grad_id!(to_grad)
{graded... | lib/nx/defn/grad.ex | 0.712632 | 0.585397 | grad.ex | starcoder |
defmodule HighRoller.Parser do
@moduledoc """
Documentation for the Parser module. This module contains all the code for parsing strings and turning them into the results of dice rolls.
"""
@doc """
Parses a roll string into a final result
## Examples
iex> HighRoller.Parser.parse("3d1")
3
... | lib/high_roller/parser.ex | 0.663342 | 0.548915 | parser.ex | starcoder |
defmodule Distributed.Replicator.Node do
@moduledoc """
The functions in `Distributed.Replicator.Node` module helps to replicate an event by processing it on the all nodes in the network.
In `Distributed.Replicator.Node`, functions execute processes in parallel.
**Note**: Since this module is only a wrapper for `N... | lib/distributed/replicator/node.ex | 0.719186 | 0.631339 | node.ex | starcoder |
defmodule ExHal.Link do
@moduledoc """
A Link is a directed reference from one resource to another resource. They
are found in the `_links` and `_embedded` sections of a HAL document
"""
use Expat
alias ExHal.{Document, NsReg}
@typedoc """
A link. Links may be simple or dereferenced (from the embe... | lib/exhal/link.ex | 0.872714 | 0.542015 | link.ex | starcoder |
defmodule Bricks.Connector.Tcp do
@moduledoc """
A Connector for TCP sockets, using `:gen_tcp`
Belongs to application `:bricks`
## Create Options
### All
Ordering: Required first, then alphabetical
Option | Type(s) | Default | Raw `gen_tcp` option
:----------------... | bricks/lib/connectors/tcp.ex | 0.808483 | 0.806243 | tcp.ex | starcoder |
defmodule Modbux.Rtu.Master do
@moduledoc """
API for a Modbus RTU Master device.
"""
use GenServer, restart: :transient
alias Modbux.Rtu.{Master, Framer}
alias Modbux.Rtu
alias Circuits.UART
require Logger
@timeout 1000
@speed 115_200
defstruct tty: nil,
timeout: nil,
c... | lib/rtu/master.ex | 0.886635 | 0.667107 | master.ex | starcoder |
defmodule UsersService.Infra.MapHelper do
@doc """
Convert map string camelCase keys to underscore_keys
"""
def underscore_keys(nil), do: nil
def underscore_keys(map = %{}) do
map
|> Enum.map(fn {k, v} -> {Macro.underscore(k), underscore_keys(v)} end)
|> Enum.map(fn {k, v} -> {String.replace(k, "... | users_service/lib/infra/map_helper.ex | 0.731155 | 0.465448 | map_helper.ex | starcoder |
defmodule Sourceror.Comments do
@moduledoc """
Utilities to merge an un-merge comments and quoted expressions.
"""
import Sourceror.Identifier, only: [is_pipeline_op: 1, is_binary_op: 1]
@doc """
Merges the comments into the given quoted expression.
The comments are inserted into the metadata of their ... | lib/sourceror/comments.ex | 0.747524 | 0.616532 | comments.ex | starcoder |
import Kernel, except: [apply: 2]
defmodule Ecto.Query.Builder.Select do
@moduledoc false
alias Ecto.Query.Builder
@doc """
Escapes a select.
It allows tuples, lists and variables at the top level. Inside the
tuples and lists query expressions are allowed.
## Examples
iex> escape({1, 2}, [], _... | lib/ecto/query/builder/select.ex | 0.791055 | 0.444444 | select.ex | starcoder |
defmodule Crux.Structs do
@moduledoc """
Provides a unified function to create one or a list of structs, invoking their `create/1` function if available.
"""
alias Crux.Structs.Util
require Util
Util.modulesince("0.1.0")
@doc """
Can be implemented by structs to transform the inital data.
"""
... | lib/structs.ex | 0.860589 | 0.680912 | structs.ex | starcoder |
defmodule AshJsonApi.Resource do
@route_schema [
route: [
type: :string,
required: true,
doc: "The path of the route"
],
action: [
type: :atom,
required: true,
doc: "The action to call when this route is hit"
],
primary?: [
type: :boolean,
default: f... | lib/ash_json_api/resource/resource.ex | 0.808748 | 0.747869 | resource.ex | starcoder |
defmodule StepFlow.Workflows.Status do
use Ecto.Schema
import Ecto.Changeset
import Ecto.Query, warn: false
import EctoEnum
alias StepFlow.Jobs
alias StepFlow.Progressions.Progression
alias StepFlow.Repo
alias StepFlow.Workflows
alias StepFlow.Workflows.Workflow
require Logger
@moduledoc false
... | lib/step_flow/workflows/status.ex | 0.658966 | 0.438424 | status.ex | starcoder |
defmodule FixtureBuilder.Executer do
@moduledoc false
alias FixtureBuilder.Op
alias FixtureBuilder.Utils
def execute(fixtures, module), do: execute_next(fixtures, module)
defp execute_next(%FixtureBuilder{ops: []} = fixtures, _), do: fixtures
defp execute_next(%FixtureBuilder{ops: [%Op{name: :put} = op ... | lib/fixture_builder/executer.ex | 0.698638 | 0.513851 | executer.ex | starcoder |
defmodule Garuda.RoomManager.RoomDb do
@moduledoc false
# Stores the info of all the game-rooms and functions to manage those data.
# Orwell uses data from RoomDb, for rendering the live interactive dashboard
alias Garuda.MatchMaker.Matcher
alias Garuda.RoomManager.Records
use GenServer
@room_db_name :... | lib/room_manager/room_db.ex | 0.807916 | 0.44077 | room_db.ex | starcoder |
defmodule Nostrum.Struct.Guild.Role do
@moduledoc ~S"""
Struct representing a Discord role.
## Mentioning Roles in Messages
A `Nostrum.Struct.Guild.Role` can be mentioned in message content using the `String.Chars`
protocol or `mention/1`.
```Elixir
role = %Nostrum.Struct.Guild.Role{id: 431886897539973... | lib/nostrum/struct/guild/role.ex | 0.893434 | 0.723138 | role.ex | starcoder |
defmodule Weber.Utils do
@moduledoc """
Weber utils functions.
"""
import Enum
@doc """
Convert :calendar.local_time to string
"""
def get_time() do
{{year, month, day}, {hours, minutes, seconds}} = :calendar.local_time()
Integer.to_string(year) <> "." <> Integer.to_string(month) <> "." ... | lib/weber/utils/utils.ex | 0.697712 | 0.417717 | utils.ex | starcoder |
defmodule Game.Command.Move do
@moduledoc """
The movement commands: north, east, south, west
"""
use Game.Command
use Game.Zone
alias Data.Exit
alias Game.Command.AFK
alias Game.Door
alias Game.Player
alias Game.Quest
alias Game.Session.GMCP
alias Metrics.CharacterInstrumenter
@must_be_ali... | lib/game/command/move.ex | 0.786049 | 0.410638 | move.ex | starcoder |
defmodule Terrasol.Author do
@moduledoc """
Handling of Earthstar author strings and resulting
Terrasol.Author.t structures
"""
@enforce_keys [
:string,
:shortname,
:publickey
]
defstruct string: "",
shortname: "",
publickey: "",
privatekey: nil
@typedoc... | lib/terrasol/author.ex | 0.735547 | 0.603844 | author.ex | starcoder |
defmodule Crdt.VectorClock do
@moduledoc """
A Vector Clock is capable of generating a partial ordering of events in a distributed system and
detecting causality vioations. It is essentially a map of actors to their logical clock value.
"""
@type t :: %{any() => non_neg_integer()}
@doc """
Returns a new... | lib/crdt/vector_clock.ex | 0.883513 | 0.703269 | vector_clock.ex | starcoder |
defmodule QueryBuilder.Query.Where do
@moduledoc false
require Ecto.Query
import QueryBuilder.Utils
def where(ecto_query, assoc_list, filters, or_filters) do
dynamic_query = build_dynamic_query(ecto_query, assoc_list, filters, or_filters)
Ecto.Query.where(ecto_query, ^dynamic_query)
end
def buil... | lib/query/where.ex | 0.670177 | 0.536009 | where.ex | starcoder |
defmodule Slime.Parser.Nodes do
defmodule HTMLNode do
@moduledoc """
An HTML node.
* :name — tag name,
* :attributes — a list of {"name", :v} tuples, where :v is
either a string or an {:eex, "content"} tuple,
* :spaces — tag whitespace, represented as a keyword list of boolean
values for ... | lib/slime/parser/nodes.ex | 0.78374 | 0.666283 | nodes.ex | starcoder |
defmodule Enchufeweb do
@moduledoc """
`Enchufeweb` is a websocket client library written in Elixir and based on
the Erlang library [websocket_client](https://hex.pm/packages/websocket_client).
"""
@type frame :: :close | :ping | :pong | binary
@type conn_mode :: :disconnected | :once | :reconnect
@type... | lib/enchufeweb.ex | 0.731538 | 0.405743 | enchufeweb.ex | starcoder |
defmodule Vow.Ref do
@moduledoc """
This vow is a reference to a 0-arity function that returns a vow.
This allows for the named definition of commonly used vows, and for
the definition of recursive vows.
"""
@behaviour Access
import Vow.FunctionWrapper, only: [wrap: 1]
alias Vow.ResolveError
defst... | lib/vow/ref.ex | 0.809464 | 0.471406 | ref.ex | starcoder |
defmodule Meddle.Pipe do
@moduledoc false
defstruct queue: :queue.new(),
stack: [],
direction: :enter
@type t :: %__MODULE__{
queue: :queue.queue(),
stack: list,
direction: direction
}
@type direction :: :enter | :leave
@spec new(list, direction... | lib/meddle/pipe.ex | 0.820972 | 0.473536 | pipe.ex | starcoder |
defmodule StarkInfra.Webhook do
alias __MODULE__, as: Webhook
alias StarkInfra.Utils.Rest
alias StarkInfra.Utils.Check
alias StarkInfra.User.Project
alias StarkInfra.User.Organization
alias StarkInfra.Error
@moduledoc """
Groups Webhook related functions
"""
@doc """
A Webhook is used to subscri... | lib/webhook/webhook.ex | 0.885359 | 0.470311 | webhook.ex | starcoder |
defmodule Web3x.Abi do
@doc "Decodes event based on given data and provided signature"
@spec decode_event(binary(), binary()) :: any()
def decode_event(data, signature) do
formatted_data =
data
|> String.slice(2..-1)
|> Base.decode16!(case: :lower)
fs = ABI.FunctionSelector.decode(signa... | lib/web3x/abi.ex | 0.817429 | 0.451447 | abi.ex | starcoder |
defmodule ExImageInfo do
alias ExImageInfo.Types.{PNG, GIF, JPEG, BMP, TIFF, WEBP, PSD, JP2, PNM, ICO}
@moduledoc """
ExImageInfo is an Elixir library to parse images (binaries) and get the dimensions (size), detected mime-type and overall validity for a set of image formats. Main module to parse a binary and g... | lib/ex_image_info.ex | 0.846514 | 0.732041 | ex_image_info.ex | starcoder |
defmodule Adventofcode.Day14DiskDefragmentation do
alias Adventofcode.Day10KnotHash
def squares_count(input) do
input
|> squares()
|> Enum.map(&used_square_count/1)
|> Enum.sum()
end
def regions_count(input) do
input
|> regions()
|> length()
end
def regions(input) do
input... | lib/day_14_disk_defragmentation.ex | 0.539226 | 0.594669 | day_14_disk_defragmentation.ex | starcoder |
defmodule Flower.Bloom do
use Bitwise
alias Flower.Native.BitArray, as: BitArray
@moduledoc """
Flower.Bloom implements a Bloom Filter.
For this Bloom Filter sha256 or sha512 is used as hash function.
"""
@ser_vsn 1
@byte_sizes [
:"8 Byte",
:"16 Byte",
:"32 Byte",
:"64 Byte",
:"1... | lib/flower/bloom.ex | 0.915724 | 0.474449 | bloom.ex | starcoder |
defmodule PassiveSupport.String do
@moduledoc """
Helper functions for working with strings and UTF-8 binary data.
"""
@doc ~S"""
Converts the provided pattern to a regular expression, if necessary,
and then invokes `Regex.run` on the expression and the string.
Useful for invoking regular expressions on... | lib/passive_support/base/string.ex | 0.889466 | 0.621311 | string.ex | starcoder |
defmodule Raygun do
@moduledoc """
Send errors to Raygun. Errors can be captured in three different ways.
1. Any errors that are logged
2. Any exceptions that occur in a Plug
3. Programmatically
All the functions will return `:ok`, `{:error, reason}`, or :ignored
"""
@api_endpoint "https://api.raygun... | lib/raygun.ex | 0.759582 | 0.424889 | raygun.ex | starcoder |
defmodule Servy.PledgeServer do
@name :pledge_server
use GenServer
defmodule State do
defstruct cache_size: 3, pledges: []
end
# Client Interface
def start do
IO.puts "Starting the pledge server..."
GenServer.start(__MODULE__, %State{}, name: @name)
end
def create_pledge(name, amount) ... | video-code/28-linking-processes/servy/lib/servy/pledge_server.ex | 0.552419 | 0.416678 | pledge_server.ex | starcoder |
defmodule AOC.Y2021.Day15 do
@behaviour AOC.Solution
@neighbor_offsets [{-1, 0}, {1, 0}, {0, -1}, {0, 1}]
def input_path() do
"./lib/2021/input/day15.txt"
end
def parse_input(input) do
# Expand grid to 5x5 repeating tiles (we'll calc the risk increases dynamically)
rows =
input
|> S... | lib/2021/day15.ex | 0.744656 | 0.662201 | day15.ex | starcoder |
defmodule RDF.XSD.AnyURI do
@moduledoc """
`RDF.XSD.Datatype` for XSD anyURIs.
See: <http://www.w3.org/TR/xmlschema11-2/#anyURI>
"""
@type valid_value :: URI.t()
use RDF.XSD.Datatype.Primitive,
name: "anyURI",
id: RDF.Utils.Bootstrapping.xsd_iri("anyURI")
alias RDF.{IRI, XSD}
import RDF.Gua... | lib/rdf/xsd/datatypes/any_uri.ex | 0.712032 | 0.505676 | any_uri.ex | starcoder |
defmodule Riffed.Struct do
@moduledoc ~S"""
Parses your thrift files and builds some Elixir-y structs and conversion functions for you.
Assuming you have the following Thrift structs defined in src/request_types.erl:
struct User {
1: i32 id,
2: string firstName,
3: string lastName;... | lib/riffed/struct.ex | 0.67854 | 0.463201 | struct.ex | starcoder |
defmodule Imagineer.Image.PNG.Filter.Basic.Sub do
import Imagineer.Image.PNG.Helpers, only: [null_binary: 1]
@moduledoc """
The Sub filter transmits the difference between each byte and the value of the
corresponding byte of the prior pixel.
"""
@doc """
Takes in the uncompressed binary for a sub-filter... | lib/imagineer/image/png/filter/basic/sub.ex | 0.825308 | 0.521898 | sub.ex | starcoder |
defmodule Ecto.Query.Builder.Filter do
@moduledoc false
alias Ecto.Query.Builder
@doc """
Escapes a where or having clause.
It allows query expressions that evaluate to a boolean
or a keyword list of field names and values. In a keyword
list multiple key value pairs will be joined with "and".
"""
@... | lib/ecto/query/builder/filter.ex | 0.827828 | 0.496277 | filter.ex | starcoder |
defmodule ExXml do
@moduledoc """
ExXml allows you to use XML in your library to construct code.
This can be helpful if you need to deal more descriptive type of
programming like the ones that are already using a SGML or XML languages
like HTML and ODF. It also allows you to compose components out of Pascal
... | lib/ex_xml.ex | 0.840881 | 0.465145 | ex_xml.ex | starcoder |
defmodule Rummage.Ecto.CustomHook.SimpleSearch do
@moduledoc """
`Rummage.Ecto.CustomHook.SimpleSearch` is an example of a Custom Hook that
comes with `Rummage.Ecto`.
This module provides a operations that can add searching functionality to
a pipeline of `Ecto` queries. This module works by taking fields, an... | lib/rummage_ecto/custom_hooks/simple_search.ex | 0.812198 | 0.936227 | simple_search.ex | starcoder |
defmodule Lichex.Summary do
defmodule Category do
defstruct count: 0, wins: 0
def new(attrs \\ []) do
struct(__MODULE__, attrs)
end
def inc(%{count: count, wins: wins}, true) do
new(count: count + 1, wins: wins + 1)
end
def inc(%{count: count} = cat, false) do
%{cat | coun... | lib/lichess/summary.ex | 0.708112 | 0.459076 | summary.ex | starcoder |
defmodule PoxTool.CLI do
@moduledoc """
PoxTool is a utility for working with poxels.
usage:
poxtool [command] [args]
Commands:
* `create` - Create a poxel.
* `help` - Prints this message and exits.
### create
poxtool create [options] FILE
Options:
... | lib/pox_tool/cli.ex | 0.781164 | 0.568326 | cli.ex | starcoder |
defmodule Handle do
@moduledoc """
Handle module for list entries such as `items` and `emails`.
The most used function and the `calculate/2` function.
"""
@doc """
Function calculates the total value of a list of items,
divides the total amount according to the amount and past emails.
## Function para... | lib/handle.ex | 0.868227 | 0.922552 | handle.ex | starcoder |
defmodule Uplink.Monitor do
@moduledoc """
A behaviour module for implementing a library or application monitor.
Uplink Monitors provide a template for the most common requirements to instrument a library
or application in a consistent manner. These provide a simple abstraction for building
standard observab... | lib/uplink/monitor.ex | 0.909754 | 0.506286 | monitor.ex | starcoder |
defmodule Timex.Ecto.Time do
@moduledoc """
Support for using Timex with :time fields
"""
use Timex
@behaviour Ecto.Type
def type, do: :time
@doc """
We can let Ecto handle blank input
"""
defdelegate blank?(value), to: Ecto.Type
@doc """
Handle casting to Timex.Ecto.Time
"""
def cast(in... | lib/types/time.ex | 0.765593 | 0.406479 | time.ex | starcoder |
defmodule AnyAscii do
@moduledoc """
Unicode to ASCII transliteration
Converts Unicode characters to their best ASCII representation
AnyAscii provides ASCII-only replacement strings for practically all Unicode
characters. Text is converted character-by-character without considering the
context. The mappin... | impl/elixir/lib/any_ascii.ex | 0.751375 | 0.406391 | any_ascii.ex | starcoder |
defmodule Mix.Tasks.Xtra do
use Mix.Task
alias Extractly.Toc.Options
@shortdoc "Transforms templates"
@moduledoc """
## Mix task to Transform EEx templates in the context of the `Extractly` module.
This tool serves two purposes.
1. A simple CLI to basicly `EEx.eval_file/2`
1. Access to the... | lib/tasks/xtra.ex | 0.646237 | 0.509764 | xtra.ex | starcoder |
defmodule Formex.View do
use Phoenix.HTML
alias Formex.Form
alias Formex.Field
alias Formex.FormCollection
alias Formex.FormNested
alias Formex.Button
@moduledoc """
Helper functions for templating.
Example of use:
<%= formex_form_for @form, @action, fn f -> %>
<%= if @form.submitted?... | lib/formex/view.ex | 0.765067 | 0.501221 | view.ex | starcoder |
defmodule AWS.GameLift do
@moduledoc """
Amazon GameLift Service
Amazon GameLift is a managed service for developers who need a scalable,
dedicated server solution for their multiplayer games. Use Amazon GameLift
for these tasks: (1) set up computing resources and deploy your game
servers, (2) run game se... | lib/aws/gamelift.ex | 0.806777 | 0.623749 | gamelift.ex | starcoder |
defmodule Hand do
@hands %{
high_card: 1,
pair: 2,
two_pair: 3,
three_of_a_kind: 4,
straight: 5,
flush: 6,
full_house: 7,
four_of_a_kind: 8,
straight_flush: 9,
royal_flush: 10
}
def high(hand) do
hand = Enum.sort_by(h... | poker_equity_evaluator/lib/hand.ex | 0.542621 | 0.44089 | hand.ex | starcoder |
defmodule Plymio.Funcio.Enum.Map do
@moduledoc ~S"""
Map Functions for an Enumerable.
See `Plymio.Funcio` for overview and documentation terms.
> The concurrent functions currently produce a `List` rather than a
`Stream`. But this could change in the future. The examples below assumes a `Stream` was retur... | lib/funcio/enum/map/map.ex | 0.841044 | 0.488527 | map.ex | starcoder |
defmodule Sue.DB do
@moduledoc """
The following is, I suppose, temporary. While I find Mnesia really cool, I
think going forward we're better off using something else.
"""
use GenServer
require Logger
alias __MODULE__
alias :mnesia, as: Mnesia
@kv_tables [:state]
def start_link(args) do
... | lib/sue/db/d_b.ex | 0.786336 | 0.413033 | d_b.ex | starcoder |
defmodule GenStage.BroadcastDispatcher do
@moduledoc """
A dispatcher that accumulates demand from all consumers
before broadcasting events to all of them.
If a producer uses `GenStage.BroadcastDispatcher`, its subscribers
can specify an optional `:selector` function that receives the event
and returns a b... | deps/gen_stage/lib/gen_stage/dispatchers/broadcast_dispatcher.ex | 0.846101 | 0.611034 | broadcast_dispatcher.ex | starcoder |
defmodule Casex do
@moduledoc """
Simple case conversion for web applications.
Easily decodes `camelCase` body payloads to `snake_case` and
response payloads from `camelCase` to `snake_case`.
Useful to maintain to expose your API in `camelCase` but keep internally the elixir naming conventions.
It leverage... | lib/casex.ex | 0.857351 | 0.866076 | casex.ex | starcoder |
defmodule AlgorithmSelector do
@moduledoc """
Determines which weighting and summing strategy to use to validate a
bank account number.
"""
@doc """
Checks that a given bank_id, bank_branch, and base falls has the expected
value or falls within the expected range.
Returns {:ok, <summing strategy>, <we... | lib/algorithm_selector.ex | 0.76145 | 0.734976 | algorithm_selector.ex | starcoder |
defmodule BatchPlease do
@moduledoc ~S"""
BatchPlease is a tool for collecting batches of items, and doing something
with each batch when it reaches a certain size or age.
It is built on top of GenServer, implemented as a behaviour,
and usually invoked through `use BatchPlease`.
Simple/trivial usage examp... | lib/batch_please.ex | 0.789031 | 0.560132 | batch_please.ex | starcoder |
defmodule ExRets.DigestAccessAuthentication.Challenge do
@moduledoc false
@moduledoc since: "0.1.0"
defstruct realm: nil,
domain: [],
nonce: nil,
opaque: nil,
stale: false,
algorithm: :md5,
qop: []
@typedoc "Digest access authentication c... | lib/ex_rets/digest_access_authentication/challenge.ex | 0.923782 | 0.549399 | challenge.ex | starcoder |
defmodule AlchemyVM.HostFunction do
@moduledoc """
Exposes a DSL for defining and importing host functions
"""
@doc false
defmacro __using__(_opts) do
quote do
import AlchemyVM.HostFunction
@before_compile AlchemyVM.HostFunction
Module.register_attribute(__MODULE__, :host_funcs, ac... | lib/execution/host_function.ex | 0.821044 | 0.406067 | host_function.ex | starcoder |
defmodule ConCache.Item do
@moduledoc """
This struct can be used in place of naked values to set per-item TTL values.
"""
defstruct value: nil, ttl: 0
@type t :: %ConCache.Item{value: ConCache.value, ttl: pos_integer}
end
defmodule ConCache do
@moduledoc """
Implements an ETS based key/value storage wit... | lib/con_cache.ex | 0.895583 | 0.457076 | con_cache.ex | starcoder |
defmodule Softmax.AllReduce do
@world_size 3
def start(rank, vector, world_size, caller) do
name = String.to_atom("node_#{inspect(rank)}")
:logger.debug("Rank #{inspect(rank)} - Got: #{inspect(vector)}")
Process.register(self(), name)
normalizer =
vector
|> Matrex.to_list()
|> E... | lib/allreduce_softmax.ex | 0.641198 | 0.504455 | allreduce_softmax.ex | starcoder |
defmodule Discuss.Discussions do
@moduledoc """
The Discussions context.
"""
import Ecto.Query, warn: false
alias Discuss.Repo
alias Discuss.Discussions.Topic2
@doc """
Returns the list of topics.
## Examples
iex> list_topics()
[%Topic2{}, ...]
"""
def list_topics do
Repo.all... | programming/elixir-course/discuss/lib/discuss/discussions.ex | 0.771499 | 0.492859 | discussions.ex | starcoder |
defmodule XUtil.Dsf do
@moduledoc "Utilities for working with X-Plane's DSF scenery tiles"
import Comb
import XUtil.Math
# These values are for Mobile; Desktop uses 3x2 or even 4x3
@lon_degrees_loaded 2
@lat_degrees_loaded 2
@doc """
The DSF for a given lon/lat.
iex(1)> XUtil.Dsf.dsf(0.1234, 0.... | lib/x_util/dsf.ex | 0.730001 | 0.572723 | dsf.ex | starcoder |
% Regular expressions for Elixir built on top of the re module
% in the Erlang Standard Library. More information can be found
% on re documentation: http://www.erlang.org/doc/man/re.html
%
% Regular expressions in Elixir can be created using Regexp.new,
% Regexp.compile (check their documentation) or using the special... | lib/regexp.ex | 0.747984 | 0.548069 | regexp.ex | starcoder |
defmodule Spf.Context do
@moduledoc """
Functions to create, access and update an SPF evaluation context.
Many functions take and return an evaluation context whose purpose
is to store information gathered during the evaluation. This includes
a dns cache, an ip lookup table that maps prefixes to SPF terms t... | lib/spf/context.ex | 0.853974 | 0.836588 | context.ex | starcoder |
defmodule Ws.Models.Bird do
@moduledoc """
A model entry. A struct is currently the preferred data structure vs, say, a record.
"""
defstruct name: "<new>", type: "<type>", age: 0
end
defmodule Ws.Models.Birds do
require Ws.Models.Bird
use GenServer
@moduledoc """
Demonstrates a simple Model consistin... | lib/ws/models/birds.ex | 0.591487 | 0.505188 | birds.ex | starcoder |
defmodule Bounds.Set do
use Bitwise
import Bounds.Map.Records
alias Bounds.Map.Impl
defstruct [
root: nil,
segments: 0
]
@infinityish 1.0e100
def new, do: %__MODULE__{}
def new(coerceable) do
{bounds, _} = Coerce.coerce(coerceable, %Bounds{})
from_bounds(bounds)
end
def from_c... | lib/bounds/set.ex | 0.657098 | 0.550064 | set.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.