Friday, July 31, 2009

Perl: File::Path::mkpath results in error: "No such file or directory"

I was running a Perl script that came with ACE to generate doxygen documentation. When trying to run it on Windows via Cygwin, I got the following mysterious error:
... : No such file or directory at line …

Tuesday, July 21, 2009

How to Changing Your Reviewer Color in MS Word 2003

When you have 'track changes' enabled in MS Word 2003 (and earlier), it automatically assigns colors to each reviewer in sequence. I, for one, can't stand to have all of my changes to a document showing in bright, stark RED! It just gets hard to look at if I have a lot of updates to make. Well, if I am the first reviewer of a document, then that's what I'll get.

But you can trick MS Word into giving you a different color.

Wednesday, April 8, 2009

Using POST to Send Form Data to a Servlet

Ajax is a great way to make your pages more dynamic. When using ajax, it's common to send data to your servlet in url-encoded form using a GET request. But there can actually be issues with sending information in GET requests. It's generally better practice to send data as a POST request, but there's one subtle detail required to make it work.

Friday, March 20, 2009

How to Get Thumbnails to Show Up for More File Types in Gnome's File Explorer (Nautilus)

Gnome's file explorer was showing thumbnail images for some file types, but not others. It does so for video files by using the default installation of Totem to get the preview image. So, for example I was getting preview images for .flv files, but not for .mpg files.

Sunday, March 15, 2009

How to Swap Control and Caps Lock on Windows

A lot of programmers like to swap caps lock and control. This is especially big with Emacs users, so they can avoid "emacs pinky" from constantly holding down the control key at the bottom corner of the keyboard. The caps lock location is much easier to reach and can make a huge difference if you use a lot of control key combinations. Swapping these keys is pretty easy on Linux, but on Windows, you have to hack the registry.

Saturday, March 14, 2009

Making Fonts Look Good on Linux

Fonts on Linux have always been a sore subject for me. I love Linux, and I like almost everything about it more than Windows. But why can't the fonts look as good as they do on Windows???

msxml3.dll: The system cannot locate the resource specified

I recently started getting this error in my Ajax application:
msxml3.dll: The system cannot locate the resource specified

Bash: Use "if" instead of "&&"

Using the –e option in a bash script can be quite useful. It causes the shell to stop processing and exit whenever a command results in an error. There are many situations where continuing processing after an error has occurred can be detrimental and result in a loss of data. But if you use the '&&' conditional a lot in your scripts, it can also cause them to exit unexpectedly.

How to do a while-sleep loop in Javascript

There is no sleep() function in Javascript. It makes sense, really, because Javascript is single threaded. So, a sleep would freeze the entire browser until it returned. But, being able to sleep before continuing processing is a very common need when programming.

The example that comes immediately to mind is polling. When polling a resource, one would naturally do so in a while loop, exiting when the conditions are right for processing to continue.

But how can this be done in Javascript gracefully if there is no way to sleep? You could poll without a sleep, but that would consume all of the browser's processing cycles, effectively locking it up, which is probably not what you would want. Well, here is how to simulate a while-sleep loop in Javascript.

Friday, March 13, 2009

How to create a .profile/.login file in Windows XP

In the Unix world, a script is run every time you log in. The exact file depends on the type of shell. For example, tcsh uses the .login file, while sh and bash use .profile. But on windows, if there is something I want to run at startup, I just add it to the 'Startup' folder in the Programs menu.

But, in some cases, I want to run a set of commands, but I don't want it to be in the 'Startup' folder where it can be run again by just clicking it. I want to be able to execute certain commands at login without putting them in the 'Startup' folder.

Cannot define a function with window.eval() in IE 7

Sometimes it's useful to evaluate a string in Javascript. There a variety of reasons why one would want to do that, and it's reasonable to expect that the code would be evaluated in the same way as the code in your .js files. I needed to evaluate some code using the window.eval function in Javascript. It worked fine, until I got an error when the evaluated string tried to define a function.

Monday, March 9, 2009

Simple Setup for Sending Email from the Command-Line in Ubuntu

In setting up my new Ubuntu box, I wanted to set up some automatic backups. I did that, putting the backup script in a cronjob. But what if the backup fails? How will I know, unless I remember to check on it every day? How can I send myself an email from the script when there's an error?

Saturday, March 7, 2009

How to put a USB drive into /etc/fstab

I recently started rebuilding my Linux PC. It's intended to be the household's primary storage for documents, photos, etc.... So, that means it makes the most sense to attach my external hard drive to that computer.

But the external drive is a USB drive. I'm not really familiar with the inner workings of Linux's support for USB, but I have a feeling that it might not be mapped to the same device file (/dev/xyz) every time I attach it to the system. So, how can I automate backups when I'm not sure that the drive can be mounted on the system the same way every time? Which device do I put into fstab? What if I plug it into a different USB port? Will that make the device different, meaning that I'll need to mount it differently?

Monday, March 2, 2009

How to Get the CURRENT Style of an Element in Firefox

I was trying to write some Javascript to get some style information about an HTML element. My instinct was to get the element object and access its 'style' property. But this only seemed to work some of the time, which was particularly frustrating! Eventually, I figured it out...

Sunday, March 1, 2009

How 'closures' work in Javascript (and Perl)

When I was learning Perl, the concept of a "closure" was one of the more difficult for me. And the first time around, I didn't really get it. So, I put it aside for later and didn't really use them. It then promptly fell to the bottom of the pile and slipped through the cracks. I later started writing a lot of Javascript and re-encountered closures. This time, I was determined to understand what they are and how they work.

Friday, February 20, 2009

Adding Derby DB support to Apache Tomcat

I'm creating a web application that is really just made up of JSPs, servlets, html, Javascript, and a Derby database. I'd like to use Apache Tomcat, because it integrates with Netbeans, and is lighter weight than a full-blown EE server. But Tomcat doesn't ship with Derby.

Saturday, February 14, 2009

Windows Mounted Drives in an SSH Session

SSH is a great tool because it gives you remote shells on your hosts, allows you to copy files between hosts, creates tunnels for you via port forwarding, forwards your X connection, and the list goes on... Usually, SSH is taken advantage of on Linux and/or other Unix systems. But it can be run on Windows systems too, using the SSH server that comes with Cygwin.

The problem I had was that when I logged in to my Windows machine with SSH, my mounted drives were all missing!

Sunday, January 25, 2009

How to learn the Dvorak Keyboard

I made the switch to the Dvorak keyboard layout in 2005, and I still use it almost exclusively. In my experience, it is far, far superior to the standard QWERTY layout.

I've described my whole experience in another blog entry:
How I switched to the Dvorak Keyboard Layout

After trying it twice unsuccessfully, the third time was the charm, and I’ve never looked back!

The real key to success was my technique for learning to touch type:
Learning to Touch-Type, Once and for All, Without Drills or Gimmicks

You can teach yourself to touch-type without tutorials, typing tutors, drills, or any of that stuff. If you have work to do, and your work requires typing, then that's all you need. There's no need to try to find time in your crazy life to dedicate to Type-Master 101 (or whatever).

Thursday, January 22, 2009

How to get rid of the "no XAuth data" msg from 'ssh -Y'

I use SSH a lot. Quite often I use X11 forwarding to open up graphical applications from the remote host. But one of the most common warning messages printed by the SSH client is this:

Warning: No xauth data; using fake authentication data for x11 forwarding

Luckily, this can be fixed with two quick commands.