Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Thursday, 26 January 2006

Greasemonkey User Scripts for Firefox

Greasemonkey is an extension for the Firefox web browser that lets users run their own JavaScript programs on any or all web pages they visit. I've written a few Greasemonkey scripts, two of which are listed below.

For more information about Greasemonkey, see one of the following links:

User Scripts

After installing Greasemonkey, click the user script name below to view and install the script.

IBM Infocenter Cleanup
Makes the IBM Information Centers easier to use by removing the large header, and making sure the navigation and content have white backgrounds.
Geocaching Google Maps Travel Bug
Adds a link to the Trackable Item Options on geocaching.com to open travel bugs tracks in Google Maps, as well as Google Earth. See Pop’s Green Jeep Racers Geocoin for an example.

Tuesday, 5 October 2004

Wikipedia Search Plugins for Firefox and IE 7+

This is a collection of search plugins for Wikipedia for a selection of languages. Other versions of some of them are available from from Mycroft.

These days, you’re best to install the search plugins directly from Wikipedia.

Select a site from the list below to install the search plugin.

Tuesday, 22 June 2004

Nokia M11 Interface Address via SNMP

I used to use a Nokia M11 to connect to the Internet. The M11 acts as a router, so the IP address of the router on the Internet bore no resemblance to the IP address of my computer. However, I needed that external address to send to DynDNS.org.

The M11 supports SNMP, so I wrote a short shell script using NET-SNMP. It finds the external IP address in two steps:

  1. Loop through the network interface descriptions under ifDescr to find the ifIndex of the PPP interface.

  2. Loop through the IP addresses under ipAdEntIfIndex to find the matching index, and get the IP address of the selected interface from ipAdEntAddr.

The command line syntax has probably changed since I used this program, so you might need to make some minor changes.

Friday, 20 February 2004

Python fcrypt

I’ve written a pure Python implementation of the Unix crypt(3) algorithm, and packaged it with Distutils and with doc strings for pydoc and doctest. It’s based on Eric A. Young’s optimised fcrypt code, which was written in C.

Download the most recent version:

There are some known problems with this software:

  • The bitwise arithmetic relies on the specific behaviour of Python 2.2 and earlier when overflowing an integer on 32-bit architectures. Python 2.3 works the same but generates a very large number of warnings. Python 2.4 converts many of the intermediate results from the int to the long type, which still works, but is a bit slower.

    Since I don’t really understand how the original algorithm and C code works, fixing this is quite difficult for me.

  • If you try to use MD5-crypted passwords which use a salt beginning with $1$, the current version uses $1 as the salt, and the DES crypt algorithm.

In view of the preceding points, and the low security provided by the DES-based password hashing algorithm, I recommend that you use Michal Wallace’s md5crypt unless you really need compatibility with other software using the same algorithm. In a future version, I may try to provide MD5-based hashing in addition to the current algorithm.

If you’re still on Python 2.3 and you’d like to just get rid of the warnings, you have two options. You could add a command line option when you start Python:

    python2.3 -Wignore::FutureWarning:fcrypt ...

Or you could include extra code before importing the module:

    import warnings
    warnings.filterwarnings('ignore', '', FutureWarning, 'fcrypt$', 0)

Monday, 19 January 2004

CD-ROM Access in Python

Quite some time ago I had the idea of writing a Python program to access the CDDB. This didn’t get very far, but the code samples I came up with might be useful to someone else.

If you’re looking for other software like this, Ben Gertzfield has his own CDDB modules for Python.

There are three files for download here:

  • cddbid.py is a small module to calculate the CDDB ID for a CD-ROM, given the track lengths.
  • cdtoc.py is some example code that uses the ioctl functions in Python to retrieve the track lengths from a CD-ROM, at least under x86 Linux.
  • CDROM.py is an automatically generated file from the Linux cdrom.h header, that provides constants needed by cdtoc.py.

Sunday, 28 November 1999

Perl File::Sync

This module provides the POSIX fsync() function call to Perl. It has been obsoleted by IO::Handle, but you can still download it here, or from CPAN.
The module is licensed under the same license as Perl itself.