Current section

Files

Jump to
blah src blah@internet.erl
Raw

src/blah@internet.erl

-module(blah@internet).
-compile([no_auto_import, nowarn_unused_vars]).
-export([username/0, email/0, password/0, passphrase/0, domain_name/0, url/0, ip_v4/0, ip_v6/0, mac/0, long_hex_color/0, short_hex_color/0, hex_color/0, uuid/0, mongo_object_id/0, semver/0, language_code/0, status_code/0, status_code_in_class/1]).
-export_type([http_status_class/0]).
-type http_status_class() :: informational |
successful |
redirection |
client_error |
server_error.
-spec username() -> binary().
username() ->
Adjective = blah@en@word:adjective(),
Last_name = blah@name:last_name(),
Nonce = gleam@int:random(4, 2048),
case Nonce rem 4 of
0 ->
_pipe = [Adjective, Last_name],
gleam@string:join(_pipe, <<""/utf8>>);
1 ->
_pipe@1 = [Adjective, gleam@string:lowercase(Last_name)],
gleam@string:join(_pipe@1, <<"."/utf8>>);
2 ->
_pipe@2 = [Adjective, gleam@string:lowercase(Last_name)],
gleam@string:join(_pipe@2, <<"-"/utf8>>);
3 ->
_pipe@3 = [Adjective, gleam@string:lowercase(Last_name)],
gleam@string:join(_pipe@3, <<"_"/utf8>>)
end.
-spec email() -> binary().
email() ->
Email_domain = blah@utils:get_random_item(
[<<"aol.com"/utf8>>,
<<"gmail.com"/utf8>>,
<<"hotmail.com"/utf8>>,
<<"live.com"/utf8>>,
<<"mail.ru"/utf8>>,
<<"msn.com"/utf8>>,
<<"outlook.com"/utf8>>,
<<"proton.me"/utf8>>,
<<"protonmail.com"/utf8>>,
<<"yahoo.com"/utf8>>,
<<"ymail.com"/utf8>>]
),
_pipe = [username(), Email_domain],
gleam@string:join(_pipe, <<"@"/utf8>>).
-spec password() -> binary().
password() ->
Length = gleam@int:random(8, 32),
blah@en@string:alphanumeric(Length).
-spec passphrase() -> binary().
passphrase() ->
_pipe@1 = [blah@en@word:adjective(),
begin
_pipe = blah@name:first_name(),
gleam@string:lowercase(_pipe)
end,
blah@en@word:verb(),
blah@en@word:adverb()],
gleam@string:join(_pipe@1, <<" "/utf8>>).
-spec domain_name() -> binary().
domain_name() ->
Adjective = blah@en@word:adjective(),
Noun = blah@en@word:noun(),
Nonce = gleam@int:random(4, 2048),
Hostname = case Nonce rem 3 of
0 ->
_pipe = [Adjective, Noun],
gleam@string:join(_pipe, <<"."/utf8>>);
1 ->
_pipe@1 = [Adjective, Noun],
gleam@string:join(_pipe@1, <<"-"/utf8>>);
2 ->
_pipe@2 = [Adjective, Noun],
gleam@string:join(_pipe@2, <<"_"/utf8>>)
end,
Suffix = blah@utils:get_random_item(
[<<"co"/utf8>>,
<<"com"/utf8>>,
<<"edu"/utf8>>,
<<"gov"/utf8>>,
<<"int"/utf8>>,
<<"io"/utf8>>,
<<"mil"/utf8>>,
<<"net"/utf8>>,
<<"org"/utf8>>]
),
_pipe@3 = [Hostname, Suffix],
gleam@string:join(_pipe@3, <<"."/utf8>>).
-spec url() -> binary().
url() ->
Protocol = blah@utils:get_random_item([<<"http"/utf8>>, <<"https"/utf8>>]),
_pipe = [Protocol, <<"://"/utf8>>, domain_name()],
gleam@string:join(_pipe, <<""/utf8>>).
-spec ip_v4() -> binary().
ip_v4() ->
_pipe = gleam@list:repeat(<<""/utf8>>, 4),
_pipe@1 = gleam@list:map(_pipe, fun(_) -> gleam@int:random(0, 256) end),
_pipe@2 = gleam@list:map(_pipe@1, fun gleam@int:to_string/1),
gleam@string:join(_pipe@2, <<"."/utf8>>).
-spec ip_v6() -> binary().
ip_v6() ->
_pipe = gleam@list:repeat(<<""/utf8>>, 8),
_pipe@1 = gleam@list:map(_pipe, fun(_) -> gleam@int:random(0, 65536) end),
_pipe@4 = gleam@list:map(_pipe@1, fun(Field) -> _pipe@2 = Field,
_pipe@3 = gleam@int:to_base16(_pipe@2),
gleam@string:lowercase(_pipe@3) end),
gleam@string:join(_pipe@4, <<":"/utf8>>).
-spec mac() -> binary().
mac() ->
_pipe = gleam@list:repeat(<<""/utf8>>, 6),
_pipe@1 = gleam@list:map(_pipe, fun(_) -> gleam@int:random(0, 256) end),
_pipe@4 = gleam@list:map(_pipe@1, fun(Field) -> _pipe@2 = Field,
_pipe@3 = gleam@int:to_base16(_pipe@2),
gleam@string:lowercase(_pipe@3) end),
gleam@string:join(_pipe@4, <<":"/utf8>>).
-spec long_hex_color() -> binary().
long_hex_color() ->
_pipe@5 = [<<"#"/utf8>> |
begin
_pipe = gleam@list:repeat(<<""/utf8>>, 3),
_pipe@1 = gleam@list:map(
_pipe,
fun(_) -> gleam@int:random(0, 256) end
),
gleam@list:map(_pipe@1, fun(Field) -> _pipe@2 = Field,
_pipe@3 = gleam@int:to_base16(_pipe@2),
_pipe@4 = gleam@string:lowercase(_pipe@3),
gleam@string:pad_left(_pipe@4, 2, <<"0"/utf8>>) end)
end],
gleam@string:join(_pipe@5, <<""/utf8>>).
-spec short_hex_color() -> binary().
short_hex_color() ->
_pipe@4 = [<<"#"/utf8>> |
begin
_pipe = gleam@list:repeat(<<""/utf8>>, 3),
_pipe@1 = gleam@list:map(
_pipe,
fun(_) -> gleam@int:random(0, 15) end
),
gleam@list:map(_pipe@1, fun(Field) -> _pipe@2 = Field,
_pipe@3 = gleam@int:to_base16(_pipe@2),
gleam@string:lowercase(_pipe@3) end)
end],
gleam@string:join(_pipe@4, <<""/utf8>>).
-spec hex_color() -> binary().
hex_color() ->
Nonce = gleam@int:random(4, 2048),
case Nonce rem 2 of
0 ->
long_hex_color();
1 ->
short_hex_color()
end.
-spec uuid() -> binary().
uuid() ->
_pipe = gleam@list:repeat(<<""/utf8>>, 32),
_pipe@1 = gleam@list:map(_pipe, fun(_) -> gleam@int:random(0, 15) end),
_pipe@4 = gleam@list:map(_pipe@1, fun(Digit) -> _pipe@2 = Digit,
_pipe@3 = gleam@int:to_base16(_pipe@2),
gleam@string:lowercase(_pipe@3) end),
gleam@list:fold(
_pipe@4,
<<""/utf8>>,
fun(Uuid, Char) ->
Uuid@1 = gleam@string:append(Uuid, Char),
case gleam@string:length(Uuid@1) of
8 ->
gleam@string:append(Uuid@1, <<"-"/utf8>>);
13 ->
gleam@string:append(Uuid@1, <<"-"/utf8>>);
18 ->
gleam@string:append(Uuid@1, <<"-"/utf8>>);
23 ->
gleam@string:append(Uuid@1, <<"-"/utf8>>);
_ ->
Uuid@1
end
end
).
-spec mongo_object_id() -> binary().
mongo_object_id() ->
_pipe = gleam@list:repeat(<<""/utf8>>, 24),
_pipe@1 = gleam@list:map(_pipe, fun(_) -> gleam@int:random(0, 15) end),
_pipe@4 = gleam@list:map(_pipe@1, fun(Digit) -> _pipe@2 = Digit,
_pipe@3 = gleam@int:to_base16(_pipe@2),
gleam@string:lowercase(_pipe@3) end),
gleam@string:join(_pipe@4, <<""/utf8>>).
-spec semver() -> binary().
semver() ->
_pipe = gleam@list:repeat(<<""/utf8>>, gleam@int:random(2, 4)),
_pipe@1 = gleam@list:map(_pipe, fun(_) -> gleam@int:random(0, 32) end),
_pipe@2 = gleam@list:map(_pipe@1, fun gleam@int:to_string/1),
gleam@string:join(_pipe@2, <<"."/utf8>>).
-spec language_code() -> binary().
language_code() ->
blah@utils:get_random_item(
[<<"aa"/utf8>>,
<<"ab"/utf8>>,
<<"ae"/utf8>>,
<<"af"/utf8>>,
<<"ak"/utf8>>,
<<"am"/utf8>>,
<<"an"/utf8>>,
<<"ar"/utf8>>,
<<"as"/utf8>>,
<<"av"/utf8>>,
<<"ay"/utf8>>,
<<"az"/utf8>>,
<<"ba"/utf8>>,
<<"be"/utf8>>,
<<"bg"/utf8>>,
<<"bh"/utf8>>,
<<"bi"/utf8>>,
<<"bm"/utf8>>,
<<"bn"/utf8>>,
<<"bo"/utf8>>,
<<"br"/utf8>>,
<<"bs"/utf8>>,
<<"ca"/utf8>>,
<<"ce"/utf8>>,
<<"ch"/utf8>>,
<<"co"/utf8>>,
<<"cr"/utf8>>,
<<"cs"/utf8>>,
<<"cu"/utf8>>,
<<"cv"/utf8>>,
<<"cy"/utf8>>,
<<"da"/utf8>>,
<<"de"/utf8>>,
<<"dv"/utf8>>,
<<"dz"/utf8>>,
<<"ee"/utf8>>,
<<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status_code() -> integer().
status_code() ->
{_, Codes} = blah@utils:get_random_item(
[{<<"informational"/utf8>>, [100, 101, 102, 103]},
{<<"successful"/utf8>>,
[200, 201, 202, 203, 204, 205, 206, 207, 208, 226]},
{<<"redirection"/utf8>>,
[300, 301, 302, 303, 304, 305, 306, 307, 308]},
{<<"client_error"/utf8>>,
[400,
401,
402,
403,
404,
405,
406,
407,
408,
409,
410,
411,
412,
413,
414,
415,
416,
417,
418,
421,
422,
423,
424,
425,
426,
428,
429,
431,
451]},
{<<"server_error"/utf8>>,
[500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511]}]
),
blah@utils:get_random_item(Codes).
-spec status_code_in_class(http_status_class()) -> integer().
status_code_in_class(Class) ->
Class_string = case Class of
informational ->
<<"informational"/utf8>>;
successful ->
<<"successful"/utf8>>;
redirection ->
<<"redirection"/utf8>>;
client_error ->
<<"client_error"/utf8>>;
server_error ->
<<"server_error"/utf8>>
end,
[{_, Codes}] = gleam@list:filter(
[{<<"informational"/utf8>>, [100, 101, 102, 103]},
{<<"successful"/utf8>>,
[200, 201, 202, 203, 204, 205, 206, 207, 208, 226]},
{<<"redirection"/utf8>>,
[300, 301, 302, 303, 304, 305, 306, 307, 308]},
{<<"client_error"/utf8>>,
[400,
401,
402,
403,
404,
405,
406,
407,
408,
409,
410,
411,
412,
413,
414,
415,
416,
417,
418,
421,
422,
423,
424,
425,
426,
428,
429,
431,
451]},
{<<"server_error"/utf8>>,
[500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511]}],
fun(Kv) -> gleam@pair:first(Kv) =:= Class_string end
),
blah@utils:get_random_item(Codes).