735 reputation
914
bio website
location Moscow, Russia
age
visits member for 4 years, 2 months
seen 10 hours ago

isidore.john.r at gmail dot com


Dec
7
awarded  Nice Answer
Oct
28
comment How to play a fixed frequency sound using Python
it should be (2*math.pi)
Oct
28
comment How to play a fixed frequency sound using Python
@user98415: add at the top from __future__ import division to avoid unnecessary truncation on Python 2.
Oct
25
comment Getting + installing gcc/g++ 4.9 on Ubuntu?
some steps are missing for 14.04. sudo pbuilder build gcc-4.9_4.9.0-6.dsc fails.
Oct
17
comment How can a script check if it's being run as root?
in a bash script, you could use if ((EUID)); then, see @geirha's comment
Oct
17
awarded  Necromancer
Oct
14
revised Command for determining my public IP?
use only builtin commands
Oct
14
revised Command for determining my public IP?
send http 0.9 request
Oct
1
awarded  Civic Duty
Sep
30
comment How to display a random line from a text file?
@EliahKagan: 15-bit fails too. It seems failing dieharder tests accept only 32bit input.
Sep
30
comment How to display a random line from a text file?
@EliahKagan: $(( RANDOM <<15 | RANDOM )) (30bit generator) fails the dieharder tests for some reason. See make test-file test.
Sep
26
comment How to display a random line from a text file?
@EliahKagan: you are right ,$_ is missing at the end in the perl command. I might have checked it with ,$_ and edited it out later. Another way to check for zeros is to pipe to hexdump: | hd instead of > out. diehard_birthdays test is passed with while echo $(( RANDOM << 17 | RANDOM << 2 | RANDOM >> 13 )); do :; done | perl -ne 'print pack "I>",$_' | dieharder -a -g 200 command
Sep
26
comment How to display a random line from a text file?
@EliahKagan: RANDOM-based prng for 0..2^32-1 fails dieharder tests: while echo $(( RANDOM << 17 | RANDOM << 2 | RANDOM >> 13 )); do :; done | perl -ne 'print pack "I>"' | dieharder -a -g 200. I also tried to use lower bits (RANDOM & 3) instead of (RANDOM >> 13) (higher bits). I'm not optimistic about $((RANDOM<<15|RANDOM)) for 0..2^30-1 range.
Sep
24
awarded  Autobiographer
Sep
24
comment How to display a random line from a text file?
note: sort -R produces different result than shuf -n1 or select-random if there are duplicate lines in the input. See @EliahKagan's comment.
Sep
24
comment How to display a random line from a text file?
@EliahKagan: How is sort -R different? E.g., even if a lines occur twice as much as any other line: for i in `seq 1000000`; do echo -e 'a\nc\na\nb\n' | sort -R | head -n1 ; done | python -c'from collections import Counter; import sys; print(Counter(sys.stdin))' the result does not show skew: Counter({'\n': 250559, 'a\n': 250100, 'c\n': 249726, 'b\n': 249615})
Sep
24
revised How to display a random line from a text file?
use more direct reference, fix typo
Sep
24
comment How to display a random line from a text file?
e.g., look at the last picture in Test PRNG using gray bitmap to understand why it is not a good idea to apply % n to a random number.
Sep
24
comment How to display a random line from a text file?
Note: $RANDOM % n may skew your random distribution even if $RANDOM itself is ok
Sep
24
comment How to display a random line from a text file?
Note: $RANDOM % n may skew your random distribution even if $RANDOM itself is ok