Skip to content

Instantly share code, notes, and snippets.

@gaurav
Created May 12, 2009 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaurav/110333 to your computer and use it in GitHub Desktop.
Save gaurav/110333 to your computer and use it in GitHub Desktop.
A Perl one-liner to check that $seconds_since_the_house % $NO will distribute correctly across $NO machines.
# A one-liner to ensure that $seconds_since_the_hour % $NO will distribute equally.
perl -Mstrict -e 'my $NO = 6; my @a = (); push @a, int rand(60) for(1 .. 1_000); my %b = (); $b{$_ % $NO}++ for(@a); print "$_ => $b{$_}\n" for sort { $a <=> $b } keys %b;'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment