Pseudo random number generator

Digg linked to an article that explained how pseudo-random numbers were generated. The formula was simple enough and the article mentionned that the real challenge was coming up with a good seed. I wrote a little method in Ruby to generate a random number, and I used an equation with the current time (in seconds with the decimals) to make a seed. Does that seem reasonably random? Should the method return an integer instead of a float?

def random_number
  t = Time.now.to_f / (Time.now.to_f % Time.now.to_i)
  random_seed = t * 1103515245 + 12345;
  (random_seed / 65536) % 32768;
end

And here’s a sample run

irb(main):099:0> 20.times { puts random_seed }
10960.046875
11691.03125
6374.328125
26752.921875
28869.171875
14963.625
30334.25
15930.8125
30066.5625
23285.0
15296.703125
3166.296875
12232.296875
32135.703125
24721.375
17301.765625
25407.796875
11514.828125
9394.5
30683.4375
20
irb(main):100:0>

That looks pretty random to me, wouldn’t you agree? Thanks for the input.

Dabble demo

Avi and Andrew were at LispVan last Thursday and they demoed Dabble. The fine Lisp folks captured the demo for us all to enjoy and drool. Dabble looks absolutely amazing. A few things are mentionned with the Lisp folks, namely the lack of formulas, which should be coming in a future version, but as Avi (or was it Andrew?) noted, most users use formulas in Excel to do counts, sums and averages, and those three operations are already built into Dabble. Another thing I noted was when Andrew was hiding a few columns, he had to do them one by one. However, I guess with the web you don’t have much choice but to settle for a somewhat cheaper interface to gain maximum portability.

I strongly recommend you watch it. I posted the small version, check out this post by Bill Clementson for the large version, as well as for the presentation on AllegroCache (which I’ve yet to watch).

Harry Potter and The Goblet of Fire

Last night, I went to see the newest Harry Potter movie with Sebastien, Etienne and another guy, Alexandre. Etienne and Alex had orginally planned to catch the 2PM representation, but the theater was jam-packed, and there were no more tickets. They decided to get tickets for the 10:30PM representation. We left for the Colisée at 8:30, we were there at 9:00. We waited in line for an hour and a half, but that was the right thing to do, even though the representation was quite late, every single seat was serving a butt. Coming in early meant we were able to pick good seats, a little above the center of the theater. A good thing: no kids were present. Only pre-teens and up, so no baby crying.

SPOILERS LIE BEYOND THIS POINT! PROCEED ONLY IF YOU HAVE SEEN THE MOVIE, READ THE BOOK, OR DON’T CARE IF I RUIN THE MOVIE FOR YOU!

Of course, we were treated with 10 minutes of publicity, then 20 minutes of movie previews before the actual feature presentation. And at that point, it seems someone in the projection booth decided to piss of the entire audience by projecting a large transparent blue square on the screen. It was quite annoying, and it took them a good 5 minutes to remove it, which ruined the first scene for us, the one were an old guy is killed by Volemort. The blue square was removed afterwards, and we were able to enjoy the movie without further annoyances.

The three actors, Daniel, Emma and Rupert, looked quite older than the first time we saw them, and they were great! Since the book was much longer the previous three, a lot of stuff had to be cut, but the director did a great job taking the essential stuff in and leaving some stuff out. For instance, the quidditch world cup which takes place until page 120 in the book was covered in ten minutes! But you got to see all you needed to see: the port key, the luxury tents, the breath-taking stadium, the death eaters and the mark in the sky. It was very nicely done. No bothering with the purchase of school furniture or hopping aboard the Hogwarts Express.

The Tri-wizard tournament was very interesting. The dragon Harry fights was pretty scary, and the pursuit on the broom was nicely done! The scene, when Harry is in a bath with the golden egg and Mimi Something (what’s her name?) comes over and sort of teases him, was hilarious. The bal was nice too, Hermione looked stunning and Ron looked like a dork. You could really fell in Emma Watson’s interpretation that Hermione was hurt by Ron’s jealousy.

And when Harry and Cedric touched the cup and were transported in the graveyard, wow! I don’t think Ralph Fiennes could ever do a good character, and seeing him as Lord Voldemort only reinforced that belief. He was downright scary: he was so pale, he was almost white, his face looked like that of a snake, his feet and hands had long digits with long, scary-looking nails. I wonder though if it would’ve been better if he’d had a cloak over his head, to make him look more like the grimreaper. I would also have altered his voice: either make it a bit higher with a more snake-like feel, or make it lower with a very faint echo. In any case, he will undoubtly go down in movie history as one of the best evil characters, up there with Darth Vader.

I really enjoyed my night, although I was dead when I came home. I strongly recommend that you see the movie and if you can manage it, read the book too!