LJRandText

Please note that all blog posts before 8 April 2007 were automatically imported from LiveJournal.  To see the comments and any LiveJournal-specific extras such as polls and user icons, please find the source posting at http://brianenigma.livejournal.com/2003/08/

So this past hour or so, I wrote a little program. Or rather, “rewrote” more accurately describes it. Basically, it will take a random username from LJ, grab a page of their entries, and return one entry. I had something like this a while back in Perl, but I think I lost the code, and I do not really know Perl very well, so it was a major hack. This new version is written in Java and has a few different options for what it returns to you: just a username without an entry, an entry that has been HTML-scrubbed, or an entry that has all of the original HTML formatting. The app is a command-line program contained in a Jar file, so everything is returned on stdout and stderr, like and good Unix program.

So, anyway, in case anyone is interested, it is available at https://netninja.com/files/LJRandText-1.0.zip. It requires Java 1.4 installed, but most people have that nowadays. It is invoked by simply running the Jar file from the command line, like java -jar LJRandText.jar -t where the “-t” returns text and can be substituted with “-h” for HTML or “-u” for a username. The result is on stdout and can be piped to the program of your choice. Right now, there is a minor bug where certain journals appear, to the program, to be entirely private with no public entries. It is not a big deal because it retries until it finds a journal it likes (or until it times out).

Previously, I had it hooked up to the XScreensaver “Star Wars scrolling text” module, so you see this epic text scroller sending people's log entries into galaxies long ago and far away. I do not use XScreensaver anymore (OS X, and all), but I am sure I will come up with an interesting and unusual way to use this.

Posted in: Code Dear Diary

Leave a Reply

Your email address will not be published. Required fields are marked *