-module(blah@internet). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([username/1, password/0, passphrase/0, ip_v4/0, ip_v6/0, mac/0, long_hex_color/0, short_hex_color/0, hex_color/0, email/1, domain_name/0, uri/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()) -> binary(). username(Name) -> Adjective = blah@en@word:adjective(), Nonce = blah@utils:get_random_int(4, 2048), case Nonce rem 8 of 0 -> _pipe = [Adjective, gleam@string:replace(Name, <<" "/utf8>>, <<""/utf8>>)], gleam@string:join(_pipe, <<""/utf8>>); 1 -> _pipe@1 = [Adjective, gleam@string:replace( gleam@string:lowercase(Name), <<" "/utf8>>, <<"."/utf8>> )], gleam@string:join(_pipe@1, <<"."/utf8>>); 2 -> _pipe@2 = [Adjective, gleam@string:replace( gleam@string:lowercase(Name), <<" "/utf8>>, <<"-"/utf8>> )], gleam@string:join(_pipe@2, <<"-"/utf8>>); 3 -> _pipe@3 = [Adjective, gleam@string:replace( gleam@string:lowercase(Name), <<" "/utf8>>, <<"_"/utf8>> )], gleam@string:join(_pipe@3, <<"_"/utf8>>); 4 -> _pipe@4 = [Adjective, gleam@string:replace(Name, <<" "/utf8>>, <<""/utf8>>), blah@en@string:with_pattern(<<"%d%d"/utf8>>)], gleam@string:join(_pipe@4, <<""/utf8>>); 5 -> _pipe@5 = [Adjective, gleam@string:replace( gleam@string:lowercase(Name), <<" "/utf8>>, <<"."/utf8>> ), blah@en@string:with_pattern(<<"%d%d"/utf8>>)], gleam@string:join(_pipe@5, <<"."/utf8>>); 6 -> _pipe@6 = [Adjective, gleam@string:replace( gleam@string:lowercase(Name), <<" "/utf8>>, <<"-"/utf8>> ), blah@en@string:with_pattern(<<"%d%d"/utf8>>)], gleam@string:join(_pipe@6, <<"-"/utf8>>); _ -> _pipe@7 = [Adjective, gleam@string:replace( gleam@string:lowercase(Name), <<" "/utf8>>, <<"_"/utf8>> ), blah@en@string:with_pattern(<<"%d%d"/utf8>>)], gleam@string:join(_pipe@7, <<"_"/utf8>>) end. -spec password() -> binary(). password() -> Length = blah@utils:get_random_int(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 ip_v4() -> binary(). ip_v4() -> _pipe = gleam@list:repeat(<<""/utf8>>, 4), _pipe@1 = gleam@list:map(_pipe, fun(_) -> gleam@int:random(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(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(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(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(16) 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 = blah@utils:get_random_int(4, 2048), case Nonce rem 2 of 0 -> long_hex_color(); _ -> short_hex_color() end. -spec email(binary()) -> binary(). email(Name) -> 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(Name), Email_domain], gleam@string:join(_pipe, <<"@"/utf8>>). -spec domain_name() -> binary(). domain_name() -> Adjective = blah@en@word:adjective(), Noun = blah@en@word:noun(), Nonce = blah@utils:get_random_int(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>>); _ -> _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 uri() -> binary(). uri() -> Nonce = blah@utils:get_random_int(4, 2048), Protocol = blah@utils:get_random_item([<<"http"/utf8>>, <<"https"/utf8>>]), case Nonce rem 4 of 0 -> _pipe = [Protocol, <<"://"/utf8>>, domain_name()], gleam@string:join(_pipe, <<""/utf8>>); 1 -> _pipe@1 = [Protocol, <<"://"/utf8>>, domain_name(), <<"/"/utf8>>], gleam@string:join(_pipe@1, <<""/utf8>>); 2 -> _pipe@4 = [Protocol, <<"://"/utf8>>, domain_name(), <<"/"/utf8>>, begin _pipe@2 = gleam@list:repeat( <<""/utf8>>, blah@utils:get_random_int(2, 8) ), _pipe@3 = gleam@list:map( _pipe@2, fun(_) -> blah@en@word:noun() end ), gleam@string:join(_pipe@3, <<"/"/utf8>>) end], gleam@string:join(_pipe@4, <<""/utf8>>); _ -> _pipe@7 = [Protocol, <<"://"/utf8>>, domain_name(), <<"/"/utf8>>, begin _pipe@5 = gleam@list:repeat( <<""/utf8>>, blah@utils:get_random_int(2, 8) ), _pipe@6 = gleam@list:map( _pipe@5, fun(_) -> blah@en@word:noun() end ), gleam@string:join(_pipe@6, <<"/"/utf8>>) end, <<"/"/utf8>>], gleam@string:join(_pipe@7, <<""/utf8>>) end. -spec status_code() -> integer(). status_code() -> {_, Codes} = blah@utils:get_random_item( [{informational, [100, 101, 102, 103]}, {successful, [200, 201, 202, 203, 204, 205, 206, 207, 208, 226]}, {redirection, [300, 301, 302, 303, 304, 305, 306, 307, 308]}, {client_error, [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, [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) -> _assert_subject = gleam@list:filter( [{informational, [100, 101, 102, 103]}, {successful, [200, 201, 202, 203, 204, 205, 206, 207, 208, 226]}, {redirection, [300, 301, 302, 303, 304, 305, 306, 307, 308]}, {client_error, [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, [500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511]}], fun(Kv) -> gleam@pair:first(Kv) =:= Class end ), [{_, Codes}] = case _assert_subject of [{_, _}] -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"blah/internet"/utf8>>, function => <<"status_code_in_class"/utf8>>, line => 234}) end, blah@utils:get_random_item(Codes).