soyjeansoy
StreamData: how to generate a list of 2 strings with varied length
Hi!, how do i generate a list contains only 2 strings with varied length ie [“foo”, “baaar”]?
I tried:
# returns ["QrGgkWA7o1", "NbWbClnTYk"]
Enum.take(StreamData.string(:alphanumeric, length: 10), 2)
Marked As Solved
rodrigues
yeah @soyjeansoy it starts with the smallest strings and progresses into bigger lengths, not sure how “random” that can be.
iex(1)> StreamData.string(:alphanumeric) |> Enum.take(2)
["D", "k"]
iex(2)> StreamData.string(:alphanumeric) |> Enum.take(2)
["E", "yj"]
iex(3)> StreamData.string(:alphanumeric) |> Enum.take(20)
["j", "g", "yLc", "", "DxC8", "", "n", "q9kgIX", "", "Jg", "b", "jJs1",
"3UrpsF", "IcNUZBQ", "NC70Mt6Y4Daa", "s61D8798DT", "KiBfNzUonUT0Bg", "DVWUXgE",
"5J3s6GlISUrIGE", "SQLtS0KHTakmLhU"]
iex(4)> StreamData.string(:alphanumeric, max_length: 12) |> Enum.take(83)
["b", "LE", "", "", "H", "kMYa", "", "4hZuN", "jJ3dy", "0mGT9", "FURUUin",
"DzOI", "TTZhhaw6N9", "82vV", "nOYc1QH7", "4BWy", "OLeM4nH53Qw", "TDgXLM",
"tRl4ldXT", "vtu3H", "ZgRk", "", "o9xU", "S7wMlwblNv", "l3O0elqjVs1I",
"y2uedOct", "8esTi7", "dntRYmip", "ZADJRjfc4X", "AW", "Skpd8cO5YzI", "",
"OUxE", "QhFmCxkid", "", "XwofgD7aPVZ", "881", "xSgP5fmwnHbX", "Q6pF7jcLdx",
"L53yvQVqgcDQ", "H", "FMci4VTvM", "BsVp", "56", "eA2ZV", "", "llEjsPyurF",
"QFYnr", "uNIp", "kmbMS", ...]
You can pass a min_length if you don’t want them too small.
2
Popular in Questions
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I’m writing a test for one of the...
New
For example for a current url like
http://localhost:4000/cosmetic/products?_utf8=✓&query=perfume&page=2,
I would like to get:
...
New
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
I am trying to implement my new.html.eex file to create new posts on my website.
new.html.eex:
<h1>Create Post</h1>
<%= ...
New
Hi all,
Trying to get some more clarity over utc_datetime and naive_datetime for Ecto:
The documentation above suggests that while ...
New
Hi!
In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir?
Searched the docs for ip address and the web, no good results.
Thanks!
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
Hi everyone,
I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Other popular topics
lets say i have a sample like
a = 20; b = 10;
if (a > b) do
{:ok, "a"}
end
if (a < b) do
{:ok, b}
end
if (a == b) do
{:ok, "equa...
New
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance










