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 Ello.Search.Post.Trending do
def build_boosting_queries(search_struct) do
search_struct
|> boost_recent
|> boost_comment_count
|> boost_repost_count
|> boost_view_count
|> boost_love_count
|> update_score_mode
end
defp boost_recent(%{trending: true, following: false, catego... | apps/ello_search/lib/ello_search/post/trending.ex | 0.546496 | 0.465266 | trending.ex | starcoder |
defmodule UrbitEx.Session do
@moduledoc """
GenServer to keep state of an Urbit Session.
Creates a struct keeping track of global data, and client functions to add and remove channels.
"""
alias UrbitEx.{API, Channel, S3Config, Unread, Resource, Notification}
@derive Jason.Encoder
use GenServer
def... | lib/types/session.ex | 0.577019 | 0.411584 | session.ex | starcoder |
defmodule Tablespoon.Transport.FakeModem do
@moduledoc """
Transport implementation which pretends to be a modem.
By default, sends an initial "OK\n" line, then responds to any lines it receives with "OK".
However, there are some configuration variables that can be set to change that.
- send_error_rate: th... | lib/tablespoon/transport/fake_modem.ex | 0.740831 | 0.437343 | fake_modem.ex | starcoder |
defmodule Stop do
defstruct name: nil, ref: nil, timetable: [], lines: []
@last_time_checked {2017, 4, 10}
@last_time_checked_formatted @last_time_checked
|> Tuple.to_list
|> Enum.join("-")
@moduledoc """
Dublin Bus API
=============
Access to the Real Time Passenger Information (RTPI) for Dublin... | lib/stop.ex | 0.777933 | 0.519095 | stop.ex | starcoder |
defmodule D4 do
@moduledoc """
--- Day 4: Passport Processing ---
You arrive at the airport only to realize that you grabbed your North Pole Credentials instead of your passport. While these documents are extremely similar, North Pole Credentials aren't issued by a country and therefore aren't actually valid docu... | lib/days/04.ex | 0.675229 | 0.768255 | 04.ex | starcoder |
defmodule ExRabbitMQ.Producer do
@moduledoc """
A behaviour module that abstracts away the handling of RabbitMQ connections and channels.
It also provides hooks to allow the programmer to publish a message without having to directly
access the AMPQ interfaces.
For a connection configuration example see `ExR... | lib/ex_rabbit_m_q/producer.ex | 0.894086 | 0.801315 | producer.ex | starcoder |
defmodule Prog do
@moduledoc """
Documentation for `Prog`.
"""
@doc """
Hello world.
## Examples
iex> Prog.hello()
:world
"""
def solve do
{:ok, raw} = File.read("data/day_1/input")
strings = String.split(raw, "\n")
as_ints = Enum.map(strings, fn(s) -> String.to_integer(s) en... | lib/days/day_1.ex | 0.867275 | 0.455501 | day_1.ex | starcoder |
defmodule Kino.DataTable do
@moduledoc """
A kino for interactively viewing tabular data.
The data must be a tabular data supported by `Table`.
## Examples
data = [
%{id: 1, name: "Elixir", website: "https://elixir-lang.org"},
%{id: 2, name: "Erlang", website: "https://www.erlang.org"}
... | lib/kino/data_table.ex | 0.910177 | 0.741768 | data_table.ex | starcoder |
defmodule Arango.Graph do
@moduledoc "ArangoDB Graph methods"
alias Arango.Request
defmodule EdgeDefinition do
@moduledoc false
defstruct [:collection, :from, :to]
@type t :: %__MODULE__{
# The name of the collection
collection: String.t,
# The vertex types an edge can come from... | lib/arango/graph.ex | 0.613121 | 0.423279 | graph.ex | starcoder |
defmodule Tempo.Iso8601.Parser.Numbers do
@moduledoc """
Numbers aren't just numbers in ISO8601 when considering
the extension formats. In some situations they may:
* Have exponents
* Have precision
* Have unknown digits
And how these are formed varies by whether the
number is being parsed for an impl... | lib/parser/numbers.ex | 0.822474 | 0.594581 | numbers.ex | starcoder |
defmodule Mix.Tasks.Sobelow do
use Mix.Task
@moduledoc """
Sobelow is a static analysis tool for discovering
vulnerabilities in Phoenix applications.
This tool should be run in the root of the project directory
with the following command:
mix sobelow
## Command line options
* `--root -r` - Sp... | lib/mix/tasks/sobelow.ex | 0.648466 | 0.521959 | sobelow.ex | starcoder |
defmodule Pow.Store.Backend.MnesiaCache do
@moduledoc """
GenServer based key value Mnesia cache store with auto expiration.
When the MnesiaCache starts, it'll initialize invalidators for all stored
keys using the `expire` value. If the `expire` datetime is past, it'll
send call the invalidator immediately.
... | lib/pow/store/backend/mnesia_cache.ex | 0.799325 | 0.497376 | mnesia_cache.ex | starcoder |
defmodule Oban.Job do
@moduledoc """
A Job is an Ecto schema used for asynchronous execution.
Job changesets are created by your application code and inserted into the database for
asynchronous execution. Jobs can be inserted along with other application data as part of a
transaction, which guarantees that j... | lib/oban/job.ex | 0.904734 | 0.527012 | job.ex | starcoder |
defmodule ExAudit.Repo do
@moduledoc """
Adds ExAudit version tracking to your Ecto.Repo actions. The following functions are
extended to detect if the given struct or changeset is in the list of :tracked_schemas
given in :ex_audit config:
insert: 2,
update: 2,
insert_or_update: 2,
delete: 2,
... | lib/repo/repo.ex | 0.870101 | 0.748191 | repo.ex | starcoder |
defmodule AWS.AuditManager do
@moduledoc """
Welcome to the Audit Manager API reference.
This guide is for developers who need detailed information about the Audit
Manager API operations, data types, and errors.
Audit Manager is a service that provides automated evidence collection so that
you can contin... | lib/aws/generated/audit_manager.ex | 0.778776 | 0.487673 | audit_manager.ex | starcoder |
defmodule Ccxtex do
alias Ccxtex.OHLCVS.Opts
alias Ccxtex.{Ticker, Utils, OHLCV, Market}
@type result_tuple :: {:ok, any} | {:error, String.t()}
@moduledoc """
Ccxtex main module
"""
@doc """
Usage example:
`exchanges = exchanges()`
Return value example:
```
[
...
%{
has: %{
can... | lib/ccxtex.ex | 0.804751 | 0.759337 | ccxtex.ex | starcoder |
defmodule Hui do
@moduledoc """
Hui 辉 ("shine" in Chinese) is an [Elixir](https://elixir-lang.org) client and library for
[Solr enterprise search platform](http://lucene.apache.org/solr/).
### Usage
- Searching Solr: `q/1`, `q/6`, `search/2`, `search/7`
- Updating: `update/3`, `delete/3`, `delete_by_qu... | lib/hui.ex | 0.890711 | 0.78899 | hui.ex | starcoder |
defmodule EctoSchemaStore.Fetch do
@moduledoc false
defmacro build(schema, repo) do
quote do
defp __preload__(model, preload), do: preload_assocs model, preload
defp __to_map__(model, true), do: to_map(model)
defp __to_map__(model, false), do: model
defp __order_by__(query, nil), do: ... | lib/ecto_schema_store/fetch.ex | 0.831006 | 0.501831 | fetch.ex | starcoder |
defmodule Xray do
@moduledoc """
Xray offers utility functions for inspecting string binaries, their
code points, and their base2 representations.
This package was the result of my own studying of Elixir strings and binaries.
It's unlikely you would actually use this as a dependency, but I offer it up
for ... | lib/xray.ex | 0.92944 | 0.894835 | xray.ex | starcoder |
defmodule Robotica.Plugins.Hs100 do
@moduledoc """
hs100 switch plugin
"""
use GenServer
use Robotica.Plugin
require Logger
defmodule Config do
@moduledoc false
@type t :: %__MODULE__{id: String.t()}
defstruct [:id]
end
defmodule State do
@moduledoc false
@type t :: %__MODULE__{... | robotica/lib/robotica/plugins/hs100.ex | 0.61173 | 0.406774 | hs100.ex | starcoder |
defmodule Ace.HTTP.Worker do
@moduledoc """
Run a Raxx application in isolation to handle a single HTTP exchange.
- The application consists of a behaviour module and initial state.
- An HTTP exchange is a single response to a single request.
See `Raxx.Server` for details on implementing a valid module.
... | lib/ace/http/worker.ex | 0.865835 | 0.416352 | worker.ex | starcoder |
defmodule AOC.Day4 do
@moduledoc """
Solution to Day 4 of the Advent of code 2021
https://adventofcode.com/2021/day/4
"""
@doc """
Read the input file
Returns the data as a tuple with inputs as first element and bingo boards as second
"""
@spec get_inputs(File) :: [String.t()]
def get_inputs(f \\ "... | elixir/advent_of_code/lib/2021/day4.ex | 0.801237 | 0.63375 | day4.ex | starcoder |
defmodule Neoscan.Blocks do
@moduledoc """
The boundary for the Blocks system.
"""
import Ecto.Query, warn: true
alias Neoscan.Repo
alias Neoscan.Block
alias Neoscan.BlockMeta
alias Neoscan.Counters
alias Neoscan.Transaction
alias Neoscan.Transfer
require Logger
@page_size 15
@missing_block_... | apps/neoscan/lib/neoscan/blocks/blocks.ex | 0.712432 | 0.427576 | blocks.ex | starcoder |
defmodule StableMarriage.Match do
@doc """
Start the process with two properly formatted data structures.
All men are initially known as bachelors.
First bachelor starts the proposal cycle.
"""
def start(men_prefs, women_prefs) do
men_prefs = Enum.into(men_prefs, HashDict.new)
women_prefs =... | lib/stable_marriage/match.ex | 0.560493 | 0.549459 | match.ex | starcoder |
defmodule ServerSentEvent do
@moduledoc """
**Push updates to Web clients over HTTP or using dedicated server-push protocols.**
Messages are sent in the following form, with the `text/event-stream` MIME type:
```txt
data: This is the first message.
data: This is the second message, it
data: has two lin... | lib/server_sent_event.ex | 0.910483 | 0.738846 | server_sent_event.ex | starcoder |
defmodule AWS.MigrationHubRefactorSpaces do
@moduledoc """
Amazon Web Services Migration Hub Refactor Spaces
` This API reference provides descriptions, syntax, and other details about each
of the actions and data types for Amazon Web Services Migration Hub Refactor
Spaces (Refactor Spaces).
The topic fo... | lib/aws/generated/migration_hub_refactor_spaces.ex | 0.845544 | 0.623348 | migration_hub_refactor_spaces.ex | starcoder |
defmodule Elsol.Query do
@moduledoc """
Example of a simple and extensible Elixir module for building Solr query string
according to existing syntax, using a single `build` function type with
pattern-matching and recursion.
For sub-parameters (dotted) such as `facet.count`, `facet.range.gap`, subst... | lib/elsol/query.ex | 0.874386 | 0.685074 | query.ex | starcoder |
defmodule Plug.Telemetry do
@moduledoc """
A plug to instrument the pipeline with `:telemetry` events.
When plugged, the event prefix is a required option:
plug Plug.Telemetry, event_prefix: [:my, :plug]
In the example above, two events will be emitted:
* `[:my, :plug, :start]` - emitted when the ... | lib/plug/telemetry.ex | 0.920634 | 0.705024 | telemetry.ex | starcoder |
defmodule CRUD do
@moduledoc """
A module for easy access to the database.
"""
@moduledoc since: "1.0.5"
use Ecto.Schema
defmacro __using__(opts) do
quote bind_quoted: [opts: opts] do
import Ecto.Query, only: [from: 2, where: 2, where: 3, offset: 2]
@cont Keyword.get(opts, :context)
... | lib/CRUD.ex | 0.895042 | 0.470372 | CRUD.ex | starcoder |
defmodule TimeMachinex.Compiler do
@moduledoc false
@test_env Mix.env() == :test
@default_precision :microsecond
@doc false
@spec compile(Keyword.t()) :: :ok
def compile(opts \\ []) do
config =
:time_machinex
|> Application.get_env(TimeMachinex, [])
|> Keyword.merge(opts)
|> Key... | lib/time_machinex/compiler.ex | 0.877457 | 0.700677 | compiler.ex | starcoder |
defmodule Explorer.PolarsBackend.Shared do
# A collection of **private** helpers shared in Explorer.PolarsBackend.
@moduledoc false
alias Explorer.DataFrame, as: DataFrame
alias Explorer.PolarsBackend.DataFrame, as: PolarsDataFrame
alias Explorer.PolarsBackend.LazyDataFrame, as: PolarsLazyFrame
alias Explo... | lib/explorer/polars_backend/shared.ex | 0.7237 | 0.619399 | shared.ex | starcoder |
defmodule DiffList do
@moduledoc """
Difference lists are a way of encoding a list as the action of preappending them.
Instead of a list being `[1, 2, 3]`, it is the anonymous function `fn(ys) -> [1, 2, 3] ++ ys end`.
Difference lists are fast for left-associated appends (`list ++ [x]`) as they are represente... | lib/difflist.ex | 0.818156 | 0.688665 | difflist.ex | starcoder |
defmodule Tanx.ContinuousGame.Mazes do
pi = :math.pi()
@mazes %{
standard: %Tanx.Game.Arena{
size: {20.0, 20.0},
walls: [
[
{10, 10},
{5.5, 10},
{5.5, 8},
{5, 8},
{5, 10},
{-8, 10},
{-8, 7},
{-8.5, 7},
... | apps/tanx/lib/tanx/continuous_game/mazes.ex | 0.514888 | 0.457803 | mazes.ex | starcoder |
defmodule Kl.Primitives do
alias Kl.Equality
alias Kl.Env, as: E
alias Kl.Types, as: T
alias Kl.Eval
import Kl.Curry
require IEx
@spec kl_and(boolean, boolean) :: boolean
def kl_and(x, y) when is_boolean(x) and is_boolean(y), do: x and y
@spec kl_or(boolean, boolean) :: boolean
def kl_or(x, y) whe... | lib/primitives.ex | 0.705278 | 0.5425 | primitives.ex | starcoder |
defmodule DealerReviewScraper.Review do
@moduledoc """
Review context
All function used to parse data from HTML into a Review.t() is live here.
"""
defstruct title: nil,
date: nil,
user: nil,
user_comment: nil,
user_overall_rating: nil,
user_de... | lib/review/review.ex | 0.731922 | 0.42913 | review.ex | starcoder |
defmodule AWS.Forecast do
@moduledoc """
Provides APIs for creating and managing Amazon Forecast resources.
"""
alias AWS.Client
alias AWS.Request
def metadata do
%AWS.ServiceMetadata{
abbreviation: nil,
api_version: "2018-06-26",
content_type: "application/x-amz-json-1.1",
cr... | lib/aws/generated/forecast.ex | 0.952827 | 0.574335 | forecast.ex | starcoder |
defmodule PlayfabEx.Client.Default.SharedGroupData do
@doc """
Adds users to the set of those able to update both the shared data, as well as the set of users in the group. Only users in the group can add new members. Shared Groups are designed for sharing data between a very small number of players, please see ... | lib/client/default/shared_group_data.ex | 0.645679 | 0.408749 | shared_group_data.ex | starcoder |
defmodule Ockam.Stream do
@moduledoc """
Defines an Ockam Stream
"""
@doc false
use GenServer
alias Ockam.Router
require Logger
# Set the name of the supervisor that will be used to start workers.
# The supervisor is assumed to be a DynamicSupervisor later in this module.
@supervisor Ockam.Strea... | implementations/elixir/lib/ockam/stream.ex | 0.904619 | 0.419618 | stream.ex | starcoder |
defmodule Hextille.Cube do
alias Hextille.Cube, as: Cube
@moduledoc """
Cube module that represents hexagon tiles using Cube coordinates.
Instead of names x, y, z this module uses names q, r, s.
Cube coordinates have a constraint `q + r + s = 0`,
even with floating point cube coordinates. This has to be a... | lib/cube.ex | 0.947345 | 0.866698 | cube.ex | starcoder |
defmodule Ankh.HTTP2.Frame.PushPromise do
@moduledoc false
defmodule Flags do
@moduledoc false
@type t :: %__MODULE__{end_headers: boolean(), padded: boolean()}
defstruct end_headers: false, padded: false
defimpl Ankh.HTTP2.Frame.Encodable do
def decode(%Flags{} = flags, <<_::4, fd00:c2b6:b... | lib/ankh/http2/frame/push_promise.ex | 0.781331 | 0.434701 | push_promise.ex | starcoder |
defmodule ParentTeen do
@moduledoc """
Parent asks the teen if the baby is okay. Teen can't answer until the baby
says its okay. Baby takes a couple of seconds. How does the teen handle this?
Teen answers `handle_call` with `:noreply` but keeps the `from` in `state`.
When teen gets the `handle_cast` from the... | lib/parent_teen.ex | 0.59302 | 0.880077 | parent_teen.ex | starcoder |
defmodule Day21 do
def part1(rules, string) do
Parser.parse(rules)
|> Enum.reduce(string, &execute/2)
end
def part2(rules, string) do
Parser.parse(rules)
|> Enum.reverse
|> Enum.map(&reverse_command/1)
|> Enum.reduce(string, &execute/2)
end
defp execute(command, string) do
case c... | day21/lib/day21.ex | 0.576304 | 0.478773 | day21.ex | starcoder |
defmodule Siariwyd.Normalise do
@moduledoc false
require Logger
defp maybe_ast_realise(value, opts \\ [])
defp maybe_ast_realise(value, _opts)
when is_atom(value)
or is_bitstring(value)
or is_boolean(value)
or is_function(value)
or is_map(value)
or is_number(value)
or is_pid(value)
or is_por... | lib/siariwyd/normalise.ex | 0.64131 | 0.420332 | normalise.ex | starcoder |
defmodule Crontab.DateHelper do
@moduledoc false
@type unit :: :year | :month | :day | :hour | :minute | :second | :microsecond
@units [
{:year, {nil, nil}},
{:month, {1, 12}},
{:day, {1, :end_onf_month}},
{:hour, {0, 23}},
{:minute, {0, 59}},
{:second, {0, 59}},
{:microsecond, {{0, ... | lib/crontab/date_helper.ex | 0.911407 | 0.628407 | date_helper.ex | starcoder |
defmodule Utils.Slide do
def case do
[
"
We create a case statement.
```elixir
case \"snowy\" do
\"sunny\" -> \"wear a t-shirt\"
\"rainy\" -> \"wear a rain jacket\"
\"cold\" -> \"wear a sweater\"
\"snowy\" -> \"wear a thick coat\"
end
```
",
"
Check if snowy equals sunny.
```elixir
case \"sn... | utils/lib/slide.ex | 0.516108 | 0.875255 | slide.ex | starcoder |
defmodule AssertHTML.DSL do
@moduledoc ~S"""
Add aditional syntax to passing current context inside block
### Example: pass context
```
assert_html html, ".container" do
assert_html "form", action: "/users" do
refute_html ".flash_message"
assert_html ".control_group" do
assert_html "l... | lib/assert_html/dsl.ex | 0.822653 | 0.716268 | dsl.ex | starcoder |
defmodule Oli.Interop.LegacySupport do
@resources [
"x-oli-workbook_page",
"x-oli-inline-assessment"
]
@supported [
"activity_link",
"link",
"sym",
"em",
"sub",
"sup",
"term",
"var",
"code",
"codeblock",
"p",
"ul",
"ol",
"dl",
"dd",
"dt",
... | lib/oli/interop/legacy_support.ex | 0.563378 | 0.48054 | legacy_support.ex | starcoder |
defmodule ToyRobot.Simulation do
alias ToyRobot.{Robot, Table, Simulation}
defstruct [:table, :robot]
@doc """
Returns next position of the robot.
## Examples
iex> alias ToyRobot.{Robot, Table, Simulation}
[ToyRobot.Robot, ToyRobot.Table, ToyRobot.Simulation]
iex> table = %Table{north_boundary... | lib/toy_robot/simulation.ex | 0.913953 | 0.770465 | simulation.ex | starcoder |
defmodule Cadet.Test.Seeds do
@moduledoc """
This module contains functions that seed more complex setups into the DB for tests.
"""
import Cadet.Factory
@doc """
This sets up the common assessments environment by inserting relevant entries into the DB.
Returns a map of the following format:
%{
acc... | test/support/seeds.ex | 0.672869 | 0.426441 | seeds.ex | starcoder |
defmodule EXNN.Sensor do
@moduledoc """
_Sensor server metamodule to be used within your implementation_
#### Modules using EXNN.Sensor are turned into Sensor servers.
Sensor modules *MUST* implement either
a `sense/2` function emitting a tuple containing scalar impulses
of length compatible with the con... | lib/exnn/sensor.ex | 0.892824 | 0.6306 | sensor.ex | starcoder |
defmodule Cldr.Time.Interval.Backend do
@moduledoc false
def define_time_interval_module(config) do
backend = config.backend
config = Macro.escape(config)
quote location: :keep, bind_quoted: [config: config, backend: backend] do
defmodule Time.Interval do
@moduledoc """
Interval ... | lib/cldr/backend/interval/time.ex | 0.918911 | 0.642671 | time.ex | starcoder |
defmodule Geocoder.Providers.OpenCageData do
use HTTPoison.Base
use Towel
@endpoint "http://api.opencagedata.com/"
@path "geocode/v1/json"
def geocode(opts) do
request(@path, opts |> extract_opts())
|> fmap(&parse_geocode/1)
end
def geocode_list(opts) do
request_all(@path, opts |> extract_o... | lib/geocoder/providers/open_cage_data.ex | 0.613237 | 0.512632 | open_cage_data.ex | starcoder |
defmodule Commanded.Aggregates.AggregateLifespan do
@moduledoc """
The `Commanded.Aggregates.AggregateLifespan` behaviour is used to control an
aggregate lifespan.
By default an aggregate instance process will run indefinitely once started.
You can control this by implementing the
`Commanded.Aggregates.Agg... | lib/commanded/aggregates/aggregate_lifespan.ex | 0.847179 | 0.548674 | aggregate_lifespan.ex | starcoder |
defmodule Wand.Test.Helpers.System do
import Mox
def stub_update_deps() do
message = "Resolving Hex dependencies"
expect(Wand.SystemMock, :cmd, fn "mix", ["deps.get"], _opts -> {message, 0} end)
end
def stub_failed_update_deps() do
message =
"Could not find a Mix.Project, please ensure you a... | test/support/system.ex | 0.660391 | 0.474509 | system.ex | starcoder |
defmodule OLEDVirtual.MultiDisplay do
@moduledoc """
Multi display to invoke several displays simultaneously.
It supports the same functions as `OLEDVirtual.Display` and `OLED.Display`.
The only difference is that the functions always return a list of `{display, result}` tuples,
where `display` is the displa... | lib/oled_virtual/multi_display.ex | 0.909451 | 0.479138 | multi_display.ex | starcoder |
defmodule Type.Iolist do
@moduledoc false
# this module is a PRIVATE module to segregate the challenging
# iolist logic away from the Type module.
# note that the public methods here don't conform to any of the
# method schemata implemented by any of the other modules.
import Type, only: :macros
alias ... | lib/type/iolist.ex | 0.515864 | 0.479382 | iolist.ex | starcoder |
defmodule Train do
@moduledoc"""
Train a network to respond to the given scape.
"""
@doc"""
Default training on XOR scape. Generates genotype, then trains it x number of iterations.
"""
def genotype(iterations) do
geno = Genotype.create
network(geno, iterations)
end
def network(geno_initial... | lib/train.ex | 0.721841 | 0.519338 | train.ex | starcoder |
defmodule TypeCheck.TypeError.DefaultFormatter do
@behaviour TypeCheck.TypeError.Formatter
def format(problem_tuple, location \\ []) do
res =
do_format(problem_tuple)
|> indent() # Ensure we start with four spaces, which multi-line exception pretty-printing expects
|> indent()
location_s... | lib/type_check/type_error/default_formatter.ex | 0.797714 | 0.447883 | default_formatter.ex | starcoder |
defmodule StepFlow.WorkflowView do
use StepFlow, :view
alias StepFlow.{ArtifactView, JobView, RightView, WorkflowView}
def render("index.json", %{workflows: %{data: workflows, total: total}}) do
%{
data: render_many(workflows, WorkflowView, "workflow.json"),
total: total
}
end
def render... | lib/step_flow/view/workflow_view.ex | 0.587707 | 0.456349 | workflow_view.ex | starcoder |
defmodule StrawHat.GraphQL.Types do
@moduledoc """
Common Absinthe Types.
## Interfaces
`straw_hat_node`
Just a simple interface that will force you to have an ID
`straw_hat_mutation_response`
Shape of the mutation response.
**Important:** read the usage guide because `payload` field is not includ... | lib/straw_hat_graphql/types.ex | 0.818954 | 0.54698 | types.ex | starcoder |
defmodule StringConverter do
@moduledoc """
StringConverter convert string value to proper [integer | float | string]
"""
@doc """
convert string to proper type [integer | float | string]
## Examples
iex> StringConverter.to_type("34")
34
iex> StringConverter.to_type(".3f")
0.3
iex... | lib/string_converter.ex | 0.890571 | 0.573678 | string_converter.ex | starcoder |
defmodule EQRCode do
@moduledoc """
Simple QR Code Generator written in Elixir with no other dependencies.
To generate the SVG QR code:
```elixir
qr_code_content = "your_qr_code_content"
qr_code_content
|> EQRCode.encode()
|> EQRCode.svg()
```
"""
alias EQRCode.{Encode, ReedSolomon, Matrix}
... | lib/eqrcode.ex | 0.901453 | 0.807119 | eqrcode.ex | starcoder |
defmodule Solana do
@moduledoc """
A library for interacting with the Solana blockchain.
"""
@typedoc "See `t:Solana.Key.t/0`"
@type key :: Solana.Key.t()
@typedoc "See `t:Solana.Key.pair/0`"
@type keypair :: Solana.Key.pair()
@doc """
See `Solana.Key.pair/0`
"""
defdelegate keypair(), to: Sola... | lib/solana.ex | 0.844553 | 0.485234 | solana.ex | starcoder |
defmodule Flippant.Adapter.Memory do
@moduledoc """
This module provides ETS backed rule storage.
The Memory adapter is not persisted between application restarts, and
therefore is intended for testing.
"""
use GenServer
import Flippant.Rules, only: [enabled_for_actor?: 2]
@doc """
Starts the Memo... | lib/flippant/adapters/memory.ex | 0.703346 | 0.504455 | memory.ex | starcoder |
defmodule Reaper.UrlBuilder do
alias Reaper.Collections.Extractions
@moduledoc """
This module builds a URL to download a source file
"""
@doc """
Returns a string containing the URL with all query string parameters based on the `Reaper.ReaperConfig`
"""
@spec build(SmartCity.Dataset.t()) :: String.t(... | apps/reaper/lib/reaper/url_builder.ex | 0.842475 | 0.433022 | url_builder.ex | starcoder |
defmodule Ada.CLI do
@default_target_node :"<EMAIL>"
@cli_node :"cli@127.0.0.1"
@moduledoc """
Remotely control an Ada device via the Elixir distribution.
Among other things, the CLI allows to:
- control the display brightness
- manage device data (users, locations, tasks)
- manage device preferences... | lib/ada/cli.ex | 0.868646 | 0.786787 | cli.ex | starcoder |
defmodule Cereal.Utils do
@doc """
Given a the name of a serializer, will return a string
that represents the type of the entity being processed.
"""
def module_to_type(module) do
module
|> Module.split()
|> List.last()
|> String.replace("Serializer", "")
|> String.replace("View", "")
... | lib/cereal/utils.ex | 0.865423 | 0.453383 | utils.ex | starcoder |
defmodule ExWareki.Data do
@moduledoc """
Data module is a storage of era-data. You may not need to use this module directly.
"""
def data() do
raw_data()
|> Enum.map(fn d -> parse(d) end)
end
@doc """
str2date/1 converts date-string into date struct
## Examples
iex> ExWareki.Data.str2... | lib/ex_wareki/data.ex | 0.649356 | 0.532 | data.ex | starcoder |
defmodule Phoenix.LiveDashboard.SystemInfo do
# Helpers for fetching and formatting system info.
@moduledoc false
def format_uptime(uptime) do
{d, {h, m, _s}} = :calendar.seconds_to_daystime(div(uptime, 1000))
cond do
d > 0 -> "#{d}d#{h}h#{m}m"
h > 0 -> "#{h}h#{m}m"
true -> "#{m}m"
... | lib/phoenix/live_dashboard/system_info.ex | 0.626696 | 0.401072 | system_info.ex | starcoder |
defmodule Basalt.Hex do
alias Basalt.Hex, as: Hex
@moduledoc """
Basalt hexagon tiles ("hexes") are represented by hexagon tiles using
"Cube" coordinates by default. Hexagons can be conceived as having
three primary axes, as in a cube sliced on a diagonal plane. Hexes are
in oriented "pointy"-side up, ⬢. T... | lib/basalt.ex | 0.96336 | 0.743378 | basalt.ex | starcoder |
defmodule Rummage.Phoenix.SortView do
@moduledoc """
Sort View Module for Rummage. This has view helpers that can generate rummagable links and forms.
Usage:
Usage:
```elixir
defmodule MyApp.ProductView do
use MyApp.Web, :view
use Rummage.Phoenix.View, only: [:paginate]
end
```
OR
```el... | lib/rummage_phoenix/hooks/views/sort_view.ex | 0.675015 | 0.785185 | sort_view.ex | starcoder |
defmodule Period do
@moduledoc """
Period does represent a timeframe.
## Creating a Period
A Period is a opaque type, so it's not meant to be directly created like
other structs, but you should rather use `Period.new/3`, `Period.new!/3` or
`Period.from_naive/3` to create a Period.
Internally Period's d... | lib/period.ex | 0.938498 | 0.596433 | period.ex | starcoder |
defmodule Xattr do
import Xattr.Nif
@moduledoc ~S"""
API module for accessing custom extended filesystem attributes.
Attributes managed by this module are stored in isolation, in custom namespace.
Because implementation concepts of extended attributes differ in supported
platforms, it would not be possibl... | lib/xattr.ex | 0.902939 | 0.722148 | xattr.ex | starcoder |
defmodule Gradient.TypeData do
@spec all_pp_test_data() :: [{name :: String.t(), type :: tuple(), expected :: String.t()}]
def all_pp_test_data() do
[
value_test_data(),
builtin_types_test_data(),
op_types_test_data(),
fun_types_test_data(),
map_types_test_data(),
tuple_types... | test/support/type_data.ex | 0.590071 | 0.523603 | type_data.ex | starcoder |
defmodule BSV.UTXO do
@moduledoc """
A UTXO is a data structure representing an unspent transaction output.
A UTXO consists of a `t:BSV.OutPoint.t/0` and the `t:BSV.TxOut.t/0` itself.
UTXOs are used in the `BSV.TxBuilder` module to create transaction inputs.
"""
alias BSV.{OutPoint, Script, Tx, TxOut}
im... | lib/bsv/utxo.ex | 0.87701 | 0.687289 | utxo.ex | starcoder |
defmodule Linnerud do
@doc """
Lenear Regression with linnerud datasets
features: physiological data
weight
waist
pulse
targets: exersize data
chins
situps
jumps
"""
def run do
# load dataset
features = load_linnerud_feature_dataset()
targets = load_linnerud_targe... | apps/sample/lib/linnerud.ex | 0.664758 | 0.791055 | linnerud.ex | starcoder |
defmodule Elastic.HTTP do
alias Elastic.AWS
@moduledoc ~S"""
Used to make raw calls to Elastic Search.
Each function returns a tuple indicating whether or not the request
succeeded or failed (`:ok` or `:error`), the status code of the response,
and then the processed body of the response.
For example, a... | lib/elastic/http.ex | 0.899274 | 0.803328 | http.ex | starcoder |
defmodule Mix.Tasks.Ecto.Gen.Migration do
use Mix.Task
import Macro, only: [camelize: 1, underscore: 1]
import Mix.Generator
import Mix.Ecto
import Mix.EctoSQL
@shortdoc "Generates a new migration for the repo"
@aliases [
r: :repo
]
@switches [
change: :string,
repo: [:string, :keep],
... | lib/mix/tasks/ecto.gen.migration.ex | 0.738858 | 0.419232 | ecto.gen.migration.ex | starcoder |
defmodule Mix.Ecto do
# Conveniences for writing Mix.Tasks in Ecto.
@moduledoc false
@doc """
Parses the repository as the first argument in the given list
and ensure the repository is loaded and available.
"""
@spec parse_repo([term]) :: {Ecto.Repo.t, [term]} | no_return
def parse_repo([h|t]) when is_... | lib/mix/ecto.ex | 0.696578 | 0.446917 | ecto.ex | starcoder |
defmodule DeepGet do
@moduledoc """
`DeepGet` allows you to take an object (map/struct/keyword list/list) or list
of them, nested to an arbitrary level, and extract the values corresponding
to a list of keys.
"""
@doc """
Fetches a list of all objects under a struct/map/keyword list/list matching
the l... | lib/deep_get.ex | 0.634317 | 0.481637 | deep_get.ex | starcoder |
defmodule Client do
@moduledoc """
The client module contains two functions of note, `do_request/6` and
`do_request!/6` which perform HTTP actions as well as encoding and decoding
data and setting headers involved in the request.
## Actions
Actions are the part that actually make the HTTP Request, if th... | lib/client.ex | 0.88856 | 0.401746 | client.ex | starcoder |
defmodule Challenges.One do
@doc """
From https://edabit.com/challenge/qvpHxkZnTh4m9Dk4X
Create a function that determines whether or not a player is holding a Full House in their hand. A hand is represented as an array of 5 cards. A full house is defined as a pair of cards and a three-of-a-kind.
To illu... | lib/challenges_one.ex | 0.830353 | 0.907845 | challenges_one.ex | starcoder |
defmodule Exchange.MatchingEngine do
@moduledoc """
This is the core of the Exchange
The matching engine is responsible for matching the orders on the order book
"""
use GenServer
alias Exchange.{Order, OrderBook}
@type ticker :: atom
require Logger
# Client
@check_expiration_rate 1_000
@price_b... | lib/exchange/matching_engine.ex | 0.867668 | 0.64484 | matching_engine.ex | starcoder |
use Dogma.RuleBuilder
defrule Dogma.Rule.FinalCondition, [catch_all: true] do
@moduledoc """
A rule that checks that the last condition of a `cond` statement is `true`.
For example, prefer this:
cond do
1 + 2 == 5 ->
"Nope"
1 + 3 == 5 ->
"Uh, uh"
true ->
... | lib/dogma/rule/final_condition.ex | 0.794185 | 0.583292 | final_condition.ex | starcoder |
defmodule Exhort.SAT.Builder do
@moduledoc """
Provide for the building of a model for eventual solving.
All functions except `build/0` are pure Elixir.
Create a new builder with `new/0`. Build a model with `build/0`.
`build/0` interacts with the underlying native implementation, returning a
`Exhort.SAT.... | lib/exhort/sat/builder.ex | 0.919453 | 0.612136 | builder.ex | starcoder |
defmodule CodeCorps.GitHub.SuccessAPI do
@moduledoc ~S"""
A mocked github API layer which returns a default successful response for all
GitHub API requests.
All tests in the test environment use this module as a mock for GitHub API
requests by default.
If certain tests explicitly depend on the data return... | test/support/github/success_api.ex | 0.738669 | 0.589687 | success_api.ex | starcoder |
defmodule ExAws.Dynamo.Decoder do
@moduledoc """
Decodes a dynamo response into a struct.
If Dynamo.Decodable is implemented for the struct it will be called
after the completion of the coercion.
This is important for handling nested maps if you wanted the nested maps
to have atom keys.
"""
def decode... | lib/ex_aws/dynamo/decoder.ex | 0.735737 | 0.623706 | decoder.ex | starcoder |
defmodule ExWire.Packet.Capability.Eth.GetBlockBodies do
@moduledoc """
Request the bodies for a set of blocks by hash.
```
`GetBlockBodies` [`+0x05`, `hash_0`: `B_32`, `hash_1`: `B_32`, ...]
Require peer to return a BlockBodies message. Specify the set of blocks that
we're interested in with the hashes.
... | apps/ex_wire/lib/ex_wire/packet/capability/eth/get_block_bodies.ex | 0.885798 | 0.848282 | get_block_bodies.ex | starcoder |
defmodule Membrane.RTP.Header do
@moduledoc """
Describes RTP Header defined in [RFC3550](https://tools.ietf.org/html/rfc3550#page-13)
```
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-... | lib/membrane/rtp/header.ex | 0.694924 | 0.635166 | header.ex | starcoder |
defmodule ElixirALE.GPIO do
use GenServer
@moduledoc """
This is an Elixir interface to Linux GPIOs. Each GPIO is an
independent GenServer.
"""
def child_spec(opts) do
%{
id: __MODULE__,
start: {__MODULE__, :start_link, opts}
}
end
defmodule State do
@moduledoc false
defst... | lib/elixir_ale/gpio.ex | 0.862352 | 0.490785 | gpio.ex | starcoder |
defmodule Tds.Protocol.Grammar do
@moduledoc """
Grammar Definition for Token Description, General Rules.
Data structure encodings in TDS are defined in terms of the
fundamental definitions.
"""
@doc """
A single bit value of either 0 or 1.
"""
defmacro bit(n \\ 1), do: quote(do: size(1) - unit(unqu... | lib/tds/protocol/grammar.ex | 0.797557 | 0.625524 | grammar.ex | starcoder |
defmodule TxtLocalEx.HttpMessenger do
@behaviour TxtLocalEx.Messenger
@ets_bucket_prefix "txt-local-rate-limited-api"
@dry_run_on "1"
# Define API endpoints
@send_sms_path "/send/?"
@bulk_send_path "/bulk_json/?"
@message_status_path "/status_message/?"
@batch_status_path "/status_batch/?"
@api_name... | lib/messengers/http_messenger.ex | 0.743541 | 0.441011 | http_messenger.ex | starcoder |
defmodule CustomSet do
alias CustomSet, as: Set
defstruct [:value, :left, :right, size: 0]
@opaque t ::
%Set{value: nil, left: nil, right: nil, size: 0}
| %Set{value: any, left: t, right: t, size: pos_integer}
@spec new(Enum.t()) :: t
def new(enumerable), do: Enum.reduce(enumerable,... | elixir/custom-set/lib/custom_set.ex | 0.902276 | 0.800731 | custom_set.ex | starcoder |
defmodule DataDaemon.Util do
@moduledoc false
@doc ~S"""
Pack a metric as iodata.
"""
@spec package(DataDaemon.key(), DataDaemon.value(), DataDaemon.type(), Keyword.t()) :: iodata
def package(key, value, type, opts \\ []) do
[key, ?:, pack_value(value), ?|, pack_type(type)]
|> tag(opts[:tags])
en... | lib/data_daemon/util.ex | 0.870101 | 0.485112 | util.ex | starcoder |
defmodule Video.Track do
@known_params [
:from,
:to,
:text,
:parent_ref,
:videos,
:group,
:direction
]
@type plain :: [{binary(), Video.Timestamp.t() | :start, Video.Timestamp.t() | :end}]
# 32*8=256
@type hash :: <<_::256>>
@type t :: %__MODULE__{
from: binary(),
... | lib/video/track.ex | 0.848251 | 0.418905 | track.ex | starcoder |
defmodule Resourceful.Collection.Ecto do
defmodule NoRepoError do
defexception message:
"No Ecto.Repo has been specified! You must either " <>
"pass one explicity using the :ecto_repo option or you " <>
"can specify a global default by setting the confi... | lib/resourceful/collection/ecto.ex | 0.638723 | 0.438545 | ecto.ex | starcoder |
defmodule ExStoneOpenbank do
@moduledoc """
ExStoneOpenbank is a library for calling Stone Open Bank APIs.
In order to use this library you need to create an application profile. Please see docs of
the service at https://docs.openbank.stone.com.br
The steps to use this SDK are:
1. Create a user and open ... | lib/ex_stone_openbank.ex | 0.758511 | 0.446555 | ex_stone_openbank.ex | starcoder |
defmodule ExDiceRoller.Compilers.Separator do
@moduledoc """
Handles the `,` separator for rolls.
The separator allows for multiple, separate dice expressions to be evaluated
and only one returned based on provided options:
* `:highest`: returns the highest calculated value and is the default option
* `:l... | lib/compilers/separator.ex | 0.840177 | 0.72812 | separator.ex | starcoder |
defmodule ExSlackBot do
@moduledoc ~s"""
`ExSlackBot` provides a base upon which SlackBots can more easily be built. Each bot is addressable by a name and is supervised, so handles errors and restarts.
"""
require Logger
defmacro __using__(override_name \\ nil) do
quote do
require Logger
use ... | lib/exslackbot.ex | 0.758242 | 0.694147 | exslackbot.ex | starcoder |
defmodule SmartCity.Ingestion do
alias SmartCity.Helpers
alias SmartCity.Ingestion.Transformation
@moduledoc """
Struct defining an ingestion update event.
```javascript
const Ingestion = {
"id": "",
"name", "",
"allow_duplicates": boolean,
"cadence": "",
"extractSteps": [],
"schem... | lib/smart_city/ingestion.ex | 0.871844 | 0.728169 | ingestion.ex | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.