Hacks

Perl

Perl is usually my first choice language for small scripts and bigger projects, particularly where there is no graphical interface.

wallpaper

Client/Server background setting application. It can be used to change backgrounds at regular intervals, or on certain events.

It consists of
wallpaperd - the server daemon
wallpaperer - the client
showpaper - a simple script to identify the current background

mmv.pl

Rename multiple files.

massub.pl

Make substitutions in multiple files.

scale.pl

Scale one or more images to fit a size, or by a scale factor. This is a wrapper around pbmplus tools. It's useful if you have a number of images to scale, e.g. to produce thumbnails, or to scale digital photos down to a reasonable size for displaying on a web page.

Requires:libjpeg
 netpbm
 Image::Size
cvt.pl

Convert from one image format to another. This is a wrapper around pbmplus tools. It's useful if you have a number of images to convert, e.g. to from a non-lossy format produced by a scanner to jpg for use on the web.

Requires:libjpeg
 netpbm
olddate.pl

Print a date so many days or hours ago, in an arbitrary format. Useful for checking log files for entries for the previous day or hour.

Requires:Date::Format
swipe.pl

Remove non-ASCII characters from a file. Useful for getting rid of DOS line-feeds and other control characters

untime.pl

Turn a unix time stamp into a human readable date.


Python

Any language which uses indentation as part of the syntax is the exhaust from Satan's bottom. However python has a really good binding to the GTK toolkit which makes producing simple GUIs really, erm. simple.

pyinfo.py

A simple alert dialog. Allows any number of buttons, can sleep and beep and play a sound. I use it in combination with e-reminder as a simple reminder tool

An alarm with a sleep option

An alarm with a sleep option

launcher.py

A button box with vertical, horizontal or table layouts, allow actions to be assigned to small icons and generates help balloons when the mouse is over the icon. Similar in effect to Gnome's quicklaunch

Sample input file
A 2 row layout, showing a help balloon

A 2 row layout, showing a help balloon

multimounter.py

Mount and unmount removable media with a mouse click. Supports arbitrary mount points and arbitrary icons. Re-checks all mount points every 60 seconds (configurable)

Sample input file
A floppy and a flash memory card

A floppy and a flash memory card


Bash

aptclean.sh

Very simple script to rename an rpm as %{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm. Useful for renaming the rpms fetched by apt.


PHP web pages

Most of this site is written in php. The scripts below are simple and easy to use.

calendar.php

Display a calendar for any month and year.

See it in action: This month

slider.php

Display an on-the-fly png depending on input parameters. Can display linear or triangular scale, with or without the value shown on the slider handle

Screenshots:

In use as part of the Sinaas web interface
A Progress meter

A Progress meter


Fvwm

These are scripts I use for creating menus for fvwm.

appmenus.pl

Generate a heirarchical fvwm menu from /usr/share/applications/*.desktop files. If you have scale.pl installed and the supplied icon is too big it creates a scaled down image on-the-fly and saves this in a cache. You will also need a list of icons for the menu titles

Screenshots:

Sample usage on a Fedora Core 1 machine
launch.sh

Launch an application with optional logging. Allows you to set the name and parameters of an application in one place to be called from many places - e.g the menu option can be

+ "&Mail%mail.png%" Exec exec launch mail &

and launch will specify to use sylpheed (or evolution or kmail).

.edrc

This is an adaption of a bash script I found on the internet to implement cd history. There are many copies of this script on the internet still, but none contain the original author's name. This adaption uses exactly the same mechanism, but tracks recent edits instead. It uses $EDITOR to do the work, which I set to emacs, but which can be any editor that takes a filename as a parameter (i.e. almost certainly all of them). It should be included in .bashrc like so:

. /path/to/.edrc

Usage is:

e -l Displays the most recently used MAXFILES documents.
e -foostring Edits most recent file whose name contains the string foostring.
e -8 Edits the eighth most recent file
e -r Resets the file history
e foo Edits foo
e Edits last file
e -? Displays a usage message

 

showrecent.pl

Create menus for the most recent applications and documents. Currently uses the same editor for all documents. Relies on launch.sh to log the most recent applications, and .edrc to log the most recent documents. It is glued to fvwm (2.5.10 or newer) like this:

AddToMenu Applications
+ "&Most Recent...%package_applications.png%" Popup Recent
+ DynamicPopupAction Piperead showrecent

Here is an example recent applications logfile, an example file used to set the icons and titles, and an example recent documents logfile,

Screenshots:

Most recent menu

Scripts used maintaining this site

These are scripts for setting up the links and then making sure that the site is identical to my local copy and that any 'file not found' errors are due to mistyping rather than broken links

Also useful are The W3C Markup Validation Service and The W3C Link Checker.

rumblecheck.pl

Checks the log file on this site and makes sure that any files requested really exist. Produces a list of files which don't. Most of these are user typos or attempted hacks or broken search robots (go and stand in the corner slurp@inktomi.com), but it has also caught me out when I've left links dangling.

Requires:Date::Format
mklink.pl

Produces html code fragments, either containing a thumbnail with a caption, plus a link to the full size image, or a table of thumbnails with captions. The former can then be inserted into a page of text to produce effects such as those seen on the links from the photos page, the latter can be used for producing sheets of thumbnails

Sample input file
Requires:Image::Size

Bigger Projects

Projects using perl, python and bash. Just one at the moment.

sinaas

sinaas is a simple network audio system.

Rational: I have a cheap, headless box plugged into my hifi which I wanted to control from my laptop. Running an X-based app displayed remotely wasn't an option because it's a) slow and clunky, and b) I didn't want to have to install a lot of X libraries.

How it works: On the machine with a sound card, the server, sind is started at boot time. It can use a mysql database (local or remote) or a text file for authorisation. Authorisation is fairly basic. Any other machine on the network can run client apps - typically the web or pygtk interface. I also assign sincl shortcuts to icons on my desktop so that I can easily start live radio. The client and server can be on the same machine.

For more simple use, sinplay can play all the files supplied as arguments whether they are oggs, mp3s or wavs. I use this on my laptop if I'm away from home.

sinaas is mostly written in perl, with the web interface written in php.

Due to differences in perl versions it is recommended to rebuild the rpms from the SRPM. The supplied rpms are for Fedora Core 4.

Screenshots:

The small GUI
The Songs and Playlist editor
The Shortcut editor
RPM:sinaas-1.0.0-69.rhfc4.rr.i386.rpm
  sinaas-clients-1.0.0-69.rhfc4.rr.i386.rpm
  sinaas-db-1.0.0-69.rhfc4.rr.i386.rpm
  sinaas-server-1.0.0-69.rhfc4.rr.i386.rpm
  sinaas-utils-1.0.0-69.rhfc4.rr.i386.rpm
  sinaas-web-1.0.0-69.rhfc4.rr.i386.rpm
SRPM: sinaas-1.0.0-69.rhfc4.rr.src.rpm
Requires:alsa-utils
 vorbis-tools
 mpg321
 wavplay
 mysql
 pygtk2
 MP3::Info
 Ogg::Vorbis::Header::PurePerl
 Audio::Wav
 XML::Simple
 DBD::MySQL
 Proc::Killall
 URI::Escape
 IPC::Shareable

All of the above are released under the GNU General Public License. This license is available at http://www.gnu.org/licenses/gpl.txt. If you find any of these scripts useful, please let me know.



© Copyright Chris Rouch. 1999-2008. Comments, complaints, abuse and beers to
chris_at_rouchrumble_dot_org

Last modified on 27th November 2006 6:34 AM EST

[Back to photos]  Back to photos
Valid HTML 4.01! Valid CSS!