A while back,
evan added an
RSS feed that constantly spits out the most-recent public LJ posts. I just hacked up
a little perl script that reads that and converts it to line-wrapped Latin1 text, after doing minimal de-HTMLification. This means you can use it as a "fortune" program with xscreensaver. For example:
My understanding of Perl Unicode handling has not yet risen to the "cargo cult" level, so any improvements would be welcome (I think it should be possible to make Perl do the charset munging I did, but I couldn't figure out how.)
Reminds me: XScreensaver vs. RedHat
Did you build XScreensaver by hand, or did you install RH's package for it?
'cause, uh, /usr/games doesn't exist under any Linux distro (it's a BSD thing). And it's very easy to change the fortune path, at least at compile-time.
It exists under Debian.
man 7 hier:
/usr/games
Binaries for games and educational programs (optional).
ls /usr/games:
banner fortune robotfindskitten
It's actually in /usr/share/games on newer Red Hats (fsstd or whatever), but that's neither here nor there. As of Red Hat 9 they're no longer shipping fortune due to "unclear copyright status".
don't most distro's give you the option to install the bsdgames? i've seen the option on most that i've installed.
quoth the perlunicode(1) man page from v5.6.1:
so it seems that, while you can read it in as unicode, you can't force it to output as latin1. iirc, the character encoding support is much better in perl 5.8, but i don't think that has wide enough adoption to require it.
The perl core doesn't support it, but there are Perl modules to do it. We do it on LiveJournal with Unicode::MapUTF8 which can go to/from UTF-8 and any other charset.
true. there's a perl module for damn near everything conceivable. but requiring a perl module for things to work has its own problems. as it is, his solution is kind of a hack, but at least it works without anybody having to download a module or install a new version of perl.
Python has nice unicode support, and a decent XML parser "out of the box", making it very useful for this kind of web services work. I'll see if I can hack something together if I ever stop sneezing today.
I'm one of those people who, despite Python's lispy hype, will not ever even consider going near the language because of The Whitespace Abomination.
Er, you know that every experienced programmer reacts that way right up until the point where they've tried it for a while?
Good for them.
Amen. My code should not get fucked up if I want space it differently than how someone decides that I should.
And thus, line-numbered source code was born.
mmm... line numbers
Great Movie.
Ah-fucking-men. I've been working with make for 9 years. I am not an idiot. Yet, just today I got bit by the vs. insanity.
I'm with you.
I'm guessing that was supposed to be the <TAB> vs. <SP> insanity.
Anyway, Perl and Ruby are lispier. Python's lambda doesn't do closures automatically. Perl's anonymous sub does, and Ruby's blocks do. Ruby lets you do a whole bunch of stuff which feels a bit like redefining the syntax of the language.
yeah, i can't get past the whitespace thing either.
that and there's no support for hyper, meta, and super bits on characters.
Wow, that's funny--I posted Java code a couple of days ago to do something similar. (I had a version in Perl a while back, but it was the worst Perl hack ever, considering I suck with the language.) The Java code uses the "find random user" function in LJ along with another function to force an entry to be viewed in a particular style (for easy parsing) instead of the recent posts feed, but I use it for the same sort of thing (the starwars screensaver on my Freevo box hooked to a big TV).
Now, if we could just hack the LJ code to return a random entry as an RSS feed...
The script is wonderful, but now that I can see the latest lj posts, oi..
It's depressing.
30 seconds isn't enough to download the rss file over 33.6k dialup. 60 seconds appears to work fine.
(Reposted without the formatting that messed up the table in your comments page. Sorry.)
You're doing...
...and so on.
This is reinventing a wheel; no need. Use HTML::Entities and save yourself a whole lot of pain.
Try something like Unicode::Lite.
Use HTML::Entities
something like Unicode::Lite
Are these things that come with Perl, and are thus useful in a program meant to be distributed; or are they in the CPAN abomination?
abomination
With an attitude like that it's clearly not worth my time answering.