Things, what I have made.
A few of the little projects I've been working on, may be useful to someone else. I use Perl for almost everything these days.
All Perl code has been tested on both Linux and Mac OS X systems. Most require the Term::ANSIColor module. It's installed as standard on most modern systems.
All my work belongs to me and anyone can use it under the terms of the GPL. So if you find it handy, let me know. If you find some problems, or if you fix some obvious ones, please do let me know.
Libraries
Any libraries, that is shared code, required by the programs are listed along
with them. Just keep them in the same folder/directory as the program.
-DOWNLOAD
Some of the files you download will now have -DOWNLOAD at the end of the filename, this is to stop the
web server from trying to execute them and let you have the source code. To use the files just delete
the -DOWNLOAD from the end of the filename.
I'll try and find a more elegant solution soon.
Thu, 25 Sep 2008 19:01:51 GMT
Update: cleaned up the output, slimmed down the code.
I've been fiddling with a bit more Perl code and built two versions of a quite useful tool for searching the BBC iPlayer.
There is no system for subscribing to shows so I can see when new episodes appear.
So I made one.
It's very simple, runs as a cron job and sends me an e-mail when episodes of of shows I'm interested in appear.
As I have a few tools that search the iPlayer and tell me about it in different ways, I moved the actual searching subroutine into a shared file.
So first up, here is the simple iPlayer search tool modified to use this.
iplayer-search
This presents the results in a nicely colour coded way, like this:
While this looks nice, I needed a version that is silent when there is no hits, iplayer-search always returns the header and the search term, also the ANSIColor details make no difference when viewed with a mail client, so I can leave them out too.
iplayer-notify
The quiet and plain version is called iplayer-notify.
This I add as cron jobs, using:
Like this:
So each morning I get e-mails about any available episodes of shows I may like to see.
Make sure you set your actual email address in the crontab file, like this:
Obviously use your own address not mine. You need it to tell you when your shows are on, not me. :)
Hopefully that will be a bit helpful to someone.
Libraries
lib-rf-iplayer.pl
Download
iplayer-search
iplayer-notify
All these tools require LWP::Simple, which Ubuntu/Debian users can install from the console with:
Everyone else can use CPAN.
Thu, 04 Sep 2008 18:49:35 GMT
Update: The code has been updated to only take the last 20 posts for the RSS file. The file was getting too big to be useful as one large file.
Also the HTML generation was adjusted to create separate pages with 20 posts per page.
An RSS feed generation system, the RSS feed generation is generic enough to be useful, the HTML generating code could be handy but it would take some adaptation to make any real use of it.
I wanted to add an RSS feed to the site. Mostly as I find them so handy elsewhere. Of course I wanted it integrated nicely into my pages, also as this web host doesn't provide CGI bin it had to work offline and upload the pages from here.
So, simple enough. First I looked up the spec of RSS on Wikipedia, which lead me to the RSS Advisory Board. Also very handy was feedvalidator.org.
Next I created an RSS feed for this site by hand. Once I had it validating okay I moved on to the next stage.
All the update posts are stored as individual files in a directory called posts. The files are very simple, the first line is the title, second the date, third the category and the rest of the file is the article text.
The script (sitebuild-update-rss) opens the RSS file, writes a standard header, then reads each post, pulling the first three lines off to create the item header then writes the item to the file.
Once that's done, it writes the foot to the page and it's done.
Similar scripts create the front page (sitebuild-update-index) and a set of pages of previous blog posts (sitebuild-update-html).
The shell script (sitebuild-update) runs each script in turn and then uploads the whole lot using ncftp.
Download
sitebuild-update-rss
sitebuild-update-html
sitebuild-update-index
sitebuild-update
Libraries
lib-rf-sitebuild.pl
lib-rf-babble.pl
lib-rf-date.pl
Thu, 04 Sep 2008 15:31:36 GMT
A simple tool for generating a date string in the format needed for RSS feeds. This replaces a shell script that called the GNU date tool.
The shell script was very, very simple. Like this:
I used the same command as this in the sitebuild-update-rss script. But a pure Perl solution is faster that starting a shell, running an external command and capturing that output.
So I wanted a Perl version. And here it is.
Download
mydate
Libraries
lib-rf-date.pl
Thu, 04 Sep 2008 14:22:26 GMT
I've been collecting together the Perl versions of my various random stuff for roleplay programs, collecting the arrays and subroutines into a shared library of code so I can combine the effects in new ways.
I started this a while back, but the last few days I've got all the old code moved over.
As a first step, here are the old programs, tavern, dishoftheday, names-male and names-female converted to use the combined library.
As an example, here is the new version of tavern:
The $RealBin finds the directory where you've put the program and finds the library there.
Then it's simple calling the tavern() function from library and printing the result.
To install all this stuff, just dump it in a directory together and run the programs from a terminal.
If terminals aren't you're thing, there are still the web based Javascript versions here:
As well as these roleplay tools, I've converted the technobabble generator in the same way. The sitebuild tools that create this page now use the babble library for the blog pages.
The plan is to create more kinds of technobabble and add them to the babble library soon.
Download
tavern
dishoftheday
names-female
names-male
babble
Libraries
lib-rf-babble.pl
lib-rf-roleplay.pl
A simple tool for the d20 Modern roleplay game. Converts a value in dollars to the abstract wealth check value used in the game. Also works in reverse.
Usage:
Download
wealth
A simple script for randomly generating some technobabble, it pulls a random element from three arrays and prints the result.
Usually I'd do this sort of thing in Perl, I've done similar things for random name generators in the past. However this was for the Tuesday nights group to use during our games and I wanted to host it here on my webspace. This free webspace doesn't provide CGI for me so I had to do something client-side, to put this together with a little JavaScript.
This was my first Javascript project for over ten years. I may just start using it more.
As an update I rewrote the technobabbler as a function, this allows me to pull random technobabble into other pages more easily, such as the subtitle for this part of the page. Refresh the page to see it change, view the source to see how it works.
As that was so handy I wrote random thing generators for our D&D games too, creating NPCs and Taverns. These two are still under development but you can see the progress with the code here.
Download
babble.js
npc.js
tavern.js
Open the Technobabbler.
My Wife's POP3 mailbox was jammed up with 6000 junk mails, so I went and wrote this little tool to clear the thing out. I didn't fancy typing "dele" 6000 times. It uses the module Net::Telnet you can get from CPAN or your distro.
Update: Added a version that just checks, not clears the mailbox, check-mailbox.
Usage:
Download
clear-mailbox
check-mailbox
When s/s/z/g was cool.
Part of a project I did at Uni, a free floating toolbox of commonly used HTML, handy alongside any text editor.
This was done back on Windows 3.1 and requires the Visual Basic 3 libraries available from Microsoft.com. Works with WINE too.
Usage: Just run the Executable.
Download
toolz.exe