php

ShuffleBag Ports

shuffling diagram
The art of shuffling

What it says on the tin, really

Here you'll get Flash (AS3), haXe, JavaScript, PHP, Perl, and Python ports of my continuous shuffled sequence algorithm. (Update: There are C# and C++ versions in the comments.) As usual the code is available under a Zero-clause BSD-style license, which means you can use it in any way you like.

All implementations utilize an un-seeded default source of randomness. If determinism is required, you'll only need to hand over a PRNG and use that one instead. Or hand the seed over and initialize the PRNG with that one as the original Java version did it.

If you port it to other languages or if you modify it a bit (e.g. as outlined above), you'll have to verify that it works correctly. Fortunately testing it isn't that hard. E.g. if you add "X" and "O" and call next four times you should receive one of the following sequences:

  • XXOO
  • OOXX
  • XOOX
  • OXXO
  • XOXO
  • OXOX

Generating a QR Code for the Current URL (Google Chart API/Drupal 6.x)

QR code of this URL
QR code for this URL

Just a few hours ago Google announced the latest feature of their chart API: QR Codes. I always thought that it might be cool to have some QR image of the current URL on my website. So, if someone happens to read one of my articles over at some internet café or at a friend's machine, a QR code might be handy for "bookmarking".

Writing a QR encoder with PHP didn't look like much fun though. And then there is the processing overhead, which can be addressed with caching, but that only means more work. There is also that random string DoS attack vector. Far too much hassle, really. But if Google takes care of all that, it's a piece of cake.

That's why I wrote a little test module for Drupal. It lacks width/height options, but apart from that it's fully functional (as far as I can tell).

Syndicate content