Archive for the 'Programming' Category

Page 2 of 4

SMTP Tester 1.1

A new version of SMTP Tester has been released with some minor bug fixes and miscellaneous code refactoring.

SMTP Tester 1.0

Since I keep finding SMTP Tester so useful, I figured I should finish it up, create the obligatory Win32 installer, and release it to the world. The only issue I’m having right now is that the Win32 executable created by py2exe is HUGE (~17MB). Luckily, the resulting NSIS package is only ~4MB, but even that seems pretty ridiculous for what the tool is/does. Needless to say, I’m very interested in suggestions for compressing this down further.

How to Get the Absolute Location of the Currently Running Program or Script

Okay, It’s about time I document this trick since I use it so often and have to keep looking it up!

I like to make life easy for my successors, so whenever I write a program that needs to access files in or below its current directory, I avoid absolute paths like the plague. I find that it’s almost always better to use a relative path, so that if the program needs to be moved someday, it will continue to run with the expected behavior, regardless of where it lives on the filesystem.

The problem is that when a program is executed, all relative paths are relative to the current working directory of the user who executed it instead of the directory that the program actually lives in. To work around this, you just need to prefix your relative paths with a variable containing the absolute location of the program itself:

PHP:

$cwd = dirname(__FILE__)

Python:

cwd = os.path.abspath(sys.path[0])

Note that the above won’t work when your program is “frozen” (e.g. compiled with py2exe).

Windows Shell:

set CWD=%~dp0

Automatic, Rotating VM Snapshots on Xen with xen-vm-autosnapshot.py

My new Xen Tools project page is up, and my first tool is ready for wide-spread use.  xen-vm-autosnapshot.py is a command line program (written in Python, of course) that will take automatic, rotating snapshots of virtual machines running on a Xen host. Enjoy!

Dreamweaver is Dying?

So apparently, Dreamweaver is dying. This article is interesting to me for a couple reasons. First of all, I’m happy that other people are finally saying what I’ve been thinking since I started making dynamic websites with Perl and PHP in the late nineties! I’ve played around with HTML editors a bit, but I’ve never found them to be of much use on a dynamic Internet. I guess I just assumed that some people were using HTML editors for rapid prototyping, and I figured that maybe they could be helpful when editing the HTML template files used to dynamically create pages. But this article makes it sound like HTML editors are still mostly used to create static websites (static as in “just a bunch of .html files”). Seriously? It’s 2009, and web “developers” are still doing that? Holy shit, I am shocked, saddened and completely baffeled at the same time!