jwz - "it's like morons have invaded your screen saver!" [entries|archive|friends|userinfo]
jwz

  www.jwz.org
  userinfo
  archive
  rss

Links
[»| [DNA Lounge] [Blog] [iCal] ]
[»| [DNA Lounge Legal Defense Fund] ]
[»| [WebCollage] [LJ WebCollage] ]

"it's like morons have invaded your screen saver!" [Mon, 1-Sep-2003 6:13 AM]
Previous Entry Add to Memories Tell a Friend Next Entry
[Tags|, , ]
[music |Scar Tissue -- Stance]

A while back, [info]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:

    phosphor -geom =800x900 -scale 3 -delay 25000 -program './ljlatest --cols 40'

    starwars -geom =800x400 -lines 30 -steps 3 -program ./ljlatest

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.)

linkReply

Comments:
[User Picture]From: [info]waider
Mon, 1-Sep-2003 6:26 AM (UTC)

(Link)

[User Picture]From: [info]grumpy_sysadmin
Mon, 1-Sep-2003 6:53 AM (UTC)

Erm...

(Link)

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.
[User Picture]From: [info]eru
Mon, 1-Sep-2003 7:06 AM (UTC)

Re: Erm...

(Link)

It exists under Debian.

man 7 hier:
/usr/games
Binaries for games and educational programs (optional).

ls /usr/games:
banner fortune robotfindskitten
[User Picture]From: [info]waider
Mon, 1-Sep-2003 7:15 AM (UTC)

Re: Erm...

(Link)

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".
[User Picture]From: [info]suppafly
Mon, 1-Sep-2003 11:47 AM (UTC)

(Link)

don't most distro's give you the option to install the bsdgames? i've seen the option on most that i've installed.
[User Picture]From: [info]saintnobody
Mon, 1-Sep-2003 7:27 AM (UTC)

(Link)

quoth the perlunicode(1) man page from v5.6.1:
As of yet, there is no method for automatically coercing input and output to some encoding other than UTF-8. This is planned in the near future, however.

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.
[User Picture]From: [info]brad
Mon, 1-Sep-2003 11:11 AM (UTC)

(Link)

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.
[User Picture]From: [info]saintnobody
Mon, 1-Sep-2003 11:47 AM (UTC)

(Link)

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.
[User Picture]From: [info]ivorjawa
Mon, 1-Sep-2003 8:44 AM (UTC)

(Link)

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.
[User Picture]From: [info]jwz
Mon, 1-Sep-2003 12:12 PM (UTC)

"sewer rat may taste like pumpkin pie, but I'll never know"

(Link)

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.
[User Picture]From: [info]ciphergoth
Mon, 1-Sep-2003 1:08 PM (UTC)

Re: "sewer rat may taste like pumpkin pie, but I'll never know"

(Link)

Er, you know that every experienced programmer reacts that way right up until the point where they've tried it for a while?
[User Picture]From: [info]jwz
Mon, 1-Sep-2003 1:12 PM (UTC)

Re: "sewer rat may taste like pumpkin pie, but I'll never know"

(Link)

Good for them.
[User Picture]From: [info]marklyon
Tue, 2-Sep-2003 4:59 AM (UTC)

Re: "sewer rat may taste like pumpkin pie, but I'll never know"

(Link)

Amen. My code should not get fucked up if I want space it differently than how someone decides that I should.
[User Picture]From: [info]denshi
Wed, 3-Sep-2003 9:13 PM (UTC)

Re: "sewer rat may taste like pumpkin pie, but I'll never know"

(Link)

And thus, line-numbered source code was born.
[User Picture]From: [info]phygelus
Thu, 4-Sep-2003 7:18 AM (UTC)

Re: "sewer rat may taste like pumpkin pie, but I'll never know"

(Link)

mmm... line numbers
[User Picture]From: [info]livejournalsux
Tue, 2-Sep-2003 6:55 AM (UTC)

(Link)

Great Movie.
[User Picture]From: [info]cyeh
Thu, 17-Mar-2005 8:12 PM (UTC)

Re: "sewer rat may taste like pumpkin pie, but I'll never know"

(Link)


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.




[User Picture]From: [info]gwillen
Tue, 27-May-2008 4:30 PM (UTC)

Re: "sewer rat may taste like pumpkin pie, but I'll never know"

(Link)

I'm guessing that was supposed to be the <TAB> vs. <SP> insanity.
[User Picture]From: [info]novalis
Thu, 17-Mar-2005 10:17 PM (UTC)

Re: "sewer rat may taste like pumpkin pie, but I'll never know"

(Link)

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.
[User Picture]From: [info]ch
Fri, 18-Mar-2005 1:40 AM (UTC)

Re: "sewer rat may taste like pumpkin pie, but I'll never know"

(Link)

yeah, i can't get past the whitespace thing either.

that and there's no support for hyper, meta, and super bits on characters.
[User Picture]From: [info]brianenigma
Mon, 1-Sep-2003 10:53 AM (UTC)

(Link)

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...
[User Picture]From: [info]nerpdawg
Mon, 1-Sep-2003 11:14 AM (UTC)

(Link)

The script is wonderful, but now that I can see the latest lj posts, oi..
[User Picture]From: [info]evan
Mon, 1-Sep-2003 12:50 PM (UTC)

(Link)

It's depressing.
From: [info]node
Mon, 1-Sep-2003 2:45 PM (UTC)

timeout

(Link)

30 seconds isn't enough to download the rss file over 33.6k dialup. 60 seconds appears to work fine.
[User Picture]From: [info]earle
Tue, 2-Sep-2003 6:22 AM (UTC)

No need to do the hard work yourself

(Link)

(Reposted without the formatting that messed up the table in your comments page. Sorry.)

You're doing...
my %entity_table = (
   "quot"   => '"', "amp"    => '&', "lt"     => '<', "gt"     => '>',
   "nbsp"   => ' ', "iexcl"  => '¡', "cent"   => '¢', "pound"  => '£',

...and so on.

This is reinventing a wheel; no need. Use HTML::Entities and save yourself a whole lot of pain.

> My understanding of Perl Unicode handling has not 
> yet risen to the "cargo cult" level

Try something like Unicode::Lite.

[User Picture]From: [info]gwillen
Tue, 27-May-2008 5:12 PM (UTC)

Re: No need to do the hard work yourself

(Link)

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?
[User Picture]From: [info]earle
Wed, 28-May-2008 8:11 AM (UTC)

Re: No need to do the hard work yourself

(Link)

abomination

With an attitude like that it's clearly not worth my time answering.