perl hacks

This page contains links to some of my perl hacks. It is autogenerated from the comments (if any) at the head of each file.

DCOP.pm(updated Wed Jan 23 07:27:33 2008)
# the CPAN-provided DCOP is awful: it uses backticks to do the heavy
# lifting, so you need to preprocess any data you hand to it to remove
# dangerous things like, well, more backticks. So I'm fixing it
# here.


Device(updated Wed Nov 21 12:29:52 2012)
Subdirectory
ExchangeRate.pm(updated Tue Jan 6 01:00:14 2009)


MapServer(updated Wed Nov 21 12:29:52 2012)
Subdirectory
MapServer.pm(updated Wed Jul 6 16:41:00 2005)
# Interface to various online map servers.
# Waider 2001


Monitor(updated Wed Nov 21 12:29:53 2012)
Subdirectory
Monitor.pm(updated Sat Jun 5 14:51:59 2004)
# Created: Waider 26 September 2000
# Last Modified: Waider 08 October 2000
# October 2002:
# Use Gtk::Perl
# -----------------------------------------------------------------------------


Net(updated Wed Nov 21 12:53:04 2012)
Subdirectory
RVP.pm(updated Mon Aug 27 06:22:06 2007)
#
# cheap RVP server implementation.
#
# Bolting this onto your Apache server:
# PerlSwitches -I/path/to/RVP/module
# <Location /instmsg>
# PerlHeaderParserHandler RVP
# </Location>
#
# You also require a mysql database; the schemas required are at the
# end of this script.
#
# Main TODO item:
# * implement ACL controls.
# most of this works pretty well
# * polling would be good


SrvMon.pl(updated Fri Oct 4 08:50:48 2002)
# Quick hack to monitor some stuff on Spike / Waider, May/June 2000


Stock.pm(updated Sat Sep 29 14:49:39 2018)
#
# Stock Quote Module
#
# Currently actually a Yahoo Stock Quote Module; if I feel the urge I
# may build a module tree instead. Based on previous Stock Exchange
# efforts.
#
# Waider 07/06/2003


UPC(updated Wed Nov 21 12:29:53 2012)
Subdirectory
UPC.pm(updated Mon Jan 4 22:49:46 2016)


advert-server.pl(updated Tue Jan 13 16:47:27 2004)
# Ad Banner server for ad-free webbing.
# Original code Waider 1997 or so.
# Revamped July 2000 when I learned a little more about Perl, but it's
# still disgusting. It's not multithreaded or anything.
#
# December 2001: Mozilla no longer groks XBMs, or at least not with
# the headers I'm putting out. So I'm switching to PNGs, as I'd
# planned on doing at some point anyway.
#
# While I was at it, I cleaned up the code a little. Not much, though.
#
# April 20, 2003: Conditionalised printing of request details
# 06/08/2003: fortune is no longer packaged on redhat, alas.


airprint-republish.pl(updated Mon May 4 10:27:28 2015)
#
# add airprint records to match any existing printers
#


botrc(updated Sun Jul 2 12:02:52 2006)


cabarc(updated Sun Jul 20 21:01:25 2003)
#
# Perl Script to emulate Windows cabarc
# Incomplete, naturally.
# Waider, some time in 1998
#
# Wow. Listing mode actually works on old cabfiles.
# 2003/01/06 Add use strict, fix resulting errors
# 2003/07/14 Started working on cab creation


cd-thing.pl(updated Mon Oct 29 12:28:58 2007)
#
# This script is intended to assist you in renaming/retagging MP3
# files you've downl^Wripped from your legally-purchased CDs but
# neglected to tag/name correctly. It uses FreeDB to check what your
# file's supposed to be tagged as based on information gleaned from
# the file. If you've got a griprc, it uses that to determine what the
# file should be named.
#
# Basically, it's part of my ongoing quest to have my computer do damn
# near everything for me,
#
# 22/06/2003 Created
#


cddb-thing.pl(updated Fri Aug 22 20:17:56 2003)
#
# Recover lost cddb files using discid files created by Gronk
#
# Correct said files from info stored in the directory structure, if
# possible. Some people are utter monkies when it comes to putting
# data into CDDB.
#
# CDDB HTTP Query Format:
# http://www.freedb.org/~cddb/cddb.cgi?cmd=cddb+read+rock+12345678&hello=joe+my.host.com+xmcd+2.1&proto=1


clamc(updated Tue Oct 2 20:47:42 2012)
# -*-CPerl-*-
# clamd client
#


cleanup.pl(updated Tue Dec 6 20:56:23 2011)
#
# I use up2date, and have it not delete the binaries. This accumulates
# cruft over time, and up2date doesn't have the "delete older
# binaries" option that I'd like it to have. So, this script attempts
# to clean up the specified (default current) directory in that
# manner.
#
# CAUTION: Deletes files. YHBW.
#
# September 2002:
# Use RPM::Header to examine and compare versions
# Use Getopts::Long to get options
# 08/06/2003 RPM::Header is no longer viable. curses!
# 15/02/2004 Added back in a hand-rolled vercmp
# 22/02/2004 Swapped meaning of debug & verbose flags (sanity)
# Try and find a viable RPM package


cpan-to-rpm.pl(updated Thu Jun 26 23:33:06 2008)
#
# Grab a module from CPAN and sock it into an RPM using cpanflute2
#


dart.pl(updated Mon Jan 28 00:14:25 2008)
#
# Get dart times and parse them into something readable
#
# http://www.irishrail.ie/your_journey/picker_real_time_results.asp?station_name=Glenageary&station=GYDN%2CGYUP&direction=S&mins=60&image1.x=11&image1.y=5&radioservice=1&radioservice1=1
# http://www.irishrail.ie/your_journey/picker_real_time_results.asp?station_name=Glenageary&direction=S&mins=60&image1.x=11&image1.y=5&radioservice=1&radioservice1=1 also works
#


dersrc.pl(updated Tue Oct 2 20:47:42 2012)
# decompile the resource fork of a CodeWarrior .rsrc file
# Waider 1999/2000


digest-to-folder.pl(updated Thu Sep 6 22:02:28 2001)
# Convert a majordomo digest to a mbox folder. rough and ready.
# Waider August 2000


films.pl(updated Sat May 8 08:45:39 2010)
#
# TV listings toy
#


gps.pl(updated Thu Sep 6 22:02:28 2001)
# Playing with GPS toy
# Waider, September 2000


jstest.pl(updated Thu Sep 6 22:02:28 2001)
# Joystick Test Toy
# Waider November 12 2000
# Because I didn't have jstest on my system.
# Open the joystick device


junzip.pl(updated Sun Mar 28 17:16:57 2004)
#
# unpack a japanese zipfile, converting sjis filenames to unicode on the way
#


ktwittering.pl(updated Tue Jan 22 23:51:09 2008)
# use knotify to watch twitter
#
# FIXME:
# shouldn't have username & password on command line
# should remember last seen tweet
# should replace $tweet->[] with $tweet->{}
# should be smarter about putting entries in the @tweet array so that we don't have to sort it
# should have a better time format than unix time...
#


ljnntp.pl(updated Tue Oct 2 20:47:42 2012)
#
# Bad things with lj
#


lotto.pl(updated Sat Dec 8 18:11:43 2001)
#
# Lotto checking script. stupid idea, but heck, I'm crazy enough to try it.
#


mailman.pl(updated Tue Oct 2 20:47:42 2012)
#
# MAILMAN BLOWS GOATS.
# You can't block mails to mailman, you can only redirect them to the
# admin address. So my attempts to stop up some of the spam on the
# BBDB list results in me getting a steady stream of crap at the admin
# address instead. This script is designed to go in and rip them
# out. If there's a real admin request in there, tough. I might notice
# it in the mailshots I get, and then again I might not.
# 22/05/2003 Rewrote to use HTML::TokeParser and also Mail::SpamAssassin
#
# 22/08/2003 HTA: Added some stuff to make Mailman 2.1 easier
# (mailman 2.1 has to have details=all in order to get
# the messages, but fails if you add that into the URL
# when blipping them)
# Also added reporting of nonspam.
#
# 23/08/2003 Add support for custom SpamAssassin config file (--saconfig)
#
# 15/04/2003 Add learning support (Ted T'so)
#
# 24/04/2003 Merge SpamAssassin 3.0.0 and MailMan 2.1.4 support (Justin Mason)
#
# 27/05/2006 Switch to using WWW::Mechanize
#
# TODO:
# * cgi mode, where it generates a Mailman admin page, but with
# defaults set sanely (i.e. if it's spam, set the default option to
# 'discard')
#


mailstats.pl(updated Thu Mar 29 16:43:31 2007)
#
# Rough shot at how much spam I'm getting
#
# Note the input, from.old, is just a procmail log file.
#


makerpm.pl(updated Sat Dec 12 22:33:11 2009)
#
# Make an rpm out of a tarball.
#
# 30-Jun-2002
# Started making this actually work, although I'm sure there are
# three hundred scripts to do this on Freshmeat.
# 20/06/2003
# Allow --group
# Clean up test area
# use %configure and %makeinstall macros
# 08/11/2003
# Use --eval instead of -E for rpm macro expansion
# 18/02/2006
# Merge in rebuildspec code
#
# * Detects some configure scripts
# * Tries to guess if %setup needs any parameters
# * Tries to populate %doc
# * Tries to locate GPL, Apache, or Artistic License
#
# Fixmes:
# - check for existing specfile and use it for defaults
# - use Archive::Tar to unpack
# - Archive::Zip
# - Compress::Zlib
# - bzip handling also


mapflow.pl(updated Tue Oct 2 20:47:42 2012)
#
# Go fishing for map data on Mapflow via myhome.ie
#


maptest.pl(updated Sun Jan 28 16:45:57 2007)
# Testing map retrieval
# Last Modified: Waider / 07/04/2003
# April 2003: Did some mucking about with satellite strength and location.
# May 2003: POE conversion


migrate-xchat.pl(updated Wed Apr 27 09:10:30 2005)
# migrate your xchat settings from v1 to v2
#
# this contains just enough to work in my environment. In particular,
# server/network flags are incomplete, and various things like
# passwords, eom_cmds and per-server nicks aren't migrated because I
# don't use any of that.
#
# New files are created in .xchat-migrated; you will need to change
# this to .xchat2 or otherwise copy the files to .xchat2 in order to
# have them take effect. Obviously, don't do this while xchat is
# running.


mimesend.pl(updated Tue Oct 2 20:47:42 2012)
# Simple script to send the contents of stdin as an
# application/octet-stream MIME block. Parameters are "-s Subject",
# "-n Suggested Name For File" (defaults to "no-name"), and as many
# recipients as you like.
#
# Uses sendmail to do the actual send, so you gotta have that
# configured.


mkthumbs.pl(updated Fri Jan 4 23:05:17 2002)
# Part of a bunch of stuff for making thumbnail images, e.g. for a web
# gallery. Despite the name, this is merely a half-assed image viewer
# that allows you to rotate the image 'in place'. In fact, it calls a
# script to do that, too. Jeez. Talk about kludges.
# Waider Feb 2001


mozpass.pl(updated Thu Apr 12 23:41:20 2007)
#
# dig out mozilla passwords that I've forgotten
#


mp3name.pl(updated Wed Jan 12 08:11:04 2011)


multimsgstr.pl(updated Fri Dec 10 16:49:05 2004)
#
# combine multiple gettext files into one, OR split such a merged file
# into its component languages.
#


nmea.pl(updated Thu Sep 6 22:02:28 2001)
# NMEA parser
# Waider / September 7, 2000
# Need a map?
# http://www.mapquest.com/cgi-bin/ia_find?link=btwn/twn-map_latlong_degrees_form
# grab all the input fields, especially the hidden ones.
# set latdeg latmin latsec lngdeg lngmin lngsec appropriately
# set "Find Map" to "Get Map"
# call ia_find
# look for http://sitemap.mapquest.com/mqmapgend?MQMapGenRequest,
# that's your map.
# 65th character in URL seems to control the magnification:
# *->9->1->l->q->d->g->0->5->h
# cont. region city street
# You can also try:
#
#http://www.mapblast.com/gif?
#
# Location of Icon
# Lat Long Icon
# Icon:
# 1 - circle with dot
# 2 - circle with dot, nontransparent
# 3 - small red circle
# 4 - big red circle
# 5 - cross
#&IC=53.1913:-6.0801:8:
#
# Centre of map
# Lat Long Scale
# Smaller number = closer zoom. seems to zoom up pretty well.
#&CT=53.1913:-6.0801:200000
#
# @ scale = 5000, ( 0.0020 N =~ 130 pixels, 0.0060 W =~ 228 pixels )
# Width/Height of map
#&W=456
#&H=259
#
# Required
# &FAM=mymapblast


nnevil.pl(updated Sun Jun 9 14:35:36 2002)
# Beginnings of a program to migrate news-servers. Currently, allows
# you to scan a list of free news servers for a particular group (such
# as, say, alt.sex.leek)
# Waider June 2000
# URLs of interest
# http://www.newzbot.com/sorted-longevity-table.html


note.pl(updated Sat Apr 14 15:46:41 2007)
#
# command line interface to knotes via DCOP
#


ntlm-proxy.pl(updated Thu Sep 6 22:02:28 2001)
# $Id: proxy.perl,v 1.14 2000/11/03 21:59:03 rcaputo Exp $
# NTLM-aware proxy, since noone else seems to be.
# Waider April 2001


officebot.pl(updated Fri Sep 30 06:46:35 2005)
# This is a simple IRC bot based on the example in the POE cookbook
# Things:
# + tracking logins/logouts/aways/last active
# check per-server botnick instead of global one
# how to deal with Not Talking To Myself stuff?


patchcheck.pl(updated Fri Jan 4 23:05:17 2002)
# Fetch patches from Sun's public patch server. This is pretty much
# duplicating a lot of the work done by other scripts, but heck, I
# didn't know about them at the time. Sun's own tool is next to
# useless if you don't have a Sunsolve login.
#
# Waider 1998ish


patchreport.pl(updated Mon Jan 19 15:31:15 2004)
# This program is intended to parse the patchdiag.xref file downloaded from
# the sunsolve ftp site. It parses the file, and returns a list of patches that
# need to be evalutated for installation.
# @(#) PatchReport_Solaris7 1.14@(#) (Shamblin) 05/01/99 13:48:23
# Modified by Waider <waider@waider.ie> Jan/Feb 2002
# Cleaned up warnings when run under Perl -w
# Debugged contract operation
# Handle patches that aren't zipped (.tar, .tar.Z)
# NB this allows one script to be used for <= Sol 2.6 and >= Sol 7
# Disregard (for now) patches that don't show up in the checksum file
# Optionally MD5-sum the local copy of a patch before fetching a new copy
# of same.
# Enable the -l flag
# Move file fetches to a single function, to centralise option checking
# and diagnostics
# Allow preserving of downloaded xref & CHECKSUM files
# Create -Z dir if it doesn't exist (otherwise files end up in /!)
# Use a sub to do rm -rf
# Added proxy support to non-contract mode
# Allowed non-contract mode to use xref and CHECKSUM files
# Handle missing patches (usu. non-contract mode)
# Cleaned up the fastpatch output
# Smarter default base URL
# If -Q is specified, then imply -q
# Moved file cleanups to an exit handler, so files get cleaned up if
# the program dies
# Added cookie-login support, including redirecting to Sun's choice of
# URL if necessary
# Bumped the version number
#
# TODO
# Better error reporting on fetch failure (auth failed, etc.)
# Is it possible to figure out the correct order to apply patches in,
# to avoid multiple runs?
# Use "patch-not-installed" errors to generate a machine-specific
# exclude file, keyed against the contents file in /var/sadm/install
# (so we know when it's potentially out of date)
# Checksum subroutine
# Clean up: remove unpacked dirs unconditionally
# Clean up: remove old versions of a patch
# Detect if xref or checksum file is trashed
#
# Copyright (c) 1997 by W. Joseph Shamblin. All rights reserved.
# Permission is granted to reproduce and distribute this program
# with the following restrictions:
# 1) This copyright notice and the author identification below
# must be left intact in the program and in any copies.
# 2) Any modifications to the program must be clearly identified
# in the source file.
#
# UNIX Systems Administrator
# Department of Computer Science
# Duke University, Durham, NC
# Phone: 919.660.6582
# Email: wjs@cs.duke.edu
#
#
# THIS SOFTWARE IS PROVIDED AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. YOU ARE RESPONSIBLE
# FOR ANY DAMAGE THIS MIGHT DO TO YOUR MACHINES!!! IN NO EVENT SHALL THE
# AUTHOR OF THIS PROGRAM BE LIABLE FOR DAMAGE THIS PROGRAM CAUSES.
# Load all needed modules


phone.pl(updated Tue Oct 2 20:47:42 2012)
#
# GSM phone toy
#
# actual functionality changes every time I edit it. handle with care.
#


pkg-to-rpm.pl(updated Fri Jan 4 23:05:17 2002)
# Make an rpm file out of a pkg, or something. Incomplete.
# Waider Feb 1998


pktsniffer.pl(updated Tue Jul 15 14:52:30 2003)
# Not really a packet sniffer, more a proxy that dumps what it
# proxies. Written in the days before I learned to write perl somewhat
# cleanly. This would probably explode if you put in 'use strict'.
# Waider 1996 or 1997
# 13/05/2003 Make sockets reusable and non-lingering


property.pl(updated Sun Dec 16 12:33:39 2001)
# property search toy
# Waider, January 2001


ptoc.pl(updated Thu Sep 6 22:02:29 2001)
# Nastiness to start converting Pascal into C
# Optimized SOLELY for hacking a particular file. Caveat, uh, Runnor.
# Waider, November 1997


ptsb-to-ynab.pl(updated Thu Feb 13 21:49:19 2014)
# quick hack:
# export your PTSB stuff to XLS, then save as csv, then run this over
# it, and you should be able to feed it to YNAB.


randompokey.pl(updated Sun Dec 16 12:33:39 2001)
# Create a random pokey cartoon
# Waider May 2000


randompokeyhack.pl(updated Thu Aug 14 10:59:20 2003)
# Create a random pokey cartoon for xscreensaver
# Waider August 14 2003
# put this into your .xscreensaver to make it work
# "RandomPokey" randompokeyhack.pl
# and note that the preview won't work in the config front-end
# and also you may be left with /tmp/rpNNNN directories because I'm
# too lazy to do proper cleanup.


rebuildspec.pl(updated Sun Nov 7 18:02:43 2004)
# Rebuild an RPM .spec file from a package
# Waider July 25 2000
#
# 03/11/2004 Add changelog
# Check for other packages built from the same source file
# Clean up file listing a little


rss-fetch.pl(updated Tue Feb 4 22:49:59 2014)
#
# All the cool kids are doing RSS. ME TOO!
#


rss.pl(updated Sun Sep 4 23:05:52 2005)
#
# compile some RSS feeds into a single page
#


setiposition.pl(updated Thu Mar 25 11:58:21 2004)
#
# Graph the state of Top 100 SETI folks in Ireland. I'm in red. Gives
# deltas for the last time checked: position change (negative for
# moving up the ranks) and number of units completed. Needs to be
# hacked to cope with what happens when I run off the right-hand side
# of the graph. Also would be nice to cope in the event of me falling
# off the top 100 (continue and find out where I am, I guess)
#
# March 2003: crude hack to left-shift
# colour people doing better than me vs. people doing worse


sharemon.pl(updated Sun Dec 16 12:33:39 2001)
# share monitor. suitable for use in FvwmButtons, which is where I use mine.
# Waider August 2000
# Adapted from SrvMon; there's an argument for making this and that
# generic enough that you can do
#
# use Monitor::apm;
# monitors->addmonitor( Monitor::apm->new );
#
# or something.


smb-clone-acls.pl(updated Tue Oct 2 20:47:42 2012)
#
# Rough tool to migrate ACLs from a server you've already done a file
# clone on.
#


smb-clone-printers.pl(updated Tue Oct 2 20:47:42 2012)
#
# Clone printers from one machine to another.
#
# Expects a credentials file in /root/cred; ignores the user and
# password parameters, but I never bothered cleaning them up.
# Not really necessary since the getdriver call gets the full path anyway
# getdriverdir "Windows 4.0" | "Windows NT x86" | "Windows NT PowerPC" | "Windows Alpha_AXP" | "Windows NT R4000"


smb-clone-shares.pl(updated Tue Oct 2 20:47:42 2012)
#
# Clone shares from one machine to another.
#
# uses a credentials file called "cred" in the current dir, ignores
# username and password params.


sonar.pl(updated Sun Aug 1 12:39:16 2004)
#
# Audible ping. GNEE!
#


threader.pl(updated Sun Jan 28 16:57:50 2007)
# Thread a bunch of mail messages
# Based on jwz's threading algorithm
# Created: Waider August 29 2000
# Modified:
# Waider |2001/03/14| clean up and comment code, add HTMLifyer
# Waider |2001/03/15| tweak threading algorithm, date sorting
# Waider |2001/03/20| adding navigation
# Waider |2001/03/24| discarded nav, trying to improve threading further
# -----------------------------------------------------------------------------


triggers(updated Mon Sep 19 21:48:09 2005)
# triggers for officebot -*-CPerl-*-
#
# Waider, May 2004


unar.pl(updated Tue Oct 2 20:47:42 2012)
# unpack a .ar file from MM2
#
# File format:
# *** numbers are stored in little-endian format
# offset size (bytes) function
# 0x00000000 4 Magic: "DAVE"
# 0x00000004 4 number of files stored in this archive
# 0x00000008 4 offset to filenames OR size of file header block
# 0x00000012 4 offset to data OR size of filename block
# * lots of zeros here
# 0x00000800 16 file header. there's [offset 4] of these
# * [offset 8] bytes of data
# variable zero-terminated filename
# * [offset 12] bytes of data
# variable possibly deflated file
#
# File header:
# 0x00000000 4 offset from start of filename block to filename
# 0x00000004 4 offset from start of file to data block
# 0x00000008 4 uncompressed size of file
# 0x00000012 4 compressed size of file
#
# if compressed size != uncompressed size, the file data is compressed
# using zlib, maximum compression, WindowBits => -MAX_WBITS (disables
# production of header bytes)
#


updateme.pl(updated Mon Oct 13 13:49:01 2003)
# Nastiness to automatically update a redhat box from assorted update sites.
# Then I discovered rpmfind (http://www.rpmfind.net/)
# Waider 1999
#
# 2002 rehack
# * discovered that the RPM package has a neat version comparison tool
# * discovered that it doesn't appear to work any better than what I'd
# written myself. Ptui.
#
# 09/05/2003 Merging all the versions
# 30/05/2003 Use home-made ftp->get mechanism
# 08/06/2003 RPM.pm is defunct. RPM2 appears to be The Good Shit.


winpopup.pl(updated Thu Sep 6 22:02:29 2001)
# SMB Messenger
# Waider, January 1998
# Modified January 2001


workshop-update.pl(updated Wed Nov 21 12:29:51 2012)
#
# Update the workshop section of the website
#
# - Trawl the source directories
#
# - If there's a file in the workshop that's also in the source
# directory, and the source directory version is newer, copy it
# over. This allows me full control over what's in the website
# while at the same time keeping it up-to-date
#
# - Also generate an entry on index.html for the file
#
# September 2002:
# Sort the files by filename
# 08/03/2004 Add timestamp to file listing
# 16/11/2004 Woo, google adsense


worktimer.pl(updated Fri Mar 17 17:53:39 2006)
#
# Timer to keep track of how long I'm working on something
# Waider February 19, 2002
#
# Waider January 26 2002: Converted to Gtk, got stuck on OptionMenu. Docs, dammit.


xchat-hacks.pl(updated Tue Oct 2 20:47:42 2012)
# XChat hooks and hacks
#


xmms-frob.pl(updated Tue Oct 2 20:47:42 2012)
#
# Tooling with XMMS
#
# toys: lyrics!
# http://www.lyrics007.com/Sugababes%20Lyrics/Hole%20In%20The%20Head%20Lyrics.html
#



Waider Ugh. Did I write that?