hexsha
stringlengths
40
40
size
int64
2
991k
ext
stringclasses
2 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
208
max_stars_repo_name
stringlengths
6
106
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
sequence
max_stars_count
int64
1
33.5k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
208
max_issues_repo_name
stringlengths
6
106
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
sequence
max_issues_count
int64
1
16.3k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
208
max_forks_repo_name
stringlengths
6
106
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
sequence
max_forks_count
int64
1
6.91k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
2
991k
avg_line_length
float64
1
36k
max_line_length
int64
1
977k
alphanum_fraction
float64
0
1
9e79ffe7a742389a0b3fc79b0341d24c0463d1c9
107
exs
Elixir
test/platform/speech/speech_test.exs
lucab85/audioslides.io
cb502ccf6ed0b2db42d9fb20bb4c963bcca3cfa9
[ "MIT" ]
17
2017-11-14T14:03:18.000Z
2021-12-10T04:18:48.000Z
test/platform/speech/speech_test.exs
lucab85/audioslides.io
cb502ccf6ed0b2db42d9fb20bb4c963bcca3cfa9
[ "MIT" ]
21
2017-11-19T13:38:07.000Z
2022-02-10T00:11:14.000Z
test/platform/speech/speech_test.exs
lucab85/audioslides.io
cb502ccf6ed0b2db42d9fb20bb4c963bcca3cfa9
[ "MIT" ]
2
2019-09-03T03:32:13.000Z
2021-02-23T21:52:57.000Z
defmodule Platform.SpeechTest do use ExUnit.Case import Platform.Speech doctest Platform.Speech end
15.285714
32
0.803738
9e7a21d2eee6c7d515349ce992164198983361e2
808
exs
Elixir
mix.exs
ericentin/snooper
1713e97db35ab0b11e7df8c2231c5d4d5c1a651d
[ "Apache-2.0" ]
null
null
null
mix.exs
ericentin/snooper
1713e97db35ab0b11e7df8c2231c5d4d5c1a651d
[ "Apache-2.0" ]
null
null
null
mix.exs
ericentin/snooper
1713e97db35ab0b11e7df8c2231c5d4d5c1a651d
[ "Apache-2.0" ]
null
null
null
defmodule Snooper.MixProject do use Mix.Project def project do [ app: :snooper, version: "0.1.0", elixir: "~> 1.8", start_permanent: Mix.env() == :prod, deps: deps(), description: description(), package: package(), source_url: "https://github.com/ericentin/snooper" ] end def application do [ extra_applications: [:logger] ] end defp description do "Easily debug, inspect, and log a function's behavior on a line-by-line basis." end defp deps do [{:ex_doc, "~> 0.19", only: :dev, runtime: false}] end defp package do [ files: ~w(lib .formatter.exs mix.exs README.md LICENSE src), licenses: ["Apache 2.0"], links: %{"GitHub" => "https://github.com/ericentin/snooper"} ] end end
20.717949
83
0.591584
9e7a29e1875b0b8ae63db243f610fd6f4bb0de79
2,220
exs
Elixir
config/dev.exs
yliaho/suomi.dev
4e1946adbeb67cebdc1b7e2009ddecf66497a9c7
[ "MIT" ]
19
2020-08-24T02:50:26.000Z
2021-05-31T20:54:30.000Z
config/dev.exs
yliaho/suomi.dev
4e1946adbeb67cebdc1b7e2009ddecf66497a9c7
[ "MIT" ]
2
2020-08-24T06:59:46.000Z
2020-08-26T09:51:40.000Z
config/dev.exs
yliaho/suomi.dev
4e1946adbeb67cebdc1b7e2009ddecf66497a9c7
[ "MIT" ]
6
2020-08-26T02:52:48.000Z
2022-03-08T12:55:51.000Z
use Mix.Config # Configure your database config :suomidev, Suomidev.Repo, username: "suomidev", password: "suomidev", database: "suomidev2_dev", hostname: "localhost", show_sensitive_data_on_connection_error: true, pool_size: 10, types: Suomidev.PostgresTypes config :suomidev, :use_plausible, false # For development, we disable any cache and enable # debugging and code reloading. # # The watchers configuration can be used to run external # watchers to your application. For example, we use it # with webpack to recompile .js and .css sources. config :suomidev, SuomidevWeb.Endpoint, http: [port: 4000], debug_errors: true, code_reloader: true, check_origin: false, watchers: [ node: [ "node_modules/webpack/bin/webpack.js", "--mode", "development", "--watch-stdin", cd: Path.expand("../assets", __DIR__) ] ] # ## SSL Support # # In order to use HTTPS in development, a self-signed # certificate can be generated by running the following # Mix task: # # mix phx.gen.cert # # Note that this task requires Erlang/OTP 20 or later. # Run `mix help phx.gen.cert` for more information. # # The `http:` config above can be replaced with: # # https: [ # port: 4001, # cipher_suite: :strong, # keyfile: "priv/cert/selfsigned_key.pem", # certfile: "priv/cert/selfsigned.pem" # ], # # If desired, both `http:` and `https:` keys can be # configured to run both http and https servers on # different ports. # Watch static and templates for browser reloading. config :suomidev, SuomidevWeb.Endpoint, live_reload: [ patterns: [ ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", ~r"priv/gettext/.*(po)$", ~r"lib/suomidev_web/(live|views)/.*(ex)$", ~r"lib/suomidev_web/templates/.*(eex)$" ] ] # Do not include metadata nor timestamps in development logs config :logger, :console, format: "[$level] $message\n" # Set a higher stacktrace during development. Avoid configuring such # in production as building large stacktraces may be expensive. config :phoenix, :stacktrace_depth, 20 # Initialize plugs at runtime for faster development compilation config :phoenix, :plug_init_mode, :runtime
27.75
68
0.695045
9e7a31363c1c41e3d770361a304a3a10c46ff81c
138
ex
Elixir
test/helpers/connections/ranch_socket_connection.ex
manulitic/instream
5ad521dcf6a456325ba30b4c0dbb40f1f5107f32
[ "Apache-2.0" ]
null
null
null
test/helpers/connections/ranch_socket_connection.ex
manulitic/instream
5ad521dcf6a456325ba30b4c0dbb40f1f5107f32
[ "Apache-2.0" ]
null
null
null
test/helpers/connections/ranch_socket_connection.ex
manulitic/instream
5ad521dcf6a456325ba30b4c0dbb40f1f5107f32
[ "Apache-2.0" ]
null
null
null
defmodule Instream.TestHelpers.Connections.RanchSocketConnection do @moduledoc false use Instream.Connection, otp_app: :instream end
23
67
0.833333
9e7a3da81fc7ef69c1c359f4af8627b7d246594d
399
ex
Elixir
lib/transmission/torrent_add.ex
zhulik/ex_transmission
f7c977bb3535a7c0a976951b9dff51bc94c1575b
[ "MIT" ]
1
2022-01-07T17:17:22.000Z
2022-01-07T17:17:22.000Z
lib/transmission/torrent_add.ex
zhulik/ex_transmission
f7c977bb3535a7c0a976951b9dff51bc94c1575b
[ "MIT" ]
null
null
null
lib/transmission/torrent_add.ex
zhulik/ex_transmission
f7c977bb3535a7c0a976951b9dff51bc94c1575b
[ "MIT" ]
1
2020-05-01T12:34:57.000Z
2020-05-01T12:34:57.000Z
defmodule Transmission.TorrentAdd do alias Transmission.Utils @default_options [filename: nil, metainfo: nil] def method(options \\ []) do options = Keyword.merge(@default_options, options) %{ method: "torrent-add", arguments: %{ filename: options[:filename], metainfo: options[:metainfo] } |> Utils.compact() } end end
19.95
54
0.601504
9e7a5d1606af3d34ea752a1c2bec7e42dcb98e73
849
ex
Elixir
lib/adyen_checkout_ex/model/open_invoice_details.ex
rsystem-se/adyen_checkout_ex
4210f1c7150152e81f350dc6ca55aeb19665b85b
[ "MIT" ]
1
2021-05-30T20:45:10.000Z
2021-05-30T20:45:10.000Z
lib/adyen_checkout_ex/model/open_invoice_details.ex
rsystem-se/adyen_checkout_ex
4210f1c7150152e81f350dc6ca55aeb19665b85b
[ "MIT" ]
null
null
null
lib/adyen_checkout_ex/model/open_invoice_details.ex
rsystem-se/adyen_checkout_ex
4210f1c7150152e81f350dc6ca55aeb19665b85b
[ "MIT" ]
null
null
null
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). # https://openapi-generator.tech # Do not edit the class manually. defmodule AdyenCheckoutEx.Model.OpenInvoiceDetails do @moduledoc """ """ @derive [Poison.Encoder] defstruct [ :"billingAddress", :"deliveryAddress", :"personalDetails", :"recurringDetailReference", :"storedPaymentMethodId", :"type" ] @type t :: %__MODULE__{ :"billingAddress" => String.t | nil, :"deliveryAddress" => String.t | nil, :"personalDetails" => String.t | nil, :"recurringDetailReference" => String.t | nil, :"storedPaymentMethodId" => String.t | nil, :"type" => String.t | nil } end defimpl Poison.Decoder, for: AdyenCheckoutEx.Model.OpenInvoiceDetails do def decode(value, _options) do value end end
23.583333
91
0.6702
9e7a66f5dec1efb0f722f4cdb376c6873ad3141e
758
ex
Elixir
apps/evm/lib/evm/configuration/tangerine_whistle.ex
wolflee/mana
db66dac85addfaad98d40da5bd4082b3a0198bb1
[ "ECL-2.0", "Apache-2.0", "MIT-0", "MIT" ]
152
2018-10-27T04:52:03.000Z
2022-03-26T10:34:00.000Z
apps/evm/lib/evm/configuration/tangerine_whistle.ex
wolflee/mana
db66dac85addfaad98d40da5bd4082b3a0198bb1
[ "ECL-2.0", "Apache-2.0", "MIT-0", "MIT" ]
270
2018-04-14T07:34:57.000Z
2018-10-25T18:10:45.000Z
apps/evm/lib/evm/configuration/tangerine_whistle.ex
wolflee/mana
db66dac85addfaad98d40da5bd4082b3a0198bb1
[ "ECL-2.0", "Apache-2.0", "MIT-0", "MIT" ]
25
2018-10-27T12:15:13.000Z
2022-01-25T20:31:14.000Z
defmodule EVM.Configuration.TangerineWhistle do alias EVM.Configuration.Homestead use EVM.Configuration, fallback_config: Homestead, overrides: %{ extcodesize_cost: 700, extcodecopy_cost: 700, balance_cost: 400, sload_cost: 200, call_cost: 700, selfdestruct_cost: 5_000, new_account_destruction_cost: 25_000, should_fail_nested_operation_lack_of_gas: false } @impl true def selfdestruct_cost(config, new_account: false), do: config.selfdestruct_cost def selfdestruct_cost(config, new_account: true) do config.selfdestruct_cost + config.new_account_destruction_cost end @impl true def limit_contract_code_size?(config, _size) do config.limit_contract_code_size end end
26.137931
81
0.746702
9e7a951196d4ce141fe05a3867c99c87b68994cc
84,458
ex
Elixir
clients/dataflow/lib/google_api/dataflow/v1b3/api/projects.ex
hauptbenutzer/elixir-google-api
7b9e3a114a49cfc774a7afd03e299a0d43e4e6b2
[ "Apache-2.0" ]
null
null
null
clients/dataflow/lib/google_api/dataflow/v1b3/api/projects.ex
hauptbenutzer/elixir-google-api
7b9e3a114a49cfc774a7afd03e299a0d43e4e6b2
[ "Apache-2.0" ]
null
null
null
clients/dataflow/lib/google_api/dataflow/v1b3/api/projects.ex
hauptbenutzer/elixir-google-api
7b9e3a114a49cfc774a7afd03e299a0d43e4e6b2
[ "Apache-2.0" ]
1
2020-11-10T16:58:27.000Z
2020-11-10T16:58:27.000Z
# Copyright 2017 Google Inc. # # 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 License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule GoogleApi.Dataflow.V1b3.Api.Projects do @moduledoc """ API calls for all endpoints tagged `Projects`. """ alias GoogleApi.Dataflow.V1b3.Connection alias GoogleApi.Gax.{Request, Response} @doc """ List the jobs of a project across all regions. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The project which owns the jobs. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :filter (String.t): The kind of filter to use. - :location (String.t): The location that contains this job. - :pageToken (String.t): Set this to the 'next_page_token' field of a previous response to request additional results in a long list. - :pageSize (integer()): If there are many jobs, limit response to at most this many. The actual number of jobs returned will be the lesser of max_responses and an unspecified server-defined limit. - :view (String.t): Level of information requested in response. Default is `JOB_VIEW_SUMMARY`. ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.ListJobsResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_jobs_aggregated(Tesla.Env.client(), String.t(), keyword()) :: {:ok, GoogleApi.Dataflow.V1b3.Model.ListJobsResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_jobs_aggregated(connection, project_id, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :filter => :query, :location => :query, :pageToken => :query, :pageSize => :query, :view => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1b3/projects/{projectId}/jobs:aggregated", %{ "projectId" => URI.encode_www_form(project_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.ListJobsResponse{}) end @doc """ Creates a Cloud Dataflow job. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The ID of the Cloud Platform project that the job belongs to. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :replaceJobId (String.t): Deprecated. This field is now in the Job message. - :view (String.t): The level of information requested in response. - :location (String.t): The location that contains this job. - :body (Job): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.Job{}} on success {:error, info} on failure """ @spec dataflow_projects_jobs_create(Tesla.Env.client(), String.t(), keyword()) :: {:ok, GoogleApi.Dataflow.V1b3.Model.Job.t()} | {:error, Tesla.Env.t()} def dataflow_projects_jobs_create(connection, project_id, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :replaceJobId => :query, :view => :query, :location => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1b3/projects/{projectId}/jobs", %{ "projectId" => URI.encode_www_form(project_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.Job{}) end @doc """ Get encoded debug configuration for component. Not cacheable. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The project id. - job_id (String.t): The job id. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :body (GetDebugConfigRequest): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.GetDebugConfigResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_jobs_debug_get_config( Tesla.Env.client(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.GetDebugConfigResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_jobs_debug_get_config(connection, project_id, job_id, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1b3/projects/{projectId}/jobs/{jobId}/debug/getConfig", %{ "projectId" => URI.encode_www_form(project_id), "jobId" => URI.encode_www_form(job_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.GetDebugConfigResponse{}) end @doc """ Send encoded debug capture data for component. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The project id. - job_id (String.t): The job id. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :body (SendDebugCaptureRequest): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.SendDebugCaptureResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_jobs_debug_send_capture( Tesla.Env.client(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.SendDebugCaptureResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_jobs_debug_send_capture(connection, project_id, job_id, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1b3/projects/{projectId}/jobs/{jobId}/debug/sendCapture", %{ "projectId" => URI.encode_www_form(project_id), "jobId" => URI.encode_www_form(job_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.SendDebugCaptureResponse{}) end @doc """ Gets the state of the specified Cloud Dataflow job. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The ID of the Cloud Platform project that the job belongs to. - job_id (String.t): The job ID. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :view (String.t): The level of information requested in response. - :location (String.t): The location that contains this job. ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.Job{}} on success {:error, info} on failure """ @spec dataflow_projects_jobs_get(Tesla.Env.client(), String.t(), String.t(), keyword()) :: {:ok, GoogleApi.Dataflow.V1b3.Model.Job.t()} | {:error, Tesla.Env.t()} def dataflow_projects_jobs_get(connection, project_id, job_id, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :view => :query, :location => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1b3/projects/{projectId}/jobs/{jobId}", %{ "projectId" => URI.encode_www_form(project_id), "jobId" => URI.encode_www_form(job_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.Job{}) end @doc """ Request the job status. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): A project id. - job_id (String.t): The job to get messages for. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :startTime (DateTime.t): Return only metric data that has changed since this time. Default is to return all information about all metrics for the job. - :location (String.t): The location which contains the job specified by job_id. ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.JobMetrics{}} on success {:error, info} on failure """ @spec dataflow_projects_jobs_get_metrics(Tesla.Env.client(), String.t(), String.t(), keyword()) :: {:ok, GoogleApi.Dataflow.V1b3.Model.JobMetrics.t()} | {:error, Tesla.Env.t()} def dataflow_projects_jobs_get_metrics(connection, project_id, job_id, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :startTime => :query, :location => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1b3/projects/{projectId}/jobs/{jobId}/metrics", %{ "projectId" => URI.encode_www_form(project_id), "jobId" => URI.encode_www_form(job_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.JobMetrics{}) end @doc """ List the jobs of a project in a given region. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The project which owns the jobs. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :filter (String.t): The kind of filter to use. - :location (String.t): The location that contains this job. - :pageToken (String.t): Set this to the 'next_page_token' field of a previous response to request additional results in a long list. - :pageSize (integer()): If there are many jobs, limit response to at most this many. The actual number of jobs returned will be the lesser of max_responses and an unspecified server-defined limit. - :view (String.t): Level of information requested in response. Default is `JOB_VIEW_SUMMARY`. ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.ListJobsResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_jobs_list(Tesla.Env.client(), String.t(), keyword()) :: {:ok, GoogleApi.Dataflow.V1b3.Model.ListJobsResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_jobs_list(connection, project_id, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :filter => :query, :location => :query, :pageToken => :query, :pageSize => :query, :view => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1b3/projects/{projectId}/jobs", %{ "projectId" => URI.encode_www_form(project_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.ListJobsResponse{}) end @doc """ Request the job status. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): A project id. - job_id (String.t): The job to get messages about. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :location (String.t): The location which contains the job specified by job_id. - :endTime (DateTime.t): Return only messages with timestamps < end_time. The default is now (i.e. return up to the latest messages available). - :startTime (DateTime.t): If specified, return only messages with timestamps >= start_time. The default is the job creation time (i.e. beginning of messages). - :pageToken (String.t): If supplied, this should be the value of next_page_token returned by an earlier call. This will cause the next page of results to be returned. - :pageSize (integer()): If specified, determines the maximum number of messages to return. If unspecified, the service may choose an appropriate default, or may return an arbitrarily large number of results. - :minimumImportance (String.t): Filter to only get messages with importance >= level ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.ListJobMessagesResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_jobs_messages_list( Tesla.Env.client(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.ListJobMessagesResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_jobs_messages_list(connection, project_id, job_id, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :location => :query, :endTime => :query, :startTime => :query, :pageToken => :query, :pageSize => :query, :minimumImportance => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1b3/projects/{projectId}/jobs/{jobId}/messages", %{ "projectId" => URI.encode_www_form(project_id), "jobId" => URI.encode_www_form(job_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.ListJobMessagesResponse{}) end @doc """ Updates the state of an existing Cloud Dataflow job. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The ID of the Cloud Platform project that the job belongs to. - job_id (String.t): The job ID. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :location (String.t): The location that contains this job. - :body (Job): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.Job{}} on success {:error, info} on failure """ @spec dataflow_projects_jobs_update(Tesla.Env.client(), String.t(), String.t(), keyword()) :: {:ok, GoogleApi.Dataflow.V1b3.Model.Job.t()} | {:error, Tesla.Env.t()} def dataflow_projects_jobs_update(connection, project_id, job_id, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :location => :query, :body => :body } request = Request.new() |> Request.method(:put) |> Request.url("/v1b3/projects/{projectId}/jobs/{jobId}", %{ "projectId" => URI.encode_www_form(project_id), "jobId" => URI.encode_www_form(job_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.Job{}) end @doc """ Leases a dataflow WorkItem to run. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): Identifies the project this worker belongs to. - job_id (String.t): Identifies the workflow job this worker belongs to. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :body (LeaseWorkItemRequest): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.LeaseWorkItemResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_jobs_work_items_lease( Tesla.Env.client(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.LeaseWorkItemResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_jobs_work_items_lease(connection, project_id, job_id, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1b3/projects/{projectId}/jobs/{jobId}/workItems:lease", %{ "projectId" => URI.encode_www_form(project_id), "jobId" => URI.encode_www_form(job_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.LeaseWorkItemResponse{}) end @doc """ Reports the status of dataflow WorkItems leased by a worker. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The project which owns the WorkItem's job. - job_id (String.t): The job which the WorkItem is part of. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :body (ReportWorkItemStatusRequest): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.ReportWorkItemStatusResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_jobs_work_items_report_status( Tesla.Env.client(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.ReportWorkItemStatusResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_jobs_work_items_report_status(connection, project_id, job_id, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1b3/projects/{projectId}/jobs/{jobId}/workItems:reportStatus", %{ "projectId" => URI.encode_www_form(project_id), "jobId" => URI.encode_www_form(job_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.ReportWorkItemStatusResponse{}) end @doc """ Creates a Cloud Dataflow job. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The ID of the Cloud Platform project that the job belongs to. - location (String.t): The location that contains this job. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :replaceJobId (String.t): Deprecated. This field is now in the Job message. - :view (String.t): The level of information requested in response. - :body (Job): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.Job{}} on success {:error, info} on failure """ @spec dataflow_projects_locations_jobs_create( Tesla.Env.client(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.Job.t()} | {:error, Tesla.Env.t()} def dataflow_projects_locations_jobs_create(connection, project_id, location, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :replaceJobId => :query, :view => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1b3/projects/{projectId}/locations/{location}/jobs", %{ "projectId" => URI.encode_www_form(project_id), "location" => URI.encode_www_form(location) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.Job{}) end @doc """ Get encoded debug configuration for component. Not cacheable. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The project id. - location (String.t): The location which contains the job specified by job_id. - job_id (String.t): The job id. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :body (GetDebugConfigRequest): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.GetDebugConfigResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_locations_jobs_debug_get_config( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.GetDebugConfigResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_locations_jobs_debug_get_config( connection, project_id, location, job_id, opts \\ [] ) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url( "/v1b3/projects/{projectId}/locations/{location}/jobs/{jobId}/debug/getConfig", %{ "projectId" => URI.encode_www_form(project_id), "location" => URI.encode_www_form(location), "jobId" => URI.encode_www_form(job_id) } ) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.GetDebugConfigResponse{}) end @doc """ Send encoded debug capture data for component. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The project id. - location (String.t): The location which contains the job specified by job_id. - job_id (String.t): The job id. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :body (SendDebugCaptureRequest): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.SendDebugCaptureResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_locations_jobs_debug_send_capture( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.SendDebugCaptureResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_locations_jobs_debug_send_capture( connection, project_id, location, job_id, opts \\ [] ) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url( "/v1b3/projects/{projectId}/locations/{location}/jobs/{jobId}/debug/sendCapture", %{ "projectId" => URI.encode_www_form(project_id), "location" => URI.encode_www_form(location), "jobId" => URI.encode_www_form(job_id) } ) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.SendDebugCaptureResponse{}) end @doc """ Gets the state of the specified Cloud Dataflow job. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The ID of the Cloud Platform project that the job belongs to. - location (String.t): The location that contains this job. - job_id (String.t): The job ID. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :view (String.t): The level of information requested in response. ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.Job{}} on success {:error, info} on failure """ @spec dataflow_projects_locations_jobs_get( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.Job.t()} | {:error, Tesla.Env.t()} def dataflow_projects_locations_jobs_get(connection, project_id, location, job_id, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :view => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1b3/projects/{projectId}/locations/{location}/jobs/{jobId}", %{ "projectId" => URI.encode_www_form(project_id), "location" => URI.encode_www_form(location), "jobId" => URI.encode_www_form(job_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.Job{}) end @doc """ Request the job status. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): A project id. - location (String.t): The location which contains the job specified by job_id. - job_id (String.t): The job to get messages for. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :startTime (DateTime.t): Return only metric data that has changed since this time. Default is to return all information about all metrics for the job. ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.JobMetrics{}} on success {:error, info} on failure """ @spec dataflow_projects_locations_jobs_get_metrics( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.JobMetrics.t()} | {:error, Tesla.Env.t()} def dataflow_projects_locations_jobs_get_metrics( connection, project_id, location, job_id, opts \\ [] ) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :startTime => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1b3/projects/{projectId}/locations/{location}/jobs/{jobId}/metrics", %{ "projectId" => URI.encode_www_form(project_id), "location" => URI.encode_www_form(location), "jobId" => URI.encode_www_form(job_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.JobMetrics{}) end @doc """ List the jobs of a project in a given region. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The project which owns the jobs. - location (String.t): The location that contains this job. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :filter (String.t): The kind of filter to use. - :pageToken (String.t): Set this to the 'next_page_token' field of a previous response to request additional results in a long list. - :pageSize (integer()): If there are many jobs, limit response to at most this many. The actual number of jobs returned will be the lesser of max_responses and an unspecified server-defined limit. - :view (String.t): Level of information requested in response. Default is `JOB_VIEW_SUMMARY`. ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.ListJobsResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_locations_jobs_list( Tesla.Env.client(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.ListJobsResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_locations_jobs_list(connection, project_id, location, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :filter => :query, :pageToken => :query, :pageSize => :query, :view => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1b3/projects/{projectId}/locations/{location}/jobs", %{ "projectId" => URI.encode_www_form(project_id), "location" => URI.encode_www_form(location) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.ListJobsResponse{}) end @doc """ Request the job status. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): A project id. - location (String.t): The location which contains the job specified by job_id. - job_id (String.t): The job to get messages about. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :pageToken (String.t): If supplied, this should be the value of next_page_token returned by an earlier call. This will cause the next page of results to be returned. - :startTime (DateTime.t): If specified, return only messages with timestamps >= start_time. The default is the job creation time (i.e. beginning of messages). - :pageSize (integer()): If specified, determines the maximum number of messages to return. If unspecified, the service may choose an appropriate default, or may return an arbitrarily large number of results. - :minimumImportance (String.t): Filter to only get messages with importance >= level - :endTime (DateTime.t): Return only messages with timestamps < end_time. The default is now (i.e. return up to the latest messages available). ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.ListJobMessagesResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_locations_jobs_messages_list( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.ListJobMessagesResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_locations_jobs_messages_list( connection, project_id, location, job_id, opts \\ [] ) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :pageToken => :query, :startTime => :query, :pageSize => :query, :minimumImportance => :query, :endTime => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1b3/projects/{projectId}/locations/{location}/jobs/{jobId}/messages", %{ "projectId" => URI.encode_www_form(project_id), "location" => URI.encode_www_form(location), "jobId" => URI.encode_www_form(job_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.ListJobMessagesResponse{}) end @doc """ Updates the state of an existing Cloud Dataflow job. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The ID of the Cloud Platform project that the job belongs to. - location (String.t): The location that contains this job. - job_id (String.t): The job ID. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :body (Job): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.Job{}} on success {:error, info} on failure """ @spec dataflow_projects_locations_jobs_update( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.Job.t()} | {:error, Tesla.Env.t()} def dataflow_projects_locations_jobs_update( connection, project_id, location, job_id, opts \\ [] ) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :body => :body } request = Request.new() |> Request.method(:put) |> Request.url("/v1b3/projects/{projectId}/locations/{location}/jobs/{jobId}", %{ "projectId" => URI.encode_www_form(project_id), "location" => URI.encode_www_form(location), "jobId" => URI.encode_www_form(job_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.Job{}) end @doc """ Leases a dataflow WorkItem to run. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): Identifies the project this worker belongs to. - location (String.t): The location which contains the WorkItem's job. - job_id (String.t): Identifies the workflow job this worker belongs to. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :body (LeaseWorkItemRequest): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.LeaseWorkItemResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_locations_jobs_work_items_lease( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.LeaseWorkItemResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_locations_jobs_work_items_lease( connection, project_id, location, job_id, opts \\ [] ) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url( "/v1b3/projects/{projectId}/locations/{location}/jobs/{jobId}/workItems:lease", %{ "projectId" => URI.encode_www_form(project_id), "location" => URI.encode_www_form(location), "jobId" => URI.encode_www_form(job_id) } ) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.LeaseWorkItemResponse{}) end @doc """ Reports the status of dataflow WorkItems leased by a worker. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The project which owns the WorkItem's job. - location (String.t): The location which contains the WorkItem's job. - job_id (String.t): The job which the WorkItem is part of. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :body (ReportWorkItemStatusRequest): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.ReportWorkItemStatusResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_locations_jobs_work_items_report_status( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.ReportWorkItemStatusResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_locations_jobs_work_items_report_status( connection, project_id, location, job_id, opts \\ [] ) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url( "/v1b3/projects/{projectId}/locations/{location}/jobs/{jobId}/workItems:reportStatus", %{ "projectId" => URI.encode_www_form(project_id), "location" => URI.encode_www_form(location), "jobId" => URI.encode_www_form(job_id) } ) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.ReportWorkItemStatusResponse{}) end @doc """ Creates a Cloud Dataflow job from a template. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): Required. The ID of the Cloud Platform project that the job belongs to. - location (String.t): The location to which to direct the request. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :body (CreateJobFromTemplateRequest): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.Job{}} on success {:error, info} on failure """ @spec dataflow_projects_locations_templates_create( Tesla.Env.client(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.Job.t()} | {:error, Tesla.Env.t()} def dataflow_projects_locations_templates_create(connection, project_id, location, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1b3/projects/{projectId}/locations/{location}/templates", %{ "projectId" => URI.encode_www_form(project_id), "location" => URI.encode_www_form(location) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.Job{}) end @doc """ Get the template associated with a template. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): Required. The ID of the Cloud Platform project that the job belongs to. - location (String.t): The location to which to direct the request. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :gcsPath (String.t): Required. A Cloud Storage path to the template from which to create the job. Must be a valid Cloud Storage URL, beginning with `gs://`. - :view (String.t): The view to retrieve. Defaults to METADATA_ONLY. ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.GetTemplateResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_locations_templates_get( Tesla.Env.client(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.GetTemplateResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_locations_templates_get(connection, project_id, location, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :gcsPath => :query, :view => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1b3/projects/{projectId}/locations/{location}/templates:get", %{ "projectId" => URI.encode_www_form(project_id), "location" => URI.encode_www_form(location) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.GetTemplateResponse{}) end @doc """ Launch a template. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): Required. The ID of the Cloud Platform project that the job belongs to. - location (String.t): The location to which to direct the request. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :gcsPath (String.t): Required. A Cloud Storage path to the template from which to create the job. Must be valid Cloud Storage URL, beginning with 'gs://'. - :validateOnly (boolean()): If true, the request is validated but not actually executed. Defaults to false. - :body (LaunchTemplateParameters): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.LaunchTemplateResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_locations_templates_launch( Tesla.Env.client(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.LaunchTemplateResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_locations_templates_launch(connection, project_id, location, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :gcsPath => :query, :validateOnly => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1b3/projects/{projectId}/locations/{location}/templates:launch", %{ "projectId" => URI.encode_www_form(project_id), "location" => URI.encode_www_form(location) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.LaunchTemplateResponse{}) end @doc """ Send a worker_message to the service. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The project to send the WorkerMessages to. - location (String.t): The location which contains the job - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :body (SendWorkerMessagesRequest): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.SendWorkerMessagesResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_locations_worker_messages( Tesla.Env.client(), String.t(), String.t(), keyword() ) :: {:ok, GoogleApi.Dataflow.V1b3.Model.SendWorkerMessagesResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_locations_worker_messages(connection, project_id, location, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1b3/projects/{projectId}/locations/{location}/WorkerMessages", %{ "projectId" => URI.encode_www_form(project_id), "location" => URI.encode_www_form(location) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.SendWorkerMessagesResponse{}) end @doc """ Creates a Cloud Dataflow job from a template. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): Required. The ID of the Cloud Platform project that the job belongs to. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :body (CreateJobFromTemplateRequest): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.Job{}} on success {:error, info} on failure """ @spec dataflow_projects_templates_create(Tesla.Env.client(), String.t(), keyword()) :: {:ok, GoogleApi.Dataflow.V1b3.Model.Job.t()} | {:error, Tesla.Env.t()} def dataflow_projects_templates_create(connection, project_id, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1b3/projects/{projectId}/templates", %{ "projectId" => URI.encode_www_form(project_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.Job{}) end @doc """ Get the template associated with a template. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): Required. The ID of the Cloud Platform project that the job belongs to. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :gcsPath (String.t): Required. A Cloud Storage path to the template from which to create the job. Must be a valid Cloud Storage URL, beginning with `gs://`. - :location (String.t): The location to which to direct the request. - :view (String.t): The view to retrieve. Defaults to METADATA_ONLY. ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.GetTemplateResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_templates_get(Tesla.Env.client(), String.t(), keyword()) :: {:ok, GoogleApi.Dataflow.V1b3.Model.GetTemplateResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_templates_get(connection, project_id, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :gcsPath => :query, :location => :query, :view => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1b3/projects/{projectId}/templates:get", %{ "projectId" => URI.encode_www_form(project_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.GetTemplateResponse{}) end @doc """ Launch a template. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): Required. The ID of the Cloud Platform project that the job belongs to. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :gcsPath (String.t): Required. A Cloud Storage path to the template from which to create the job. Must be valid Cloud Storage URL, beginning with 'gs://'. - :location (String.t): The location to which to direct the request. - :validateOnly (boolean()): If true, the request is validated but not actually executed. Defaults to false. - :body (LaunchTemplateParameters): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.LaunchTemplateResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_templates_launch(Tesla.Env.client(), String.t(), keyword()) :: {:ok, GoogleApi.Dataflow.V1b3.Model.LaunchTemplateResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_templates_launch(connection, project_id, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :gcsPath => :query, :location => :query, :validateOnly => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1b3/projects/{projectId}/templates:launch", %{ "projectId" => URI.encode_www_form(project_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.LaunchTemplateResponse{}) end @doc """ Send a worker_message to the service. ## Parameters - connection (GoogleApi.Dataflow.V1b3.Connection): Connection to server - project_id (String.t): The project to send the WorkerMessages to. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for response. - :access_token (String.t): OAuth access token. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :upload_protocol (String.t): Upload protocol for media (e.g. \"raw\", \"multipart\"). - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :fields (String.t): Selector specifying which fields to include in a partial response. - :uploadType (String.t): Legacy upload protocol for media (e.g. \"media\", \"multipart\"). - :callback (String.t): JSONP - :oauth_token (String.t): OAuth 2.0 token for the current user. - :$.xgafv (String.t): V1 error format. - :body (SendWorkerMessagesRequest): ## Returns {:ok, %GoogleApi.Dataflow.V1b3.Model.SendWorkerMessagesResponse{}} on success {:error, info} on failure """ @spec dataflow_projects_worker_messages(Tesla.Env.client(), String.t(), keyword()) :: {:ok, GoogleApi.Dataflow.V1b3.Model.SendWorkerMessagesResponse.t()} | {:error, Tesla.Env.t()} def dataflow_projects_worker_messages(connection, project_id, opts \\ []) do optional_params = %{ :alt => :query, :access_token => :query, :key => :query, :upload_protocol => :query, :quotaUser => :query, :prettyPrint => :query, :fields => :query, :uploadType => :query, :callback => :query, :oauth_token => :query, :"$.xgafv" => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1b3/projects/{projectId}/WorkerMessages", %{ "projectId" => URI.encode_www_form(project_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Dataflow.V1b3.Model.SendWorkerMessagesResponse{}) end end
42.763544
213
0.655722
9e7a9a709bf5f303f3cf51ebc7f2159761c1fd11
919
ex
Elixir
testData/org/elixir_lang/parser_definition/unmatched_expression_parsing_test_case/AtQualifiedNoArgumentsCallBlock.ex
keyno63/intellij-elixir
4033e319992c53ddd42a683ee7123a97b5e34f02
[ "Apache-2.0" ]
1,668
2015-01-03T05:54:27.000Z
2022-03-25T08:01:20.000Z
testData/org/elixir_lang/parser_definition/unmatched_expression_parsing_test_case/AtQualifiedNoArgumentsCallBlock.ex
keyno63/intellij-elixir
4033e319992c53ddd42a683ee7123a97b5e34f02
[ "Apache-2.0" ]
2,018
2015-01-01T22:43:39.000Z
2022-03-31T20:13:08.000Z
testData/org/elixir_lang/parser_definition/unmatched_expression_parsing_test_case/AtQualifiedNoArgumentsCallBlock.ex
keyno63/intellij-elixir
4033e319992c53ddd42a683ee7123a97b5e34f02
[ "Apache-2.0" ]
145
2015-01-15T11:37:16.000Z
2021-12-22T05:51:02.000Z
@@one[two].three do end @@one[two].three.four do end @@one.two do end @@one.two.three do end @one()().two do end @one()().two.three do end @one[two].three do end @one[two].three.four do end @one.two do end @one.two.three do end @@1.two do end @@1.two.three do end @&1.two do end @&1.two.three do end @^1.two do end @^1.two.three do end @not 1.two do end @not 1.two.three do end @(->).one do end @(->).one.two do end @1.two do end @1.two.three do end @[].one do end @[].one.two do end @%{}.one do end @%{}.one.two do end @{}.one do end @{}.one.two do end @<<>>.one do end @<<>>.one.two do end @"one".two do end @"one".two.three do end @""" one """.two do end @""" one """.two.three do end @'one'.two do end @'one'.two.three do end @~x{one}.two do end @~x{one}.two.three do end @false.one do end @false.one.two do end @:one.two do end @:one.two.three do end @One.two do end @One.two.three do end
13.128571
28
0.611534
9e7aa8163a543038ad62a61da9c022a6ceabebd7
4,202
exs
Elixir
integration_test/cases/type.exs
timgestson/ecto
1c1eb6d322db04cfa48a4fc81da1332e91adbc1f
[ "Apache-2.0" ]
null
null
null
integration_test/cases/type.exs
timgestson/ecto
1c1eb6d322db04cfa48a4fc81da1332e91adbc1f
[ "Apache-2.0" ]
null
null
null
integration_test/cases/type.exs
timgestson/ecto
1c1eb6d322db04cfa48a4fc81da1332e91adbc1f
[ "Apache-2.0" ]
null
null
null
defmodule Ecto.Integration.TypeTest do use Ecto.Integration.Case require Ecto.Integration.TestRepo, as: TestRepo import Ecto.Query alias Ecto.Integration.Post alias Ecto.Integration.Tag test "primitive types" do integer = 1 float = 0.1 text = <<0,1>> uuid = <<0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15>> decimal = Decimal.new("1.0") datetime = %Ecto.DateTime{year: 2014, month: 1, day: 16, hour: 20, min: 26, sec: 51, usec: 0} TestRepo.insert(%Post{text: text, uuid: uuid, public: true, visits: integer, inserted_at: datetime, cost: decimal, intensity: float}) # nil assert [nil] = TestRepo.all(from Post, select: nil) # Integers assert [1] = TestRepo.all(from p in Post, where: p.visits == ^integer, select: p.visits) assert [1] = TestRepo.all(from p in Post, where: p.visits == 1, select: p.visits) # Floats assert [0.1] = TestRepo.all(from p in Post, where: p.intensity == ^float, select: p.intensity) assert [0.1] = TestRepo.all(from p in Post, where: p.intensity == 0.1, select: p.intensity) # Decimal assert [^decimal] = TestRepo.all(from p in Post, where: p.cost == ^decimal, select: p.cost) assert [^decimal] = TestRepo.all(from p in Post, where: p.cost == ^1.0, select: p.cost) assert [^decimal] = TestRepo.all(from p in Post, where: p.cost == ^1, select: p.cost) assert [^decimal] = TestRepo.all(from p in Post, where: p.cost == 1.0, select: p.cost) assert [^decimal] = TestRepo.all(from p in Post, where: p.cost == 1, select: p.cost) # Booleans assert [true] = TestRepo.all(from p in Post, where: p.public == ^true, select: p.public) assert [true] = TestRepo.all(from p in Post, where: p.public == true, select: p.public) # Binaries assert [^text] = TestRepo.all(from p in Post, where: p.text == ^text, select: p.text) # UUID assert [^uuid] = TestRepo.all(from p in Post, where: p.uuid == ^uuid, select: p.uuid) # Datetime assert [^datetime] = TestRepo.all(from p in Post, where: p.inserted_at == ^datetime, select: p.inserted_at) end test "tagged types" do TestRepo.insert(%Post{}) # Integer assert [1] = TestRepo.all(from Post, select: type(^"1", :integer)) assert [1.0] = TestRepo.all(from Post, select: type(^1.0, :float)) # UUID uuid = <<0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15>> assert [^uuid] = TestRepo.all(from Post, select: type(^uuid, :uuid)) # Datetime datetime = {{2014, 04, 17}, {14, 00, 00, 00}} assert [^datetime] = TestRepo.all(from Post, select: type(^datetime, :datetime)) # Custom wrappers assert [1] = TestRepo.all(from Post, select: type(^"1", Elixir.Custom.Permalink)) # Custom types datetime = %Ecto.DateTime{year: 2014, month: 1, day: 16, hour: 20, min: 26, sec: 51, usec: 0} assert [^datetime] = TestRepo.all(from Post, select: type(^datetime, Ecto.DateTime)) end test "composite types in select" do assert %Post{} = TestRepo.insert(%Post{title: "1", text: "hai"}) assert [{"1", "hai"}] == TestRepo.all(from p in Post, select: {p.title, p.text}) assert [["1", "hai"]] == TestRepo.all(from p in Post, select: [p.title, p.text]) assert [%{:title => "1", 3 => "hai", "text" => "hai"}] == TestRepo.all(from p in Post, select: %{ :title => p.title, "text" => p.text, 3 => p.text }) end @tag :array_type test "array type" do TestRepo.insert(%Tag{ints: [1, 2, 3], uuids: ["51FCFBDD-AD60-4CCB-8BF9-47AABD66D075"]}) assert [] = TestRepo.all(from p in Tag, where: p.ints == ^[], select: p.ints) assert [[1, 2, 3]] = TestRepo.all(from p in Tag, where: p.ints == ^[1, 2, 3], select: p.ints) assert [[1, 2, 3]] = TestRepo.all(from p in Tag, where: p.ints == [1, 2, 3], select: p.ints) assert [] = TestRepo.all(from p in Tag, where: p.uuids == ^[], select: p.uuids) assert [["51FCFBDD-AD60-4CCB-8BF9-47AABD66D075"]] = TestRepo.all(from p in Tag, where: p.uuids == ^["51FCFBDD-AD60-4CCB-8BF9-47AABD66D075"], select: p.uuids) end end
38.907407
111
0.599476
9e7accc643bc38b7ee381bdb34e11c98feb57f5b
71
ex
Elixir
lib/cryptozaur/repo.ex
DenisGorbachev/crypto-cli
94e5097ff24237fbc5fdd3fea371a5c9a1f727e4
[ "MIT" ]
5
2018-09-19T09:13:15.000Z
2021-10-20T23:29:57.000Z
lib/cryptozaur/repo.ex
DenisGorbachev/crypto-cli
94e5097ff24237fbc5fdd3fea371a5c9a1f727e4
[ "MIT" ]
6
2018-07-29T05:33:02.000Z
2018-09-18T20:42:19.000Z
lib/cryptozaur/repo.ex
DenisGorbachev/crypto-cli
94e5097ff24237fbc5fdd3fea371a5c9a1f727e4
[ "MIT" ]
3
2018-07-24T05:55:04.000Z
2018-09-19T09:14:08.000Z
defmodule Cryptozaur.Repo do use Ecto.Repo, otp_app: :cryptozaur end
17.75
37
0.788732
9e7ad6f1e11b751961b05a9557bf80746a70f32e
2,891
exs
Elixir
test/acceptance/ast/list_and_inline_code_test.exs
RobertDober/earmark_parser
8a4e2bf47f4ce0d749df67288046f5a69e8f1f5d
[ "Apache-2.0" ]
32
2020-07-01T17:25:08.000Z
2022-03-23T05:38:38.000Z
test/acceptance/ast/list_and_inline_code_test.exs
RobertDober/earmark_parser
8a4e2bf47f4ce0d749df67288046f5a69e8f1f5d
[ "Apache-2.0" ]
91
2020-06-30T09:08:00.000Z
2022-03-24T18:11:16.000Z
test/acceptance/ast/list_and_inline_code_test.exs
RobertDober/earmark_parser
8a4e2bf47f4ce0d749df67288046f5a69e8f1f5d
[ "Apache-2.0" ]
22
2020-07-02T08:50:17.000Z
2022-02-21T08:31:27.000Z
defmodule Acceptance.Ast.ListAndInlineCodeTest do use ExUnit.Case, async: true import Support.Helpers, only: [as_ast: 1, parse_html: 1] import EarmarkAstDsl describe "List parsing running into EOI inside inline code" do test "simple case" do markdown = ~s(* And\n`Hello\n* World) ast = tag("ul", [tag("li", "And\n`Hello"), tag("li", "World")]) messages = [{:warning, 2, "Closing unclosed backquotes ` at end of input"}] assert as_ast(markdown) == {:error, [ast], messages} end test "link with title" do markdown = ~s(* And\n* `Hello\n* World) ast = tag("ul", [tag("li", "And"), tag("li","`Hello\n* World")]) messages = [{:warning, 2, "Closing unclosed backquotes ` at end of input"}] assert as_ast(markdown) == {:error, [ast], messages} end test "error in spaced part" do markdown = ~s(* And\n `Hello\n * World) ast = tag("ul", tag("li", "And\n`Hello\n * World")) messages = [{:warning, 2, "Closing unclosed backquotes ` at end of input"}] assert as_ast(markdown) == {:error, [ast], messages} end test "error in doubly spaced part" do markdown = ~s(* And\n\n `Hello\n * World) ast = tag("ul", tag("li", ["And", "`Hello\n * World"])) messages = [{:warning, 3, "Closing unclosed backquotes ` at end of input"}] assert as_ast(markdown) == {:error, [ast], messages} end test "even more complex spaced example (checking for one offs)" do markdown = ~s(Prefix1\n* And\n\n Prefix2\n `Hello\n * World) ast = [p("Prefix1"), tag("ul", tag("li", ["And", "Prefix2\n`Hello\n * World"]))] messages = [{:warning, 5, "Closing unclosed backquotes ` at end of input"}] assert as_ast(markdown) == {:error, ast, messages} end end describe "indentation of code (was regtest #85)" do test "losing some indent" do markdown = "1. one\n\n ```elixir\n defmodule```\n" html = "<ol>\n<li><p>one</p>\n<pre><code class=\"elixir\"> defmodule```</code></pre>\n</li>\n</ol>\n" ast = parse_html(html) messages = [] assert as_ast(markdown) == {:ok, ast, messages} end test "less aligned fence is not part of the inline code block" do markdown = "1. one\n\n ~~~elixir\n defmodule\n ~~~" ast = [tag("ol", tag("li", [p("one"), tag("pre", tag("code", " defmodule", class: "elixir"))])), pre_code("")] messages = [] assert as_ast(markdown) == {:ok, ast, messages} end test "more aligned fence is part of the inlinde code block" do markdown = " 1. one\n ~~~elixir\n defmodule\n ~~~" ast = [tag("ol", tag("li", ["one", tag("pre", tag("code", ["defmodule"], [{"class", "elixir"}]))]))] messages = [] assert as_ast(markdown) == {:ok, ast, messages} end end end
38.039474
121
0.571429
9e7af99ddfdbdbba7bd2cf6415a3a6927fbf13b5
4,151
ex
Elixir
lib/benx/decoder.ex
sschneider1207/benx
ab3ff74188c6f8bfbc2e494499b5df492dff84ae
[ "MIT" ]
1
2017-02-01T13:17:18.000Z
2017-02-01T13:17:18.000Z
lib/benx/decoder.ex
sschneider1207/benx
ab3ff74188c6f8bfbc2e494499b5df492dff84ae
[ "MIT" ]
null
null
null
lib/benx/decoder.ex
sschneider1207/benx
ab3ff74188c6f8bfbc2e494499b5df492dff84ae
[ "MIT" ]
null
null
null
defmodule Benx.Decoder do @moduledoc """ Provides decoding for iodata according to the Bencoding specification. """ alias Benx.Decoder.SyntaxError @doc """ Decodes a Bencoded iolist. """ @spec decode(iodata) :: {:ok, Benx.Encoder.t} | {:error, SyntaxError.t} def decode(data) do with flattened = :lists.flatten(data), {:ok, term, [], _pos} <- do_decode(flattened) do {:ok, term} else {:ok, _term, _rest, pos} -> {:error, SyntaxError.exception(message: "unable to determine type", position: pos)} {:error, reason, pos} -> {:error, SyntaxError.exception(message: reason, position: pos)} end end @doc """ Decodes a Bencoded iolist. Raises on syntax errors. """ @spec decode!(iodata) :: String.t def decode!(data) do case decode(data) do {:ok, term} -> term {:error, err} -> raise err end end defp do_decode(data, pos \\ 0) defp do_decode([?i|rem], pos) do decode_integer(rem, pos + 1) end defp do_decode([?l|rem], pos) do decode_list(rem, pos + 1) end defp do_decode([?d|rem], pos) do decode_map(rem, pos + 1) end defp do_decode(data, pos) do decode_string_length(data, pos) end defp decode_integer(data, pos, acc \\ []) defp decode_integer([?-|[?0|[?e|_rest]]], pos, _acc) do {:error, "-0 is an invalid integer", pos} end defp decode_integer([?e|rest], pos, acc) do integer = acc |> :lists.reverse() |> :erlang.list_to_integer() {:ok, integer, rest, pos + 1} end defp decode_integer([digit|rem], pos, acc) do decode_integer(rem, pos + 1, [digit|acc]) end defp decode_list(data, pos, acc \\ []) defp decode_list([?e|rest], pos, acc) do {:ok, :lists.reverse(acc), rest, pos + 1} end defp decode_list([?i|rem], pos, acc) do with {:ok, integer, rest, new_pos} <- decode_integer(rem, pos + 1), do: decode_list(rest, new_pos, [integer|acc]) end defp decode_list([?l|rem], pos, acc) do with {:ok, list, rest, new_pos} <- decode_list(rem, pos + 1), do: decode_list(rest, new_pos, [list|acc]) end defp decode_list([?d|rem], pos, acc) do with {:ok, map, rest, new_pos} <- decode_map(rem, pos + 1), do: decode_list(rest, new_pos, [map|acc]) end defp decode_list([], pos, _acc) do {:error, "expected 'e' for end of list or for list to continue", pos} end defp decode_list(data, pos, acc) do with {:ok, string, rest, new_pos} <- decode_string_length(data, pos), do: decode_list(rest, new_pos, [string|acc]) end defp decode_map(data, pos, acc \\ %{}) defp decode_map([?e|rest], pos, acc) do {:ok, acc, rest, pos + 1} end defp decode_map([], pos, _acc) do {:error, "expected 'e' for end of dict or for dict to continue", pos} end defp decode_map(data, pos, acc) do with {:ok, key, rest, new_pos} <- decode_string_length(data, pos), {:ok, value, rest, new_pos} <- do_decode(rest, new_pos), do: decode_map(rest, new_pos, Map.put(acc, key, value)) end defp decode_string_length(data, pos, acc \\ []) defp decode_string_length([?:|_rem], pos, []) do {:error, "expected string length", pos} end defp decode_string_length([?:|rem], pos, acc) do length = acc |> :lists.reverse() |> :erlang.list_to_integer() decode_string(rem, length, pos + 1) end defp decode_string_length([], pos, acc) do start_pos = pos - length(acc) {:error, "unable to determine type", start_pos} end defp decode_string_length([digit|rem], pos, acc) do decode_string_length(rem, pos + 1, [digit|acc]) end defp decode_string(data, length, pos, acc \\ []) defp decode_string(rest, 0, pos, acc) do string = acc |> :lists.reverse() |> :erlang.iolist_to_binary() {:ok, string, rest, pos} end defp decode_string([], length, pos, acc) do start_pos = pos - length(acc) {:error, "expected #{length} more character(s) for string", start_pos} end defp decode_string([char|rem], length, pos, acc) do decode_string(rem, length - 1, pos + 1, [char|acc]) end end
29.863309
91
0.61696
9e7b21083db9c86f07844885861811d2cb1b2f56
137
ex
Elixir
lib/yacco_web/controllers/page_controller.ex
rengel-de/yacco
b8714165d2d1ace07f4116719b54e8ea077c3587
[ "Apache-2.0" ]
null
null
null
lib/yacco_web/controllers/page_controller.ex
rengel-de/yacco
b8714165d2d1ace07f4116719b54e8ea077c3587
[ "Apache-2.0" ]
null
null
null
lib/yacco_web/controllers/page_controller.ex
rengel-de/yacco
b8714165d2d1ace07f4116719b54e8ea077c3587
[ "Apache-2.0" ]
null
null
null
defmodule YaccoWeb.PageController do use YaccoWeb, :controller def index(conn, _params) do render(conn, "index.html") end end
17.125
36
0.729927
9e7b33f9c320f7ad3c55d221281c9a0a3a45f303
2,223
exs
Elixir
test/fault_tree_test.exs
hexedpackets/fault_tree
340d08e8ea7733999531f79bdc712515053e0e85
[ "Apache-2.0" ]
3
2019-06-05T14:16:24.000Z
2020-08-10T00:33:05.000Z
test/fault_tree_test.exs
hexedpackets/fault_tree
340d08e8ea7733999531f79bdc712515053e0e85
[ "Apache-2.0" ]
15
2019-05-15T21:38:48.000Z
2019-06-04T17:26:43.000Z
test/fault_tree_test.exs
hexedpackets/fault_tree
340d08e8ea7733999531f79bdc712515053e0e85
[ "Apache-2.0" ]
null
null
null
defmodule FaultTreeTest do use ExUnit.Case import ExUnit.CaptureLog doctest FaultTree setup do or_tree = FaultTree.create(:or) |> FaultTree.add_basic("root", "0.01", "foo") |> FaultTree.add_basic("root", "0.01", "bar") and_tree = FaultTree.create(:and) |> FaultTree.add_basic("root", "0.01", "foo") |> FaultTree.add_basic("root", "0.01", "bar") %{or_tree: or_tree, and_tree: and_tree} end test "ATLEAST can only have a single child" do tree = FaultTree.create(:atleast) |> FaultTree.add_basic("root", "0.01", "foo") capture_log(fn -> assert FaultTree.add_basic(tree, "root", "0.01", "bar") == {:error, :invalid} end) end test "OR gate probability", %{or_tree: tree} do tree = FaultTree.build(tree) assert tree.probability == Decimal.new("0.0199") end test "AND gate probability", %{and_tree: tree} do tree = FaultTree.build(tree) assert tree.probability == Decimal.new("0.0001") end test "multi level gates", %{or_tree: or_tree} do tree = or_tree |> FaultTree.add_or_gate("root", "l2") |> FaultTree.add_basic("l2", "0.02", "l2_foo") |> FaultTree.add_basic("l2", "0.02", "l2_bar") |> FaultTree.build() assert tree.probability == Decimal.new("0.05871196") end test "ATLEAST gate probability" do tree = %FaultTree.Node{type: :atleast, id: 0, name: "root", atleast: {2, 3}} |> FaultTree.create() |> FaultTree.add_basic("root", "0.01", "foo") |> FaultTree.build() assert tree.probability == Decimal.new("0.0001495") end test "names of nodes are unique", %{or_tree: tree} do new = FaultTree.validate_name(tree, %{name: "jimjamjon"}) old = FaultTree.validate_name(tree, %{name: "root"}) assert elem(new, 0) == :ok assert elem(old, 0) == :error end test "TRANSFER gate probability", %{or_tree: or_tree} do tree = or_tree |> FaultTree.add_or_gate("root", "l2") |> FaultTree.add_and_gate("l2", "host") |> FaultTree.add_basic("host", "0.1", "disk") |> FaultTree.add_basic("host", "0.1", "backup") |> FaultTree.add_transfer("root", "host") |> FaultTree.build() assert tree.probability == Decimal.new("0.03940399") end end
29.25
83
0.62933
9e7b6456e9179e470c0626c6100db282c4908c08
711
exs
Elixir
test/wallet_test.exs
sgessa/dpos-ex
b2b3407fd120224b800fe755e3966556fd609e20
[ "MIT" ]
4
2018-07-10T09:39:01.000Z
2020-09-11T22:46:45.000Z
test/wallet_test.exs
lwfcoin/dpos-ex
b2b3407fd120224b800fe755e3966556fd609e20
[ "MIT" ]
null
null
null
test/wallet_test.exs
lwfcoin/dpos-ex
b2b3407fd120224b800fe755e3966556fd609e20
[ "MIT" ]
null
null
null
defmodule Dpos.WalletTest do use ExUnit.Case alias Dpos.Wallet @wallet %{ secret: "robust swift grocery peasant forget share enable convince deputy road keep cheap", address: "8273455169423958419S", pub_key: "9d3058175acab969f41ad9b86f7a2926c74258670fe56b37c429c01fca9f2f0f" } describe "wallet" do test "should match example wallet" do wallet = Wallet.generate_shift(@wallet.secret) assert wallet == Wallet.generate(@wallet.secret, "S") assert byte_size(wallet.priv_key) == 64 assert byte_size(wallet.pub_key) == 32 assert Base.encode16(wallet.pub_key, case: :lower) == @wallet.pub_key assert wallet.address == @wallet.address end end end
29.625
95
0.7173
9e7b886b4ca41a8eb92e3f63a9637d0c85d42fb0
1,206
ex
Elixir
lib/batched_communication/buffer.ex
skirino/batched_communication
14dea7075a13c94df0e3c63c034029cc36bd0ab0
[ "MIT" ]
4
2018-08-28T03:49:08.000Z
2020-06-25T16:00:13.000Z
lib/batched_communication/buffer.ex
skirino/batched_communication
14dea7075a13c94df0e3c63c034029cc36bd0ab0
[ "MIT" ]
null
null
null
lib/batched_communication/buffer.ex
skirino/batched_communication
14dea7075a13c94df0e3c63c034029cc36bd0ab0
[ "MIT" ]
null
null
null
use Croma defmodule BatchedCommunication.Buffer do alias BatchedCommunication.{Compression, EncodedBatch} @type proc :: pid | atom @type dest :: proc | [proc] @type t :: {pos_integer, reference, [{dest, any}]} defun make(node :: node, wait_time :: pos_integer, dest :: dest, msg :: any) :: t do timer = Process.send_after(self(), {:timeout, node}, wait_time) {1, timer, [{dest, msg}]} end defun add({n1, timer, pairs1} :: t, max :: pos_integer, compression :: Compression.t, dest :: dest, msg :: any) :: {:flush, EncodedBatch.t} | t do pairs2 = [{dest, msg} | pairs1] case n1 + 1 do n2 when n2 < max -> {n2, timer, pairs2} n2 -> Process.cancel_timer(timer, [async: true]) {:flush, encode_messages_impl(n2, pairs2, compression)} end end defun encode_messages({n, _, pairs} :: t, compression :: Compression.t) :: EncodedBatch.t do encode_messages_impl(n, pairs, compression) end defp encode_messages_impl(n, pairs, compression) do b = :erlang.term_to_binary(pairs) z = case compression do :raw -> b :gzip -> :zlib.gzip(b) end {n, byte_size(b), compression, z} end end
30.923077
148
0.617745
9e7ba93d17009a0d83239ad07e9843373192d421
4,464
ex
Elixir
deps/ex_aws/lib/ex_aws/request.ex
fast-radius/kinesis
f98e1792c650c18bb1967d1067e77fe365245f2a
[ "MIT" ]
null
null
null
deps/ex_aws/lib/ex_aws/request.ex
fast-radius/kinesis
f98e1792c650c18bb1967d1067e77fe365245f2a
[ "MIT" ]
null
null
null
deps/ex_aws/lib/ex_aws/request.ex
fast-radius/kinesis
f98e1792c650c18bb1967d1067e77fe365245f2a
[ "MIT" ]
null
null
null
defmodule ExAws.Request do require Logger @moduledoc """ Makes requests to AWS. """ @type http_status :: pos_integer @type success_content :: %{body: binary, headers: [{binary, binary}]} @type success_t :: {:ok, success_content} @type error_t :: {:error, {:http_error, http_status, binary}} @type response_t :: success_t | error_t def request(http_method, url, data, headers, config, service) do body = case data do [] -> "{}" d when is_binary(d) -> d _ -> config[:json_codec].encode!(data) end request_and_retry(http_method, url, service, config, headers, body, {:attempt, 1}) end def request_and_retry(_method, _url, _service, _config, _headers, _req_body, {:error, reason}), do: {:error, reason} def request_and_retry(method, url, service, config, headers, req_body, {:attempt, attempt}) do full_headers = ExAws.Auth.headers(method, url, service, config, headers, req_body) with {:ok, full_headers} <- full_headers do safe_url = replace_spaces(url) if config[:debug_requests] do Logger.debug( "ExAws: Request URL: #{inspect(safe_url)} HEADERS: #{inspect(full_headers)} BODY: #{ inspect(req_body) } ATTEMPT: #{attempt}" ) end case config[:http_client].request( method, safe_url, req_body, full_headers, Map.get(config, :http_opts, []) ) do {:ok, %{status_code: status} = resp} when status in 200..299 or status == 304 -> {:ok, resp} {:ok, %{status_code: status} = _resp} when status == 301 -> Logger.warn("ExAws: Received redirect, did you specify the correct region?") {:error, {:http_error, status, "redirected"}} {:ok, %{status_code: status} = resp} when status in 400..499 -> case client_error(resp, config[:json_codec]) do {:retry, reason} -> request_and_retry( method, url, service, config, headers, req_body, attempt_again?(attempt, reason, config) ) {:error, reason} -> {:error, reason} end {:ok, %{status_code: status} = resp} when status >= 500 -> body = Map.get(resp, :body) reason = {:http_error, status, body} request_and_retry( method, url, service, config, headers, req_body, attempt_again?(attempt, reason, config) ) {:error, %{reason: reason}} -> Logger.warn( "ExAws: HTTP ERROR: #{inspect(reason)} for URL: #{inspect(safe_url)} ATTEMPT: #{ attempt }" ) request_and_retry( method, url, service, config, headers, req_body, attempt_again?(attempt, reason, config) ) end end end def client_error(%{status_code: status, body: body} = error, json_codec) do case json_codec.decode(body) do {:ok, %{"__type" => error_type, "message" => message} = err} -> error_type |> String.split("#") |> case do [_, type] -> handle_aws_error(type, message) _ -> {:error, {:http_error, status, err}} end _ -> {:error, {:http_error, status, error}} end end def client_error(%{status_code: status} = error, _) do {:error, {:http_error, status, error}} end def handle_aws_error("ProvisionedThroughputExceededException" = type, message) do {:retry, {type, message}} end def handle_aws_error("ThrottlingException" = type, message) do {:retry, {type, message}} end def handle_aws_error(type, message) do {:error, {type, message}} end def attempt_again?(attempt, reason, config) do if attempt >= config[:retries][:max_attempts] do {:error, reason} else attempt |> backoff(config) {:attempt, attempt + 1} end end def backoff(attempt, config) do (config[:retries][:base_backoff_in_ms] * :math.pow(2, attempt)) |> min(config[:retries][:max_backoff_in_ms]) |> trunc |> :rand.uniform() |> :timer.sleep() end defp replace_spaces(url) do String.replace(url, " ", "%20") end end
28.075472
97
0.553987
9e7bd15e9ac3df76a44367b9f63d193c3cd1fb9f
2,838
exs
Elixir
mix.exs
wingyplus/quantum-core
91a4df2490b9ebf01e6a46299920cd0550a89f62
[ "Apache-2.0" ]
null
null
null
mix.exs
wingyplus/quantum-core
91a4df2490b9ebf01e6a46299920cd0550a89f62
[ "Apache-2.0" ]
null
null
null
mix.exs
wingyplus/quantum-core
91a4df2490b9ebf01e6a46299920cd0550a89f62
[ "Apache-2.0" ]
null
null
null
defmodule Quantum.Mixfile do @moduledoc false use Mix.Project @source_url "https://github.com/quantum-elixir/quantum-core" @version "3.3.0" def project do [ app: :quantum, build_embedded: Mix.env() == :prod, deps: deps(), description: "Cron-like job scheduler for Elixir.", docs: docs(), elixir: "~> 1.8", name: "Quantum", elixirc_paths: elixirc_paths(Mix.env()), package: package(), start_permanent: Mix.env() == :prod, test_coverage: [tool: ExCoveralls], version: @version, build_embedded: (System.get_env("BUILD_EMBEDDED") || "false") in ["1", "true"], dialyzer: [ ignore_warnings: "dialyzer.ignore-warnings" ] ++ if (System.get_env("DIALYZER_PLT_PRIV") || "false") in ["1", "true"] do [ plt_file: {:no_warn, "priv/plts/dialyzer.plt"} ] else [] end ] end def application do [extra_applications: [:logger]] end defp elixirc_paths(:test), do: ["lib", "test/support"] defp elixirc_paths(_), do: ["lib"] defp package do %{ maintainers: [ "Constantin Rack", "Dan Swain", "Lenz Gschwendtner", "Lucas Charles", "Rodion Vshevtsov", "Stanislav Krasnoyarov", "Kai Faber", "Jonatan Männchen" ], exclude_patterns: [~r[priv/plts]], licenses: ["Apache-2.0"], links: %{ "Changelog" => "#{@source_url}/blob/master/CHANGELOG.md", "GitHub" => @source_url } } end defp docs do [ main: "readme", source_ref: "v#{@version}", source_url: @source_url, logo: "assets/quantum-elixir-logo.svg", extras: [ "CHANGELOG.md", "README.md", "pages/supervision-tree.md", "pages/configuration.md", "pages/runtime-configuration.md", "pages/crontab-format.md", "pages/run-strategies.md", "pages/telemetry.md" ], groups_for_modules: [ "Run Strategy": [ Quantum.RunStrategy, Quantum.RunStrategy.All, Quantum.RunStrategy.Local, Quantum.RunStrategy.NodeList, Quantum.RunStrategy.Random ], Storage: [ Quantum.Storage, Quantum.Storage.Noop ] ] ] end defp deps do [ {:crontab, "~> 1.1"}, {:gen_stage, "~> 0.14 or ~> 1.0"}, {:telemetry, ">= 0.4.3 and < 1.0.0"}, {:tzdata, "~> 1.0", only: [:dev, :test]}, {:ex_doc, ">= 0.0.0", only: [:dev, :docs], runtime: false}, {:excoveralls, "~> 0.5", only: [:test], runtime: false}, {:dialyxir, "~> 1.0-rc", only: [:dev], runtime: false}, {:credo, "~> 1.0", only: [:dev], runtime: false} ] end end
25.567568
85
0.526075
9e7be1ddf0d55283f7d1ff08f9a44b7216d0412f
2,979
exs
Elixir
apps/gitgud/test/gitgud/repo_test.exs
chulkilee/gitgud
7a9b1023ff986ca08fb821a5e7658904a6061ba3
[ "MIT" ]
null
null
null
apps/gitgud/test/gitgud/repo_test.exs
chulkilee/gitgud
7a9b1023ff986ca08fb821a5e7658904a6061ba3
[ "MIT" ]
null
null
null
apps/gitgud/test/gitgud/repo_test.exs
chulkilee/gitgud
7a9b1023ff986ca08fb821a5e7658904a6061ba3
[ "MIT" ]
null
null
null
defmodule GitGud.RepoTest do use GitGud.DataCase alias GitRekt.Git alias GitGud.User alias GitGud.Repo alias GitGud.RepoQuery @valid_attrs %{name: "project-awesome", description: "Awesome things are going on here!"} setup do user = User.register!(name: "Mario Flach", username: "redrabbit", email: "[email protected]", password: "test1234") on_exit fn -> File.rm_rf!(Path.join(Application.get_env(:gitgud, :git_dir), user.username)) end {:ok, %{user: user}} end test "creates a bare repository", %{user: user} do params = Map.put(@valid_attrs, :owner_id, user.id) assert {:ok, repo, ref} = Repo.create(params) assert File.dir?(Repo.workdir(repo)) assert Git.repository_bare?(ref) end test "fails to create a repository with invalid params", %{user: user} do params = Map.put(@valid_attrs, :owner_id, user.id) assert {:error, changeset} = Repo.create(%{params|name: "foo$bar"}) assert "has invalid format" in errors_on(changeset).name assert {:error, changeset} = Repo.create(%{params|name: "xy"}) assert "should be at least 3 character(s)" in errors_on(changeset).name end test "fails to create two repositories with same path", %{user: user} do params = Map.put(@valid_attrs, :owner_id, user.id) assert {:ok, _repo, _pid} = Repo.create(params) assert {:error, changeset} = Repo.create(params) assert "has already been taken" in errors_on(changeset).name end test "gets all repositories owned by a user", %{user: user} do params = Map.put(@valid_attrs, :owner_id, user.id) repos = 1..5 |> Enum.map(fn i -> update_in(params.name, &"#{&1}-#{i}") end) |> Enum.map(&Repo.create!/1) |> Enum.map(&elem(&1, 0)) |> DB.preload(:owner) assert repos == RepoQuery.user_repositories(user) end test "gets a single user repository", %{user: user} do params = Map.put(@valid_attrs, :owner_id, user.id) assert {:ok, repo, _pid} = Repo.create(params) repo = DB.preload(repo, :owner) assert ^repo = RepoQuery.user_repository(user, repo.name) end test "updates a repository", %{user: user} do params = Map.put(@valid_attrs, :owner_id, user.id) assert {:ok, old_repo, _pid} = Repo.create(params) assert {:ok, new_repo} = Repo.update(old_repo, name: "project-super-awesome") refute File.dir?(Repo.workdir(old_repo)) assert File.dir?(Repo.workdir(new_repo)) end test "deletes a repository", %{user: user} do params = Map.put(@valid_attrs, :owner_id, user.id) assert {:ok, repo, _pid} = Repo.create(params) assert {:ok, repo} = Repo.delete(repo) refute File.dir?(Repo.workdir(repo)) end test "ensures user has read and write permissions to own repository", %{user: user} do params = Map.put(@valid_attrs, :owner_id, user.id) assert {:ok, repo, _pid} = Repo.create(params) assert Repo.can_read?(repo, user) assert Repo.can_write?(repo, user) end end
35.464286
127
0.667002
9e7be6eef2992cd21c66e858d32e732807d8b399
36,208
ex
Elixir
lib/aws/generated/cognito_identity_provider.ex
benmmari/aws-elixir
b97477498a9e8ba0d46a09255302d88c6a1c8573
[ "Apache-2.0" ]
null
null
null
lib/aws/generated/cognito_identity_provider.ex
benmmari/aws-elixir
b97477498a9e8ba0d46a09255302d88c6a1c8573
[ "Apache-2.0" ]
null
null
null
lib/aws/generated/cognito_identity_provider.ex
benmmari/aws-elixir
b97477498a9e8ba0d46a09255302d88c6a1c8573
[ "Apache-2.0" ]
null
null
null
# WARNING: DO NOT EDIT, AUTO-GENERATED CODE! # See https://github.com/aws-beam/aws-codegen for more details. defmodule AWS.CognitoIdentityProvider do @moduledoc """ Using the Amazon Cognito User Pools API, you can create a user pool to manage directories and users. You can authenticate a user to obtain tokens related to user identity and access policies. This API reference provides information about user pools in Amazon Cognito User Pools. For more information, see the Amazon Cognito Documentation. """ @doc """ Adds additional user attributes to the user pool schema. """ def add_custom_attributes(client, input, options \\ []) do request(client, "AddCustomAttributes", input, options) end @doc """ Adds the specified user to the specified group. Calling this action requires developer credentials. """ def admin_add_user_to_group(client, input, options \\ []) do request(client, "AdminAddUserToGroup", input, options) end @doc """ Confirms user registration as an admin without using a confirmation code. Works on any user. Calling this action requires developer credentials. """ def admin_confirm_sign_up(client, input, options \\ []) do request(client, "AdminConfirmSignUp", input, options) end @doc """ Creates a new user in the specified user pool. If `MessageAction` is not set, the default is to send a welcome message via email or phone (SMS). This message is based on a template that you configured in your call to create or update a user pool. This template includes your custom sign-up instructions and placeholders for user name and temporary password. Alternatively, you can call `AdminCreateUser` with “SUPPRESS” for the `MessageAction` parameter, and Amazon Cognito will not send any email. In either case, the user will be in the `FORCE_CHANGE_PASSWORD` state until they sign in and change their password. `AdminCreateUser` requires developer credentials. """ def admin_create_user(client, input, options \\ []) do request(client, "AdminCreateUser", input, options) end @doc """ Deletes a user as an administrator. Works on any user. Calling this action requires developer credentials. """ def admin_delete_user(client, input, options \\ []) do request(client, "AdminDeleteUser", input, options) end @doc """ Deletes the user attributes in a user pool as an administrator. Works on any user. Calling this action requires developer credentials. """ def admin_delete_user_attributes(client, input, options \\ []) do request(client, "AdminDeleteUserAttributes", input, options) end @doc """ Disables the user from signing in with the specified external (SAML or social) identity provider. If the user to disable is a Cognito User Pools native username + password user, they are not permitted to use their password to sign-in. If the user to disable is a linked external IdP user, any link between that user and an existing user is removed. The next time the external user (no longer attached to the previously linked `DestinationUser`) signs in, they must create a new user account. See [AdminLinkProviderForUser](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminLinkProviderForUser.html). This action is enabled only for admin access and requires developer credentials. The `ProviderName` must match the value specified when creating an IdP for the pool. To disable a native username + password user, the `ProviderName` value must be `Cognito` and the `ProviderAttributeName` must be `Cognito_Subject`, with the `ProviderAttributeValue` being the name that is used in the user pool for the user. The `ProviderAttributeName` must always be `Cognito_Subject` for social identity providers. The `ProviderAttributeValue` must always be the exact subject that was used when the user was originally linked as a source user. For de-linking a SAML identity, there are two scenarios. If the linked identity has not yet been used to sign-in, the `ProviderAttributeName` and `ProviderAttributeValue` must be the same values that were used for the `SourceUser` when the identities were originally linked using ` AdminLinkProviderForUser` call. (If the linking was done with `ProviderAttributeName` set to `Cognito_Subject`, the same applies here). However, if the user has already signed in, the `ProviderAttributeName` must be `Cognito_Subject` and `ProviderAttributeValue` must be the subject of the SAML assertion. """ def admin_disable_provider_for_user(client, input, options \\ []) do request(client, "AdminDisableProviderForUser", input, options) end @doc """ Disables the specified user. Calling this action requires developer credentials. """ def admin_disable_user(client, input, options \\ []) do request(client, "AdminDisableUser", input, options) end @doc """ Enables the specified user as an administrator. Works on any user. Calling this action requires developer credentials. """ def admin_enable_user(client, input, options \\ []) do request(client, "AdminEnableUser", input, options) end @doc """ Forgets the device, as an administrator. Calling this action requires developer credentials. """ def admin_forget_device(client, input, options \\ []) do request(client, "AdminForgetDevice", input, options) end @doc """ Gets the device, as an administrator. Calling this action requires developer credentials. """ def admin_get_device(client, input, options \\ []) do request(client, "AdminGetDevice", input, options) end @doc """ Gets the specified user by user name in a user pool as an administrator. Works on any user. Calling this action requires developer credentials. """ def admin_get_user(client, input, options \\ []) do request(client, "AdminGetUser", input, options) end @doc """ Initiates the authentication flow, as an administrator. Calling this action requires developer credentials. """ def admin_initiate_auth(client, input, options \\ []) do request(client, "AdminInitiateAuth", input, options) end @doc """ Links an existing user account in a user pool (`DestinationUser`) to an identity from an external identity provider (`SourceUser`) based on a specified attribute name and value from the external identity provider. This allows you to create a link from the existing user account to an external federated user identity that has not yet been used to sign in, so that the federated user identity can be used to sign in as the existing user account. For example, if there is an existing user with a username and password, this API links that user to a federated user identity, so that when the federated user identity is used, the user signs in as the existing user account. <note> The maximum number of federated identities linked to a user is 5. </note> <important> Because this API allows a user with an external federated identity to sign in as an existing user in the user pool, it is critical that it only be used with external identity providers and provider attributes that have been trusted by the application owner. </important> This action is enabled only for admin access and requires developer credentials. """ def admin_link_provider_for_user(client, input, options \\ []) do request(client, "AdminLinkProviderForUser", input, options) end @doc """ Lists devices, as an administrator. Calling this action requires developer credentials. """ def admin_list_devices(client, input, options \\ []) do request(client, "AdminListDevices", input, options) end @doc """ Lists the groups that the user belongs to. Calling this action requires developer credentials. """ def admin_list_groups_for_user(client, input, options \\ []) do request(client, "AdminListGroupsForUser", input, options) end @doc """ Lists a history of user activity and any risks detected as part of Amazon Cognito advanced security. """ def admin_list_user_auth_events(client, input, options \\ []) do request(client, "AdminListUserAuthEvents", input, options) end @doc """ Removes the specified user from the specified group. Calling this action requires developer credentials. """ def admin_remove_user_from_group(client, input, options \\ []) do request(client, "AdminRemoveUserFromGroup", input, options) end @doc """ Resets the specified user's password in a user pool as an administrator. Works on any user. When a developer calls this API, the current password is invalidated, so it must be changed. If a user tries to sign in after the API is called, the app will get a PasswordResetRequiredException exception back and should direct the user down the flow to reset the password, which is the same as the forgot password flow. In addition, if the user pool has phone verification selected and a verified phone number exists for the user, or if email verification is selected and a verified email exists for the user, calling this API will also result in sending a message to the end user with the code to change their password. Calling this action requires developer credentials. """ def admin_reset_user_password(client, input, options \\ []) do request(client, "AdminResetUserPassword", input, options) end @doc """ Responds to an authentication challenge, as an administrator. Calling this action requires developer credentials. """ def admin_respond_to_auth_challenge(client, input, options \\ []) do request(client, "AdminRespondToAuthChallenge", input, options) end @doc """ Sets the user's multi-factor authentication (MFA) preference, including which MFA options are enabled and if any are preferred. Only one factor can be set as preferred. The preferred MFA factor will be used to authenticate a user if multiple factors are enabled. If multiple options are enabled and no preference is set, a challenge to choose an MFA option will be returned during sign in. """ def admin_set_user_m_f_a_preference(client, input, options \\ []) do request(client, "AdminSetUserMFAPreference", input, options) end @doc """ Sets the specified user's password in a user pool as an administrator. Works on any user. The password can be temporary or permanent. If it is temporary, the user status will be placed into the `FORCE_CHANGE_PASSWORD` state. When the user next tries to sign in, the InitiateAuth/AdminInitiateAuth response will contain the `NEW_PASSWORD_REQUIRED` challenge. If the user does not sign in before it expires, the user will not be able to sign in and their password will need to be reset by an administrator. Once the user has set a new password, or the password is permanent, the user status will be set to `Confirmed`. """ def admin_set_user_password(client, input, options \\ []) do request(client, "AdminSetUserPassword", input, options) end @doc """ *This action is no longer supported.* You can use it to configure only SMS MFA. You can't use it to configure TOTP software token MFA. To configure either type of MFA, use [AdminSetUserMFAPreference](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminSetUserMFAPreference.html) instead. """ def admin_set_user_settings(client, input, options \\ []) do request(client, "AdminSetUserSettings", input, options) end @doc """ Provides feedback for an authentication event as to whether it was from a valid user. This feedback is used for improving the risk evaluation decision for the user pool as part of Amazon Cognito advanced security. """ def admin_update_auth_event_feedback(client, input, options \\ []) do request(client, "AdminUpdateAuthEventFeedback", input, options) end @doc """ Updates the device status as an administrator. Calling this action requires developer credentials. """ def admin_update_device_status(client, input, options \\ []) do request(client, "AdminUpdateDeviceStatus", input, options) end @doc """ Updates the specified user's attributes, including developer attributes, as an administrator. Works on any user. For custom attributes, you must prepend the `custom:` prefix to the attribute name. In addition to updating user attributes, this API can also be used to mark phone and email as verified. Calling this action requires developer credentials. """ def admin_update_user_attributes(client, input, options \\ []) do request(client, "AdminUpdateUserAttributes", input, options) end @doc """ Signs out users from all devices, as an administrator. It also invalidates all refresh tokens issued to a user. The user's current access and Id tokens remain valid until their expiry. Access and Id tokens expire one hour after they are issued. Calling this action requires developer credentials. """ def admin_user_global_sign_out(client, input, options \\ []) do request(client, "AdminUserGlobalSignOut", input, options) end @doc """ Returns a unique generated shared secret key code for the user account. The request takes an access token or a session string, but not both. """ def associate_software_token(client, input, options \\ []) do request(client, "AssociateSoftwareToken", input, options) end @doc """ Changes the password for a specified user in a user pool. """ def change_password(client, input, options \\ []) do request(client, "ChangePassword", input, options) end @doc """ Confirms tracking of the device. This API call is the call that begins device tracking. """ def confirm_device(client, input, options \\ []) do request(client, "ConfirmDevice", input, options) end @doc """ Allows a user to enter a confirmation code to reset a forgotten password. """ def confirm_forgot_password(client, input, options \\ []) do request(client, "ConfirmForgotPassword", input, options) end @doc """ Confirms registration of a user and handles the existing alias from a previous user. """ def confirm_sign_up(client, input, options \\ []) do request(client, "ConfirmSignUp", input, options) end @doc """ Creates a new group in the specified user pool. Calling this action requires developer credentials. """ def create_group(client, input, options \\ []) do request(client, "CreateGroup", input, options) end @doc """ Creates an identity provider for a user pool. """ def create_identity_provider(client, input, options \\ []) do request(client, "CreateIdentityProvider", input, options) end @doc """ Creates a new OAuth2.0 resource server and defines custom scopes in it. """ def create_resource_server(client, input, options \\ []) do request(client, "CreateResourceServer", input, options) end @doc """ Creates the user import job. """ def create_user_import_job(client, input, options \\ []) do request(client, "CreateUserImportJob", input, options) end @doc """ Creates a new Amazon Cognito user pool and sets the password policy for the pool. """ def create_user_pool(client, input, options \\ []) do request(client, "CreateUserPool", input, options) end @doc """ Creates the user pool client. """ def create_user_pool_client(client, input, options \\ []) do request(client, "CreateUserPoolClient", input, options) end @doc """ Creates a new domain for a user pool. """ def create_user_pool_domain(client, input, options \\ []) do request(client, "CreateUserPoolDomain", input, options) end @doc """ Deletes a group. Currently only groups with no members can be deleted. Calling this action requires developer credentials. """ def delete_group(client, input, options \\ []) do request(client, "DeleteGroup", input, options) end @doc """ Deletes an identity provider for a user pool. """ def delete_identity_provider(client, input, options \\ []) do request(client, "DeleteIdentityProvider", input, options) end @doc """ Deletes a resource server. """ def delete_resource_server(client, input, options \\ []) do request(client, "DeleteResourceServer", input, options) end @doc """ Allows a user to delete himself or herself. """ def delete_user(client, input, options \\ []) do request(client, "DeleteUser", input, options) end @doc """ Deletes the attributes for a user. """ def delete_user_attributes(client, input, options \\ []) do request(client, "DeleteUserAttributes", input, options) end @doc """ Deletes the specified Amazon Cognito user pool. """ def delete_user_pool(client, input, options \\ []) do request(client, "DeleteUserPool", input, options) end @doc """ Allows the developer to delete the user pool client. """ def delete_user_pool_client(client, input, options \\ []) do request(client, "DeleteUserPoolClient", input, options) end @doc """ Deletes a domain for a user pool. """ def delete_user_pool_domain(client, input, options \\ []) do request(client, "DeleteUserPoolDomain", input, options) end @doc """ Gets information about a specific identity provider. """ def describe_identity_provider(client, input, options \\ []) do request(client, "DescribeIdentityProvider", input, options) end @doc """ Describes a resource server. """ def describe_resource_server(client, input, options \\ []) do request(client, "DescribeResourceServer", input, options) end @doc """ Describes the risk configuration. """ def describe_risk_configuration(client, input, options \\ []) do request(client, "DescribeRiskConfiguration", input, options) end @doc """ Describes the user import job. """ def describe_user_import_job(client, input, options \\ []) do request(client, "DescribeUserImportJob", input, options) end @doc """ Returns the configuration information and metadata of the specified user pool. """ def describe_user_pool(client, input, options \\ []) do request(client, "DescribeUserPool", input, options) end @doc """ Client method for returning the configuration information and metadata of the specified user pool app client. """ def describe_user_pool_client(client, input, options \\ []) do request(client, "DescribeUserPoolClient", input, options) end @doc """ Gets information about a domain. """ def describe_user_pool_domain(client, input, options \\ []) do request(client, "DescribeUserPoolDomain", input, options) end @doc """ Forgets the specified device. """ def forget_device(client, input, options \\ []) do request(client, "ForgetDevice", input, options) end @doc """ Calling this API causes a message to be sent to the end user with a confirmation code that is required to change the user's password. For the `Username` parameter, you can use the username or user alias. The method used to send the confirmation code is sent according to the specified AccountRecoverySetting. For more information, see [Recovering User Accounts](https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-recover-a-user-account.html) in the *Amazon Cognito Developer Guide*. If neither a verified phone number nor a verified email exists, an `InvalidParameterException` is thrown. To use the confirmation code for resetting the password, call [ConfirmForgotPassword](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ConfirmForgotPassword.html). """ def forgot_password(client, input, options \\ []) do request(client, "ForgotPassword", input, options) end @doc """ Gets the header information for the .csv file to be used as input for the user import job. """ def get_csv_header(client, input, options \\ []) do request(client, "GetCSVHeader", input, options) end @doc """ Gets the device. """ def get_device(client, input, options \\ []) do request(client, "GetDevice", input, options) end @doc """ Gets a group. Calling this action requires developer credentials. """ def get_group(client, input, options \\ []) do request(client, "GetGroup", input, options) end @doc """ Gets the specified identity provider. """ def get_identity_provider_by_identifier(client, input, options \\ []) do request(client, "GetIdentityProviderByIdentifier", input, options) end @doc """ This method takes a user pool ID, and returns the signing certificate. """ def get_signing_certificate(client, input, options \\ []) do request(client, "GetSigningCertificate", input, options) end @doc """ Gets the UI Customization information for a particular app client's app UI, if there is something set. If nothing is set for the particular client, but there is an existing pool level customization (app `clientId` will be `ALL`), then that is returned. If nothing is present, then an empty shape is returned. """ def get_u_i_customization(client, input, options \\ []) do request(client, "GetUICustomization", input, options) end @doc """ Gets the user attributes and metadata for a user. """ def get_user(client, input, options \\ []) do request(client, "GetUser", input, options) end @doc """ Gets the user attribute verification code for the specified attribute name. """ def get_user_attribute_verification_code(client, input, options \\ []) do request(client, "GetUserAttributeVerificationCode", input, options) end @doc """ Gets the user pool multi-factor authentication (MFA) configuration. """ def get_user_pool_mfa_config(client, input, options \\ []) do request(client, "GetUserPoolMfaConfig", input, options) end @doc """ Signs out users from all devices. It also invalidates all refresh tokens issued to a user. The user's current access and Id tokens remain valid until their expiry. Access and Id tokens expire one hour after they are issued. """ def global_sign_out(client, input, options \\ []) do request(client, "GlobalSignOut", input, options) end @doc """ Initiates the authentication flow. """ def initiate_auth(client, input, options \\ []) do request(client, "InitiateAuth", input, options) end @doc """ Lists the devices. """ def list_devices(client, input, options \\ []) do request(client, "ListDevices", input, options) end @doc """ Lists the groups associated with a user pool. Calling this action requires developer credentials. """ def list_groups(client, input, options \\ []) do request(client, "ListGroups", input, options) end @doc """ Lists information about all identity providers for a user pool. """ def list_identity_providers(client, input, options \\ []) do request(client, "ListIdentityProviders", input, options) end @doc """ Lists the resource servers for a user pool. """ def list_resource_servers(client, input, options \\ []) do request(client, "ListResourceServers", input, options) end @doc """ Lists the tags that are assigned to an Amazon Cognito user pool. A tag is a label that you can apply to user pools to categorize and manage them in different ways, such as by purpose, owner, environment, or other criteria. You can use this action up to 10 times per second, per account. """ def list_tags_for_resource(client, input, options \\ []) do request(client, "ListTagsForResource", input, options) end @doc """ Lists the user import jobs. """ def list_user_import_jobs(client, input, options \\ []) do request(client, "ListUserImportJobs", input, options) end @doc """ Lists the clients that have been created for the specified user pool. """ def list_user_pool_clients(client, input, options \\ []) do request(client, "ListUserPoolClients", input, options) end @doc """ Lists the user pools associated with an AWS account. """ def list_user_pools(client, input, options \\ []) do request(client, "ListUserPools", input, options) end @doc """ Lists the users in the Amazon Cognito user pool. """ def list_users(client, input, options \\ []) do request(client, "ListUsers", input, options) end @doc """ Lists the users in the specified group. Calling this action requires developer credentials. """ def list_users_in_group(client, input, options \\ []) do request(client, "ListUsersInGroup", input, options) end @doc """ Resends the confirmation (for confirmation of registration) to a specific user in the user pool. """ def resend_confirmation_code(client, input, options \\ []) do request(client, "ResendConfirmationCode", input, options) end @doc """ Responds to the authentication challenge. """ def respond_to_auth_challenge(client, input, options \\ []) do request(client, "RespondToAuthChallenge", input, options) end @doc """ Configures actions on detected risks. To delete the risk configuration for `UserPoolId` or `ClientId`, pass null values for all four configuration types. To enable Amazon Cognito advanced security features, update the user pool to include the `UserPoolAddOns` key`AdvancedSecurityMode`. """ def set_risk_configuration(client, input, options \\ []) do request(client, "SetRiskConfiguration", input, options) end @doc """ Sets the UI customization information for a user pool's built-in app UI. You can specify app UI customization settings for a single client (with a specific `clientId`) or for all clients (by setting the `clientId` to `ALL`). If you specify `ALL`, the default configuration will be used for every client that has no UI customization set previously. If you specify UI customization settings for a particular client, it will no longer fall back to the `ALL` configuration. <note> To use this API, your user pool must have a domain associated with it. Otherwise, there is no place to host the app's pages, and the service will throw an error. </note> """ def set_u_i_customization(client, input, options \\ []) do request(client, "SetUICustomization", input, options) end @doc """ Set the user's multi-factor authentication (MFA) method preference, including which MFA factors are enabled and if any are preferred. Only one factor can be set as preferred. The preferred MFA factor will be used to authenticate a user if multiple factors are enabled. If multiple options are enabled and no preference is set, a challenge to choose an MFA option will be returned during sign in. """ def set_user_m_f_a_preference(client, input, options \\ []) do request(client, "SetUserMFAPreference", input, options) end @doc """ Set the user pool multi-factor authentication (MFA) configuration. """ def set_user_pool_mfa_config(client, input, options \\ []) do request(client, "SetUserPoolMfaConfig", input, options) end @doc """ *This action is no longer supported.* You can use it to configure only SMS MFA. You can't use it to configure TOTP software token MFA. To configure either type of MFA, use [SetUserMFAPreference](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_SetUserMFAPreference.html) instead. """ def set_user_settings(client, input, options \\ []) do request(client, "SetUserSettings", input, options) end @doc """ Registers the user in the specified user pool and creates a user name, password, and user attributes. """ def sign_up(client, input, options \\ []) do request(client, "SignUp", input, options) end @doc """ Starts the user import. """ def start_user_import_job(client, input, options \\ []) do request(client, "StartUserImportJob", input, options) end @doc """ Stops the user import job. """ def stop_user_import_job(client, input, options \\ []) do request(client, "StopUserImportJob", input, options) end @doc """ Assigns a set of tags to an Amazon Cognito user pool. A tag is a label that you can use to categorize and manage user pools in different ways, such as by purpose, owner, environment, or other criteria. Each tag consists of a key and value, both of which you define. A key is a general category for more specific values. For example, if you have two versions of a user pool, one for testing and another for production, you might assign an `Environment` tag key to both user pools. The value of this key might be `Test` for one user pool and `Production` for the other. Tags are useful for cost tracking and access control. You can activate your tags so that they appear on the Billing and Cost Management console, where you can track the costs associated with your user pools. In an IAM policy, you can constrain permissions for user pools based on specific tags or tag values. You can use this action up to 5 times per second, per account. A user pool can have as many as 50 tags. """ def tag_resource(client, input, options \\ []) do request(client, "TagResource", input, options) end @doc """ Removes the specified tags from an Amazon Cognito user pool. You can use this action up to 5 times per second, per account """ def untag_resource(client, input, options \\ []) do request(client, "UntagResource", input, options) end @doc """ Provides the feedback for an authentication event whether it was from a valid user or not. This feedback is used for improving the risk evaluation decision for the user pool as part of Amazon Cognito advanced security. """ def update_auth_event_feedback(client, input, options \\ []) do request(client, "UpdateAuthEventFeedback", input, options) end @doc """ Updates the device status. """ def update_device_status(client, input, options \\ []) do request(client, "UpdateDeviceStatus", input, options) end @doc """ Updates the specified group with the specified attributes. Calling this action requires developer credentials. <important> If you don't provide a value for an attribute, it will be set to the default value. </important> """ def update_group(client, input, options \\ []) do request(client, "UpdateGroup", input, options) end @doc """ Updates identity provider information for a user pool. """ def update_identity_provider(client, input, options \\ []) do request(client, "UpdateIdentityProvider", input, options) end @doc """ Updates the name and scopes of resource server. All other fields are read-only. <important> If you don't provide a value for an attribute, it will be set to the default value. </important> """ def update_resource_server(client, input, options \\ []) do request(client, "UpdateResourceServer", input, options) end @doc """ Allows a user to update a specific attribute (one at a time). """ def update_user_attributes(client, input, options \\ []) do request(client, "UpdateUserAttributes", input, options) end @doc """ Updates the specified user pool with the specified attributes. You can get a list of the current user pool settings using [DescribeUserPool](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeUserPool.html). <important> If you don't provide a value for an attribute, it will be set to the default value. </important> """ def update_user_pool(client, input, options \\ []) do request(client, "UpdateUserPool", input, options) end @doc """ Updates the specified user pool app client with the specified attributes. You can get a list of the current user pool app client settings using [DescribeUserPoolClient](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeUserPoolClient.html). <important> If you don't provide a value for an attribute, it will be set to the default value. </important> """ def update_user_pool_client(client, input, options \\ []) do request(client, "UpdateUserPoolClient", input, options) end @doc """ Updates the Secure Sockets Layer (SSL) certificate for the custom domain for your user pool. You can use this operation to provide the Amazon Resource Name (ARN) of a new certificate to Amazon Cognito. You cannot use it to change the domain for a user pool. A custom domain is used to host the Amazon Cognito hosted UI, which provides sign-up and sign-in pages for your application. When you set up a custom domain, you provide a certificate that you manage with AWS Certificate Manager (ACM). When necessary, you can use this operation to change the certificate that you applied to your custom domain. Usually, this is unnecessary following routine certificate renewal with ACM. When you renew your existing certificate in ACM, the ARN for your certificate remains the same, and your custom domain uses the new certificate automatically. However, if you replace your existing certificate with a new one, ACM gives the new certificate a new ARN. To apply the new certificate to your custom domain, you must provide this ARN to Amazon Cognito. When you add your new certificate in ACM, you must choose US East (N. Virginia) as the AWS Region. After you submit your request, Amazon Cognito requires up to 1 hour to distribute your new certificate to your custom domain. For more information about adding a custom domain to your user pool, see [Using Your Own Domain for the Hosted UI](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-add-custom-domain.html). """ def update_user_pool_domain(client, input, options \\ []) do request(client, "UpdateUserPoolDomain", input, options) end @doc """ Use this API to register a user's entered TOTP code and mark the user's software token MFA status as "verified" if successful. The request takes an access token or a session string, but not both. """ def verify_software_token(client, input, options \\ []) do request(client, "VerifySoftwareToken", input, options) end @doc """ Verifies the specified user attributes in the user pool. """ def verify_user_attribute(client, input, options \\ []) do request(client, "VerifyUserAttribute", input, options) end @spec request(AWS.Client.t(), binary(), map(), list()) :: {:ok, map() | nil, map()} | {:error, term()} defp request(client, action, input, options) do client = %{client | service: "cognito-idp"} host = build_host("cognito-idp", client) url = build_url(host, client) headers = [ {"Host", host}, {"Content-Type", "application/x-amz-json-1.1"}, {"X-Amz-Target", "AWSCognitoIdentityProviderService.#{action}"} ] payload = encode!(client, input) headers = AWS.Request.sign_v4(client, "POST", url, headers, payload) post(client, url, payload, headers, options) end defp post(client, url, payload, headers, options) do case AWS.Client.request(client, :post, url, payload, headers, options) do {:ok, %{status_code: 200, body: body} = response} -> body = if body != "", do: decode!(client, body) {:ok, body, response} {:ok, response} -> {:error, {:unexpected_response, response}} error = {:error, _reason} -> error end end defp build_host(_endpoint_prefix, %{region: "local", endpoint: endpoint}) do endpoint end defp build_host(_endpoint_prefix, %{region: "local"}) do "localhost" end defp build_host(endpoint_prefix, %{region: region, endpoint: endpoint}) do "#{endpoint_prefix}.#{region}.#{endpoint}" end defp build_url(host, %{:proto => proto, :port => port}) do "#{proto}://#{host}:#{port}/" end defp encode!(client, payload) do AWS.Client.encode!(client, payload, :json) end defp decode!(client, payload) do AWS.Client.decode!(client, payload, :json) end end
33.902622
141
0.720283
9e7c17dcb9dbc71a1f2b84fd0990d3f61146b040
338
exs
Elixir
test/integration/pages_test.exs
knewter/markdown_server
0b852d23247589ad23557bf1a205e9d1b9af7dda
[ "Unlicense" ]
null
null
null
test/integration/pages_test.exs
knewter/markdown_server
0b852d23247589ad23557bf1a205e9d1b9af7dda
[ "Unlicense" ]
1
2015-12-13T19:55:09.000Z
2015-12-13T19:55:09.000Z
test/integration/pages_test.exs
knewter/markdown_server
0b852d23247589ad23557bf1a205e9d1b9af7dda
[ "Unlicense" ]
null
null
null
defmodule Integration.PagesTest do use IntegrationTest.Case test "renders an index of available files" do body = get("/pages") assert Regex.match?(%r/Index of markdown files/, body) assert Regex.match?(%r/basic/, body) assert Regex.match?(%r/middling/, body) refute Regex.match?(%r/notmd.blergh/, body) end end
28.166667
58
0.695266
9e7c1aee3d5936ef068e355ded31375ab15e341b
324
exs
Elixir
phoenix158/my-phoenix-json-api/priv/repo/20210301071821_create_gifts.exs
salbador/oldphp7_vs_laravel7_vs_phoenix1.5.8_vs_phalcon4
294b8668dc4940c07d6dde198f02b38100a1dc00
[ "MIT" ]
null
null
null
phoenix158/my-phoenix-json-api/priv/repo/20210301071821_create_gifts.exs
salbador/oldphp7_vs_laravel7_vs_phoenix1.5.8_vs_phalcon4
294b8668dc4940c07d6dde198f02b38100a1dc00
[ "MIT" ]
null
null
null
phoenix158/my-phoenix-json-api/priv/repo/20210301071821_create_gifts.exs
salbador/oldphp7_vs_laravel7_vs_phoenix1.5.8_vs_phalcon4
294b8668dc4940c07d6dde198f02b38100a1dc00
[ "MIT" ]
null
null
null
defmodule MyApp.Repo.Migrations.CreateGifts do use Ecto.Migration def change do create table(:gifts, primary_key: false) do add :id, :binary_id, primary_key: true add :name, :string add :categories, {:array, :string} timestamps() end create unique_index(:gifts, [:name]) end end
20.25
47
0.660494
9e7c44427b576a2429204d9d98e4570d6cca0ab2
2,767
ex
Elixir
clients/cloud_search/lib/google_api/cloud_search/v1/model/restrict_item.ex
yoshi-code-bot/elixir-google-api
cdb6032f01fac5ab704803113c39f2207e9e019d
[ "Apache-2.0" ]
null
null
null
clients/cloud_search/lib/google_api/cloud_search/v1/model/restrict_item.ex
yoshi-code-bot/elixir-google-api
cdb6032f01fac5ab704803113c39f2207e9e019d
[ "Apache-2.0" ]
null
null
null
clients/cloud_search/lib/google_api/cloud_search/v1/model/restrict_item.ex
yoshi-code-bot/elixir-google-api
cdb6032f01fac5ab704803113c39f2207e9e019d
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # 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 License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.CloudSearch.V1.Model.RestrictItem do @moduledoc """ Information relevant only to a restrict entry. NextId: 12 ## Attributes * `driveFollowUpRestrict` (*type:* `GoogleApi.CloudSearch.V1.Model.DriveFollowUpRestrict.t`, *default:* `nil`) - * `driveLocationRestrict` (*type:* `GoogleApi.CloudSearch.V1.Model.DriveLocationRestrict.t`, *default:* `nil`) - * `driveMimeTypeRestrict` (*type:* `GoogleApi.CloudSearch.V1.Model.DriveMimeTypeRestrict.t`, *default:* `nil`) - Drive Types. * `driveTimeSpanRestrict` (*type:* `GoogleApi.CloudSearch.V1.Model.DriveTimeSpanRestrict.t`, *default:* `nil`) - * `searchOperator` (*type:* `String.t`, *default:* `nil`) - The search restrict (e.g. "after:2017-09-11 before:2017-09-12"). """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :driveFollowUpRestrict => GoogleApi.CloudSearch.V1.Model.DriveFollowUpRestrict.t() | nil, :driveLocationRestrict => GoogleApi.CloudSearch.V1.Model.DriveLocationRestrict.t() | nil, :driveMimeTypeRestrict => GoogleApi.CloudSearch.V1.Model.DriveMimeTypeRestrict.t() | nil, :driveTimeSpanRestrict => GoogleApi.CloudSearch.V1.Model.DriveTimeSpanRestrict.t() | nil, :searchOperator => String.t() | nil } field(:driveFollowUpRestrict, as: GoogleApi.CloudSearch.V1.Model.DriveFollowUpRestrict) field(:driveLocationRestrict, as: GoogleApi.CloudSearch.V1.Model.DriveLocationRestrict) field(:driveMimeTypeRestrict, as: GoogleApi.CloudSearch.V1.Model.DriveMimeTypeRestrict) field(:driveTimeSpanRestrict, as: GoogleApi.CloudSearch.V1.Model.DriveTimeSpanRestrict) field(:searchOperator) end defimpl Poison.Decoder, for: GoogleApi.CloudSearch.V1.Model.RestrictItem do def decode(value, options) do GoogleApi.CloudSearch.V1.Model.RestrictItem.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.CloudSearch.V1.Model.RestrictItem do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
43.920635
129
0.732562
9e7ca5c76497ca8a27a58e302d4f39bc6e1f8512
217
exs
Elixir
rna-transcription/dna.exs
wobh/xelixir
63e5beec40d5c441cf6cf87f30c29848f481bb1b
[ "MIT" ]
null
null
null
rna-transcription/dna.exs
wobh/xelixir
63e5beec40d5c441cf6cf87f30c29848f481bb1b
[ "MIT" ]
null
null
null
rna-transcription/dna.exs
wobh/xelixir
63e5beec40d5c441cf6cf87f30c29848f481bb1b
[ "MIT" ]
null
null
null
defmodule DNA do @doc """ Transcribes a character list representing DNA nucleotides to RNA ## Examples iex> DNA.to_rna('ACTG') 'UGAC' """ @spec to_rna([char]) :: [char] def to_rna(dna) do end end
14.466667
66
0.640553
9e7cd002a18b0889489f3573afbe510bf222d8cd
2,655
exs
Elixir
lib/elixir/test/elixir/integer_test.exs
jquadrin/elixir
98746e08eaa2bf58c202e8500b6cf83ed2368cc0
[ "Apache-2.0" ]
null
null
null
lib/elixir/test/elixir/integer_test.exs
jquadrin/elixir
98746e08eaa2bf58c202e8500b6cf83ed2368cc0
[ "Apache-2.0" ]
null
null
null
lib/elixir/test/elixir/integer_test.exs
jquadrin/elixir
98746e08eaa2bf58c202e8500b6cf83ed2368cc0
[ "Apache-2.0" ]
null
null
null
Code.require_file "test_helper.exs", __DIR__ defmodule IntegerTest do use ExUnit.Case, async: true require Integer test :odd? do assert Integer.is_odd(0) == false assert Integer.is_odd(1) == true assert Integer.is_odd(2) == false assert Integer.is_odd(3) == true assert Integer.is_odd(-1) == true assert Integer.is_odd(-2) == false assert Integer.is_odd(-3) == true end test :even? do assert Integer.is_even(0) == true assert Integer.is_even(1) == false assert Integer.is_even(2) == true assert Integer.is_even(3) == false assert Integer.is_even(-1) == false assert Integer.is_even(-2) == true assert Integer.is_even(-3) == false end test :digits do assert Integer.digits(101) == [1,0,1] assert Integer.digits(1) == [1] assert Integer.digits(0) == [0] assert Integer.digits(0,2) == [0] assert Integer.digits(58127,2) == [1,1,1,0,0,0,1,1,0,0,0,0,1,1,1,1] end test :undigits do assert Integer.undigits([1, 0, 1]) == 101 assert Integer.undigits([1]) == 1 assert Integer.undigits([0]) == 0 assert Integer.undigits([]) == 0 assert Integer.undigits([1,4], 16) == 0x14 assert Integer.undigits([1,4], 8) == 0o14 assert Integer.undigits([1,1], 2) == 0b11 assert Integer.undigits([1, 2, 3, 4, 5]) == 12345 assert Integer.undigits([1, 0, -5]) == 95 assert Integer.undigits([-1, -1, -5]) == -115 end test :parse do assert Integer.parse("12") === {12, ""} assert Integer.parse("-12") === {-12, ""} assert Integer.parse("123456789") === {123456789, ""} assert Integer.parse("12.5") === {12, ".5"} assert Integer.parse("7.5e-3") === {7, ".5e-3"} assert Integer.parse("12x") === {12, "x"} assert Integer.parse("++1") === :error assert Integer.parse("--1") === :error assert Integer.parse("+-1") === :error assert Integer.parse("three") === :error assert Integer.parse("12", 10) === {12, ""} assert Integer.parse("-12", 12) === {-14, ""} assert Integer.parse("12345678", 9) === {6053444, ""} assert Integer.parse("3.14", 4) === {3, ".14"} assert Integer.parse("64eb", 16) === {25835, ""} assert Integer.parse("64eb", 10) === {64, "eb"} assert Integer.parse("10", 2) === {2, ""} assert Integer.parse("++4", 10) === :error # Base should be in range 2..36 assert_raise ArgumentError, "invalid base 0", fn -> Integer.parse("2", 0) end assert_raise ArgumentError, "invalid base 41", fn -> Integer.parse("2", 41) end # Base should be an integer assert_raise ArgumentError, "invalid base 10.2", fn -> Integer.parse("2", 10.2) end end end
34.480519
87
0.60113
9e7cd3510acfc01e6e1c9e80a97d9dae00b847ce
608
exs
Elixir
mix.exs
Snake-Sanders/pcanlog-parser
e933601b2847d43378c958da3f46bdec98b5239c
[ "MIT" ]
1
2022-03-18T21:57:43.000Z
2022-03-18T21:57:43.000Z
mix.exs
Snake-Sanders/pcanlog-parser
e933601b2847d43378c958da3f46bdec98b5239c
[ "MIT" ]
null
null
null
mix.exs
Snake-Sanders/pcanlog-parser
e933601b2847d43378c958da3f46bdec98b5239c
[ "MIT" ]
null
null
null
defmodule PcanlogParser.MixProject do use Mix.Project def project do [ app: :pcanlog_parser, version: "0.1.0", elixir: "~> 1.12", start_permanent: Mix.env() == :prod, deps: deps() ] end # Run "mix help compile.app" to learn about applications. def application do [ extra_applications: [:logger] ] end # Run "mix help deps" to learn about dependencies. defp deps do [ {:csv, "~> 2.4"} # {:dep_from_hexpm, "~> 0.3.0"}, # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} ] end end
20.266667
87
0.572368
9e7d000880963e89f1cbd233ee972e590bfcadc1
1,685
ex
Elixir
lib/party_hub_web/telemetry.ex
AminArria/party_hub
aef6d17500856789c115e1c68fc95b853b220e1f
[ "MIT" ]
2
2020-05-22T15:45:53.000Z
2020-06-07T21:07:03.000Z
lib/party_hub_web/telemetry.ex
AminArria/party_hub
aef6d17500856789c115e1c68fc95b853b220e1f
[ "MIT" ]
1
2021-03-10T16:36:46.000Z
2021-03-10T16:36:46.000Z
lib/party_hub_web/telemetry.ex
AminArria/party_hub
aef6d17500856789c115e1c68fc95b853b220e1f
[ "MIT" ]
null
null
null
defmodule PartyHubWeb.Telemetry do use Supervisor import Telemetry.Metrics def start_link(arg) do Supervisor.start_link(__MODULE__, arg, name: __MODULE__) end @impl true def init(_arg) do children = [ {:telemetry_poller, measurements: periodic_measurements(), period: 10_000} # Add reporters as children of your supervision tree. # {Telemetry.Metrics.ConsoleReporter, metrics: metrics()} ] Supervisor.init(children, strategy: :one_for_one) end def metrics do [ # Phoenix Metrics summary("phoenix.endpoint.stop.duration", unit: {:native, :millisecond} ), summary("phoenix.router_dispatch.stop.duration", tags: [:route], unit: {:native, :millisecond} ), # Database Metrics summary("party_hub.repo.query.total_time", unit: {:native, :millisecond}), summary("party_hub.repo.query.decode_time", unit: {:native, :millisecond}), summary("party_hub.repo.query.query_time", unit: {:native, :millisecond}), summary("party_hub.repo.query.queue_time", unit: {:native, :millisecond}), summary("party_hub.repo.query.idle_time", unit: {:native, :millisecond}), # VM Metrics summary("vm.memory.total", unit: {:byte, :kilobyte}), summary("vm.total_run_queue_lengths.total"), summary("vm.total_run_queue_lengths.cpu"), summary("vm.total_run_queue_lengths.io") ] end defp periodic_measurements do [ # A module, function and arguments to be invoked periodically. # This function must call :telemetry.execute/3 and a metric must be added above. # {PartyHubWeb, :count_users, []} ] end end
31.203704
86
0.667656
9e7d06f9b7d5844cda7673417f81f4e24effad14
122
ex
Elixir
elixir/elixir-sips/samples/everyoneapi_cli/lib/everyoneapi_cli.ex
afronski/playground-erlang
6ac4b58b2fd717260c22a33284547d44a9b5038e
[ "MIT" ]
2
2015-12-09T02:16:51.000Z
2021-07-26T22:53:43.000Z
elixir/elixir-sips/samples/everyoneapi_cli/lib/everyoneapi_cli.ex
afronski/playground-erlang
6ac4b58b2fd717260c22a33284547d44a9b5038e
[ "MIT" ]
null
null
null
elixir/elixir-sips/samples/everyoneapi_cli/lib/everyoneapi_cli.ex
afronski/playground-erlang
6ac4b58b2fd717260c22a33284547d44a9b5038e
[ "MIT" ]
1
2016-05-08T18:40:31.000Z
2016-05-08T18:40:31.000Z
defmodule EveryoneapiCli do def main(number) do Everyoneapi.start IO.inspect Everyoneapi.info! number end end
17.428571
39
0.754098
9e7d2b46558ef1f38eae7841c13e8299892ad99a
233
ex
Elixir
ChatRoomServer/chat_server/lib/proto/message_respond.pb.ex
GameEssa/ChatRoom
13cc75e3fecfdd692246df2eab84eba73b6761e3
[ "MIT" ]
null
null
null
ChatRoomServer/chat_server/lib/proto/message_respond.pb.ex
GameEssa/ChatRoom
13cc75e3fecfdd692246df2eab84eba73b6761e3
[ "MIT" ]
null
null
null
ChatRoomServer/chat_server/lib/proto/message_respond.pb.ex
GameEssa/ChatRoom
13cc75e3fecfdd692246df2eab84eba73b6761e3
[ "MIT" ]
null
null
null
defmodule Data.Message.MessageRespond do @moduledoc false use Protobuf, syntax: :proto3 @type t :: %__MODULE__{ respondState: boolean } defstruct [:respondState] field :respondState, 1, type: :bool end
17.923077
40
0.67382
9e7d428bd6e32805daa14872821019f6980d092e
805
exs
Elixir
mix.exs
QuinnWilton/tiferet
d2ed7002e7e31c1ba0c7f22de8cc615416a0acb6
[ "MIT" ]
51
2020-03-08T21:52:59.000Z
2022-01-18T21:49:50.000Z
mix.exs
QuinnWilton/daat
d2ed7002e7e31c1ba0c7f22de8cc615416a0acb6
[ "MIT" ]
2
2020-03-09T23:22:38.000Z
2020-03-12T17:50:58.000Z
mix.exs
QuinnWilton/daat
d2ed7002e7e31c1ba0c7f22de8cc615416a0acb6
[ "MIT" ]
1
2020-03-09T09:32:20.000Z
2020-03-09T09:32:20.000Z
defmodule Daat.MixProject do use Mix.Project def project do [ app: :daat, version: "0.2.0", elixir: "~> 1.10", start_permanent: Mix.env() == :prod, deps: deps(), # Docs name: "Daat", docs: docs(), # Hex description: "Parameterized modules for Elixir", package: package() ] end defp deps do [ {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, {:stream_data, "~> 0.1", only: :test} ] end defp docs do [ extras: ["README.md"], main: "readme", source_url: "https://github.com/quinnwilton/daat" ] end defp package do [ licenses: ["MIT"], links: %{"GitHub" => "https://github.com/quinnwilton/daat"}, maintainers: ["Quinn Wilton"] ] end end
17.888889
66
0.520497
9e7d46d098badf6fdcc5e2bedd275eec6051fe52
118
ex
Elixir
lib/from_the_ashes/repo.ex
hazen/from_the_ashes
05b4468b6ce5ff0225ff2fed5e27d6055bf3d852
[ "MIT" ]
null
null
null
lib/from_the_ashes/repo.ex
hazen/from_the_ashes
05b4468b6ce5ff0225ff2fed5e27d6055bf3d852
[ "MIT" ]
1
2021-03-09T22:08:11.000Z
2021-03-09T22:08:11.000Z
lib/from_the_ashes/repo.ex
hazen/from_the_ashes
05b4468b6ce5ff0225ff2fed5e27d6055bf3d852
[ "MIT" ]
null
null
null
defmodule FromTheAshes.Repo do use Ecto.Repo, otp_app: :from_the_ashes, adapter: Ecto.Adapters.Postgres end
19.666667
35
0.754237
9e7d5e46adf910e94a4cf63dad4952063e40e7c5
2,101
ex
Elixir
lib/student_list_web/controllers/adult_controller.ex
jwarwick/student_list
d35a2fcef2025d3de9b7915682965c48481c1d15
[ "MIT" ]
1
2021-06-27T20:02:11.000Z
2021-06-27T20:02:11.000Z
lib/student_list_web/controllers/adult_controller.ex
jwarwick/student_list
d35a2fcef2025d3de9b7915682965c48481c1d15
[ "MIT" ]
null
null
null
lib/student_list_web/controllers/adult_controller.ex
jwarwick/student_list
d35a2fcef2025d3de9b7915682965c48481c1d15
[ "MIT" ]
null
null
null
defmodule StudentListWeb.AdultController do use StudentListWeb, :controller alias StudentList.Directory alias StudentList.Directory.Adult plug(:put_root_layout, {StudentListWeb.LayoutView, "torch.html"}) plug(:put_layout, false) def index(conn, params) do case Directory.paginate_adults(params) do {:ok, assigns} -> render(conn, "index.html", assigns) error -> conn |> put_flash(:error, "There was an error rendering Adults. #{inspect(error)}") |> redirect(to: Routes.adult_path(conn, :index)) end end def new(conn, _params) do changeset = Directory.change_adult(%Adult{}) render(conn, "new.html", changeset: changeset) end def create(conn, %{"adult" => adult_params}) do case Directory.create_adult(adult_params) do {:ok, adult} -> conn |> put_flash(:info, "Adult created successfully.") |> redirect(to: Routes.adult_path(conn, :show, adult)) {:error, %Ecto.Changeset{} = changeset} -> render(conn, "new.html", changeset: changeset) end end def show(conn, %{"id" => id}) do adult = Directory.get_adult!(id) render(conn, "show.html", adult: adult) end def edit(conn, %{"id" => id}) do adult = Directory.get_adult!(id) changeset = Directory.change_adult(adult) render(conn, "edit.html", adult: adult, changeset: changeset) end def update(conn, %{"id" => id, "adult" => adult_params}) do adult = Directory.get_adult!(id) case Directory.update_adult(adult, adult_params) do {:ok, adult} -> conn |> put_flash(:info, "Adult updated successfully.") |> redirect(to: Routes.adult_path(conn, :show, adult)) {:error, %Ecto.Changeset{} = changeset} -> render(conn, "edit.html", adult: adult, changeset: changeset) end end def delete(conn, %{"id" => id}) do adult = Directory.get_adult!(id) {:ok, _adult} = Directory.delete_adult(adult) conn |> put_flash(:info, "Adult deleted successfully.") |> redirect(to: Routes.adult_path(conn, :index)) end end
29.180556
86
0.63684
9e7d92dc78cc57c071277832c882ab78de01b62c
2,034
ex
Elixir
extra/notes.ex
TylerWasniowski/WritersUnblocked
edd74b2597289163374212cf09ca60a519b0a898
[ "MIT" ]
2
2018-04-15T00:28:41.000Z
2018-04-15T04:58:42.000Z
extra/notes.ex
TylerWasniowski/WritersUnblocked
edd74b2597289163374212cf09ca60a519b0a898
[ "MIT" ]
23
2018-04-19T02:34:29.000Z
2018-05-08T03:19:55.000Z
extra/notes.ex
TylerWasniowski/WritersUnblocked
edd74b2597289163374212cf09ca60a519b0a898
[ "MIT" ]
1
2018-04-16T05:41:14.000Z
2018-04-16T05:41:14.000Z
#[ ] is like list #can "overload" on a specific runtime value of a type, eg: a list with a head vs an empty list # or fib(0), fib (1), fib(n), where n>1 #?a is the (integer?) literal ascii of a #'abc' is a charlist [97,98,99] #"abc" is a binary #pattern matching #[head|rest] = list #<<a, b>> = <<1,2>> will result in assigning 1 to a and 2 to b #<< >> is an array of bytes, can interperet/pattern match however you want (even at bit level?) # "binary constructor" # a binary unit is 8 bits # <> is bin concat, only works if both are binarys # #more pattern matching which case statement #no god damn real multiple line comments, but can do python style string abuse #fn a, b -> a + b end #same as: #&(&1+&2) #Don't know why I decided to write atoi, not really relevant an ddoesnt seem to fit elixir well. # If wanted to sum all ints in a textfile, probably # more elixir-y to do something like split |> parse |> fold, or however thats done. defmodule Notes do def atoi(<<head::unsigned-integer-8>>, accum) do d = head - 48 if d>=0 and d<10 do {<<head>>, accum*10 + d} else {<<head>>, accum} end end def atoi(<<head::unsigned-integer-8, rest::bytes>>, accum) do d = head - 48 if d>=0 and d<10 do atoi(rest, accum*10 + d) else {<<head>> <> rest, accum} end end def atoi_v2(a, accum) do case a do <<head::unsigned-integer-8, rest::bytes>> -> d = head - 48 if d<10 and d>=0 do atoi_v2(rest, accum*10 + d) else {a, accum} end _ -> {a, accum} end end def main() do IO.puts "Hello!" a = atoi(<<"123", 0>>, 0) b = atoi(<<"321", "xyz">>, 0) IO.puts(elem(a, 1) + elem(b, 1)) IO.puts(elem(b, 0)) IO.puts byte_size("abc") atoi_v2(<<"511", 0>>, 0) |> elem(1) |> Kernel.*(3) |> IO.puts end end Notes.main() #output: # Hello! # 444 # xyz # 3 # 1533 #not very helpuful error messages... #** (ArgumentError) argument error # Notes.ex:57: Notes.atoi_v2/2 # Notes.ex:70: Notes.main/0 # (elixir) lib/code.ex:363: Code.require_file/2
23.113636
96
0.619961
9e7d96f2363535fe77d768915a1ddde51aa9dc2e
1,859
ex
Elixir
clients/android_management/lib/google_api/android_management/v1/model/block_action.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
1
2018-12-03T23:43:10.000Z
2018-12-03T23:43:10.000Z
clients/android_management/lib/google_api/android_management/v1/model/block_action.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
clients/android_management/lib/google_api/android_management/v1/model/block_action.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # 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 License is distributed on an &quot;AS IS&quot; BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the elixir code generator program. # Do not edit the class manually. defmodule GoogleApi.AndroidManagement.V1.Model.BlockAction do @moduledoc """ An action to block access to apps and data on a fully managed device or in a work profile. This action also triggers a device or work profile to displays a user-facing notification with information (where possible) on how to correct the compliance issue. Note: wipeAction must also be specified. ## Attributes * `blockAfterDays` (*type:* `integer()`, *default:* `nil`) - Number of days the policy is non-compliant before the device or work profile is blocked. To block access immediately, set to 0. blockAfterDays must be less than wipeAfterDays. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :blockAfterDays => integer() } field(:blockAfterDays) end defimpl Poison.Decoder, for: GoogleApi.AndroidManagement.V1.Model.BlockAction do def decode(value, options) do GoogleApi.AndroidManagement.V1.Model.BlockAction.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.AndroidManagement.V1.Model.BlockAction do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
39.553191
297
0.757396
9e7da52f7fb0d80073177463dc63849b4417ab8a
73
ex
Elixir
lib/plantar_web/views/user_confirmation_view.ex
pantanal-labs/plantar
8b119874fbddf50fe23d435462fb3238bb1d6e42
[ "MIT" ]
null
null
null
lib/plantar_web/views/user_confirmation_view.ex
pantanal-labs/plantar
8b119874fbddf50fe23d435462fb3238bb1d6e42
[ "MIT" ]
23
2020-07-29T21:03:00.000Z
2021-02-01T18:20:35.000Z
lib/plantar_web/views/user_confirmation_view.ex
pantanal-labs/plantar
8b119874fbddf50fe23d435462fb3238bb1d6e42
[ "MIT" ]
null
null
null
defmodule PlantarWeb.UserConfirmationView do use PlantarWeb, :view end
18.25
44
0.835616
9e7dbbc6d6a88db586ebe498347ff28b6414d4f9
676
ex
Elixir
lib/twaddler_web/context.ex
woeye/twaddler
e06a22a94520055bc33aaaacfe51989ba8ab665f
[ "Apache-2.0" ]
1
2018-10-08T13:57:08.000Z
2018-10-08T13:57:08.000Z
lib/twaddler_web/context.ex
woeye/twaddler
e06a22a94520055bc33aaaacfe51989ba8ab665f
[ "Apache-2.0" ]
null
null
null
lib/twaddler_web/context.ex
woeye/twaddler
e06a22a94520055bc33aaaacfe51989ba8ab665f
[ "Apache-2.0" ]
1
2018-10-08T13:55:44.000Z
2018-10-08T13:55:44.000Z
defmodule TwaddlerWeb.Context do @behaviour Plug import Plug.Conn # import Ecto.Query # alias Twaddler.Repo # alias Twaddler.Db.User def init(opts), do: opts def call(conn, _) do context = build_context(conn) Absinthe.Plug.put_options(conn, context: context) end defp build_context(conn) do with ["Bearer " <> token] <- get_req_header(conn, "authorization"), {:ok, current_user} <- fetch_user(token) do %{current_user: current_user} else _ -> %{} end end defp fetch_user(token) do salt = TwaddlerWeb.Endpoint.config(:token_salt) Phoenix.Token.verify(TwaddlerWeb.Endpoint, salt, token) end end
21.125
71
0.670118
9e7dca879a5859dcc9357c2550ff2c0547ea36e8
2,156
ex
Elixir
clients/you_tube/lib/google_api/you_tube/v3/model/video_category.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
1
2018-12-03T23:43:10.000Z
2018-12-03T23:43:10.000Z
clients/you_tube/lib/google_api/you_tube/v3/model/video_category.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
clients/you_tube/lib/google_api/you_tube/v3/model/video_category.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # 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 License is distributed on an &quot;AS IS&quot; BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the elixir code generator program. # Do not edit the class manually. defmodule GoogleApi.YouTube.V3.Model.VideoCategory do @moduledoc """ A videoCategory resource identifies a category that has been or could be associated with uploaded videos. ## Attributes * `etag` (*type:* `String.t`, *default:* `nil`) - Etag of this resource. * `id` (*type:* `String.t`, *default:* `nil`) - The ID that YouTube uses to uniquely identify the video category. * `kind` (*type:* `String.t`, *default:* `youtube#videoCategory`) - Identifies what kind of resource this is. Value: the fixed string "youtube#videoCategory". * `snippet` (*type:* `GoogleApi.YouTube.V3.Model.VideoCategorySnippet.t`, *default:* `nil`) - The snippet object contains basic details about the video category, including its title. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :etag => String.t(), :id => String.t(), :kind => String.t(), :snippet => GoogleApi.YouTube.V3.Model.VideoCategorySnippet.t() } field(:etag) field(:id) field(:kind) field(:snippet, as: GoogleApi.YouTube.V3.Model.VideoCategorySnippet) end defimpl Poison.Decoder, for: GoogleApi.YouTube.V3.Model.VideoCategory do def decode(value, options) do GoogleApi.YouTube.V3.Model.VideoCategory.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.YouTube.V3.Model.VideoCategory do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
38.5
186
0.717069
9e7dd241f1a9d659edb5c94d38ce089245842f3b
1,958
ex
Elixir
clients/alert_center/lib/google_api/alert_center/v1beta1/model/primary_admin_changed_event.ex
yoshi-code-bot/elixir-google-api
cdb6032f01fac5ab704803113c39f2207e9e019d
[ "Apache-2.0" ]
null
null
null
clients/alert_center/lib/google_api/alert_center/v1beta1/model/primary_admin_changed_event.ex
yoshi-code-bot/elixir-google-api
cdb6032f01fac5ab704803113c39f2207e9e019d
[ "Apache-2.0" ]
null
null
null
clients/alert_center/lib/google_api/alert_center/v1beta1/model/primary_admin_changed_event.ex
yoshi-code-bot/elixir-google-api
cdb6032f01fac5ab704803113c39f2207e9e019d
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # 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 License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.AlertCenter.V1beta1.Model.PrimaryAdminChangedEvent do @moduledoc """ Event occurred when primary admin changed in customer's account. The event are being received from insight forwarder ## Attributes * `domain` (*type:* `String.t`, *default:* `nil`) - domain in which actioned occurred * `previousAdminEmail` (*type:* `String.t`, *default:* `nil`) - Email of person who was the primary admin before the action * `updatedAdminEmail` (*type:* `String.t`, *default:* `nil`) - Email of person who is the primary admin after the action """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :domain => String.t() | nil, :previousAdminEmail => String.t() | nil, :updatedAdminEmail => String.t() | nil } field(:domain) field(:previousAdminEmail) field(:updatedAdminEmail) end defimpl Poison.Decoder, for: GoogleApi.AlertCenter.V1beta1.Model.PrimaryAdminChangedEvent do def decode(value, options) do GoogleApi.AlertCenter.V1beta1.Model.PrimaryAdminChangedEvent.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.AlertCenter.V1beta1.Model.PrimaryAdminChangedEvent do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
36.943396
127
0.733401
9e7df03fac379db70bf1946725d63e57bb40064d
1,565
ex
Elixir
lib/crit_web/views/fomantic/elements.ex
brownt23/crit19
c45c7b3ae580c193168d83144da0eeb9bc91c8a9
[ "MIT" ]
6
2019-07-16T19:31:23.000Z
2021-06-05T19:01:05.000Z
lib/crit_web/views/fomantic/elements.ex
brownt23/crit19
c45c7b3ae580c193168d83144da0eeb9bc91c8a9
[ "MIT" ]
null
null
null
lib/crit_web/views/fomantic/elements.ex
brownt23/crit19
c45c7b3ae580c193168d83144da0eeb9bc91c8a9
[ "MIT" ]
3
2020-02-24T23:38:27.000Z
2020-08-01T23:50:17.000Z
defmodule CritWeb.Fomantic.Elements do use Phoenix.HTML # import CritWeb.Fomantic.Helpers # import CritWeb.Fomantic.Informative def centered_image(src) do classes = "ui center aligned container main" ~E""" <div class="<%=classes%>"> <img src=<%=src%>> </div> """ end def list_link(text, module, action) do ~E""" <div class="item"> <%= link text, to: apply(module, :path, [action]) %> </div> """ end def unordered(list) do ~E""" <ul> <%= for elt <- list do %> <li><%=elt%></li> <% end %> </ul> """ end def big_submit_button(label) do submit label, class: "ui fluid large teal submit button" end @doc """ This is a button that is *not* a Submit button (that is, it is not selected by Return/Enter, no matter where it is in the form). It operates by calling a Javascript action """ # The `type="button"` prevents it from becoming a `submit` button inside # a form. def negative_action_button(content, action) do ~E""" <button class="ui negative button" data-action="<%=action%>" type="button"> <%= content %> </button> """ end def dropdown(f, label, form_field, opts) do dropdown_id = Keyword.fetch!(opts, :dropdown_id) options = Keyword.fetch!(opts, :options) ~E""" <div class="field"> <%= label f, form_field, label %> <%= select f, form_field, options, id: dropdown_id, class: "ui fluid dropdown" %> </div> """ end end
23.014706
74
0.576997
9e7e151297bbc9ffc57a575fc32c4e959e31c20c
4,912
ex
Elixir
lib/ex_queb.ex
leonardzhou/ex_queb
a750abcf2df56efff768b577e8e6ced71c5c81a3
[ "MIT" ]
null
null
null
lib/ex_queb.ex
leonardzhou/ex_queb
a750abcf2df56efff768b577e8e6ced71c5c81a3
[ "MIT" ]
null
null
null
lib/ex_queb.ex
leonardzhou/ex_queb
a750abcf2df56efff768b577e8e6ced71c5c81a3
[ "MIT" ]
null
null
null
defmodule ExQueb do @moduledoc """ Build Ecto filter Queries. """ import Ecto.Query @doc """ Create the filter Uses the :q query parameter to build the filter. """ def filter(query, params) do q = params[Application.get_env(:ex_queb, :filter_param, :q)] if q do filters = Map.to_list(q) |> Enum.filter(&(elem(&1, 1) not in ["", nil])) |> Enum.map(&{Atom.to_string(elem(&1, 0)), elem(&1, 1)}) query |> ExQueb.StringFilters.string_filters(filters) |> integer_filters(filters) |> date_filters(filters) else query end end defp integer_filters(builder, filters) do builder |> build_integer_filters(filters, :eq) |> build_integer_filters(filters, :lt) |> build_integer_filters(filters, :gt) end defp date_filters(builder, filters) do builder |> build_date_filters(filters, :gte) |> build_date_filters(filters, :lte) end defp build_integer_filters(builder, filters, condition) do filters |> Enum.filter(&String.match?(elem(&1, 0), ~r/_#{condition}$/)) |> Enum.map(&{String.replace(elem(&1, 0), "_#{condition}", ""), elem(&1, 1)}) |> Enum.reduce(builder, fn {k, v}, acc -> _build_integer_filter(acc, String.to_atom(k), v, condition) end) end defp _build_integer_filter(query, fld, value, :eq) do where(query, [q], field(q, ^fld) == ^value) end defp _build_integer_filter(query, fld, value, :lt) do where(query, [q], field(q, ^fld) < ^value) end defp _build_integer_filter(query, fld, value, :gte) do where(query, [q], field(q, ^fld) >= ^value) end defp _build_integer_filter(query, fld, value, :lte) do where(query, [q], field(q, ^fld) <= ^value) end defp _build_integer_filter(query, fld, value, :gt) do where(query, [q], field(q, ^fld) > ^value) end defp build_date_filters(builder, filters, condition) do filters |> Enum.filter(&String.match?(elem(&1, 0), ~r/_#{condition}$/)) |> Enum.map(&{String.replace(elem(&1, 0), "_#{condition}", ""), elem(&1, 1)}) |> Enum.reduce(builder, fn {k, v}, acc -> _build_date_filter(acc, String.to_atom(k), cast_date_time(v), condition) end) end defp _build_date_filter(query, fld, value, :gte) do where(query, [q], fragment("? >= ?", field(q, ^fld), ^value)) end defp _build_date_filter(query, fld, value, :lte) do where(query, [q], fragment("? <= ?", field(q, ^fld), ^value)) end defp cast_date_time(value) do {:ok, date} = Ecto.Type.cast(:date, value) "#{Date.to_string(date)} 00:00:00.0" end @doc """ Build order for a given query. """ def build_order_bys(query, opts, action, params) when action in ~w(index csv)a do case Keyword.get(params, :order, nil) do nil -> build_default_order_bys(query, opts, action, params) order -> case get_sort_order(order) do nil -> build_default_order_bys(query, opts, action, params) {name, sort_order} -> name_atom = String.to_existing_atom(name) if sort_order == "desc" do order_by(query, [c], desc: field(c, ^name_atom)) else order_by(query, [c], asc: field(c, ^name_atom)) end end end end def build_order_bys(query, _, _, _), do: query defp build_default_order_bys(query, opts, action, _params) when action in ~w(index csv)a do case query.order_bys do [] -> index_opts = Map.get(opts, action, []) |> Enum.into(%{}) {order, primary_key} = get_default_order_by_field(query, index_opts) order_by(query, [c], [{^order, field(c, ^primary_key)}]) _ -> query end end defp build_default_order_bys(query, _opts, _action, _params), do: query @doc """ Get the sort order for a params entry. """ def get_sort_order(nil), do: nil def get_sort_order(order) do case Regex.scan(~r/(.+)_(desc|asc)$/, order) do [] -> nil [[_, name, sort_order]] -> {name, sort_order} end end defp get_default_order_by_field(_query, %{default_sort: [{order, field}]}) do {order, field} end defp get_default_order_by_field(query, %{default_sort_order: order}) do {order, get_default_order_by_field(query)} end defp get_default_order_by_field(_query, %{default_sort_field: field}) do {:desc, field} end defp get_default_order_by_field(query, _) do {:desc, get_default_order_by_field(query)} end defp get_default_order_by_field(query) do case query do %{from: from} -> case from.source do {_, mod} -> case mod.__schema__(:primary_key) do [name] -> name [name | _] -> name _ -> mod.__schema__(:fields) |> List.first() end _ -> :id end _ -> :id end end end
26.84153
93
0.60627
9e7e47121d85796a4123b3b517536d58fbf19eea
111
exs
Elixir
test/log_forwarder_test.exs
g-viet/log_fowarder
1c2ccb25dc72651cb979ea83597e2d0824807c3f
[ "MIT" ]
null
null
null
test/log_forwarder_test.exs
g-viet/log_fowarder
1c2ccb25dc72651cb979ea83597e2d0824807c3f
[ "MIT" ]
null
null
null
test/log_forwarder_test.exs
g-viet/log_fowarder
1c2ccb25dc72651cb979ea83597e2d0824807c3f
[ "MIT" ]
null
null
null
defmodule LogForwarderTest do use ExUnit.Case doctest LogForwarder test "greets the world" do end end
13.875
29
0.765766
9e7e543b8a664f68aba4a28d7ac26c9d5308034c
253
ex
Elixir
lib/cometoid.ex
danielmarreirosdeoliveira/cometoid
7a1c4f7700eb4dbb5f4c44fdc5185d048a429e50
[ "Apache-2.0" ]
null
null
null
lib/cometoid.ex
danielmarreirosdeoliveira/cometoid
7a1c4f7700eb4dbb5f4c44fdc5185d048a429e50
[ "Apache-2.0" ]
null
null
null
lib/cometoid.ex
danielmarreirosdeoliveira/cometoid
7a1c4f7700eb4dbb5f4c44fdc5185d048a429e50
[ "Apache-2.0" ]
null
null
null
defmodule Cometoid do @moduledoc """ Cometoid keeps the contexts that define your domain and business logic. Contexts are also responsible for managing your data, regardless if it comes from the database, an external API or others. """ end
25.3
66
0.754941
9e7e7dfa5c70aaa7ea8a8fe0d4015b25828d0c6d
712
ex
Elixir
phoenix/web/gettext.ex
sap-archive/jam-login-microservice
9f4e9d465c8e3913754fb73d08a68b4e8f13a8d2
[ "Apache-2.0" ]
1
2020-01-03T16:00:09.000Z
2020-01-03T16:00:09.000Z
phoenix/web/gettext.ex
SAP/jam-login-microservice
9f4e9d465c8e3913754fb73d08a68b4e8f13a8d2
[ "Apache-2.0" ]
null
null
null
phoenix/web/gettext.ex
SAP/jam-login-microservice
9f4e9d465c8e3913754fb73d08a68b4e8f13a8d2
[ "Apache-2.0" ]
null
null
null
defmodule LoginProxy.Gettext do @moduledoc """ A module providing Internationalization with a gettext-based API. By using [Gettext](https://hexdocs.pm/gettext), your module gains a set of macros for translations, for example: import LoginProxy.Gettext # Simple translation gettext "Here is the string to translate" # Plural translation ngettext "Here is the string to translate", "Here are the strings to translate", 3 # Domain-based translation dgettext "errors", "Here is the error message to translate" See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage. """ use Gettext, otp_app: :login_proxy end
28.48
72
0.682584
9e7e7f4bef68c88dfdab71914a80dc792d7bdd08
2,012
ex
Elixir
clients/service_management/lib/google_api/service_management/v1/model/change_report.ex
hauptbenutzer/elixir-google-api
7b9e3a114a49cfc774a7afd03e299a0d43e4e6b2
[ "Apache-2.0" ]
null
null
null
clients/service_management/lib/google_api/service_management/v1/model/change_report.ex
hauptbenutzer/elixir-google-api
7b9e3a114a49cfc774a7afd03e299a0d43e4e6b2
[ "Apache-2.0" ]
null
null
null
clients/service_management/lib/google_api/service_management/v1/model/change_report.ex
hauptbenutzer/elixir-google-api
7b9e3a114a49cfc774a7afd03e299a0d43e4e6b2
[ "Apache-2.0" ]
1
2020-11-10T16:58:27.000Z
2020-11-10T16:58:27.000Z
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # 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 License is distributed on an &quot;AS IS&quot; BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule GoogleApi.ServiceManagement.V1.Model.ChangeReport do @moduledoc """ Change report associated with a particular service configuration. It contains a list of ConfigChanges based on the comparison between two service configurations. ## Attributes - configChanges ([ConfigChange]): List of changes between two service configurations. The changes will be alphabetically sorted based on the identifier of each change. A ConfigChange identifier is a dot separated path to the configuration. Example: visibility.rules[selector&#x3D;&#39;LibraryService.CreateBook&#39;].restriction Defaults to: `null`. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :configChanges => list(GoogleApi.ServiceManagement.V1.Model.ConfigChange.t()) } field(:configChanges, as: GoogleApi.ServiceManagement.V1.Model.ConfigChange, type: :list) end defimpl Poison.Decoder, for: GoogleApi.ServiceManagement.V1.Model.ChangeReport do def decode(value, options) do GoogleApi.ServiceManagement.V1.Model.ChangeReport.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.ServiceManagement.V1.Model.ChangeReport do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
41.916667
351
0.772366
9e7e7fb7622720318af9b485f2ab705bd9cc9e72
4,477
ex
Elixir
clients/service_control/lib/google_api/service_control/v1/model/log_entry.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/service_control/lib/google_api/service_control/v1/model/log_entry.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/service_control/lib/google_api/service_control/v1/model/log_entry.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # 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 License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.ServiceControl.V1.Model.LogEntry do @moduledoc """ An individual log entry. ## Attributes * `httpRequest` (*type:* `GoogleApi.ServiceControl.V1.Model.HttpRequest.t`, *default:* `nil`) - Optional. Information about the HTTP request associated with this log entry, if applicable. * `insertId` (*type:* `String.t`, *default:* `nil`) - A unique ID for the log entry used for deduplication. If omitted, the implementation will generate one based on operation_id. * `labels` (*type:* `map()`, *default:* `nil`) - A set of user-defined (key, value) data that provides additional information about the log entry. * `name` (*type:* `String.t`, *default:* `nil`) - Required. The log to which this log entry belongs. Examples: `"syslog"`, `"book_log"`. * `operation` (*type:* `GoogleApi.ServiceControl.V1.Model.LogEntryOperation.t`, *default:* `nil`) - Optional. Information about an operation associated with the log entry, if applicable. * `protoPayload` (*type:* `map()`, *default:* `nil`) - The log entry payload, represented as a protocol buffer that is expressed as a JSON object. The only accepted type currently is AuditLog. * `severity` (*type:* `String.t`, *default:* `nil`) - The severity of the log entry. The default value is `LogSeverity.DEFAULT`. * `sourceLocation` (*type:* `GoogleApi.ServiceControl.V1.Model.LogEntrySourceLocation.t`, *default:* `nil`) - Optional. Source code location information associated with the log entry, if any. * `structPayload` (*type:* `map()`, *default:* `nil`) - The log entry payload, represented as a structure that is expressed as a JSON object. * `textPayload` (*type:* `String.t`, *default:* `nil`) - The log entry payload, represented as a Unicode string (UTF-8). * `timestamp` (*type:* `DateTime.t`, *default:* `nil`) - The time the event described by the log entry occurred. If omitted, defaults to operation start time. * `trace` (*type:* `String.t`, *default:* `nil`) - Optional. Resource name of the trace associated with the log entry, if any. If this field contains a relative resource name, you can assume the name is relative to `//tracing.googleapis.com`. Example: `projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824` """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :httpRequest => GoogleApi.ServiceControl.V1.Model.HttpRequest.t(), :insertId => String.t(), :labels => map(), :name => String.t(), :operation => GoogleApi.ServiceControl.V1.Model.LogEntryOperation.t(), :protoPayload => map(), :severity => String.t(), :sourceLocation => GoogleApi.ServiceControl.V1.Model.LogEntrySourceLocation.t(), :structPayload => map(), :textPayload => String.t(), :timestamp => DateTime.t(), :trace => String.t() } field(:httpRequest, as: GoogleApi.ServiceControl.V1.Model.HttpRequest) field(:insertId) field(:labels, type: :map) field(:name) field(:operation, as: GoogleApi.ServiceControl.V1.Model.LogEntryOperation) field(:protoPayload, type: :map) field(:severity) field(:sourceLocation, as: GoogleApi.ServiceControl.V1.Model.LogEntrySourceLocation) field(:structPayload, type: :map) field(:textPayload) field(:timestamp, as: DateTime) field(:trace) end defimpl Poison.Decoder, for: GoogleApi.ServiceControl.V1.Model.LogEntry do def decode(value, options) do GoogleApi.ServiceControl.V1.Model.LogEntry.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.ServiceControl.V1.Model.LogEntry do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
47.62766
187
0.692651
9e7ed205e99484043f8fed4293873765a6d0dee5
85
ex
Elixir
exercises/practice/bob/lib/bob.ex
devtayls/elixir
67824de8209ff1b6ed2f736deedfb5bd815130ca
[ "MIT" ]
343
2017-06-22T16:28:28.000Z
2022-03-25T21:33:32.000Z
exercises/practice/bob/lib/bob.ex
devtayls/elixir
67824de8209ff1b6ed2f736deedfb5bd815130ca
[ "MIT" ]
583
2017-06-19T10:48:40.000Z
2022-03-28T21:43:12.000Z
exercises/practice/bob/lib/bob.ex
devtayls/elixir
67824de8209ff1b6ed2f736deedfb5bd815130ca
[ "MIT" ]
228
2017-07-05T07:09:32.000Z
2022-03-27T08:59:08.000Z
defmodule Bob do @spec hey(String.t()) :: String.t() def hey(input) do end end
14.166667
37
0.635294
9e7ef25de34275e7970402b0a78938d63547a950
331
ex
Elixir
lib/stripe_mock_web/endpoint.ex
whitepaperclip/stripe_mock
a8ba9101a04216f26d0650eb38448173d8e090a1
[ "MIT" ]
4
2019-06-04T20:35:21.000Z
2021-09-02T04:04:21.000Z
lib/stripe_mock_web/endpoint.ex
whitepaperclip/stripe_mock
a8ba9101a04216f26d0650eb38448173d8e090a1
[ "MIT" ]
2
2020-02-04T17:38:12.000Z
2021-04-29T06:59:06.000Z
lib/stripe_mock_web/endpoint.ex
whitepaperclip/stripe_mock
a8ba9101a04216f26d0650eb38448173d8e090a1
[ "MIT" ]
null
null
null
defmodule StripeMockWeb.Endpoint do use Phoenix.Endpoint, otp_app: :stripe_mock plug Plug.RequestId plug Plug.Logger plug Plug.Parsers, parsers: [:urlencoded, :multipart, :json], pass: ["*/*"], json_decoder: Phoenix.json_library() plug Plug.MethodOverride plug Plug.Head plug StripeMockWeb.Router end
19.470588
46
0.722054
9e7efab334addf9ac1341071c737b06467fffe39
2,266
ex
Elixir
lib/andrex/blog/entry.ex
amalbuquerque/andrex
20c298a7203c96655a992570ece6f3998739ae21
[ "MIT" ]
null
null
null
lib/andrex/blog/entry.ex
amalbuquerque/andrex
20c298a7203c96655a992570ece6f3998739ae21
[ "MIT" ]
null
null
null
lib/andrex/blog/entry.ex
amalbuquerque/andrex
20c298a7203c96655a992570ece6f3998739ae21
[ "MIT" ]
null
null
null
defmodule Andrex.Blog.Entry do alias Andrex.Blog.Pandoc defstruct [:tags, :year, :month, :day, :url_title, :filename, :pandoc, :andrex] def from_markdown(filename, markdown) when is_binary(filename) and is_binary(markdown) do with {:ok, %Pandoc{metadata: metadata} = pandoc} <- Pandoc.from_markdown(markdown), {:ok, [year, month, day]} <- yyyy_mm_dd_from_filename(filename), {:ok, url_title} <- url_title(filename) do result = %__MODULE__{ tags: tags_from_metadata(metadata), year: year, month: month, day: day, filename: filename, url_title: url_title, pandoc: pandoc, andrex: metadata[:andrex] || %{} } {:ok, result} else error -> error end end def from_markdown_without_date(filename, markdown) when is_binary(filename) and is_binary(markdown) do with {:ok, %Pandoc{metadata: metadata} = pandoc} <- Pandoc.from_markdown(markdown), url_title = String.replace_suffix(filename, ".md", "") do result = %__MODULE__{ tags: tags_from_metadata(metadata), filename: filename, url_title: url_title, pandoc: pandoc, andrex: metadata[:andrex] || %{} } {:ok, result} else error -> error end end defp yyyy_mm_dd_from_filename(filename) do filename |> String.split("-") |> case do [yyyy, mm, dd, _url_title_hd | _url_title_rest] when byte_size(yyyy) == 4 and byte_size(mm) == 2 and byte_size(dd) == 2 -> {:ok, [yyyy, mm, dd]} _ -> {:error, :unexpected_filename_format} end end def url_title(filename) do filename |> String.split("-") |> case do [yyyy, mm, dd, url_title_hd | url_title_rest] when byte_size(yyyy) == 4 and byte_size(mm) == 2 and byte_size(dd) == 2 -> url_title = [url_title_hd | url_title_rest] |> Enum.join("-") |> String.replace_suffix(".md", "") {:ok, url_title} _ -> {:error, :unexpected_filename_format} end end defp tags_from_metadata(%{tags: raw_tags}) do raw_tags |> String.split(",") |> Enum.map(&String.trim/1) end defp tags_from_metadata(_), do: ["(no tags)"] end
28.683544
128
0.59797
9e7efc5b9e100813c598b002fed85e5205e21f3b
2,714
ex
Elixir
lib/epi_locator/tr/search/filter_person_results.ex
RatioPBC/epi-locator
58c90500c4e0071ce365d76ec9812f9051d6a9f9
[ "Apache-2.0" ]
null
null
null
lib/epi_locator/tr/search/filter_person_results.ex
RatioPBC/epi-locator
58c90500c4e0071ce365d76ec9812f9051d6a9f9
[ "Apache-2.0" ]
6
2021-10-19T01:55:57.000Z
2022-02-15T01:04:19.000Z
lib/epi_locator/tr/search/filter_person_results.ex
RatioPBC/epi-locator
58c90500c4e0071ce365d76ec9812f9051d6a9f9
[ "Apache-2.0" ]
2
2022-01-21T08:38:50.000Z
2022-01-21T08:42:04.000Z
defmodule EpiLocator.Search.FilterPersonResults do alias EpiLocator.Search.PersonResult def filter(person_results, filters) do regular_filters = Map.drop(filters, ~w{phone dob}a) person_results |> apply_regular_filters(regular_filters) |> apply_phone_filter(filters[:phone]) |> apply_dob_filter(filters[:dob]) end # # # defp apply_dob_filter(search_results, nil), do: search_results defp apply_dob_filter(search_results, dob), do: search_results |> Enum.filter(&dob_filter(&1, dob)) defp apply_phone_filter(search_results, nil), do: search_results defp apply_phone_filter(search_results, filter_phone) do normalized_filter_phone = normalize_phone(filter_phone) Enum.filter(search_results, fn search_result -> Enum.any?(search_result.phone_numbers, fn %{phone: phone} -> (normalize_phone(phone) || "") |> String.starts_with?(normalized_filter_phone) end) end) end defp apply_regular_filters(search_results, filters) do Enum.filter(search_results, fn search_result -> Enum.all?(filters, fn {key, value} -> up_value = String.upcase(value || "") search_result |> Map.get(key) |> upcase() |> String.starts_with?(up_value) end) end) end defp upcase(nil), do: "" defp upcase(string) when is_binary(string), do: String.upcase(string) defp dob_filter(search_result, filter) do unavailable_string = PersonResult.unavailable_dob_string() case search_result.dob do ^unavailable_string -> false nil -> false _ -> matches_dob?(search_result.dob, filter) end end defp matches_dob?(dob, filter) do case String.split(dob, "/") do components = [_month, _day, _year] -> matches_dob_components?(components, [:month, :day, :year], filter) components = [_month, _year] -> matches_dob_components?(components, [:month, :year], filter) [year] -> matches_dob_component?(year, Map.get(filter, :year)) end end defp matches_dob_components?(components, fields, filter) do fields |> Enum.zip(components) |> Enum.all?(fn {field, value} -> matches_dob_component?(value, Map.get(filter, field)) end) end defp matches_dob_component?(_component, nil), do: true defp matches_dob_component?("XX", _filter_value), do: true defp matches_dob_component?("XXXX", _filter_value), do: true defp matches_dob_component?(nil, _filter_value), do: true defp matches_dob_component?(component, filter_value), do: component == filter_value defp normalize_phone(nil), do: nil defp normalize_phone(phone) do numeric_phone = Regex.replace(~r/[^0-9]/, phone, "") Regex.replace(~r/^1/, numeric_phone, "") end end
32.698795
110
0.699705
9e7f029b68a65af16dc62ab52c7889a06dc63a73
67
ex
Elixir
lib/watch_faces_web/views/page_view.ex
DaniruKun/watchfaces-ex
699e345596000ec3e50141e44217b155400261d6
[ "MIT" ]
null
null
null
lib/watch_faces_web/views/page_view.ex
DaniruKun/watchfaces-ex
699e345596000ec3e50141e44217b155400261d6
[ "MIT" ]
null
null
null
lib/watch_faces_web/views/page_view.ex
DaniruKun/watchfaces-ex
699e345596000ec3e50141e44217b155400261d6
[ "MIT" ]
null
null
null
defmodule WatchFacesWeb.PageView do use WatchFacesWeb, :view end
16.75
35
0.820896
9e7f144ebba85bcecf5796d2fd6e74388ff8e553
636
ex
Elixir
lib/Cogs/event_registry.ex
ElinksFr/alchemy
4c64e5c619977a62a5674dbd2b1ef29f76f6f44e
[ "MIT" ]
163
2017-03-01T09:02:35.000Z
2022-03-09T23:31:48.000Z
lib/Cogs/event_registry.ex
ElinksFr/alchemy
4c64e5c619977a62a5674dbd2b1ef29f76f6f44e
[ "MIT" ]
91
2017-02-23T23:23:35.000Z
2021-12-29T23:47:44.000Z
lib/Cogs/event_registry.ex
ElinksFr/alchemy
4c64e5c619977a62a5674dbd2b1ef29f76f6f44e
[ "MIT" ]
38
2017-03-23T13:16:44.000Z
2022-02-26T15:53:32.000Z
defmodule Alchemy.Cogs.EventRegistry do # Serves as a registry for processes wanting @moduledoc false # to subscribe to events. The dispatch will then be used to allow # for dynamic hooking into events. def start_link do Registry.start_link(keys: :duplicate, name: __MODULE__) end def subscribe do # the calling process will be sent in Registry.register(__MODULE__, :subscribed, nil) end def dispatch(events) do Registry.dispatch(__MODULE__, :subscribed, fn entries -> Enum.each(entries, fn {pid, _} -> Enum.each(events, &send(pid, {:discord_event, &1})) end) end) end end
26.5
67
0.696541
9e7f18d0438158c78d74965421cc1a2ddf616111
1,848
ex
Elixir
test/intercepted_modules/do_block/intercepted_on_success.ex
filipecabaco/interceptor
e108946d3909d9ceffb2ab9406c5534fa6dcad28
[ "MIT" ]
40
2018-09-30T13:39:20.000Z
2022-01-07T12:47:45.000Z
test/intercepted_modules/do_block/intercepted_on_success.ex
filipecabaco/interceptor
e108946d3909d9ceffb2ab9406c5534fa6dcad28
[ "MIT" ]
6
2019-02-17T22:21:17.000Z
2021-04-26T21:47:59.000Z
test/intercepted_modules/do_block/intercepted_on_success.ex
filipecabaco/interceptor
e108946d3909d9ceffb2ab9406c5534fa6dcad28
[ "MIT" ]
5
2020-05-16T00:31:45.000Z
2021-07-16T13:39:05.000Z
defmodule OnSuccess.Callback do def on_success({_module, _function, _args} = mfa, result, started_at) do Agent.update(:on_success_test_process, fn messages -> [{started_at, Interceptor.Utils.timestamp(), result, mfa} | messages] end) "Doesn't influence the function at all" end end defmodule InterceptedOnSuccess1 do require Interceptor, as: I I.intercept do def to_intercept(), do: Interceptor.Utils.timestamp() end end defmodule InterceptedOnSuccess2 do require Interceptor, as: I I.intercept do def to_intercept(), do: Process.sleep(200) def other_to_intercept(), do: "HELLO" IO.puts("This statement doesn't interfere in any way") end end defmodule InterceptedOnSuccess3 do require Interceptor, as: I def definitely_not_to_intercept(), do: "No macros plz" I.intercept do def not_to_intercept(), do: "Not intercepted" def other_to_intercept(w), do: w + private_function(1, 2, 3) defp private_function(x, y, z), do: x+y+z def trickier_args_function(first_arg, [one, two, three], {abc, xyz}, %{baz: woz}, <<g,h,i>>, foo \\ "bar") do [ first_arg, one, two, three, abc, xyz, woz, g, h, i, foo ] end end end defmodule La.Lu.Li.Weird.MyStruct do defstruct name: "ryuichi sakamoto", age: 67 end defmodule InterceptedOnSuccess4 do require Interceptor, as: I alias La.Lu.Li.Weird.MyStruct I.intercept do def with_struct(%MyStruct{name: n, age: a}) do [n, a] end def with_structs( %MyStruct{name: n1, age: a1}, %La.Lu.Li.Weird.MyStruct{name: n2, age: a2}) do [n1, a1, n2, a2] end def with_struct_already_assigned(%MyStruct{name: _n, age: _a} = xpto) do [xpto.name, xpto.age] end end end
21.741176
113
0.63961
9e7f3c89b221470342a0bd5f1c9d2e02a9ecf308
102
ex
Elixir
apps/hefty/lib/hefty/repo.ex
Cinderella-Man/crypto-streamer
b1e990d375f7143c5149930be991249f0d9c3ee3
[ "MIT" ]
49
2019-10-28T22:27:28.000Z
2021-10-11T06:40:29.000Z
apps/hefty/lib/hefty/repo.ex
Cinderella-Man/crypto-streamer
b1e990d375f7143c5149930be991249f0d9c3ee3
[ "MIT" ]
9
2019-08-30T13:15:36.000Z
2019-10-10T21:25:14.000Z
apps/hefty/lib/hefty/repo.ex
Cinderella-Man/crypto-streamer
b1e990d375f7143c5149930be991249f0d9c3ee3
[ "MIT" ]
7
2019-10-31T06:19:26.000Z
2021-09-30T04:20:58.000Z
defmodule Hefty.Repo do use Ecto.Repo, otp_app: :hefty, adapter: Ecto.Adapters.Postgres end
17
35
0.715686
9e7f4ddafa8937fe992905c3678c01bb54283707
1,254
exs
Elixir
test/auto_api/states/hood_state_test.exs
nonninz/auto-api-elixir
53e11542043285e94bbb5a0a3b8ffff0b1b47167
[ "MIT" ]
4
2018-01-19T16:11:10.000Z
2019-12-13T16:35:10.000Z
test/auto_api/states/hood_state_test.exs
nonninz/auto-api-elixir
53e11542043285e94bbb5a0a3b8ffff0b1b47167
[ "MIT" ]
5
2018-11-29T09:48:29.000Z
2019-11-06T12:11:35.000Z
test/auto_api/states/hood_state_test.exs
nonninz/auto-api-elixir
53e11542043285e94bbb5a0a3b8ffff0b1b47167
[ "MIT" ]
1
2021-02-17T18:36:13.000Z
2021-02-17T18:36:13.000Z
# AutoAPI # The MIT License # # Copyright (c) 2018- High-Mobility GmbH (https://high-mobility.com) # # 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 Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. defmodule AutoApi.HoodStateTest do use ExUnit.Case, async: true doctest AutoApi.HoodState end
46.444444
79
0.777512
9e7f50cf9dc00b054e51f35a6faf112b4c9adddb
233
exs
Elixir
installer/templates/phx_umbrella/config/prod.exs
matthewp/phoenix
af86b95db365faada58d326e98de65c811690bc7
[ "MIT" ]
1
2020-07-23T18:03:42.000Z
2020-07-23T18:03:42.000Z
installer/templates/phx_umbrella/config/prod.exs
matthewp/phoenix
af86b95db365faada58d326e98de65c811690bc7
[ "MIT" ]
null
null
null
installer/templates/phx_umbrella/config/prod.exs
matthewp/phoenix
af86b95db365faada58d326e98de65c811690bc7
[ "MIT" ]
1
2020-08-31T15:29:31.000Z
2020-08-31T15:29:31.000Z
import Config # Do not print debug messages in production config :logger, level: :info # Finally import the config/prod.secret.exs which loads secrets # and configuration from environment variables. import_config "prod.secret.exs"
25.888889
63
0.798283
9e7f5d1e653c87f1523e0a3fce9f86a4b6e2c69d
1,087
ex
Elixir
lib/whois.ex
andruby/whois.ex
07a33eeac40bf14907e9ee1c9032a6a694157a74
[ "MIT" ]
null
null
null
lib/whois.ex
andruby/whois.ex
07a33eeac40bf14907e9ee1c9032a6a694157a74
[ "MIT" ]
null
null
null
lib/whois.ex
andruby/whois.ex
07a33eeac40bf14907e9ee1c9032a6a694157a74
[ "MIT" ]
null
null
null
defmodule Whois do def request(hostname) do server = server_for(hostname) {:ok, socket} = :gen_tcp.connect(to_char_list(server["host"]), 43, [:binary, active: false]) :ok = :gen_tcp.send(socket, "#{hostname}\r\n") receive_until_closed(socket) end def available?(hostname) do server = server_for(hostname) msg = request(hostname) Regex.match?(Regex.compile!(server["available_pattern"], "i"), msg) end def server_for(hostname) do domain = domain_for(hostname) server = domain.whois_servers |> List.first end def domain_for(hostname) do GenServer.call({:global, :whois_domain_list}, {:domain_for, hostname}) end def domains do GenServer.call({:global, :whois_domain_list}, {:domains}) end # Keep receiving from the tcp socket until the socket is closed defp receive_until_closed(socket), do: receive_until_closed(socket, "") defp receive_until_closed(socket, acc) do case :gen_tcp.recv(socket, 0) do {:ok, msg} -> receive_until_closed(socket, acc <> msg) {:error, :closed} -> acc end end end
29.378378
96
0.687213
9e7f72e09b30f22c16e18eeb8a3598eff03ce6be
2,350
exs
Elixir
config/prod.exs
jdcumpson/elixir-phoenix-ssr-redux-postgres
20ecf8bac1322be273ed6441bb586b8574998286
[ "MIT" ]
1
2020-11-04T04:32:56.000Z
2020-11-04T04:32:56.000Z
config/prod.exs
jdcumpson/elixir-phoenix-ssr-redux-postgres
20ecf8bac1322be273ed6441bb586b8574998286
[ "MIT" ]
4
2021-10-06T22:46:17.000Z
2022-02-27T12:04:59.000Z
config/prod.exs
jdcumpson/elixir-phoenix-ssr-redux-postgres
20ecf8bac1322be273ed6441bb586b8574998286
[ "MIT" ]
null
null
null
use Mix.Config # For production, don't forget to configure the url host # to something meaningful, Phoenix uses this information # when generating URLs. # # Note we also include the path to a cache manifest # containing the digested version of static files. This # manifest is generated by the `mix phx.digest` task, # which you should run after static files are built and # before starting your production server. config :quickstart_web, manifest_path: Path.absname("apps/quickstart_web/assets/dist/prod/app.prod.manifest") config :quickstart_web, QuickstartWeb.Endpoint, url: [host: "quickstart.io", port: 443, protocol: "https"], static_url: [host: "quickstart.io", port: 443, path: "/assets", protocol: "https"], check_origin: [ "https://quickstart.io", "https://app.quickstart.io" ] # cache_static_manifest: "priv/static/cache_manifest.json" # ## SSL Support # # To get SSL working, you will need to add the `https` key # to the previous section and set your `:url` port to 443: # # config :quickstart_web, QuickstartWeb.Endpoint, # ... # url: [host: "example.com", port: 443], # https: [ # port: 443, # cipher_suite: :strong, # keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"), # certfile: System.get_env("SOME_APP_SSL_CERT_PATH"), # transport_options: [socket_opts: [:inet6]] # ] # # The `cipher_suite` is set to `:strong` to support only the # latest and more secure SSL ciphers. This means old browsers # and clients may not be supported. You can set it to # `:compatible` for wider support. # # `:keyfile` and `:certfile` expect an absolute path to the key # and cert in disk or a relative path inside priv, for example # "priv/ssl/server.key". For all supported SSL configuration # options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1 # # We also recommend setting `force_ssl` in your endpoint, ensuring # no data is ever sent via http, always redirecting to https: # # config :quickstart_web, QuickstartWeb.Endpoint, # force_ssl: [hsts: true] # # Check `Plug.SSL` for all available options in `force_ssl`. # Do not print debug messages in production config :logger, level: :info # Finally import the config/prod.secret.exs which loads secrets # and configuration from environment variables. import_config "prod.secret.exs"
35.074627
87
0.714894
9e7f74dac5cc6191d96e4d13153146b2d1648b70
3,071
ex
Elixir
lib/membrane_mp4/movie_fragment_box.ex
membraneframework/membrane_mp4_plugin
825249ec92b9fdb0d6faa6ca6f37ea4ed1c730e4
[ "Apache-2.0" ]
2
2021-09-29T14:31:47.000Z
2021-12-24T18:22:17.000Z
lib/membrane_mp4/movie_fragment_box.ex
membraneframework/membrane_mp4_plugin
825249ec92b9fdb0d6faa6ca6f37ea4ed1c730e4
[ "Apache-2.0" ]
13
2020-05-27T14:23:18.000Z
2022-01-10T11:48:05.000Z
lib/membrane_mp4/movie_fragment_box.ex
membraneframework/membrane_mp4_plugin
825249ec92b9fdb0d6faa6ca6f37ea4ed1c730e4
[ "Apache-2.0" ]
2
2022-03-06T13:25:23.000Z
2022-03-06T13:26:42.000Z
defmodule Membrane.MP4.MovieFragmentBox do @moduledoc """ A module containing a function for assembling an MPEG-4 movie fragment box. The movie fragment box (`moof` atom) is a top-level box and consists of: * exactly one movie fragment header (`mfhd` atom) The movie fragment header contains a sequence number that is increased for every subsequent movie fragment in order in which they occur. * zero or more track fragment box (`traf` atom) The track fragment box provides information related to a track fragment's presentation time, duration and physical location of its samples in the media data box. This box is required by Common Media Application Format. For more information about movie fragment box and its contents refer to [ISO/IEC 14496-12](https://www.iso.org/standard/74428.html) or to [ISO/IEC 23000-19](https://www.iso.org/standard/79106.html). """ alias Membrane.MP4.Container @trun_flags %{data_offset: 1, sample_duration: 0x100, sample_size: 0x200, sample_flags: 0x400} @mdat_data_offset 8 @spec assemble(%{ sequence_number: integer, elapsed_time: integer, timescale: integer, duration: integer, samples_table: [%{sample_size: integer, sample_flags: integer}] }) :: Container.t() def assemble(config) do config = config |> Map.merge(%{ sample_count: length(config.samples_table), data_offset: 0 }) moof_size = moof(config) |> Container.serialize!() |> byte_size() config = %{config | data_offset: moof_size + @mdat_data_offset} moof(config) end defp moof(config) do [ moof: %{ children: [ mfhd: %{ children: [], fields: %{flags: 0, sequence_number: config.sequence_number, version: 0} }, traf: %{ children: [ tfhd: %{ children: [], fields: %{ default_sample_duration: 0, default_sample_flags: 0, default_sample_size: 0, flags: 0b100000000000111000, track_id: 1, version: 0 } }, tfdt: %{ children: [], fields: %{ base_media_decode_time: config.elapsed_time, flags: 0, version: 1 } }, trun: %{ children: [], fields: %{ data_offset: config.data_offset, flags: @trun_flags.data_offset + @trun_flags.sample_duration + @trun_flags.sample_size + @trun_flags.sample_flags, sample_count: config.sample_count, samples: config.samples_table, version: 0 } } ], fields: %{} } ], fields: %{} } ] end end
30.107843
96
0.541843
9e7f9dd8425178969ec204dc306cf3904ef15f36
1,020
ex
Elixir
lib/elmmeetup/endpoint.ex
chasm/elmmeetup
95f9850a075dcc6ea884279485c532ac2f4db803
[ "MIT" ]
null
null
null
lib/elmmeetup/endpoint.ex
chasm/elmmeetup
95f9850a075dcc6ea884279485c532ac2f4db803
[ "MIT" ]
1
2018-12-26T09:07:03.000Z
2018-12-26T09:07:03.000Z
lib/elmmeetup/endpoint.ex
chasm/elmmeetup
95f9850a075dcc6ea884279485c532ac2f4db803
[ "MIT" ]
null
null
null
defmodule Elmmeetup.Endpoint do use Phoenix.Endpoint, otp_app: :elmmeetup socket "/socket", Elmmeetup.UserSocket # Serve at "/" the static files from "priv/static" directory. # # You should set gzip to true if you are running phoenix.digest # when deploying your static files in production. plug Plug.Static, at: "/", from: :elmmeetup, gzip: false, only: ~w(css fonts images js favicon.ico robots.txt) # Code reloading can be explicitly enabled under the # :code_reloader configuration of your endpoint. if code_reloading? do socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket plug Phoenix.LiveReloader plug Phoenix.CodeReloader end plug Plug.RequestId plug Plug.Logger plug Plug.Parsers, parsers: [:urlencoded, :multipart, :json], pass: ["*/*"], json_decoder: Poison plug Plug.MethodOverride plug Plug.Head plug Plug.Session, store: :cookie, key: "_elmmeetup_key", signing_salt: "Ae1Y/VwS" plug Elmmeetup.Router end
25.5
69
0.711765
9e7faf474831fad392f95dad5017c78aba514219
29,951
exs
Elixir
lib/ex_unit/test/ex_unit/doc_test_test.exs
fmterrorf/elixir
eafb7b87756179adac5dc2bc11edcb04c1f187cc
[ "Apache-2.0" ]
1
2019-06-27T08:47:13.000Z
2019-06-27T08:47:13.000Z
lib/ex_unit/test/ex_unit/doc_test_test.exs
fmterrorf/elixir
eafb7b87756179adac5dc2bc11edcb04c1f187cc
[ "Apache-2.0" ]
null
null
null
lib/ex_unit/test/ex_unit/doc_test_test.exs
fmterrorf/elixir
eafb7b87756179adac5dc2bc11edcb04c1f187cc
[ "Apache-2.0" ]
null
null
null
Code.require_file("../test_helper.exs", __DIR__) defmodule ExUnit.BeamHelpers do # Beam files compiled on demand path = Path.expand("../../tmp/beams", __DIR__) File.rm_rf!(path) File.mkdir_p!(path) Code.prepend_path(path) def write_beam({:module, name, bin, _} = res) do beam_path = Path.join(unquote(path), Atom.to_string(name) <> ".beam") File.write!(beam_path, bin) res end end defmodule ExUnit.DocTestTest.GoodModule do @doc """ iex> one() 1 iex> one() + 1 2 """ def one, do: 1 @doc """ iex> List.flatten([]) """ def only_call, do: :ok @doc ~S""" iex> ~S(f#{o}o) "f\#{o}o" """ def test_sigil, do: :ok @doc " iex>1 + 2\n 3" def no_trailing_new_line, do: :ok @doc """ iex> a = 1 iex> b = a + 2 3 iex> a + b 4 """ def single_context, do: :ok @doc """ iex> raise "message" ** (RuntimeError) message iex> raise "message" ** (RuntimeError) message """ def two_exceptions, do: :ok @doc """ iex> raise "message" ** (RuntimeError) message """ def exception_test, do: :ok @doc ~S""" iex> raise "foo\nbar" ** (RuntimeError) foo bar """ def multiline_exception_test, do: :ok end |> ExUnit.BeamHelpers.write_beam() defmodule ExUnit.DocTestTest.MultipleExceptions do @doc """ iex> 1 + "" ** (ArithmeticError) bad argument in arithmetic expression iex> 2 + "" ** (ArithmeticError) bad argument in arithmetic expression """ def two_exceptions, do: :ok end |> ExUnit.BeamHelpers.write_beam() defmodule ExUnit.DocTestTest.SomewhatGoodModuleWithOnly do @doc """ iex> one() 1 iex> one() + 1 2 """ def one, do: 1 @doc """ iex> two() 2 iex> two() + 1 100 """ def two, do: 2 end |> ExUnit.BeamHelpers.write_beam() defmodule ExUnit.DocTestTest.SomewhatGoodModuleWithExcept do @moduledoc """ iex> 1 + 1 1 """ @doc """ iex> one() 1 iex> one() + 1 2 """ def one, do: 1 @doc """ iex> two() 2 iex> two() + 1 100 """ def two, do: 2 end |> ExUnit.BeamHelpers.write_beam() defmodule ExUnit.DocTestTest.NoImport do @doc """ iex> ExUnit.DocTestTest.NoImport.max(1, 2) {:ok, 2} iex> max(1, 2) 2 """ def max(a, b), do: {:ok, Kernel.max(a, b)} end |> ExUnit.BeamHelpers.write_beam() defmodule ExUnit.DocTestTest.Invalid do def starting_line, do: __ENV__.line + 2 @moduledoc """ iex> 1 + * 1 1 iex> 1 + hd(List.flatten([1])) 3 iex> a = "This is an egregiously long text string." iex> b = ~r{an egregiously long} iex> c = "a slightly shorter" iex> String.replace(a, b, c) "This is a much shorter text string." iex> :oops #Inspect<[]> iex> Hello.world() :world iex> raise "oops" ** (WhatIsThis) oops iex> raise "oops" ** (RuntimeError) hello """ @doc """ iex> 1 + * 1 1 """ def a(), do: :ok @doc """ iex> 1 + * 1 1 """ defmacro b(), do: :ok @doc """ ``` iex> 1 + 2 3 ``` """ def indented_not_enough, do: :ok @doc ~S''' ``` iex> 1 + 2 3 ``` ''' def indented_too_much, do: :ok @doc """ ``` iex> 1 + 2 3 ``` """ def dedented_past_fence, do: :ok @doc """ iex> String.valid?("invalid utf8 \xFF") false """ def invalid_utf8, do: :ok @doc """ iex> {:ok, :oops} {:ok, #Inspect<[]>} """ def misplaced_opaque_type, do: :ok @typedoc """ iex> 1 + * 1 1 """ @type t :: any() @doc """ # This will fail to inspect iex> ExUnit.DocTestTest.Haiku.new(:this, :is, {:not, :a, :haiku}) #Haiku<:this_wont_be_asserted> """ def raising_inspect, do: :ok end |> ExUnit.BeamHelpers.write_beam() defmodule ExUnit.DocTestTest.IndentationHeredocs do @doc ~S''' Receives a test and formats its failure. ## Examples iex> " 1\n 2\n" """ 1 2 """ ''' def heredocs, do: :ok end |> ExUnit.BeamHelpers.write_beam() defmodule ExUnit.DocTestTest.IndentationMismatchedPrompt do @doc ~S''' iex> foo = 1 iex> bar = 2 iex> foo + bar 3 ''' def mismatched, do: :ok end |> ExUnit.BeamHelpers.write_beam() defmodule ExUnit.DocTestTest.IndentationTooMuch do @doc ~S''' iex> 1 + 2 3 ''' def too_much, do: :ok end |> ExUnit.BeamHelpers.write_beam() defmodule ExUnit.DocTestTest.IndentationNotEnough do @doc ~S''' iex> 1 + 2 3 ''' def test_fun, do: :ok end |> ExUnit.BeamHelpers.write_beam() defmodule ExUnit.DocTestTest.FencedHeredocs do @doc ~S''' Receives a test and formats its failure. ## Examples ``` iex> 1 + 2 3 ``` ``` iex> 1 + 2 3 ``` ``` iex> 1 + 2 3 ``` ''' def heredocs, do: :ok @doc ~S''' ``` iex> 1 + 2 3 ''' def incomplete, do: :ok end |> ExUnit.BeamHelpers.write_beam() defmodule ExUnit.DocTestTest.FenceIncomplete do @doc ~S''' ``` iex> 1 + 2 3 ''' def test_fun, do: :ok end |> ExUnit.BeamHelpers.write_beam() defmodule ExUnit.DocTestTest.Numbered do @doc """ iex(1)> 1 + ...(1)> 2 3 """ def test_fun(), do: :ok end |> ExUnit.BeamHelpers.write_beam() defmodule ExUnit.DocTestTest.Host do @doc """ iex(foo@bar)1> 1 + ...(foo@bar)1> 2 3 """ def test_fun(), do: :ok end |> ExUnit.BeamHelpers.write_beam() defmodule ExUnit.DocTestTest.Haiku do @moduledoc """ This module describes the ancient Japanese poem form known as Haiku. The Inspect protocol has been overridden for `%Haiku{}` so that Haikus are shown in a pretty-printed fashion. This module is part of the DocTest test suite, to ensure that DocTest can handle opaque inspect types which contain unicode and possibly consist of multiple lines. """ defstruct [:first_phrase, :second_phrase, :third_phrase, :author] @doc """ Creates a new Haiku. Optionally pass in the `author` as fourth argument. ## Examples: # Simple Haiku, inspect output consists of multiple lines. iex> ExUnit.DocTestTest.Haiku.new("Haikus are easy", "But sometimes they don't make sense", "Refrigerator") #Haiku< Haikus are easy But sometimes they don't make sense Refrigerator > # Haiku with Unicode characters (Japanese Kanji, em-dash). iex> ExUnit.DocTestTest.Haiku.new("古池や", "蛙飛びこむ", "水の音", "Matsuo Basho") #Haiku< 古池や 蛙飛びこむ 水の音 -- Matsuo Basho > """ def new(first, second, third, author \\ "") do %__MODULE__{ first_phrase: first, second_phrase: second, third_phrase: third, author: author } end @doc """ iex> ExUnit.DocTestTest.Haiku.new("古池や", "蛙飛びこむ", "水の音", "Matsuo Basho") #Haiku< 古池や 蛙飛びこむ 水の音 -- Matsuo Basho > """ |> String.replace("\n", "\r\n") def crlf_test, do: :ok defimpl Inspect do def inspect(haiku, _opts) do author = if haiku.author == "", do: "", else: "\n -- #{haiku.author}" """ #Haiku< #{haiku.first_phrase} #{haiku.second_phrase} #{haiku.third_phrase}#{author} > """ |> String.trim_trailing("\n") end end end |> ExUnit.BeamHelpers.write_beam() defmodule ExUnit.DocTestTest.PatternMatching do def starting_line, do: __ENV__.line + 2 @moduledoc """ The doctests below test pattern matching failures. iex> {1, 2}={1, 3} iex> tuple = {1, 3} iex> {1, 2} = tuple iex> "Hello, world" = "Hello world" iex> "Hello, " <> _ = "Hello world" iex> [:a | _] = [:b, :a] iex> atom = :a iex> [^atom | _] = [:b, :a] iex> %{b: _, d: :e} = %{a: :c, d: :e} iex> %{year: 2001, day: 1} = ~D[2000-01-01] iex> adder = fn int -> int + 1 end iex> num = ...> adder.(0) iex> {^num, _, _} = ...> # Comments can be here as well ...> ...> {adder.(0), adder.(1), :three} # false assertions do not accidentally raise iex> false = (List.flatten([]) != []) """ def doctest(), do: :ok end |> ExUnit.BeamHelpers.write_beam() defmodule ExUnit.DocTestTest do use ExUnit.Case # This is intentional. The doctests in DocTest's docs # fail for demonstration purposes. # doctest ExUnit.DocTest doctest ExUnit.DocTestTest.GoodModule, import: true doctest ExUnit.DocTestTest.SomewhatGoodModuleWithOnly, only: [one: 0], import: true doctest ExUnit.DocTestTest.SomewhatGoodModuleWithExcept, except: [:moduledoc, two: 0], import: true doctest ExUnit.DocTestTest.NoImport doctest ExUnit.DocTestTest.IndentationHeredocs doctest ExUnit.DocTestTest.FencedHeredocs doctest ExUnit.DocTestTest.Haiku import ExUnit.CaptureIO test "multiple functions filtered with :only" do defmodule MultipleOnly do use ExUnit.Case doctest ExUnit.DocTestTest.SomewhatGoodModuleWithOnly, only: [one: 0, two: 0], import: true end assert capture_io(fn -> ExUnit.run() end) =~ "2 doctests, 1 failure" end test "empty :only" do defmodule EmptyOnly do use ExUnit.Case doctest ExUnit.DocTestTest.SomewhatGoodModuleWithOnly, only: [], import: true end output = capture_io(fn -> ExUnit.run() end) assert output =~ "0 failures" refute output =~ "doctest" end test "allows users to tag doctests with configuration options" do defmodule TaggedTests do use ExUnit.Case doctest ExUnit.DocTestTest.SomewhatGoodModuleWithOnly, tags: [skip: true], import: true end output = capture_io(fn -> ExUnit.run() end) assert output =~ "0 failures" assert output =~ "2 skipped" end test "doctest failures" do # When adding or removing lines above this line, the tests below will # fail because we are explicitly asserting some doctest lines from # ActuallyCompiled in the format of "test/ex_unit/doc_test_test.exs:<LINE>". defmodule ActuallyCompiled do use ExUnit.Case doctest ExUnit.DocTestTest.Invalid end doctest_line = __ENV__.line - 3 starting_line = ExUnit.DocTestTest.Invalid.starting_line() + 2 ExUnit.configure(seed: 0, colors: [enabled: false]) output = capture_io(fn -> ExUnit.run() end) assert output =~ """ 1) doctest module ExUnit.DocTestTest.Invalid (1) (ExUnit.DocTestTest.ActuallyCompiled) test/ex_unit/doc_test_test.exs:#{doctest_line} Doctest did not compile, got: (SyntaxError) test/ex_unit/doc_test_test.exs:#{starting_line}:6: syntax error before: '*' #{line_placeholder(starting_line)} | #{starting_line} | 1 + * 1 #{line_placeholder(starting_line)} | ^ doctest: iex> 1 + * 1 1 stacktrace: test/ex_unit/doc_test_test.exs:#{starting_line}: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 2) doctest module ExUnit.DocTestTest.Invalid (2) (ExUnit.DocTestTest.ActuallyCompiled) test/ex_unit/doc_test_test.exs:#{doctest_line} Doctest failed doctest: iex> 1 + hd(List.flatten([1])) 3 code: 1 + hd(List.flatten([1])) === 3 left: 2 right: 3 stacktrace: test/ex_unit/doc_test_test.exs:#{starting_line + 3}: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 3) doctest module ExUnit.DocTestTest.Invalid (3) (ExUnit.DocTestTest.ActuallyCompiled) test/ex_unit/doc_test_test.exs:#{doctest_line} Doctest failed doctest: iex> a = "This is an egregiously long text string." iex> b = ~r{an egregiously long} iex> c = "a slightly shorter" iex> String.replace(a, b, c) "This is a much shorter text string." code: String.replace(a, b, c) === "This is a much shorter text string." left: "This is a slightly shorter text string." right: "This is a much shorter text string." stacktrace: test/ex_unit/doc_test_test.exs:#{starting_line + 6}: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 4) doctest module ExUnit.DocTestTest.Invalid (4) (ExUnit.DocTestTest.ActuallyCompiled) test/ex_unit/doc_test_test.exs:#{doctest_line} Doctest failed doctest: iex> :oops "#Inspect<[]>" code: inspect(:oops) === "#Inspect<[]>" left: ":oops" right: "#Inspect<[]>" stacktrace: test/ex_unit/doc_test_test.exs:#{starting_line + 12}: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 5) doctest module ExUnit.DocTestTest.Invalid (5) (ExUnit.DocTestTest.ActuallyCompiled) test/ex_unit/doc_test_test.exs:#{doctest_line} ** (UndefinedFunctionError) function Hello.world/0 is undefined (module Hello is not available) stacktrace: Hello.world() (for doctest at) test/ex_unit/doc_test_test.exs:#{starting_line + 15}: (test) """ assert output =~ """ 6) doctest module ExUnit.DocTestTest.Invalid (6) (ExUnit.DocTestTest.ActuallyCompiled) test/ex_unit/doc_test_test.exs:#{doctest_line} Doctest failed: expected exception WhatIsThis but got RuntimeError with message "oops" doctest: iex> raise "oops" ** (WhatIsThis) "oops" stacktrace: test/ex_unit/doc_test_test.exs:#{starting_line + 18}: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 7) doctest module ExUnit.DocTestTest.Invalid (7) (ExUnit.DocTestTest.ActuallyCompiled) test/ex_unit/doc_test_test.exs:#{doctest_line} Doctest failed: wrong message for RuntimeError expected: "hello" actual: "oops" doctest: iex> raise "oops" ** (RuntimeError) "hello" stacktrace: test/ex_unit/doc_test_test.exs:#{starting_line + 21}: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 8) doctest ExUnit.DocTestTest.Invalid.a/0 (8) (ExUnit.DocTestTest.ActuallyCompiled) test/ex_unit/doc_test_test.exs:#{doctest_line} Doctest did not compile, got: (SyntaxError) test/ex_unit/doc_test_test.exs:#{starting_line + 27}:6: syntax error before: '*' #{line_placeholder(starting_line + 27)} | #{starting_line + 27} | 1 + * 1 #{line_placeholder(starting_line + 27)} | ^ doctest: iex> 1 + * 1 1 stacktrace: test/ex_unit/doc_test_test.exs:#{starting_line + 27}: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 9) doctest ExUnit.DocTestTest.Invalid.dedented_past_fence/0 (9) (ExUnit.DocTestTest.ActuallyCompiled) test/ex_unit/doc_test_test.exs:#{doctest_line} Doctest did not compile, got: (SyntaxError) test/ex_unit/doc_test_test.exs:#{starting_line + 57}:5: unexpected token: "`" (column 5, code point U+0060) #{line_placeholder(starting_line + 57)} | #{starting_line + 57} | ``` #{line_placeholder(starting_line + 57)} | ^ doctest: iex> 1 + 2 3 ``` stacktrace: test/ex_unit/doc_test_test.exs:#{starting_line + 56}: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 10) doctest ExUnit.DocTestTest.Invalid.indented_not_enough/0 (10) (ExUnit.DocTestTest.ActuallyCompiled) test/ex_unit/doc_test_test.exs:#{doctest_line} Doctest did not compile, got: (SyntaxError) test/ex_unit/doc_test_test.exs:#{starting_line + 41}:1: unexpected token: "`" (column 1, code point U+0060) #{line_placeholder(starting_line + 41)} | #{starting_line + 41} | ` #{line_placeholder(starting_line + 41)} | ^ doctest: iex> 1 + 2 3 ` stacktrace: test/ex_unit/doc_test_test.exs:#{starting_line + 40}: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 11) doctest ExUnit.DocTestTest.Invalid.indented_too_much/0 (11) (ExUnit.DocTestTest.ActuallyCompiled) test/ex_unit/doc_test_test.exs:#{doctest_line} Doctest did not compile, got: (SyntaxError) test/ex_unit/doc_test_test.exs:#{starting_line + 49}:3: unexpected token: "`" (column 3, code point U+0060) #{line_placeholder(starting_line + 49)} | #{starting_line + 49} | ``` #{line_placeholder(starting_line + 49)} | ^ doctest: iex> 1 + 2 3 ``` stacktrace: test/ex_unit/doc_test_test.exs:#{starting_line + 48}: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 12) doctest ExUnit.DocTestTest.Invalid.invalid_utf8/0 (12) (ExUnit.DocTestTest.ActuallyCompiled) test/ex_unit/doc_test_test.exs:#{doctest_line} Doctest did not compile, got: (UnicodeConversionError) invalid encoding starting at <<255, 34, 41>> stacktrace: test/ex_unit/doc_test_test.exs:#{starting_line + 63}: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 13) doctest ExUnit.DocTestTest.Invalid.misplaced_opaque_type/0 (13) (ExUnit.DocTestTest.ActuallyCompiled) test/ex_unit/doc_test_test.exs:#{doctest_line} Doctest did not compile, got: (TokenMissingError) test/ex_unit/doc_test_test.exs:#{starting_line + 69}:7: missing terminator: } (for "{" starting at line #{starting_line + 69}) #{line_placeholder(starting_line + 69)} | #{starting_line + 69} | {:ok, #Inspect<[]>} #{line_placeholder(starting_line + 69)} | ^ If you are planning to assert on the result of an iex> expression which contains a value inspected as #Name<...>, please make sure the inspected value is placed at the beginning of the expression; otherwise Elixir will treat it as a comment due to the leading sign #. doctest: iex> {:ok, :oops} {:ok, #Inspect<[]>} stacktrace: test/ex_unit/doc_test_test.exs:#{starting_line + 69}: ExUnit.DocTestTest.Invalid (module) """ assert output =~ "14) doctest ExUnit.DocTestTest.Invalid.raising_inspect/0" assert output =~ "iex> ExUnit.DocTestTest.Haiku.new(:this, :is, {:not, :a, :haiku})" assert output =~ "test/ex_unit/doc_test_test.exs:#{starting_line + 82}: ExUnit.DocTestTest.Invalid (module)" assert output =~ """ 15) doctest ExUnit.DocTestTest.Invalid.b/0 (15) (ExUnit.DocTestTest.ActuallyCompiled) test/ex_unit/doc_test_test.exs:#{doctest_line} Doctest did not compile, got: (SyntaxError) test/ex_unit/doc_test_test.exs:#{starting_line + 33}:6: syntax error before: '*' #{line_placeholder(starting_line + 33)} | #{starting_line + 33} | 1 + * 1 #{line_placeholder(starting_line + 33)} | ^ doctest: iex> 1 + * 1 1 stacktrace: test/ex_unit/doc_test_test.exs:#{starting_line + 33}: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 16) doctest ExUnit.DocTestTest.Invalid.t/0 (16) (ExUnit.DocTestTest.ActuallyCompiled) test/ex_unit/doc_test_test.exs:#{doctest_line} Doctest did not compile, got: (SyntaxError) test/ex_unit/doc_test_test.exs:#{starting_line + 75}:6: syntax error before: '*' #{line_placeholder(starting_line + 75)} | #{starting_line + 75} | 1 + * 1 #{line_placeholder(starting_line + 75)} | ^ doctest: iex> 1 + * 1 1 stacktrace: test/ex_unit/doc_test_test.exs:#{starting_line + 75}: ExUnit.DocTestTest.Invalid (module) """ end test "pattern matching assertions in doctests" do defmodule PatternMatchingRunner do use ExUnit.Case doctest ExUnit.DocTestTest.PatternMatching, import: true end doctest_line = __ENV__.line - 3 starting_line = ExUnit.DocTestTest.PatternMatching.starting_line() ExUnit.configure(seed: 0, colors: [enabled: false]) output = capture_io(fn -> ExUnit.run() end) assert output =~ """ 1) doctest module ExUnit.DocTestTest.PatternMatching (1) (ExUnit.DocTestTest.PatternMatchingRunner) test/ex_unit/doc_test_test.exs:#{doctest_line} match (=) failed code: {1, 2} = {1, 3} left: {1, 2} right: {1, 3} stacktrace: (for doctest at) test/ex_unit/doc_test_test.exs:#{starting_line + 3}: (test) """ assert output =~ """ 2) doctest module ExUnit.DocTestTest.PatternMatching (2) (ExUnit.DocTestTest.PatternMatchingRunner) test/ex_unit/doc_test_test.exs:#{doctest_line} match (=) failed code: {1, 2} = tuple left: {1, 2} right: {1, 3} stacktrace: (for doctest at) test/ex_unit/doc_test_test.exs:#{starting_line + 6}: (test) """ assert output =~ """ 3) doctest module ExUnit.DocTestTest.PatternMatching (3) (ExUnit.DocTestTest.PatternMatchingRunner) test/ex_unit/doc_test_test.exs:#{doctest_line} match (=) failed code: "Hello, world" = "Hello world" left: "Hello, world" right: "Hello world" stacktrace: (for doctest at) test/ex_unit/doc_test_test.exs:#{starting_line + 8}: (test) """ assert output =~ """ 4) doctest module ExUnit.DocTestTest.PatternMatching (4) (ExUnit.DocTestTest.PatternMatchingRunner) test/ex_unit/doc_test_test.exs:#{doctest_line} match (=) failed code: "Hello, " <> _ = "Hello world" left: "Hello, " <> _ right: "Hello world" stacktrace: (for doctest at) test/ex_unit/doc_test_test.exs:#{starting_line + 10}: (test) """ assert output =~ """ 5) doctest module ExUnit.DocTestTest.PatternMatching (5) (ExUnit.DocTestTest.PatternMatchingRunner) test/ex_unit/doc_test_test.exs:#{doctest_line} match (=) failed code: [:a | _] = [:b, :a] left: [:a | _] right: [:b, :a] stacktrace: (for doctest at) test/ex_unit/doc_test_test.exs:#{starting_line + 12}: (test) """ assert output =~ """ 6) doctest module ExUnit.DocTestTest.PatternMatching (6) (ExUnit.DocTestTest.PatternMatchingRunner) test/ex_unit/doc_test_test.exs:#{doctest_line} match (=) failed The following variables were pinned: atom = :a code: [^atom | _] = [:b, :a] left: [^atom | _] right: [:b, :a] stacktrace: (for doctest at) test/ex_unit/doc_test_test.exs:#{starting_line + 15}: (test) """ assert output =~ """ 7) doctest module ExUnit.DocTestTest.PatternMatching (7) (ExUnit.DocTestTest.PatternMatchingRunner) test/ex_unit/doc_test_test.exs:#{doctest_line} match (=) failed code: %{b: _, d: :e} = %{a: :c, d: :e} left: %{b: _, d: :e} right: %{a: :c, d: :e} stacktrace: (for doctest at) test/ex_unit/doc_test_test.exs:#{starting_line + 17}: (test) """ assert output =~ """ 8) doctest module ExUnit.DocTestTest.PatternMatching (8) (ExUnit.DocTestTest.PatternMatchingRunner) test/ex_unit/doc_test_test.exs:#{doctest_line} match (=) failed code: %{year: 2001, day: 1} = ~D"2000-01-01" left: %{year: 2001, day: 1} right: ~D[2000-01-01] stacktrace: (for doctest at) test/ex_unit/doc_test_test.exs:#{starting_line + 19}: (test) """ assert output =~ "10 doctests, 8 failures" end test "IEx prefix contains a number" do defmodule NumberedUsage do use ExUnit.Case doctest ExUnit.DocTestTest.Numbered end assert capture_io(fn -> ExUnit.run() end) =~ "1 doctest, 0 failures" end test "IEx prompt contains host" do message = ~s[unknown IEx prompt: "iex(foo@bar)1> 1 +".\nAccepted formats are: iex>, iex(1)>, ...>, ...(1)>] regex = ~r[test/ex_unit/doc_test_test\.exs:\d+: #{Regex.escape(message)}] assert_raise ExUnit.DocTest.Error, regex, fn -> defmodule HostUsage do use ExUnit.Case doctest ExUnit.DocTestTest.Host end end end test "doctests type" do defmodule DoctestType do use ExUnit.Case doctest ExUnit.DocTestTest.NoImport setup test do assert test.test_type == :doctest :ok end end assert capture_io(fn -> ExUnit.run() end) =~ "2 doctests, 0 failures" end test "multiple exceptions in one test case is not supported" do message = ~r"multiple exceptions in the same doctest example are not supported" assert_raise ExUnit.DocTest.Error, message, fn -> defmodule NeverCompiled do import ExUnit.DocTest doctest ExUnit.DocTestTest.MultipleExceptions end end end test "fails on invalid module" do message = ~r"module ExUnit\.DocTestTest\.Unknown is not loaded and could not be found" assert_raise CompileError, message, fn -> defmodule NeverCompiled do import ExUnit.DocTest doctest ExUnit.DocTestTest.Unknown end end end test "fails when testing single function not found" do message = """ test/ex_unit/doc_test_test\.exs: undefined or private function given to doctest: ExUnit.DocTestTest.SomewhatGoodModuleWithOnly.three/0 """ assert_raise ExUnit.DocTest.Error, message, fn -> defmodule NeverCompiled do import ExUnit.DocTest doctest ExUnit.DocTestTest.SomewhatGoodModuleWithOnly, only: [three: 0], import: true end end end test "fails when testing multiple functions not found" do message = """ test/ex_unit/doc_test_test\.exs: undefined or private functions given to doctest: ExUnit.DocTestTest.SomewhatGoodModuleWithOnly.three/0 ExUnit.DocTestTest.SomewhatGoodModuleWithOnly.four/1 """ assert_raise ExUnit.DocTest.Error, message, fn -> defmodule NeverCompiled do import ExUnit.DocTest doctest ExUnit.DocTestTest.SomewhatGoodModuleWithOnly, only: [three: 0, four: 1], import: true end end end test "fails when there are no docs" do message = ~r"could not retrieve the documentation for module ExUnit\.DocTestTest" assert_raise ExUnit.DocTest.Error, message, fn -> defmodule NeverCompiled do import ExUnit.DocTest doctest ExUnit.DocTestTest end end end test "fails in indentation mismatch" do message = ~r[test/ex_unit/doc_test_test\.exs:\d+: indentation level mismatch on doctest line: \" iex> bar = 2\".*is exactly 2 spaces]s assert_raise ExUnit.DocTest.Error, message, fn -> defmodule NeverCompiled do import ExUnit.DocTest doctest ExUnit.DocTestTest.IndentationMismatchedPrompt end end message = ~r[test/ex_unit/doc_test_test\.exs:\d+: indentation level mismatch on doctest line: \" 3\".*is exactly 2 spaces]s assert_raise ExUnit.DocTest.Error, message, fn -> defmodule NeverCompiled do import ExUnit.DocTest doctest ExUnit.DocTestTest.IndentationTooMuch end end message = ~r[test/ex_unit/doc_test_test\.exs:\d+: indentation level mismatch on doctest line: \" 3\".*is exactly 4 spaces]s assert_raise ExUnit.DocTest.Error, message, fn -> defmodule NeverCompiled do import ExUnit.DocTest doctest ExUnit.DocTestTest.IndentationNotEnough end end end test "fails on invalid use" do assert_raise RuntimeError, ~r"cannot define doctest", fn -> defmodule FunctionClashFail do import ExUnit.DocTest doctest ExUnit.DocTestTest.Invalid end end end defp line_placeholder(line_number) do digits = line_number |> Integer.digits() |> length() String.duplicate(" ", digits) end end
29.980981
283
0.578912
9e7fbb0f201820ae954c57004decb4025582cbce
46
exs
Elixir
config/test.exs
kelvinst/httpill
7094c7582b0caf52eb949f6e40ba23aa66a7f136
[ "MIT" ]
1
2017-10-04T13:27:53.000Z
2017-10-04T13:27:53.000Z
config/test.exs
kelvinst/httpill
7094c7582b0caf52eb949f6e40ba23aa66a7f136
[ "MIT" ]
5
2017-08-15T00:13:02.000Z
2017-08-16T20:41:12.000Z
config/test.exs
kelvinst/httpill
7094c7582b0caf52eb949f6e40ba23aa66a7f136
[ "MIT" ]
null
null
null
use Mix.Config config :logger, level: :warn
9.2
28
0.717391
9e7fd99b2c03172ffbbf6db2d25f094c8522563c
60
exs
Elixir
config/test.exs
trojanh/slack-bot-test
763e3722b39cb2aeaf57b2e7c49d92f0c97a4fcf
[ "MIT" ]
3
2017-03-14T12:26:35.000Z
2022-02-19T20:17:09.000Z
config/test.exs
trojanh/slack-bot-test
763e3722b39cb2aeaf57b2e7c49d92f0c97a4fcf
[ "MIT" ]
2
2018-01-08T11:37:51.000Z
2018-01-08T12:43:16.000Z
config/test.exs
trojanh/slack-bot-test
763e3722b39cb2aeaf57b2e7c49d92f0c97a4fcf
[ "MIT" ]
2
2017-09-30T17:07:41.000Z
2018-01-08T11:20:38.000Z
use Mix.Config config :tasker, enable_tasker_worker: false
15
43
0.816667
9e800c6c73930e36e0c067b2ed1f44ad3fb5a7e7
466
ex
Elixir
lib/stripe_callbacks/worker.ex
aforward/stripe-callbacks
e9ba4a9ad2762f6b4024f346f0511d5de5152057
[ "MIT" ]
1
2019-03-14T18:56:43.000Z
2019-03-14T18:56:43.000Z
lib/stripe_callbacks/worker.ex
aforward/stripe-callbacks
e9ba4a9ad2762f6b4024f346f0511d5de5152057
[ "MIT" ]
null
null
null
lib/stripe_callbacks/worker.ex
aforward/stripe-callbacks
e9ba4a9ad2762f6b4024f346f0511d5de5152057
[ "MIT" ]
null
null
null
defmodule StripeCallbacks.Worker do use GenServer ### Public API def start_link() do {:ok, _pid} = GenServer.start_link(__MODULE__, [], name: __MODULE__) end def process(data) do GenServer.call(StripeCallbacks.Worker, {:process, data}) end ### Server Callbacks def init() do {:ok, {}} end def handle_call({:process, data}, _from, state) do answer = StripeCallbacks.Token.process(data) {:reply, answer, state} end end
17.923077
72
0.66309
9e80671abbc3accb729d50028574cf200d3fa886
1,208
ex
Elixir
apps/shopping_web/lib/shopping_web/live/checklist_live/index.ex
paulanthonywilson/shopping
11870c4d70b04fb139908793102ce3917d189275
[ "MIT" ]
null
null
null
apps/shopping_web/lib/shopping_web/live/checklist_live/index.ex
paulanthonywilson/shopping
11870c4d70b04fb139908793102ce3917d189275
[ "MIT" ]
null
null
null
apps/shopping_web/lib/shopping_web/live/checklist_live/index.ex
paulanthonywilson/shopping
11870c4d70b04fb139908793102ce3917d189275
[ "MIT" ]
null
null
null
defmodule ShoppingWeb.ChecklistLive.Index do @moduledoc """ Lists checklists """ use ShoppingWeb, :live_view alias Shopping.Checklists alias Shopping.Checklists.Checklist @impl true def mount(_params, _session, socket) do {:ok, assign(socket, :checklists, list_checklists())} end @impl true def handle_params(params, _url, socket) do {:noreply, apply_action(socket, socket.assigns.live_action, params)} end defp apply_action(socket, :edit, %{"id" => id}) do socket |> assign(:page_title, "Change name") |> assign(:checklist, Checklists.get_checklist!(id)) end defp apply_action(socket, :new, _params) do socket |> assign(:page_title, "New Checklist") |> assign(:checklist, %Checklist{}) end defp apply_action(socket, :index, _params) do socket |> assign(:page_title, "Checklists") |> assign(:checklist, nil) end @impl true def handle_event("delete", %{"id" => id}, socket) do checklist = Checklists.get_checklist!(id) {:ok, _} = Checklists.delete_checklist(checklist) {:noreply, assign(socket, :checklists, list_checklists())} end defp list_checklists do Checklists.list_checklists() end end
23.686275
72
0.683775
9e808c1e571e7a08e9e08f4c70325375ec7e268b
2,087
ex
Elixir
clients/dfa_reporting/lib/google_api/dfa_reporting/v33/model/placement_groups_list_response.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
1
2018-12-03T23:43:10.000Z
2018-12-03T23:43:10.000Z
clients/dfa_reporting/lib/google_api/dfa_reporting/v33/model/placement_groups_list_response.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
clients/dfa_reporting/lib/google_api/dfa_reporting/v33/model/placement_groups_list_response.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # 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 License is distributed on an &quot;AS IS&quot; BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the elixir code generator program. # Do not edit the class manually. defmodule GoogleApi.DFAReporting.V33.Model.PlacementGroupsListResponse do @moduledoc """ Placement Group List Response ## Attributes * `kind` (*type:* `String.t`, *default:* `dfareporting#placementGroupsListResponse`) - Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementGroupsListResponse". * `nextPageToken` (*type:* `String.t`, *default:* `nil`) - Pagination token to be used for the next list operation. * `placementGroups` (*type:* `list(GoogleApi.DFAReporting.V33.Model.PlacementGroup.t)`, *default:* `nil`) - Placement group collection. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :kind => String.t(), :nextPageToken => String.t(), :placementGroups => list(GoogleApi.DFAReporting.V33.Model.PlacementGroup.t()) } field(:kind) field(:nextPageToken) field(:placementGroups, as: GoogleApi.DFAReporting.V33.Model.PlacementGroup, type: :list) end defimpl Poison.Decoder, for: GoogleApi.DFAReporting.V33.Model.PlacementGroupsListResponse do def decode(value, options) do GoogleApi.DFAReporting.V33.Model.PlacementGroupsListResponse.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.DFAReporting.V33.Model.PlacementGroupsListResponse do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
39.377358
200
0.74413
9e808cd62d49b94e63b98a46bb0797c334959a8f
53
ex
Elixir
lib/web/views/connection_view.ex
stevegrossi/ex_venture
e02d5a63fdb882d92cfb4af3e15f7b48ad7054aa
[ "MIT" ]
2
2019-05-14T11:36:44.000Z
2020-07-01T08:54:04.000Z
lib/web/views/connection_view.ex
nickwalton/ex_venture
d8ff1b0181db03f9ddcb7610ae7ab533feecbfbb
[ "MIT" ]
null
null
null
lib/web/views/connection_view.ex
nickwalton/ex_venture
d8ff1b0181db03f9ddcb7610ae7ab533feecbfbb
[ "MIT" ]
1
2021-01-29T14:12:40.000Z
2021-01-29T14:12:40.000Z
defmodule Web.ConnectionView do use Web, :view end
13.25
31
0.773585
9e809e57f433137bce2dc39ac7ef2bf5407664aa
155
ex
Elixir
vendor/ex_brace_expansion/ex_brace_expansion/concat_map.ex
isshindev/accent
ae4c13139b0a0dfd64ff536b94c940a4e2862150
[ "BSD-3-Clause" ]
806
2018-04-07T20:40:33.000Z
2022-03-30T01:39:57.000Z
vendor/ex_brace_expansion/ex_brace_expansion/concat_map.ex
isshindev/accent
ae4c13139b0a0dfd64ff536b94c940a4e2862150
[ "BSD-3-Clause" ]
194
2018-04-07T13:49:37.000Z
2022-03-30T19:58:45.000Z
vendor/ex_brace_expansion/ex_brace_expansion/concat_map.ex
isshindev/accent
ae4c13139b0a0dfd64ff536b94c940a4e2862150
[ "BSD-3-Clause" ]
89
2018-04-09T13:55:49.000Z
2022-03-24T07:09:31.000Z
defmodule ExBraceExpansion.ConcatMap do def concat_map(coll, func) do coll |> Enum.map(fn val -> func.(val) end) |> List.flatten end end
15.5
41
0.658065
9e80c323390bfd750bda729529ac2eef58f8d7da
1,139
exs
Elixir
clients/service_broker/config/config.exs
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
1
2018-12-03T23:43:10.000Z
2018-12-03T23:43:10.000Z
clients/service_broker/config/config.exs
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
clients/service_broker/config/config.exs
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
# This file is responsible for configuring your application # and its dependencies with the aid of the Mix.Config module. use Mix.Config # This configuration is loaded before any dependency and is restricted # to this project. If another project depends on this project, this # file won't be loaded nor affect the parent project. For this reason, # if you want to provide default values for your application for # 3rd-party users, it should be done in your "mix.exs" file. # You can configure for your application as: # # config :service_broker_api, key: :value # # And access this configuration in your application as: # # Application.get_env(:service_broker_api, :key) # # Or configure a 3rd-party app: # # config :logger, level: :info # # It is also possible to import configuration files, relative to this # directory. For example, you can emulate configuration per environment # by uncommenting the line below and defining dev.exs, test.exs and such. # Configuration from the imported file will override the ones defined # here (which is why it is important to import them last). # # import_config "#{Mix.env}.exs"
36.741935
73
0.755926
9e810717cc10cc5313f3958308c155ba9da09888
65
ex
Elixir
web/views/page_view.ex
robvandenbogaard/elm-blogger
53ba88e125c9ddf90a5e5e5a0b68914bf6d81003
[ "BSD-3-Clause" ]
19
2017-02-26T10:18:00.000Z
2022-01-18T18:21:28.000Z
web/views/page_view.ex
robvandenbogaard/elm-blogger
53ba88e125c9ddf90a5e5e5a0b68914bf6d81003
[ "BSD-3-Clause" ]
1
2017-10-29T22:37:47.000Z
2017-10-29T22:37:47.000Z
web/views/page_view.ex
robvandenbogaard/elm-blogger
53ba88e125c9ddf90a5e5e5a0b68914bf6d81003
[ "BSD-3-Clause" ]
4
2017-08-07T23:33:01.000Z
2020-02-27T12:36:25.000Z
defmodule ElmBlogger.PageView do use ElmBlogger.Web, :view end
16.25
32
0.8
9e811fc7773fab2d39b5aaf3951e2bb05a121a01
1,539
exs
Elixir
dh11_live_view_ui/mix.exs
ayarhlaine/dh11_live_view
e52aebc14d7667772bd314f0a147347be0afb599
[ "MIT" ]
null
null
null
dh11_live_view_ui/mix.exs
ayarhlaine/dh11_live_view
e52aebc14d7667772bd314f0a147347be0afb599
[ "MIT" ]
null
null
null
dh11_live_view_ui/mix.exs
ayarhlaine/dh11_live_view
e52aebc14d7667772bd314f0a147347be0afb599
[ "MIT" ]
null
null
null
defmodule Dh11LiveViewUi.MixProject do use Mix.Project def project do [ app: :dh11_live_view_ui, version: "0.1.0", elixir: "~> 1.7", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(), start_permanent: Mix.env() == :prod, aliases: aliases(), deps: deps() ] end # Configuration for the OTP application. # # Type `mix help compile.app` for more information. def application do [ mod: {Dh11LiveViewUi.Application, []}, extra_applications: [:logger, :runtime_tools] ] end # Specifies which paths to compile per environment. defp elixirc_paths(:test), do: ["lib", "test/support"] defp elixirc_paths(_), do: ["lib"] # Specifies your project dependencies. # # Type `mix help deps` for examples and options. defp deps do [ {:phoenix, "~> 1.5.9"}, {:phoenix_html, "~> 2.11"}, {:phoenix_live_reload, "~> 1.2", only: :dev}, {:phoenix_live_dashboard, "~> 0.4"}, {:telemetry_metrics, "~> 0.4"}, {:telemetry_poller, "~> 0.4"}, {:gettext, "~> 0.11"}, {:jason, "~> 1.0"}, {:plug_cowboy, "~> 2.0"}, {:poison, "~> 5.0"} ] end # Aliases are shortcuts or tasks specific to the current project. # For example, to install project dependencies and perform other setup tasks, run: # # $ mix setup # # See the documentation for `Mix` for more info on aliases. defp aliases do [ setup: ["deps.get"] ] end end
25.229508
84
0.590643
9e81296e5449c93f9442a4b2234dfc84861aaddc
6,232
exs
Elixir
test/yourbot_web/controllers/user_auth_test.exs
ConnorRigby/yourbot
eea40e63b0f93963ed14b7efab9ecbe898ab11dd
[ "Apache-2.0" ]
3
2021-11-08T15:19:19.000Z
2021-11-11T03:18:35.000Z
test/yourbot_web/controllers/user_auth_test.exs
ConnorRigby/yourbot
eea40e63b0f93963ed14b7efab9ecbe898ab11dd
[ "Apache-2.0" ]
null
null
null
test/yourbot_web/controllers/user_auth_test.exs
ConnorRigby/yourbot
eea40e63b0f93963ed14b7efab9ecbe898ab11dd
[ "Apache-2.0" ]
null
null
null
defmodule YourBotWeb.UserAuthTest do use YourBotWeb.ConnCase, async: true alias YourBot.Accounts alias YourBotWeb.UserAuth import YourBot.AccountsFixtures @remember_me_cookie "_your_bot_web_user_remember_me" setup %{conn: conn} do conn = conn |> Map.replace!(:secret_key_base, YourBotWeb.Endpoint.config(:secret_key_base)) |> init_test_session(%{}) %{user: user_fixture(), conn: conn} end describe "log_in_user/3" do test "stores the user token in the session", %{conn: conn, user: user} do conn = UserAuth.log_in_user(conn, user) assert token = get_session(conn, :user_token) assert get_session(conn, :live_socket_id) == "users_sessions:#{Base.url_encode64(token)}" assert redirected_to(conn) == "/" assert Accounts.get_user_by_session_token(token) end test "clears everything previously stored in the session", %{conn: conn, user: user} do conn = conn |> put_session(:to_be_removed, "value") |> UserAuth.log_in_user(user) refute get_session(conn, :to_be_removed) end test "redirects to the configured path", %{conn: conn, user: user} do conn = conn |> put_session(:user_return_to, "/hello") |> UserAuth.log_in_user(user) assert redirected_to(conn) == "/hello" end test "writes a cookie if remember_me is configured", %{conn: conn, user: user} do conn = conn |> fetch_cookies() |> UserAuth.log_in_user(user, %{"remember_me" => "true"}) assert get_session(conn, :user_token) == conn.cookies[@remember_me_cookie] assert %{value: signed_token, max_age: max_age} = conn.resp_cookies[@remember_me_cookie] assert signed_token != get_session(conn, :user_token) assert max_age == 5_184_000 end end describe "logout_user/1" do test "erases session and cookies", %{conn: conn, user: user} do user_token = Accounts.generate_user_session_token(user) conn = conn |> put_session(:user_token, user_token) |> put_req_cookie(@remember_me_cookie, user_token) |> fetch_cookies() |> UserAuth.log_out_user() refute get_session(conn, :user_token) refute conn.cookies[@remember_me_cookie] assert %{max_age: 0} = conn.resp_cookies[@remember_me_cookie] assert redirected_to(conn) == "/" refute Accounts.get_user_by_session_token(user_token) end test "broadcasts to the given live_socket_id", %{conn: conn} do live_socket_id = "users_sessions:abcdef-token" YourBotWeb.Endpoint.subscribe(live_socket_id) conn |> put_session(:live_socket_id, live_socket_id) |> UserAuth.log_out_user() assert_receive %Phoenix.Socket.Broadcast{event: "disconnect", topic: ^live_socket_id} end test "works even if user is already logged out", %{conn: conn} do conn = conn |> fetch_cookies() |> UserAuth.log_out_user() refute get_session(conn, :user_token) assert %{max_age: 0} = conn.resp_cookies[@remember_me_cookie] assert redirected_to(conn) == "/" end end describe "fetch_current_user/2" do test "authenticates user from session", %{conn: conn, user: user} do user_token = Accounts.generate_user_session_token(user) conn = conn |> put_session(:user_token, user_token) |> UserAuth.fetch_current_user([]) assert conn.assigns.current_user.id == user.id end test "authenticates user from cookies", %{conn: conn, user: user} do logged_in_conn = conn |> fetch_cookies() |> UserAuth.log_in_user(user, %{"remember_me" => "true"}) user_token = logged_in_conn.cookies[@remember_me_cookie] %{value: signed_token} = logged_in_conn.resp_cookies[@remember_me_cookie] conn = conn |> put_req_cookie(@remember_me_cookie, signed_token) |> UserAuth.fetch_current_user([]) assert get_session(conn, :user_token) == user_token assert conn.assigns.current_user.id == user.id end test "does not authenticate if data is missing", %{conn: conn, user: user} do _ = Accounts.generate_user_session_token(user) conn = UserAuth.fetch_current_user(conn, []) refute get_session(conn, :user_token) refute conn.assigns.current_user end end describe "redirect_if_user_is_authenticated/2" do test "redirects if user is authenticated", %{conn: conn, user: user} do conn = conn |> assign(:current_user, user) |> UserAuth.redirect_if_user_is_authenticated([]) assert conn.halted assert redirected_to(conn) == "/" end test "does not redirect if user is not authenticated", %{conn: conn} do conn = UserAuth.redirect_if_user_is_authenticated(conn, []) refute conn.halted refute conn.status end end describe "require_authenticated_user/2" do test "redirects if user is not authenticated", %{conn: conn} do conn = conn |> fetch_flash() |> UserAuth.require_authenticated_user([]) assert conn.halted assert redirected_to(conn) == YourBotWeb.OAuth.Discord.login_url() assert get_flash(conn, :error) == "You must log in to access this page." end test "stores the path to redirect to on GET", %{conn: conn} do halted_conn = %{conn | path_info: ["foo"], query_string: ""} |> fetch_flash() |> UserAuth.require_authenticated_user([]) assert halted_conn.halted assert get_session(halted_conn, :user_return_to) == "/foo" halted_conn = %{conn | path_info: ["foo"], query_string: "bar=baz"} |> fetch_flash() |> UserAuth.require_authenticated_user([]) assert halted_conn.halted assert get_session(halted_conn, :user_return_to) == "/foo?bar=baz" halted_conn = %{conn | path_info: ["foo"], query_string: "bar", method: "POST"} |> fetch_flash() |> UserAuth.require_authenticated_user([]) assert halted_conn.halted refute get_session(halted_conn, :user_return_to) end test "does not redirect if user is authenticated", %{conn: conn, user: user} do conn = conn |> assign(:current_user, user) |> UserAuth.require_authenticated_user([]) refute conn.halted refute conn.status end end end
36.444444
98
0.676508
9e813f8929ccc20a09717257c85a1cffebc2ff72
265
ex
Elixir
lib/request.ex
rockerBOO/hacker_news
326e02fa5ae7de0e2b2ffe6a360641514179d314
[ "MIT" ]
null
null
null
lib/request.ex
rockerBOO/hacker_news
326e02fa5ae7de0e2b2ffe6a360641514179d314
[ "MIT" ]
null
null
null
lib/request.ex
rockerBOO/hacker_news
326e02fa5ae7de0e2b2ffe6a360641514179d314
[ "MIT" ]
null
null
null
defmodule HackerNews.Request do @moduledoc """ HTTP Request module """ use HTTPoison.Base def process_url(url) do "https://hacker-news.firebaseio.com/v0/#{url}.json" end def process_response_body(body) do body |> Poison.decode!() end end
17.666667
55
0.683019
9e815d4cd33b3b99f6cc40eac9f63f5a5faf6fa1
261
ex
Elixir
lib/secret_grinch.ex
clorofila-league/secret_grinch
b06ac85ff5f06d5405d190ccc9966b01f0406b87
[ "Apache-2.0" ]
3
2017-08-03T16:49:18.000Z
2018-10-03T03:30:26.000Z
lib/secret_grinch.ex
clorofila-league/secret_grinch
b06ac85ff5f06d5405d190ccc9966b01f0406b87
[ "Apache-2.0" ]
18
2017-08-04T12:43:08.000Z
2017-08-05T14:15:41.000Z
lib/secret_grinch.ex
clorofila-league/secret_grinch
b06ac85ff5f06d5405d190ccc9966b01f0406b87
[ "Apache-2.0" ]
1
2018-10-03T03:30:29.000Z
2018-10-03T03:30:29.000Z
defmodule SecretGrinch do @moduledoc """ SecretGrinch keeps the contexts that define your domain and business logic. Contexts are also responsible for managing your data, regardless if it comes from the database, an external API or others. """ end
26.1
66
0.762452
9e8175f7345ab6288d25d8f9a22ba91eaaacaed6
1,035
exs
Elixir
config/config.exs
MishaConway/resque-web-squared
dbc0d119cb667561867d642edab20197057f1515
[ "MIT" ]
null
null
null
config/config.exs
MishaConway/resque-web-squared
dbc0d119cb667561867d642edab20197057f1515
[ "MIT" ]
null
null
null
config/config.exs
MishaConway/resque-web-squared
dbc0d119cb667561867d642edab20197057f1515
[ "MIT" ]
null
null
null
# This file is responsible for configuring your application # and its dependencies with the aid of the Mix.Config module. # # This configuration file is loaded before any dependency and # is restricted to this project. use Mix.Config config :resque, host: "redis", port: 6379, namespace: "resque", db: 2 # General application configuration config :resque_web_potion, [] # Configures the endpoint config :resque_web_potion, ResqueWebPotionWeb.Endpoint, url: [host: "localhost"], secret_key_base: "0wvGKDe0HhbdbyXwT5MW1MWjj2AyC6yvI9O4jOEaktKxP9vzypPwFevHEtVCOlt4", render_errors: [view: ResqueWebPotionWeb.ErrorView, accepts: ~w(html json)], pubsub: [name: ResqueWebPotion.PubSub, adapter: Phoenix.PubSub.PG2] # Configures Elixir's Logger config :logger, :console, format: "$time $metadata[$level] $message\n", metadata: [:request_id] # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env}.exs"
29.571429
86
0.75942
9e81907c53365e0e2be648331a6f06d515104518
2,975
ex
Elixir
lib/strategy/erlang_hosts.ex
polyglot-concurrency/libcluster
1a0640f2b39adc430a121add01ab2ae0a4ee35b2
[ "MIT" ]
1,571
2016-09-30T20:38:30.000Z
2022-03-31T15:06:38.000Z
lib/strategy/erlang_hosts.ex
polyglot-concurrency/libcluster
1a0640f2b39adc430a121add01ab2ae0a4ee35b2
[ "MIT" ]
140
2016-10-11T10:03:06.000Z
2022-03-18T21:06:32.000Z
lib/strategy/erlang_hosts.ex
polyglot-concurrency/libcluster
1a0640f2b39adc430a121add01ab2ae0a4ee35b2
[ "MIT" ]
167
2016-10-24T09:47:16.000Z
2022-03-15T11:59:50.000Z
defmodule Cluster.Strategy.ErlangHosts do @moduledoc """ This clustering strategy relies on Erlang's built-in distribution protocol by using a `.hosts.erlang` file (as used by the `:net_adm` module). Please see [the net_adm docs](http://erlang.org/doc/man/net_adm.html) for more details. In short, the following is the gist of how it works: > File `.hosts.erlang` consists of a number of host names written as Erlang terms. It is looked for in the current work > directory, the user's home directory, and $OTP_ROOT (the root directory of Erlang/OTP), in that order. This looks a bit like the following in practice: ```erlang 'super.eua.ericsson.se'. 'renat.eua.ericsson.se'. 'grouse.eua.ericsson.se'. 'gauffin1.eua.ericsson.se'. ``` You can have `libcluster` automatically connect nodes on startup for you by configuring the strategy like below: config :libcluster, topologies: [ erlang_hosts_example: [ strategy: #{__MODULE__}, config: [timeout: 30_000] ] ] An optional timeout can be specified in the config. This is the timeout that will be used in the GenServer to connect the nodes. This defaults to `:infinity` meaning that the connection process will only happen when the worker is started. Any integer timeout will result in the connection process being triggered. In the example above, it has been configured for 30 seconds. """ use GenServer use Cluster.Strategy alias Cluster.Strategy.State def start_link([%State{topology: topology} = state]) do case :net_adm.host_file() do {:error, _} -> Cluster.Logger.warn(topology, "couldn't find .hosts.erlang file - not joining cluster") :ignore file -> new_state = %State{state | :meta => file} GenServer.start_link(__MODULE__, [new_state]) end end @impl true def init([state]) do new_state = connect_hosts(state) {:ok, new_state, configured_timeout(new_state)} end @impl true def handle_info(:timeout, state) do handle_info(:connect, state) end def handle_info(:connect, state) do new_state = connect_hosts(state) {:noreply, new_state, configured_timeout(new_state)} end defp configured_timeout(%State{config: config}) do Keyword.get(config, :timeout, :infinity) end defp connect_hosts(%State{meta: hosts_file} = state) do nodes = hosts_file |> Enum.map(&{:net_adm.names(&1), &1}) |> gather_node_names([]) |> List.delete(node()) Cluster.Strategy.connect_nodes(state.topology, state.connect, state.list_nodes, nodes) state end defp gather_node_names([], acc), do: acc defp gather_node_names([{{:ok, names}, host} | rest], acc) do names = Enum.map(names, fn {name, _} -> String.to_atom("#{name}@#{host}") end) gather_node_names(rest, names ++ acc) end defp gather_node_names([_ | rest], acc), do: gather_node_names(rest, acc) end
30.670103
121
0.684034
9e81f07a7d33f026978be3e882180c39adf8503c
2,755
ex
Elixir
lib/tirexs/elastic_search.ex
brightroll/tirexs
7bddd93c11a852ade2747c478bd2cebbc6932d50
[ "Apache-2.0" ]
null
null
null
lib/tirexs/elastic_search.ex
brightroll/tirexs
7bddd93c11a852ade2747c478bd2cebbc6932d50
[ "Apache-2.0" ]
null
null
null
lib/tirexs/elastic_search.ex
brightroll/tirexs
7bddd93c11a852ade2747c478bd2cebbc6932d50
[ "Apache-2.0" ]
null
null
null
defmodule Tirexs.ElasticSearch do @doc """ This module provides a simple convenience for connection options such as `port`, `uri`, `user`, `pass` and functions for doing a `HTTP` request to `ElasticSearch` engine directly. """ defrecord Config, [port: 9200, uri: "127.0.0.1", user: nil, pass: nil] @doc false def get(query_url, config) do do_request(make_url(query_url, config), :get) end @doc false def put(query_url, config), do: put(query_url, [], config) def put(query_url, body, config) do unless body == [], do: body = to_string(body) do_request(make_url(query_url, config), :put, body) end @doc false def delete(query_url, config), do: delete(query_url, [], config) @doc false def delete(query_url, _body, config) do unless _body == [], do: _body = to_string(_body) do_request(make_url(query_url, config), :delete) end @doc false def head(query_url, config) do do_request(make_url(query_url, config), :head) end @doc false def post(query_url, config), do: post(query_url, [], config) def post(query_url, body, config) do unless body == [], do: body = to_string(body) url = make_url(query_url, config) do_request(url, :post, body) end @doc false def exist?(url, settings) do case head(url, settings) do {:error, _, _} -> false _ -> true end end @doc false def do_request(url, method, body \\ []) do :inets.start() { url, content_type, options } = { String.to_char_list(url), 'application/json', [{:body_format, :binary}] } case method do :get -> response(:httpc.request(method, {url, []}, [], [])) :head -> response(:httpc.request(method, {url, []}, [], [])) :put -> response(:httpc.request(method, {url, make_headers, content_type, body}, [], options)) :post -> response(:httpc.request(method, {url, make_headers, content_type, body}, [], options)) :delete -> response(:httpc.request(method, {url, make_headers},[],[])) end end defp response(req) do case req do {:ok, { {_, status, _}, _, body}} -> if round(status / 100) == 4 || round(status / 100) == 5 do { :error, status, body } else case body do [] -> { :ok, status, [] } _ -> { :ok, status, get_body_json(body) } end end _ -> :error end end def get_body_json(body), do: JSEX.decode!(to_string(body), [{:labels, :atom}]) def make_url(query_url, config) do if config.port == nil || config.port == 80 do "http://#{config.uri}/#{query_url}" else "http://#{config.uri}:#{config.port}/#{query_url}" end end defp make_headers, do: [{'Content-Type', 'application/json'}] end
29
112
0.606534
9e81f84b77133f2ff26137baf5d208669cfbc7e8
2,009
ex
Elixir
clients/calendar/lib/google_api/calendar/v3/model/acl_rule_scope.ex
hauptbenutzer/elixir-google-api
7b9e3a114a49cfc774a7afd03e299a0d43e4e6b2
[ "Apache-2.0" ]
null
null
null
clients/calendar/lib/google_api/calendar/v3/model/acl_rule_scope.ex
hauptbenutzer/elixir-google-api
7b9e3a114a49cfc774a7afd03e299a0d43e4e6b2
[ "Apache-2.0" ]
null
null
null
clients/calendar/lib/google_api/calendar/v3/model/acl_rule_scope.ex
hauptbenutzer/elixir-google-api
7b9e3a114a49cfc774a7afd03e299a0d43e4e6b2
[ "Apache-2.0" ]
1
2020-11-10T16:58:27.000Z
2020-11-10T16:58:27.000Z
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # 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 License is distributed on an &quot;AS IS&quot; BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule GoogleApi.Calendar.V3.Model.AclRuleScope do @moduledoc """ The scope of the rule. ## Attributes - type (String.t): The type of the scope. Possible values are: - \&quot;default\&quot; - The public scope. This is the default value. - \&quot;user\&quot; - Limits the scope to a single user. - \&quot;group\&quot; - Limits the scope to a group. - \&quot;domain\&quot; - Limits the scope to a domain. Note: The permissions granted to the \&quot;default\&quot;, or public, scope apply to any user, authenticated or not. Defaults to: `null`. - value (String.t): The email address of a user or group, or the name of a domain, depending on the scope type. Omitted for type \&quot;default\&quot;. Defaults to: `null`. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :type => any(), :value => any() } field(:type) field(:value) end defimpl Poison.Decoder, for: GoogleApi.Calendar.V3.Model.AclRuleScope do def decode(value, options) do GoogleApi.Calendar.V3.Model.AclRuleScope.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Calendar.V3.Model.AclRuleScope do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
39.392157
446
0.720259
9e8207cbacd252fd9cf5c8ac42231da59c9754c1
1,446
ex
Elixir
lib/ex_algo/sort/exchange.ex
code-shoily/ex_algo
7837c222fd2844a151b6b92038f94ea088bec0a2
[ "MIT" ]
21
2021-11-21T08:07:38.000Z
2022-03-13T06:19:35.000Z
lib/ex_algo/sort/exchange.ex
code-shoily/ex_algo
7837c222fd2844a151b6b92038f94ea088bec0a2
[ "MIT" ]
3
2021-11-26T22:54:09.000Z
2022-03-06T21:16:12.000Z
lib/ex_algo/sort/exchange.ex
code-shoily/ex_algo
7837c222fd2844a151b6b92038f94ea088bec0a2
[ "MIT" ]
null
null
null
defmodule ExAlgo.Sort.Exchange do @moduledoc """ Implements sorting algorithms based on exchanges. """ @type item :: any() @type t :: [item()] @doc """ Perform sort by using the bubble_sort algorithm. ## Example iex> Exchange.bubble_sort([]) [] iex> Exchange.bubble_sort([1]) [1] iex> Exchange.bubble_sort([3, 2, 1]) [1, 2, 3] iex> Exchange.bubble_sort([2, 7, -1, 5]) [-1, 2, 5, 7] """ @spec bubble_sort(t) :: t def bubble_sort(list), do: list |> bubble(true, []) defp bubble([], true, acc), do: acc |> Enum.reverse() defp bubble([], false, acc), do: acc |> Enum.reverse() |> bubble(true, []) defp bubble([a, b | rest], _, acc) when a > b, do: [a | rest] |> bubble(false, [b | acc]) defp bubble([a | rest], rev?, acc), do: rest |> bubble(rev?, [a | acc]) @doc """ Perform sort by using the merge_sort algorithm. ## Example iex> Exchange.quick_sort([]) [] iex> Exchange.quick_sort([1]) [1] iex> Exchange.quick_sort([3, 2, 1]) [1, 2, 3] iex> Exchange.quick_sort([2, 7, -1, 5]) [-1, 2, 5, 7] """ @spec quick_sort(t) :: t def quick_sort([]), do: [] def quick_sort([pivot | rest]) do left = rest |> Enum.filter(&(&1 < pivot)) |> quick_sort() right = rest |> Enum.filter(&(&1 >= pivot)) |> quick_sort() left ++ List.wrap(pivot) ++ right end end
21.264706
91
0.53527
9e820f6e843bd1de49800832405396e56cbb8fee
2,241
exs
Elixir
config/prod.exs
chulkilee/hello_graphql_phoenix
d6357b000ce682c1bb037de6a9de876198baee50
[ "BSD-3-Clause" ]
87
2016-03-02T11:40:29.000Z
2022-03-02T21:21:47.000Z
config/prod.exs
chulkilee/hello_graphql_phoenix
d6357b000ce682c1bb037de6a9de876198baee50
[ "BSD-3-Clause" ]
12
2015-12-22T19:58:48.000Z
2016-02-26T06:08:29.000Z
config/prod.exs
chulkilee/hello_graphql_phoenix
d6357b000ce682c1bb037de6a9de876198baee50
[ "BSD-3-Clause" ]
13
2016-05-22T08:41:15.000Z
2017-07-20T15:27:40.000Z
use Mix.Config # For production, we configure the host to read the PORT # from the system environment. Therefore, you will need # to set PORT=80 before running your server. # # You should also configure the url host to something # meaningful, we use this information when generating URLs. # # Finally, we also include the path to a manifest # containing the digested version of static files. This # manifest is generated by the mix phoenix.digest task # which you typically run after static files are built. config :hello_graphql, HelloGraphQL.Endpoint, http: [port: {:system, "PORT"}], cache_static_manifest: "priv/static/manifest.json", secret_key_base: System.get_env("SECRET_KEY_BASE") # Do not print debug messages in production config :logger, level: :info # Configure your database config :hello_graphql, HelloGraphQL.Repo, adapter: Ecto.Adapters.Postgres, database: "hello_graphql_prod", url: System.get_env("DATABASE_URL"), pool_size: 20 # ## SSL Support # # To get SSL working, you will need to add the `https` key # to the previous section and set your `:url` port to 443: # # config :hello_graphql, HelloGraphQL.Endpoint, # ... # url: [host: "example.com", port: 443], # https: [port: 443, # keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"), # certfile: System.get_env("SOME_APP_SSL_CERT_PATH")] # # Where those two env variables return an absolute path to # the key and cert in disk or a relative path inside priv, # for example "priv/ssl/server.key". # # We also recommend setting `force_ssl`, ensuring no data is # ever sent via http, always redirecting to https: # # config :hello_graphql, HelloGraphQL.Endpoint, # force_ssl: [hsts: true] # # Check `Plug.SSL` for all available options in `force_ssl`. # ## Using releases # # If you are doing OTP releases, you need to instruct Phoenix # to start the server for all endpoints: # # config :phoenix, :serve_endpoints, true # # Alternatively, you can configure exactly which server to # start per endpoint: # # config :hello_graphql, HelloGraphQL.Endpoint, server: true # # Finally import the config/prod.secret.exs # which should be versioned separately. # import_config "prod.secret.exs"
32.478261
67
0.727354
9e8225dea59f8685507a736b748180f21b9444dd
3,944
exs
Elixir
test/dialyxir/formatter_test.exs
PragTob/dialyxir
3d0a13f17a46649bca2413d57cef45bb278d1474
[ "Apache-2.0" ]
null
null
null
test/dialyxir/formatter_test.exs
PragTob/dialyxir
3d0a13f17a46649bca2413d57cef45bb278d1474
[ "Apache-2.0" ]
null
null
null
test/dialyxir/formatter_test.exs
PragTob/dialyxir
3d0a13f17a46649bca2413d57cef45bb278d1474
[ "Apache-2.0" ]
null
null
null
defmodule Dialyxir.FormatterTest do use ExUnit.Case import ExUnit.CaptureIO, only: [capture_io: 1] alias Dialyxir.Formatter alias Dialyxir.Project defp in_project(app, f) when is_atom(app) do Mix.Project.in_project(app, "test/fixtures/#{Atom.to_string(app)}", fn _ -> f.() end) end describe "exs ignore" do test "evaluates an ignore file and ignores warnings matching the pattern" do warning = {:warn_return_no_exit, {'a/file.ex', 17}, {:no_return, [:only_normal, :format_long, 1]}} in_project(:ignore, fn -> {:warn, remaining, _unused_filters_present} = Formatter.format_and_filter([warning], Project, [], :short) assert remaining == [] end) end test "does not filter lines not matching the pattern" do warning = {:warn_return_no_exit, {'a/different_file.ex', 17}, {:no_return, [:only_normal, :format_long, 1]}} in_project(:ignore, fn -> {:warn, [remaining], _} = Formatter.format_and_filter([warning], Project, [], :short) assert remaining =~ ~r/different_file.* no local return/ end) end test "can filter by regex" do warning = {:warn_return_no_exit, {'a/regex_file.ex', 17}, {:no_return, [:only_normal, :format_long, 1]}} in_project(:ignore, fn -> {:warn, remaining, _unused_filters_present} = Formatter.format_and_filter([warning], Project, [], :short) assert remaining == [] end) end test "lists unnecessary skips" do warning = {:warn_return_no_exit, {'a/regex_file.ex', 17}, {:no_return, [:only_normal, :format_long, 1]}} in_project(:ignore, fn -> assert {:warn, [], {:unused_filters_present, warning}} = Formatter.format_and_filter([warning], Project, [], :dialyxir) assert warning =~ "Unused filters:" end) end test "error on unnecessary skips with halt_exit_status" do warning = {:warn_return_no_exit, {'a/regex_file.ex', 17}, {:no_return, [:only_normal, :format_long, 1]}} filter_args = [{:halt_exit_status, true}] in_project(:ignore, fn -> {:error, [], {:unused_filters_present, error}} = Formatter.format_and_filter([warning], Project, filter_args, :dialyxir) assert error =~ "Unused filters:" end) end test "overwrite ':list_unused_filters_present'" do warning = {:warn_return_no_exit, {'a/regex_file.ex', 17}, {:no_return, [:only_normal, :format_long, 1]}} filter_args = [{:list_unused_filters, false}] in_project(:ignore, fn -> assert {:warn, [], {:unused_filters_present, warning}} = Formatter.format_and_filter([warning], Project, filter_args, :dialyxir) refute warning =~ "Unused filters:" end) end end test "listing unused filter behaves the same for different formats" do warnings = [ {:warn_return_no_exit, {'a/regex_file.ex', 17}, {:no_return, [:only_normal, :format_long, 1]}}, {:warn_return_no_exit, {'a/another-file.ex', 18}, {:unknown_type, {:M, :F, :A}}} ] expected_warning = "a/another-file.ex:18" expected_unused_filter = "Unused filters:\n{\"a/file.ex:17:no_return Function format_long/1 has no local return.\"}" filter_args = [{:list_unused_filters, true}] for format <- [:short, :dialyxir, :dialyzer] do in_project(:ignore, fn -> capture_io(fn -> result = Formatter.format_and_filter(warnings, Project, filter_args, format) assert {:warn, [warning], {:unused_filters_present, unused}} = result assert warning =~ expected_warning assert unused =~ expected_unused_filter # A warning for regex_file.ex was explicitly put into format_and_filter. refute unused =~ "regex_file.ex" end) end) end end end
32.065041
97
0.622972
9e82335c8fe384c3f5c94e462a31b484a35ec10a
207
exs
Elixir
web_finngen_r8/priv/repo/migrations/20200416123624_alter_phenocode_add_fields_r5.exs
vincent-octo/risteys
5bb1e70b78988770048b91b42fad025faf98d84a
[ "MIT" ]
null
null
null
web_finngen_r8/priv/repo/migrations/20200416123624_alter_phenocode_add_fields_r5.exs
vincent-octo/risteys
5bb1e70b78988770048b91b42fad025faf98d84a
[ "MIT" ]
null
null
null
web_finngen_r8/priv/repo/migrations/20200416123624_alter_phenocode_add_fields_r5.exs
vincent-octo/risteys
5bb1e70b78988770048b91b42fad025faf98d84a
[ "MIT" ]
null
null
null
defmodule Risteys.Repo.Migrations.AlterPhenocodeAddFieldsR5 do use Ecto.Migration def change do alter table(:phenocodes) do add :hd_icd_10_atc, :text add :latin, :text end end end
18.818182
62
0.710145
9e8274143666beac52475f365edfbdda1cf81e41
3,396
ex
Elixir
lib/vintage_net_mobile/modem/ublox_TOBY_L2.ex
dognotdog/vintage_net_mobile
a709d8f8ce3af71c444d11ff07483b4be180c4c5
[ "Apache-2.0" ]
18
2020-03-08T21:06:10.000Z
2022-02-05T00:44:55.000Z
lib/vintage_net_mobile/modem/ublox_TOBY_L2.ex
dognotdog/vintage_net_mobile
a709d8f8ce3af71c444d11ff07483b4be180c4c5
[ "Apache-2.0" ]
27
2020-02-28T16:07:07.000Z
2022-01-19T03:51:02.000Z
lib/vintage_net_mobile/modem/ublox_TOBY_L2.ex
dognotdog/vintage_net_mobile
a709d8f8ce3af71c444d11ff07483b4be180c4c5
[ "Apache-2.0" ]
7
2020-03-25T20:08:22.000Z
2021-10-22T03:20:17.000Z
defmodule VintageNetMobile.Modem.UbloxTOBYL2 do @behaviour VintageNetMobile.Modem @moduledoc """ # u-blox TOBY-L2 support The u-blox TOBY-L2 is a series of LTE Cat 4 modules with HSPA+ and/or 2G fallback. Here's an example configuration: ```elixir VintageNet.configure( "ppp0", %{ type: VintageNetMobile, vintage_net_mobile: %{ modem: VintageNetMobile.Modem.UbloxTOBYL2, service_providers: [ %{apn: "lte-apn", usage: :eps_bearer}, %{apn: "old-apn", usage: :pdp} ] } } ) ``` This implementation currently requires APNs to be annotated for whether they are to be used on LTE (`:eps_bearer`) or on UMTS/GPRS (`:pdp`). ## Required Linux kernel options * CONFIG_USB_SERIAL=m * CONFIG_USB_SERIAL_WWAN=m * CONFIG_USB_SERIAL_OPTION=m ## Required modem preparation The Toby L2 is a composite USB device that can be configured to expose various different interfaces. By default, it has one CDC ACM interface. This implementation requires two, so you have to send it the following over a tty interface (via `Circuits.UART` or externally): ``` AT+UUSBCONF=2 ``` That command is saved NVRAM and only needs to be sent once. See section "19.17 USB profiles configuration +UUSBCONF" in the [u-blox AT commands manual](https://www.u-blox.com/en/docs/UBX-13002752) """ # Useful references: # * AT commands - https://www.u-blox.com/en/docs/UBX-13002752 alias VintageNetMobile.{ExChat, SignalMonitor, PPPDConfig, Chatscript} alias VintageNet.Interface.RawConfig @impl true def normalize(config) do config |> require_service_providers() end defp require_service_providers(%{type: VintageNetMobile, vintage_net_mobile: mobile} = config) do providers = Map.get(mobile, :service_providers, []) if eps_bearer(providers) == nil or pdp(providers) == nil do raise ArgumentError, "Must provide at least two service_providers and annotate APNs with their usage (:eps_bearer and :pdp)" end config end @impl true def add_raw_config(raw_config, %{vintage_net_mobile: mobile} = _config, opts) do ifname = raw_config.ifname files = [{Chatscript.path(ifname, opts), chatscript(mobile.service_providers)}] child_specs = [ {ExChat, [tty: "ttyACM1", speed: 115_200]}, {SignalMonitor, [ifname: ifname, tty: "ttyACM1"]} ] %RawConfig{ raw_config | files: files, child_specs: child_specs } |> PPPDConfig.add_child_spec("ttyACM2", 115_200, opts) end defp chatscript(service_providers) do lte_provider = eps_bearer(service_providers) other_provider = pdp(service_providers) [ Chatscript.prologue(120), """ # Enter airplane mode OK AT+CFUN=4 # Delete existing contexts OK AT+CGDEL # Define PDP context OK AT+UCGDFLT=1,"IP","#{lte_provider.apn}" OK AT+CGDCONT=1,"IP","#{other_provider.apn}" OK AT+CFUN=1 """, Chatscript.connect() ] |> IO.iodata_to_binary() end defp find_by_usage(service_providers, what) do Enum.find(service_providers, &(Map.get(&1, :usage) == what)) end defp eps_bearer(service_providers) do find_by_usage(service_providers, :eps_bearer) end defp pdp(service_providers) do find_by_usage(service_providers, :pdp) end end
26.325581
115
0.677562
9e82a58a80a75de9bf8a40ee668221bb613da1bc
1,913
exs
Elixir
clients/run/mix.exs
corp-momenti/elixir-google-api
fe1580e305789ab2ca0741791b8ffe924bd3240c
[ "Apache-2.0" ]
null
null
null
clients/run/mix.exs
corp-momenti/elixir-google-api
fe1580e305789ab2ca0741791b8ffe924bd3240c
[ "Apache-2.0" ]
null
null
null
clients/run/mix.exs
corp-momenti/elixir-google-api
fe1580e305789ab2ca0741791b8ffe924bd3240c
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # 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 License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.Run.Mixfile do use Mix.Project @version "0.25.0" def project() do [ app: :google_api_run, version: @version, elixir: "~> 1.6", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, description: description(), package: package(), deps: deps(), source_url: "https://github.com/googleapis/elixir-google-api/tree/master/clients/run" ] end def application() do [extra_applications: [:logger]] end defp deps() do [ {:google_gax, "~> 0.4"}, {:ex_doc, "~> 0.16", only: :dev} ] end defp description() do """ Cloud Run Admin API client library. Deploy and manage user provided container images that scale automatically based on incoming requests. The Cloud Run Admin API follows the Knative Serving API specification. """ end defp package() do [ files: ["lib", "mix.exs", "README*", "LICENSE"], maintainers: ["Jeff Ching", "Daniel Azuma"], licenses: ["Apache 2.0"], links: %{ "GitHub" => "https://github.com/googleapis/elixir-google-api/tree/master/clients/run", "Homepage" => "https://cloud.google.com/run/" } ] end end
28.552239
212
0.66022
9e82ba727df0714159bc89abeed7da15d34d7f1f
2,277
ex
Elixir
apps/omg_child_chain/lib/child_chain.ex
karmonezz/elixir-omg
3b26fc072fa553992277e1b9c4bad37b3d61ec6a
[ "Apache-2.0" ]
1
2020-05-01T12:30:09.000Z
2020-05-01T12:30:09.000Z
apps/omg_child_chain/lib/child_chain.ex
karmonezz/elixir-omg
3b26fc072fa553992277e1b9c4bad37b3d61ec6a
[ "Apache-2.0" ]
null
null
null
apps/omg_child_chain/lib/child_chain.ex
karmonezz/elixir-omg
3b26fc072fa553992277e1b9c4bad37b3d61ec6a
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 OmiseGO Pte Ltd # # 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 License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. defmodule OMG.ChildChain do @moduledoc """ Entrypoint for all the exposed public functions of the child chain server's API. Should handle all the initial processing of requests like state-less validity, decoding/encoding (but not transport-specific encoding like hex). """ use OMG.Utils.LoggerExt alias OMG.Block alias OMG.ChildChain.FeeServer alias OMG.ChildChain.FreshBlocks alias OMG.Fees alias OMG.State alias OMG.State.Transaction alias OMG.Status.Alert.Alarm @type submit_error() :: Transaction.Recovered.recover_tx_error() | State.exec_error() @spec submit(transaction :: binary) :: {:ok, %{txhash: Transaction.tx_hash(), blknum: pos_integer, txindex: non_neg_integer}} | {:error, submit_error()} def submit(transaction) do with {:ok, recovered_tx} <- Transaction.Recovered.recover_from(transaction), {:ok, fees} <- FeeServer.transaction_fees(), fees = Fees.for_transaction(recovered_tx, fees), {:ok, {tx_hash, blknum, tx_index}} <- State.exec(recovered_tx, fees) do {:ok, %{txhash: tx_hash, blknum: blknum, txindex: tx_index}} end |> result_with_logging() end @spec get_block(hash :: binary) :: {:ok, %{hash: binary, transactions: list, blknum: integer}} | {:error, :not_found | :internal_error} def get_block(hash) do with {:ok, struct_block} <- FreshBlocks.get(hash) do {:ok, Block.to_api_format(struct_block)} end |> result_with_logging() end @spec get_alarms() :: {:ok, Alarm.raw_t()} def get_alarms, do: {:ok, Alarm.all()} defp result_with_logging(result) do _ = Logger.debug(" resulted with #{inspect(result)}") result end end
35.578125
110
0.704875
9e82c55b9ddff38b09373ae28f449e8f7bdae6f6
1,962
exs
Elixir
test/cmd/runlet_filter_test.exs
msantos/runlet
d9cb44b113295387c296ab4576a09ca4a7ce0f7b
[ "ISC" ]
4
2020-01-12T19:04:46.000Z
2021-09-20T14:37:22.000Z
test/cmd/runlet_filter_test.exs
msantos/runlet
d9cb44b113295387c296ab4576a09ca4a7ce0f7b
[ "ISC" ]
null
null
null
test/cmd/runlet_filter_test.exs
msantos/runlet
d9cb44b113295387c296ab4576a09ca4a7ce0f7b
[ "ISC" ]
1
2021-09-20T14:37:25.000Z
2021-09-20T14:37:25.000Z
defmodule RunletFilterTest do use ExUnit.Case test "grep" do e = [ %Runlet.Event{ event: %Runlet.Event.Stdout{ service: "service", host: "host", description: "test" } }, %Runlet.Event{ event: %Runlet.Event.Stdout{ service: "service", host: "host", description: "abc" } }, %Runlet.Event{ event: %Runlet.Event.Stdout{ service: "service", host: "host", description: "def" } }, %Runlet.Event{ event: %Runlet.Event.Stdout{ service: "service", host: "host", description: "ghi" } }, %Runlet.Event{ event: %Runlet.Event.Stdout{ service: "service", host: "host", description: "xyz" } } ] result = e |> Stream.cycle() |> Runlet.Cmd.Filter.exec("def") |> Enum.take(3) |> Enum.reject(fn t -> t.event.description == "def" end) assert [ %Runlet.Event{ attr: %{}, event: %Runlet.Event.Stdout{ description: "test", host: "host", service: "service", time: "" }, query: "" }, %Runlet.Event{ attr: %{}, event: %Runlet.Event.Stdout{ description: "abc", host: "host", service: "service", time: "" }, query: "" }, %Runlet.Event{ attr: %{}, event: %Runlet.Event.Stdout{ description: "ghi", host: "host", service: "service", time: "" }, query: "" } ] = result end end
23.357143
62
0.380734
9e82c86edfe68285cd8fc802a9ae2f75dffdd808
635
exs
Elixir
test/instream/query/builder_injection.exs
qgadrian/instream
3dc828fe476817d442b83dc5da58ceca56e9886f
[ "Apache-2.0" ]
null
null
null
test/instream/query/builder_injection.exs
qgadrian/instream
3dc828fe476817d442b83dc5da58ceca56e9886f
[ "Apache-2.0" ]
null
null
null
test/instream/query/builder_injection.exs
qgadrian/instream
3dc828fe476817d442b83dc5da58ceca56e9886f
[ "Apache-2.0" ]
null
null
null
defmodule Instream.Query.BuilderInjectionTest do use ExUnit.Case, async: true alias Instream.Encoder.InfluxQL alias Instream.Query.Builder alias Instream.TestHelpers.Connections.DefaultConnection test "SELECT InfluxQL Injection" do # result if escaping is broken: # %{error: "error parsing query: found FROM injectable, expected FROM at line 1, char 29"} assert %{results: [_]} = "injectable" |> Builder.from() |> Builder.select(["some", ~S(broken ';stuff")]) |> InfluxQL.encode() |> DefaultConnection.query(database: "test_database") end end
33.421053
95
0.656693
9e82ceeccc7725ee0d506912cd0d22488d2a0ff8
884
ex
Elixir
lib/credo/cli/filter.ex
ayrat555/credo
517699f82fc6ebe266152d997b64878b334e7bd8
[ "MIT" ]
null
null
null
lib/credo/cli/filter.ex
ayrat555/credo
517699f82fc6ebe266152d997b64878b334e7bd8
[ "MIT" ]
null
null
null
lib/credo/cli/filter.ex
ayrat555/credo
517699f82fc6ebe266152d997b64878b334e7bd8
[ "MIT" ]
null
null
null
defmodule Credo.CLI.Filter do alias Credo.Issue alias Credo.SourceFile alias Credo.Check.ConfigComment alias Credo.Execution def important(list, exec) when is_list(list) do Enum.filter(list, &important?(&1, exec)) end def important?(%Issue{} = issue, exec) do issue.priority >= exec.min_priority end def important?(%SourceFile{filename: filename}, exec) do exec |> Execution.get_issues(filename) |> Enum.any?(&important?(&1, exec)) end def valid_issues(list, exec) when is_list(list) do Enum.reject(list, fn issue -> ignored_by_config_comment?(issue, exec) end) end def ignored_by_config_comment?(%Issue{} = issue, exec) do case exec.config_comment_map[issue.filename] do list when is_list(list) -> Enum.any?(list, &ConfigComment.ignores_issue?(&1, issue)) _ -> false end end end
23.891892
65
0.675339
9e82f506bb77618ebea0945ec4f8becc0b9fe85b
88
ex
Elixir
lib/green_worker/exceptions/deadline_exceeded_error.ex
renderedtext/green-worker
ca69c243e5a98590a6d82ca2872996783948b8fb
[ "Apache-2.0" ]
1
2019-09-05T14:40:33.000Z
2019-09-05T14:40:33.000Z
lib/green_worker/exceptions/deadline_exceeded_error.ex
renderedtext/green-worker
ca69c243e5a98590a6d82ca2872996783948b8fb
[ "Apache-2.0" ]
null
null
null
lib/green_worker/exceptions/deadline_exceeded_error.ex
renderedtext/green-worker
ca69c243e5a98590a6d82ca2872996783948b8fb
[ "Apache-2.0" ]
null
null
null
defmodule GreenWorker.Exceptions.DeadlineExceededError do defexception [:message] end
22
57
0.852273
9e831b4c2bdb0b6565a2fbaa7aac5484f68943d1
7,835
exs
Elixir
test/exw3/utils_test.exs
Metalink-App/ex_w3
dd97ec95fcb6374055010b65083384f1f0f09578
[ "Apache-2.0" ]
3
2021-09-28T21:28:15.000Z
2022-01-30T23:01:45.000Z
test/exw3/utils_test.exs
Metalink-App/ex_w3
dd97ec95fcb6374055010b65083384f1f0f09578
[ "Apache-2.0" ]
null
null
null
test/exw3/utils_test.exs
Metalink-App/ex_w3
dd97ec95fcb6374055010b65083384f1f0f09578
[ "Apache-2.0" ]
1
2022-02-16T16:13:23.000Z
2022-02-16T16:13:23.000Z
defmodule Web3x.UtilsTest do use ExUnit.Case doctest Web3x.Utils describe ".hex_to_integer/1" do test "parses a hex encoded string to an integer" do assert Web3x.Utils.hex_to_integer("0x1") == {:ok, 1} assert Web3x.Utils.hex_to_integer("0x2") == {:ok, 2} assert Web3x.Utils.hex_to_integer("0x2a") == {:ok, 42} assert Web3x.Utils.hex_to_integer("0x2A") == {:ok, 42} end test "returns an error when the string is not a valid hexidecimal" do assert Web3x.Utils.hex_to_integer("0x") == {:error, :invalid_hex_string} assert Web3x.Utils.hex_to_integer("0a") == {:error, :invalid_hex_string} assert Web3x.Utils.hex_to_integer("0xZ") == {:error, :invalid_hex_string} end end describe ".integer_to_hex/1" do test "encodes an integer to hexadecimal" do assert Web3x.Utils.integer_to_hex(0) == {:ok, "0x0"} assert Web3x.Utils.integer_to_hex(1) == {:ok, "0x1"} assert Web3x.Utils.integer_to_hex(42) == {:ok, "0x2A"} end test "returns an error when the integer is negative" do assert Web3x.Utils.integer_to_hex(-1) == {:error, :negative_integer} end test "returns an error when the value is not an integer" do assert Web3x.Utils.integer_to_hex(1.1) == {:error, :non_integer} assert Web3x.Utils.integer_to_hex(nil) == {:error, :non_integer} end end describe ".keccak256/1" do test "returns a 0x prepended 32 byte hash of the input" do hex_hash = Web3x.Utils.keccak256("foo") assert "0x" <> hash = hex_hash assert hash == "41b1a0649752af1b28b3dc29a1556eee781e4a4c3a1f7f53f90fa834de098c4d" num_bytes = byte_size(hash) assert trunc(num_bytes / 2) == 32 end end describe ".to_wei/2" do test "converts a unit to_wei" do assert Web3x.Utils.to_wei(1, :wei) == 1 assert Web3x.Utils.to_wei(1, :kwei) == 1_000 assert Web3x.Utils.to_wei(1, :Kwei) == 1_000 assert Web3x.Utils.to_wei(1, :babbage) == 1_000 assert Web3x.Utils.to_wei(1, :mwei) == 1_000_000 assert Web3x.Utils.to_wei(1, :Mwei) == 1_000_000 assert Web3x.Utils.to_wei(1, :lovelace) == 1_000_000 assert Web3x.Utils.to_wei(1, :gwei) == 1_000_000_000 assert Web3x.Utils.to_wei(1, :Gwei) == 1_000_000_000 assert Web3x.Utils.to_wei(1, :shannon) == 1_000_000_000 assert Web3x.Utils.to_wei(1, :szabo) == 1_000_000_000_000 assert Web3x.Utils.to_wei(1, :finney) == 1_000_000_000_000_000 assert Web3x.Utils.to_wei(1, :ether) == 1_000_000_000_000_000_000 assert Web3x.Utils.to_wei(1, :kether) == 1_000_000_000_000_000_000_000 assert Web3x.Utils.to_wei(1, :grand) == 1_000_000_000_000_000_000_000 assert Web3x.Utils.to_wei(1, :mether) == 1_000_000_000_000_000_000_000_000 assert Web3x.Utils.to_wei(1, :gether) == 1_000_000_000_000_000_000_000_000_000 assert Web3x.Utils.to_wei(1, :tether) == 1_000_000_000_000_000_000_000_000_000_000 assert Web3x.Utils.to_wei(1, :kwei) == Web3x.Utils.to_wei(1, :femtoether) assert Web3x.Utils.to_wei(1, :szabo) == Web3x.Utils.to_wei(1, :microether) assert Web3x.Utils.to_wei(1, :finney) == Web3x.Utils.to_wei(1, :milliether) assert Web3x.Utils.to_wei(1, :milli) == Web3x.Utils.to_wei(1, :milliether) assert Web3x.Utils.to_wei(1, :milli) == Web3x.Utils.to_wei(1000, :micro) {:ok, agent} = Agent.start_link(fn -> false end) try do Web3x.Utils.to_wei(1, :wei1) catch _ -> Agent.update(agent, fn _ -> true end) end assert Agent.get(agent, fn state -> state end) end end describe ".from_wei/2" do test "converts a unit from wei" do assert Web3x.Utils.from_wei(1_000_000_000_000_000_000, :wei) == 1_000_000_000_000_000_000 assert Web3x.Utils.from_wei(1_000_000_000_000_000_000, :kwei) == 1_000_000_000_000_000 assert Web3x.Utils.from_wei(1_000_000_000_000_000_000, :mwei) == 1_000_000_000_000 assert Web3x.Utils.from_wei(1_000_000_000_000_000_000, :gwei) == 1_000_000_000 assert Web3x.Utils.from_wei(1_000_000_000_000_000_000, :szabo) == 1_000_000 assert Web3x.Utils.from_wei(1_000_000_000_000_000_000, :finney) == 1_000 assert Web3x.Utils.from_wei(1_000_000_000_000_000_000, :ether) == 1 assert Web3x.Utils.from_wei(1_000_000_000_000_000_000, :kether) == 0.001 assert Web3x.Utils.from_wei(1_000_000_000_000_000_000, :grand) == 0.001 assert Web3x.Utils.from_wei(1_000_000_000_000_000_000, :mether) == 0.000001 assert Web3x.Utils.from_wei(1_000_000_000_000_000_000, :gether) == 0.000000001 assert Web3x.Utils.from_wei(1_000_000_000_000_000_000, :tether) == 0.000000000001 end end describe ".to_checksum_address/1" do test "returns checksum for all caps address" do assert Web3x.Utils.to_checksum_address( String.downcase("0x52908400098527886E0F7030069857D2E4169EE7") ) == "0x52908400098527886E0F7030069857D2E4169EE7" assert Web3x.Utils.to_checksum_address( String.downcase("0x8617E340B3D01FA5F11F306F4090FD50E238070D") ) == "0x8617E340B3D01FA5F11F306F4090FD50E238070D" end test "returns checksumfor all lowercase address" do assert Web3x.Utils.to_checksum_address( String.downcase("0xde709f2102306220921060314715629080e2fb77") ) == "0xde709f2102306220921060314715629080e2fb77" assert Web3x.Utils.to_checksum_address( String.downcase("0x27b1fdb04752bbc536007a920d24acb045561c26") ) == "0x27b1fdb04752bbc536007a920d24acb045561c26" end test "returns checksum for normal addresses" do assert Web3x.Utils.to_checksum_address( String.downcase("0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed") ) == "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed" assert Web3x.Utils.to_checksum_address( String.downcase("0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359") ) == "0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359" assert Web3x.Utils.to_checksum_address( String.downcase("0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB") ) == "0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB" assert Web3x.Utils.to_checksum_address( String.downcase("0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb") ) == "0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb" end end describe ".is_valid_checksum_address/1" do test "returns valid check for is_valid_checksum_address()" do assert Web3x.Utils.is_valid_checksum_address("0x52908400098527886E0F7030069857D2E4169EE7") == true assert Web3x.Utils.is_valid_checksum_address("0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB") == true assert Web3x.Utils.is_valid_checksum_address("0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb") == true assert Web3x.Utils.is_valid_checksum_address("0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed") == true assert Web3x.Utils.is_valid_checksum_address("0x27b1fdb04752bbc536007a920d24acb045561c26") == true assert Web3x.Utils.is_valid_checksum_address("0xde709f2102306220921060314715629080e2fb77") == true assert Web3x.Utils.is_valid_checksum_address("0x8617E340B3D01FA5F11F306F4090FD50E238070D") == true assert Web3x.Utils.is_valid_checksum_address("0x52908400098527886E0F7030069857D2E4169EE7") == true end test "returns invalid check for is_valid_checksum_address()" do assert Web3x.Utils.is_valid_checksum_address("0x2f015c60e0be116b1f0cd534704db9c92118fb6a") == false end end end
42.351351
99
0.69164
9e8339a5b9958062c49f182ed98660726fd5323e
568
exs
Elixir
18-NewMath/mix.exs
dvrensk/advent-of-code-2020
237e80da9958f37e51c0ac84da74bec5fec1f185
[ "Unlicense" ]
1
2020-12-02T01:34:06.000Z
2020-12-02T01:34:06.000Z
18-NewMath/mix.exs
dvrensk/advent-of-code-2020
237e80da9958f37e51c0ac84da74bec5fec1f185
[ "Unlicense" ]
null
null
null
18-NewMath/mix.exs
dvrensk/advent-of-code-2020
237e80da9958f37e51c0ac84da74bec5fec1f185
[ "Unlicense" ]
null
null
null
defmodule NewMath.MixProject do use Mix.Project def project do [ app: :aoc, version: "0.1.0", elixir: "~> 1.10", start_permanent: Mix.env() == :prod, deps: deps() ] end # Run "mix help compile.app" to learn about applications. def application do [ extra_applications: [:logger] ] end # Run "mix help deps" to learn about dependencies. defp deps do [ # {:dep_from_hexpm, "~> 0.3.0"}, # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} ] end end
19.586207
87
0.573944
9e834b53c95087d5046a9f1e95390e634b2bb9eb
903
exs
Elixir
basictypes/lists.exs
ezkemboi/elixir
5641c8c9cc24b5e51546328b7fbba04d3b28e3b2
[ "Apache-2.0" ]
1
2020-01-21T19:58:41.000Z
2020-01-21T19:58:41.000Z
basictypes/lists.exs
ezkemboi/elixir
5641c8c9cc24b5e51546328b7fbba04d3b28e3b2
[ "Apache-2.0" ]
null
null
null
basictypes/lists.exs
ezkemboi/elixir
5641c8c9cc24b5e51546328b7fbba04d3b28e3b2
[ "Apache-2.0" ]
null
null
null
# list uses square brackets IO.inspect [0, 1, "ke", true, nil] # check the length of a list mylist = [1, 2, true, nil] IO.puts length(mylist) # adding list secondlist = ["Ezrqn Kemboi", false] addedlist = mylist ++ secondlist IO.inspect addedlist # subtract list subtractitems = [false, 2] subtractedlist = addedlist -- subtractitems IO.inspect subtractedlist ~S""" List operators never modify the existing list rather it create a new list Therefore, there is no mutation rather data transformation """ # return head and tail of list IO.puts hd(mylist) ~S""" use inspect when returning tail as it will return a list head return the first grapheme in a list tail return list of the remaining grapheme Remember that head and tail of an empty list returns an argument error """ IO.inspect tl(mylist) # To keep in mind ~S""" Single quoted and double quoted representation is not equivalent in elixir """
27.363636
74
0.75526
9e83536cefa7435ad287c94fc28d6456fc421f0a
1,012
ex
Elixir
lib/phxpay_web/router.ex
ramonlimaramos/phxpay
accf0ada9581a8f8f396849fdfe10e1a1c4ae2af
[ "MIT" ]
null
null
null
lib/phxpay_web/router.ex
ramonlimaramos/phxpay
accf0ada9581a8f8f396849fdfe10e1a1c4ae2af
[ "MIT" ]
null
null
null
lib/phxpay_web/router.ex
ramonlimaramos/phxpay
accf0ada9581a8f8f396849fdfe10e1a1c4ae2af
[ "MIT" ]
null
null
null
defmodule PhxpayWeb.Router do use PhxpayWeb, :router pipeline :api do plug :accepts, ["json"] end scope "/api", PhxpayWeb do pipe_through :api get "/:filename", WellcomeController, :index post "/users", UsersController, :create post "/accounts/:id/deposit", AccountsController, :deposit post "/accounts/:id/withdraw", AccountsController, :withdraw end # Enables LiveDashboard only for development # # If you want to use the LiveDashboard in production, you should put # it behind authentication and allow only admins to access it. # If your application does not have an admins-only section yet, # you can use Plug.BasicAuth to set up some basic authentication # as long as you are also using SSL (which you should anyway). if Mix.env() in [:dev, :test] do import Phoenix.LiveDashboard.Router scope "/" do pipe_through [:fetch_session, :protect_from_forgery] live_dashboard "/dashboard", metrics: PhxpayWeb.Telemetry end end end
28.111111
70
0.711462
9e8358bfe778bb7e7d995435df6fd3b5d13a7cf9
2,484
ex
Elixir
clients/dfa_reporting/lib/google_api/dfa_reporting/v35/model/site_skippable_setting.ex
renovate-bot/elixir-google-api
1da34cd39b670c99f067011e05ab90af93fef1f6
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/dfa_reporting/lib/google_api/dfa_reporting/v35/model/site_skippable_setting.ex
swansoffiee/elixir-google-api
9ea6d39f273fb430634788c258b3189d3613dde0
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/dfa_reporting/lib/google_api/dfa_reporting/v35/model/site_skippable_setting.ex
dazuma/elixir-google-api
6a9897168008efe07a6081d2326735fe332e522c
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # 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 License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.DFAReporting.V35.Model.SiteSkippableSetting do @moduledoc """ Skippable Settings ## Attributes * `kind` (*type:* `String.t`, *default:* `nil`) - Identifies what kind of resource this is. Value: the fixed string "dfareporting#siteSkippableSetting". * `progressOffset` (*type:* `GoogleApi.DFAReporting.V35.Model.VideoOffset.t`, *default:* `nil`) - Amount of time to play videos served to this site template before counting a view. Applicable when skippable is true. * `skipOffset` (*type:* `GoogleApi.DFAReporting.V35.Model.VideoOffset.t`, *default:* `nil`) - Amount of time to play videos served to this site before the skip button should appear. Applicable when skippable is true. * `skippable` (*type:* `boolean()`, *default:* `nil`) - Whether the user can skip creatives served to this site. This will act as default for new placements created under this site. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :kind => String.t() | nil, :progressOffset => GoogleApi.DFAReporting.V35.Model.VideoOffset.t() | nil, :skipOffset => GoogleApi.DFAReporting.V35.Model.VideoOffset.t() | nil, :skippable => boolean() | nil } field(:kind) field(:progressOffset, as: GoogleApi.DFAReporting.V35.Model.VideoOffset) field(:skipOffset, as: GoogleApi.DFAReporting.V35.Model.VideoOffset) field(:skippable) end defimpl Poison.Decoder, for: GoogleApi.DFAReporting.V35.Model.SiteSkippableSetting do def decode(value, options) do GoogleApi.DFAReporting.V35.Model.SiteSkippableSetting.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.DFAReporting.V35.Model.SiteSkippableSetting do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
44.357143
220
0.736312
9e8361d4809dfe84c5d2b5d813726741b5305a51
1,045
exs
Elixir
config/dev.exs
philosodad/dashex
a3662d3b95e48fd3e7433b30c8a7505accf58e77
[ "MIT" ]
null
null
null
config/dev.exs
philosodad/dashex
a3662d3b95e48fd3e7433b30c8a7505accf58e77
[ "MIT" ]
null
null
null
config/dev.exs
philosodad/dashex
a3662d3b95e48fd3e7433b30c8a7505accf58e77
[ "MIT" ]
null
null
null
use Mix.Config # For development, we disable any cache and enable # debugging and code reloading. # # The watchers configuration can be used to run external # watchers to your application. For example, we use it # with brunch.io to recompile .js and .css sources. config :dashex, Dashex.Endpoint, http: [port: 4000], debug_errors: true, code_reloader: true, cache_static_lookup: false, watchers: [node: ["node_modules/brunch/bin/brunch", "watch"]] # Watch static and templates for browser reloading. config :dashex, Dashex.Endpoint, live_reload: [ patterns: [ ~r{priv/static/.*(js|css|png|jpeg|jpg|gif)$}, ~r{web/views/.*(ex)$}, ~r{web/templates/.*(eex)$} ] ] # Do not include metadata nor timestamps in development logs config :logger, :console, format: "[$level] $message\n" # Configure your database config :dashex, Dashex.Repo, adapter: Ecto.Adapters.Postgres, username: "postgres", password: "postgres", database: "dashex_dev", size: 10 # The amount of database connections in the pool
29.027778
63
0.70622
9e837b1e09491740171e44b9537365ed2cfb5c10
1,455
ex
Elixir
lib/exns/api.ex
walkr/exns
40379d38ce363b6f9208182dc3309529b1939fe3
[ "MIT" ]
6
2016-06-12T12:59:21.000Z
2018-09-23T06:57:42.000Z
lib/exns/api.ex
walkr/exns
40379d38ce363b6f9208182dc3309529b1939fe3
[ "MIT" ]
null
null
null
lib/exns/api.ex
walkr/exns
40379d38ce363b6f9208182dc3309529b1939fe3
[ "MIT" ]
null
null
null
defmodule Exns.Api do @moduledoc """ This module contains the public functions of the Exns app. """ defmacro __using__(_opts) do quote do import Exns.Api @doc ~S""" Call a method on a remote service """ def call(service, method, args \\ []) do make_call(service, method, args) end @doc """ Call a method on a remote service, but raise exception if remote endpoint returns an error """ def call!(service, method, args \\ []) do {:ok, result} = make_call(service, method, args) result end end end def make_call(service, method, args \\ [], checkout_timeout \\ 5000) do response = :poolboy.transaction( service, fn(worker) -> GenServer.call(worker, [method: method, args: args]) end, checkout_timeout ) # A nanoservice will return {result, error}, but in Erlang/Elixir # we will convert it to more idiomatic {:ok, result}, {:error, error} case response do # client has timed out {:error, :timeout} -> {:error, :timeout} # nanoservice has no errors {result, nil} -> {:ok, result} # nanoservice returned an error {_, error} -> {:error, error} end end end
28.529412
77
0.515464
9e837b5c23562b9d58e7c332446600a9bd01cdbd
1,215
exs
Elixir
config/config.exs
sschneider1207/RGBMonitor
a2cf73b072423831b2ef27fcd644ffddba04d524
[ "MIT" ]
null
null
null
config/config.exs
sschneider1207/RGBMonitor
a2cf73b072423831b2ef27fcd644ffddba04d524
[ "MIT" ]
null
null
null
config/config.exs
sschneider1207/RGBMonitor
a2cf73b072423831b2ef27fcd644ffddba04d524
[ "MIT" ]
null
null
null
# This file is responsible for configuring your application # and its dependencies with the aid of the Mix.Config module. use Mix.Config # This configuration is loaded before any dependency and is restricted # to this project. If another project depends on this project, this # file won't be loaded nor affect the parent project. For this reason, # if you want to provide default values for your application for # 3rd-party users, it should be done in your "mix.exs" file. # You can configure for your application as: # # config :rgb_monitor, key: :value # # And access this configuration in your application as: # # Application.get_env(:rgb_monitor, :key) # # Or configure a 3rd-party app: # # config :logger, level: :info # # It is also possible to import configuration files, relative to this # directory. For example, you can emulate configuration per environment # by uncommenting the line below and defining dev.exs, test.exs and such. # Configuration from the imported file will override the ones defined # here (which is why it is important to import them last). # # import_config "#{Mix.env}.exs" config :rgb_monitor, devices: [[address: 0x29, bus: "i2c-1"]], pubsub: :bucket_pubsub
35.735294
73
0.747325
9e839fea58103626b42d7ce0af5eff50002bf359
532
ex
Elixir
apps/service_gather/test/support/fake_step.ex
rucker/hindsight
876a5d344c5d8eebbea37684ee07e0a91e4430f0
[ "Apache-2.0" ]
12
2020-01-27T19:43:02.000Z
2021-07-28T19:46:29.000Z
apps/service_gather/test/support/fake_step.ex
rucker/hindsight
876a5d344c5d8eebbea37684ee07e0a91e4430f0
[ "Apache-2.0" ]
81
2020-01-28T18:07:23.000Z
2021-11-22T02:12:13.000Z
apps/service_gather/test/support/fake_step.ex
rucker/hindsight
876a5d344c5d8eebbea37684ee07e0a91e4430f0
[ "Apache-2.0" ]
10
2020-02-13T21:24:09.000Z
2020-05-21T18:39:35.000Z
defmodule Fake.Step do defstruct [:values, :pid, :chunk_size] defimpl Extract.Step, for: __MODULE__ do import Extract.Context def execute(step, context) do chunk_size = step.chunk_size || 2 source = fn _ -> step.values |> Stream.map(&Extract.Message.new(data: &1)) |> Stream.chunk_every(chunk_size) end context |> register_after_function(fn msgs -> send(step.pid, {:after, msgs}) end) |> set_source(source) |> Ok.ok() end end end
21.28
53
0.593985
9e83a18f8a108a1c3a46db039cf520aed0af7ed1
128
exs
Elixir
test/test_helper.exs
tailcalldev/pg_queuetopia
ea18c6a7633a78cc82473b9b60da205454009af4
[ "MIT" ]
null
null
null
test/test_helper.exs
tailcalldev/pg_queuetopia
ea18c6a7633a78cc82473b9b60da205454009af4
[ "MIT" ]
null
null
null
test/test_helper.exs
tailcalldev/pg_queuetopia
ea18c6a7633a78cc82473b9b60da205454009af4
[ "MIT" ]
null
null
null
{:ok, _pid} = PgQueuetopia.TestRepo.start_link() Ecto.Adapters.SQL.Sandbox.mode(PgQueuetopia.TestRepo, :manual) ExUnit.start()
25.6
62
0.773438
9e83c779b8e9f73f3de8030add09b983d732b4ac
3,651
ex
Elixir
lib/grizzly/packet/decode.ex
pragdave/grizzly
bcd7b46ab2cff1797dac04bc3cd12a36209dd579
[ "Apache-2.0" ]
null
null
null
lib/grizzly/packet/decode.ex
pragdave/grizzly
bcd7b46ab2cff1797dac04bc3cd12a36209dd579
[ "Apache-2.0" ]
null
null
null
lib/grizzly/packet/decode.ex
pragdave/grizzly
bcd7b46ab2cff1797dac04bc3cd12a36209dd579
[ "Apache-2.0" ]
null
null
null
defmodule Grizzly.Packet.Decode do @moduledoc false import Bitwise alias Grizzly.CommandClass.Mappings alias Grizzly.Packet.HeaderExtension require Logger @packet_types %{ nack_option_error: 0x04, nack_queue_full: 0x08, nack_waiting: 0x10, nack_response: 0x20, ack_response: 0x40, ack_request: 0x80 } @doc """ Unmask the byte for which reponse types are in teh response type byte """ @spec get_packet_types(binary) :: [atom] def get_packet_types(<<_command_data::binary-size(2), packet_types, _rest::binary>>) do @packet_types |> Enum.reduce([], fn {type, byte}, types -> if (packet_types &&& byte) == byte do types ++ [type] else types end end) end @doc """ Get the main Z-Wave body part of the packet """ @spec get_body(<<_::64>>) :: binary def get_body(binary) do header_extension_length = get_header_extension_length(binary) <<_header_data::binary-size(7), _extensions::binary-size(header_extension_length), body::binary>> = binary _ = Logger.debug( "BODY of #{inspect(binary)} is #{inspect(body)}, header extension length is #{ header_extension_length }" ) body end def get_header_extensions(<<_::binary-size(7)>>), do: [] def get_header_extensions(<<_::binary-size(7), extension_length, rest::binary>>) do length = extension_length - 1 <<extensions::binary-size(length), _::binary>> = rest HeaderExtension.from_binary(extensions) end @doc """ Get the length of the header extension """ def get_header_extension_length(<<_header_data::binary-size(7)>>), do: 0 def get_header_extension_length( <<_header_data::binary-size(7), extension_length, _rest::binary>> ), do: extension_length @doc """ Get the sequenece number from the packet """ @spec get_sequence_number(<<_::64>>) :: byte() def get_sequence_number(bytestring) do # Pay the cost of reparsing body now even if we have # parsed it else where in the code. Maybe one day, if performance # is an issue we can optimize this a bit more. body = get_body(bytestring) if network_management_command_class?(body) do get_network_management_sequence_number(body) else get_zip_packet_sequence_number(bytestring) end end def get_zip_packet_sequence_number(<<_frame_data::binary-size(4), seq_no, _rest::binary>>), do: seq_no def get_network_management_sequence_number( <<_command_class_command::binary-size(2), seq_no, _rest::binary>> ), do: seq_no @doc """ Check the body/z-wave command class to see if it is network management """ def network_management_command_class?(<<0x52, _rest::binary>>), do: true def network_management_command_class?(<<0x34, _rest::binary>>), do: true def network_management_command_class?(_), do: false @spec raw(<<_::16>>) :: map() def raw(<<command_class>>), do: %{command_class: Mappings.from_byte(command_class)} def raw(<<0x58, 0x01, _, node_id, ip::binary-size(16), home_id::binary>>) do %{ command_class: :zip_nd, command: :zip_node_advertisement, ip_address: ip_bin_to_tuple(ip), home_id: home_id, node_id: node_id } end def raw(<<0x58, 0x04, _, node_id>>) do %{ command_class: :zip_nd, command: :inv_node_solicitation, node_id: node_id } end defp ip_bin_to_tuple( <<n1::size(16), n2::size(16), n3::size(16), n4::size(16), n5::size(16), n6::size(16), n7::size(16), n8::size(16)>> ) do {n1, n2, n3, n4, n5, n6, n7, n8} end end
27.246269
94
0.657902