Craig Box's journeys, stories and notes...


Archive for the ‘Technical’ Category

Trinkets traded

Wednesday, April 18th, 2007

A while ago I offered free Ubuntu stickers to anyone who sent me a self-addressed, stamped envelope.

One person sent me an outside envelope but no inside one. I had no choice but to add the stickers and post the original envelope back to him "Return to Sender". I hope you feel good, nameless postal scammer.

I asked for people to add little messages to brighten my day, and I must say, almost a month later, I still haven't been able to bring myself to throw these things away:

Gifts from Dominic

Thanks, Dominic. You're weird, but you rock!

Some housekeeping

Saturday, April 14th, 2007

I'm going on a big trip in a few months, and figure it's a good time to start planning a bit more actively.

I've used the "Getting Things Done" methodology in my e-mail for a while (basically: your inbox should always be empty, you should have an "Action this" folder and a "Reference" folder, and you should either deal with an incoming e-mail immediately or file it into one of these two folders for later processing).  It seems like it might be fun to try it a bit more with the things I need to arrange before I go - you really do have to break things down into small steps when it's "move half way across the world for fun".  So I'm looking at Tracks, a GTD program written in Ruby on Rails.

Before setting this up though, I needed to play with my web host a little, so have categorized my posts to this site.  This crosses something off my aforementioned list-of-things-to-do, and also means that I will be a bit easier to read on planet.geek.nz, where I am now showing up.  Also, I'll probably do the whole Postcards from Uncle Travelling Matt thing, and I'm sure my Mum will find posts about Exim a bit over her head.

I've also seen a lot of people using Google Calendar, and now there is a way to get Thunderbird to use it directly, and you can publish stuff to the web in a neat fashion, I might see if it can arrange my trip for me.

Any other suggestions are welcome, bearing in mind I will need them to be easily accessible from anywhere.

Targeting .NET 1.1 harder than it seems

Wednesday, March 21st, 2007

I'd like my application to be able to run on .NET 1.1, so I've avoided using all the new niceties of .NET 2.0.

Or so I thought.

First, I experimented with MSBee, which lets you build for the .NET 1.1 environment using the VS 2005 tools. After seeing how many errors my code generated in 1.1, while it compiled cleanly in 2.0, I thought "maybe reimplementing this in VS 2003 might be easier".
And while I've specifically avoided some of the .NET 2.0 things that would have been really handy, like the SecurityIdentifier class, which makes handling SID-account mapping easy, there's things I didn't know would be a problem. You can't set a registry key to be a certain type in 1.1. And you can't use half the features that the designer implements for you automatically. And even if you could, you'd have to hack at it, because they separate code and design with partial classes in 2.0.

So, to summarize, looks like .NET was pretty crap prior to 2005. And that means you need to have XP SP2, because it's not supported on SP1.

(/rant)

Searching and replacing attached templates in Word documents

Monday, March 19th, 2007

If you have a document take 5-15 seconds at "Requesting virus scan..." in Microsoft Word, you will think "Pesky virus scanner!". But while this fault is most commonly Norton AntiVirus, it can also manifest in another circumstance: where you have a document with an attached template on a share you can't access any more.

If you are a Windows tech, you have no excuse for not knowing about Sysinternal's Filemon - when you know exactly what an application is accessing, it lets you solve a multitude of problems, including this one. We have a customer with an application that generates Word files based on a template, in the same location as the program is being run from. Long before our involvement they appear to have had a server named "Server" (imaginitive naming) and ran the program from \\Server\Share. There is no Server any more, so the documents from that period all cause a timeout trying to find a share that doesn't exist.
Thankfully, when their current server was installed, a drive mapping was created, so all the documents from that point on are attached to a template on G:\. Therefore the task becomes to search-and-replace the template on all the old Word documents.

There is no easier way to do this than using Word's VBA, which is unfortunate, as you have to script a load of each document, which means each one takes 5-15 seconds to process. There are third party utilities I've seen that handle Word automation, but you may as well just run a macro, which appears in its full splendour below the fold.

I'd be interested to know if there was a library that let you edit Word documents, so we could do this by another method.

Net result however, documents now open speedy, and customer is happy.

(more…)

RegUnloadKey failing with error 5 (Access denied)

Sunday, March 18th, 2007

Trying to unload a registry hive and finding access is denied?

I was loading in a user hive (NTUSER.DAT in the profile), and then opening the key using RegOpenKey (exposed as Registry.Users.OpenSubKey in .NET) to prove it was successful. However, I'd forgot to close this key, so the handle was staying open and thus you couldn't unload the hive.

Oddly, after some time, the handle would clean itself up, so it seemed more like a time or permissions based issue. Simple fix however.

A working release of ProfileTool isn't far away..

Planet NZTech

Wednesday, March 7th, 2007

Planet NZTech has received a facelift recently. As well as a new design, seems that the behind-the-scenes stuff has all been fixed, including the last of the unicode problems (I hope Follower wasn't calling me uncultured. I'll get him back by pointing out that his post was syndicated from his blog to Advogato, and from Advogato to the Planet, so appeared twice in a row!)

Other than the layout, the biggest change is the de-emphasising of who wrote what. It's an interesting concept, probably based around the idea of a magazine that has a single focus, and multiple people writing to that focus. In this case, I think people write for their own purposes (I still don't know what mine is, so I should stop doing it) and it's a bit confusing having everything anonymised. Plus, you don't get to have cool heads. But it's not wrong, it's different.

Free Ubuntu stickers for NZers

Wednesday, March 7th, 2007

Powered by UbuntuThe fine folks at System76, who sell Ubuntu pre-installed on laptops, desktops and servers, have sent me a stash of "Powered by Ubuntu Linux" stickers, perfect for telling the world that even though your laptop, desktop or server might be Designed for Windows Vista, it's powered by the penguin.

To receive four stickers, send a self addressed, stamped envelope, to

Ubuntu Stickers
c/o Ian Beardslee
Catalyst IT
Level 2, Eagle Tech House
150 Willis St
Wellington

(Persons reading this outside NZ are encouraged to check out System76's sticker distributors page)

Update: thank you for all the letters that came in requesting stickers...

Ubuntu sticker request letters (small pic)

GPG agent doesn't prompt for my passphrase

Thursday, February 22nd, 2007

Something that has always bothered me; I use the gpg-agent program to cache my passphrase in memory, but if I call it from dpkg-buildpackage or falcon, it just does this:

You need a passphrase to unlock the secret key for
user: "IT Partners <packages@itpartners.co.nz>"
1024-bit DSA key, ID xxxxxxx, created 2005-04-21

gpg: cancelled by user
gpg: skipped "xxxxxxxx": bad passphrase

Why does it punish me so? Turns out that pinentry, the program that asks for the passphrase, can't find a terminal, so can't run, and the key doesn't get cached.

To fix this, you can set the GPG_TTY variable, which I do in my .bashrc like so: export GPG_TTY=`tty`

Problem solved. And added to the WLUG wiki for posterity.

Copying file permissions with robocopy

Tuesday, February 13th, 2007

I like using rsync to copy files between PCs, even on Windows. You get all the niceness of copying when the files are in use, and then only doing a small synchronization when they're not, to get a complete copy.Doesn't handle Windows file permissions well though.

Enter Robocopy (available in the Resource Kit). But I've already got the files?

robocopy source dest /s /copy:sou /is

Copies only security, owner and auditing information. Very handy.

MAPI error when sending e-mail from MYOB

Thursday, December 21st, 2006

"Cannot get the function address for MAPILogon from MAPI32.dll. Please check your MAPI installation."

Nothing on the web about this one (one other person with the same problem), but a simple fix. There is a 'fixmapi.exe' in your windows\system32 directory. Run that, and MYOB starts e-mailling fine again!