The Dark Balloon

A weblog by Hao Lian.
A journey into the soft of night.
A terrible secret guarded by golems.

§
Most unique.

If set to TRUE, uniqid() will add additional entropy (using the combined linear congruential generator) at the end of the return value, which should make the results more unique.

“uniqid,” PHP documentation

It’s a weird clause. Adding additional entropy already has a highly specific, mathematical meaning, none of which is conveyed by something more unique. In fact, that would probably confuse the people who are not vaguely aware of entropy and cryptography. If it’s set to false, is it less unique? Will it somehow duplicate itself? Existential crisis, existential crisis, et cetera. All well. Without PHP, the English language would just sit there, unmolested by grammatical atrocities like these.

[(2008 June 6) .]

Recent comments (HAO, Jammies.) • (Tim, Jammies.) • (Prashanth, Wedding.) • (Hao, Hands.) • (Prashanth, Hands.).

Recent posts (03/18, The Daily Show: Oscar Romero and textbooks.) • (02/03, Butter-related greetings.) • (01/18, Happy Martin Luther King, Jr. day.) • (01/18, Chances, part one.) • (01/02, Jammies.).

§
Tunisia, you know what you did.

All these links are fascinating because I'm a fascinating person.

del.icio.us has a little-exploited JSON API. Besides the lack of documentation, it also has one other catch: It automatically backslash-escapes single quotes and turns the quotation mark into ", possibly among other characters. I can only assume the API assumes you will immediately eval the output and then spit it out onto a web page. Hilariously, del.icio.us converts to character entities again, leading you to actually see " strewn around on that demo as pictured above from my links. Anyway, the point is PHP’s json_decode, being the black box Exception-less and soulless monster it is, will silently fail on trying to parse the mess. The solution? Below.

$s = file_get_contents("http://del.icio.us/feeds/json/hao2lian?raw");
$posts = json_decode(stripslashes($s), true);

Getting rid of the automatic character entitification is left as an exercise to the people of Tunisia, who have had it too good for far too long.

[(2008 January 7) .]