Main | June 2007 »

May 2007 Archives

May 13, 2007

Ad multos et faustissimos annos!

Listening to Jeff Atwood of Coding Horror being interviewed on .NET Rocks made me decide to start a blog.

Windows Virtual PC 2007

I've installed Debian as a virtual server on my Windows Vista home box in hopes of cutting down on physical computers at home.

I had to set the color depth to 16-bit, and the xorg video driver doesn't seem to be able to handle anything above 1024x768, but that's not a big deal. I mainly ssh into the virtual server anyway.

Virtual machines are awesomely awesome. I had a Commodore 128 as my main (gaming) computer growing up. I remember the first time that I fired up a Commodore emulator and ran a far more capable software version of the older hardware marvel.

Being able to do the same thing with modern machines and accomplish actual work is amazing to me.

UPDATE:
I got 1280x1024 resolution working by using the "vesa" driver instead of the "s3" driver in my xorg.conf file. This comes at the cost of performance, but the higher resolution is nice.

May 14, 2007

stream_cast

This is the most personally useful piece of C++ I've ever written:
#include <sstream>
template<class T, class S>
T stream_cast(S input)
{
        std::stringstream ss;
        ss << input;
        T ret;
        ss >> ret;
        return ret;
}

It allows you do "stream_cast" variables just like you would do a "static_cast." To go from a c-string to an int:

int i = stream_cast<int>("123"); //i is now 123

Or to go to the other way:

string s = stream_cast<string>(123); //s is now string("123")

It's a rare project, I've found, where there is never any need to convert strings to other basic variables.

May 15, 2007

A successful project

I wrote a new interface for the Oracle requisition database at work. The old one was written in C and GTK, with user interface design by M.C. Escher. Here is a screen shot:

If you can't tell, the icon over the "New Req" button is the Ford logo, while the icon above the "Quit" button is a martini glass. Yes, it's an internal app. Yes, we all have fun working here. Except for the secretary who had to use the program.

The new program is in C++ and Qt with a much more usable interface (according to the secretary):

Connecting to Oracle was a pain. My first plan was to use Oracle's C++ libraries. Surprisingly, Oracle hasn't recompiled their libraries for gcc 4. (What's up with that, Oracle? Do you seriously expect anyone to buy Oracle Linux?) As an alternative, I used an open source library called OTL, which I'm very pleased with. The documentation is not easy to parse, but the library is wonderful.

Above the OTL layer, I was able to use Boost's "any" library to make generic containers for the database elements. The result was a generic and type safe system to build the rest of the application on top of.

On the GUI side of things, I'm less pleased. I shouldn't have let myself get drawn into Qt's object scheme so much. I should have struck out on my own instead of simply inheriting Qt classes. Where this particularly hurt me was input fields. I have 4 or 5 incompatible types of input fields (because that's what Qt has) that all do the same thing logically, even if they have interact with the user in different ways. Had I designed an intelligent object hierarchy, I could have written a few generic algorithms for pre-input data filling, constraints, and post-input validation. In fact, this will probably be done in a rewrite soon, as a kindness to future code maintainers.

One thing I found myself wanting to do more often was to write code like:

for (list of variables)
{do-something}

Abstracting the loop internals to a function is a pain when you have to pass lots of data, and it may not even reduce your code size for a small enough list.

One solution I tried was iterating through a vector that I had made on the spot -- which feels wrong when I only use two elements, but is an easy pattern to maintain.

BOOST_FOREACH would have made this even nicer, but I didn't feel comfortable using pre-release software (it was released with Boost 1.34 today).

Overall, I'm feeling pretty happy about what I've written.

May 16, 2007

Why you don't want to administer an email server

Much email joy today.

We scan every incoming email for viruses using McAfee. It takes some magic to call the McAfee scanner on a Unix system through Amavis, but it does seem to work most of the time.

It was not working today, however. Starting with the new virus definitions from the 14th, McAfee began bombing out on every email coming in. This let viruses through (that did not otherwise get flagged as spam), but more importantly it began filling up the Amavis temp directory. The subdirectory limit was hit this morning and broke everything -- at which point I discovered that McAfee wasn't working.

Unfortunately, this discovery came just as we were doing planned security and maintenance upgrades to a couple of the main servers. One of the upgrades killed some bug workarounds I had made for RHEL's autofs, and a reboot of another server broke nfs due to some bad documentation. (A script of mine had been forked by another admin. He hadn't updated the documentation, and still other admins were running the BSD rather than the RHEL version. Which broke a lot of things come reboot time, but not enough for us to notice right away.)

Fixing all that took an hour or so, and then it was back to coming up with a drop-in virus scanning solution. Clam AV seemed like the thing to do, and was merrily cranking away by the time I left this afternoon.

May 19, 2007

McAfee

It turns out that the McAfee command line scan utility for Linux hit end of life on May 14th, which is also when, not coincidently, it stopped working for us.

Our reseller hadn't sent us a notification about the new product, because...we had already bought it! VirusScan with Linux had come with our purchase of McAfee for our Windows clients.

Downloading and installing the the new version turned out to be a simple process and completely fixed McAfee.

Except that our server can't handle the load from the new version of McAfee. Adding McAfee as a virus scanner bumped scan time from 5 seconds on average to 20 seconds.

Back to ClamAV, at least until we install the spamhost cluster a couple weeks from now.

May 21, 2007

CPAN

I don't know about others, but I've never had anything but pain in installing a large Perl project with lots of dependencies. CPAN never works painlessly. Packages often fail tests, tempting you to force an install. Sometimes the packages don't even exist any more. And using non-cpan packages from your distribution provider is even more painful -- it's usually impossible to figure out what you need.

Perl isn't a language for these projects, it's a platform, like Java. Only it's an inferior platform.

I don't even want to think about security with CPAN code. A problem with a user's PHP Everquest/WoW guild website this weekend has convinced me that the bare minimum for computer security is to have every single piece of code on your machine auto-update itself as needed. Which inevitably breaks things, of course, and more so with CPAN.

May 30, 2007

New Features in the C++ Standard

There are a lot of nifty features coming with the new C++ standard. Concepts, multi-threaded programming support, garbage collection are all a shoe-in. A lot of Boost libraries have been approved already. The big feature that I'm hoping makes it in is closures.

About May 2007

This page contains all entries posted to Coding Is Hard in May 2007. They are listed from oldest to newest.

June 2007 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.35