Just coming across this. I like finding and using old gems. For this, jot does just great.
jot
jot -w %04d 9999 | shuf > /path/to/pins.txt
Or for those on a Mac using GNU coreutils (probably from brew), you'd use gshuf instead of shuf:
brew
gshuf
shuf
jot -w %04d 9999 | gshuf > /path/to/pins.txt
Of course, Ruby is just as elegant:
ruby -e 'puts ("0000"..."9999").to_a.shuffle' > /path/to/pins.txt
... but on my machine the Ruby solution is about 95% slower than the jot version: 148ms vs. 8ms, respectively.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Just coming across this. I like finding and using old gems. For this,
jot
does just great.Or for those on a Mac using GNU coreutils (probably from
brew
), you'd usegshuf
instead ofshuf
:Of course, Ruby is just as elegant:
... but on my machine the Ruby solution is about 95% slower than the
jot
version: 148ms vs. 8ms, respectively.