Log in

No account? Create an account
entries friends calendar profile my webpage Previous Previous Next Next
Random Geekiness. - Tina Marie's Ramblings
Red hair and black leather, my favorite colour scheme...
Random Geekiness.
I installed fortune yesterday, along with an http interface (found here).

My next step is to render a fortune as a jpg, so it can be embedded in my LJ without needing to call an external CGI script (which isn't allowed). I was using imc to render the text, but quickly found a bug in their regex processing that prevents you from having semicolons and double quotes in the rendered text. I'm hoping to get it fixed today. In the meantime, this is how far I've gotten: Fortune.png.

I finished Arrow's Flight yesterday morning, and started The Professor And The Madman last night. However, Dylan sent me a box of Rincewind books which take precedence, so it'll go back on the stack (is that why they call them 'stacks' in a library?).

Tags: ,

7 comments or Leave a comment
alioth1 From: alioth1 Date: March 30th, 2005 05:20 pm (UTC) (Link)
You can also use something like Perl's GD module to render the final PNG image if what you're using turns out to be a problem.
alioth1 From: alioth1 Date: March 30th, 2005 05:42 pm (UTC) (Link)
Mine is more of a hash in the form $BOOKS->{title}... rather than a stack (or list) where you'd have to push/pop or shift/unshift only off the ends :-)
skywhisperer From: skywhisperer Date: March 31st, 2005 05:34 pm (UTC) (Link)
You know, mine is closer to a stack.

I have a literal stack of unread books by the side of the bed, and they get read more-or-less in order. New stuff actually gets sorted into the stack, not necessarily pushed, and I've got a little holding area where the current book goes, but there's room there for 2, and right now there are 2 there.

Define _that_ data structure in perl. :)
alioth1 From: alioth1 Date: April 1st, 2005 05:17 pm (UTC) (Link)
Ah, that's just an array of arrays - one array being your stack, and the other array being your holding area.
So to take a book off the stack and add it to the holding area:

push $bookpile->[$holding], pop $bookpile->[$stack];

Of course if your holding area is only ever big enough for two, then you keep the stack as a simple array from which you push, pop, unshift and shift, and the holding area as two scalars.
sgillbee From: sgillbee Date: March 30th, 2005 09:41 pm (UTC) (Link)
I'm really not sure what's worse:

a. I think this is rather cool.
b. I understand the problem with the regex.
c. I actually started mentally recomposing the regex to fix this problem.
d. I found Dylan's comment about stacks/hashes both funny and very descriptive.

I am such a geek.
skywhisperer From: skywhisperer Date: March 30th, 2005 09:45 pm (UTC) (Link)
The old regexp:

while ($line =~ s/^([^;]+);(.*)/$2/) {


while ($line =~ s/^((([^"]*)("([^"]*)")([^;]*)));(.*)/$7/) {

Anyway, it's fixed now: http://www.tripacerdriver.com/fortune.png
Updates every hour, at 23 after. Feel free to link to it. :)

I sent it off to the author to go in the next fix.
alioth1 From: alioth1 Date: March 31st, 2005 05:27 pm (UTC) (Link)
Just remember whilst you hack at your Perl:

There was a Perl hacker named Ray
Who wanted the time of the day
He pushed and he popped
And shifted and chopped
Till tomorrow was somehow today.

Or if you're writing cgi scripts:

Roses are red
Violets are blue
Taint check your scripts
Or I w1ll pwn j00
7 comments or Leave a comment