Open Windows Explorer (explorer.exe) in a different folder, not in Documents folder

I use 32-bit explorer in 64-bit Vista because of a few problems that use 32-bit explorer extensions and therefore don't work in the default 64-bit explorer. So I call the explorer.exe in the SysWOW64 directory (confusingly, the apps in the SysWOW64 directory are 32-bit apps).

%systemroot%\SysWOW64\explorer.exe /separate /n,/select,%HOME%

%HOME% doesn't seem to exist prior to Vista/2008. Just replace that with whatever directory you want explorer.exe to start in. Of course if you're not using 32-bit explorer on a 64-bit system or if you are on a 32-bit system, you need something like:

%systemroot\explorer.exe /separate /n,/select,%HOME%

I also use this shortcut to launch the 64-bit Explorer (there are a few explorer extensions on my machine that are 64-bit only!)


My New 320G Hard Drives using RAID and LVM

I just bought two new 320G hard drives last weekend and they are finally up and running with my same old Gentoo Linux OS. I wanted to put them in a RAID1 configuration and this was my first experience with software RAID.

The first time I did it I just made took one third of the new drive (about 120G) and made it a RAID1, then copied the old hard drive over. I purposefully chose not to use LVM because I have used it before and although it is extremely handy I have always been worried about the difficulty of recovering data from a bricked drive when the data is scattered all about. After copying data over to this one big partition I realized that it wasn't so easy to resize a RAID. I also read about how bad it was to have everything all on one partition (/home, /, /var, etc...). So I did a complete 180 and decided to use LVM.

Here is my partition layout:

Disk /dev/sda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1         1       13      104422   fd  Linux raid autodetect (/boot, in /dev/md1)
/dev/sda2        14      622     4891792+  fd  Linux raid autodetect (empty, for Xen later, in /dev/md2)
/dev/sda3       623      866     1959930   fd  Linux raid autodetect (/, in /dev/md3)
/dev/sda4       867    38913   305612527+   5  Extended
/dev/sda5       867     5730    39070079+  fd  Linux raid autodetect (for LVM, in /dev/md5)
/dev/sda6      5731    10594    39070079+  fd  Linux raid autodetect (for LVM, in /dev/md6)
/dev/sda7     10595    15458    39070079+  fd  Linux raid autodetect (for LVM, in /dev/md7)
/dev/sda8     15459    20322    39070079+  fd  Linux raid autodetect (for LVM, in /dev/md8)
lots of free space
/dev/sda9     38670    38913     51657007   82 Linux swap / Solaris (in /dev/md9)

/dev/sdb looks exactly the same of course, which you can do very easily with:

sfdisk -d /dev/sda | sfdisk /dev/sdb

Basically /dev/sda5 onward are all 40G physical partitions. I'll RAID1 them with the corresponding partitions on /dev/sdb. I have also RAID'ed the /boot partition and the root partition, and the sdb2/sda3 partitions for future use. So far, I have 7 raids:

-(~:$)-> cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid6] [raid5] [raid4]
md8 : active raid1 sdb8[1] sda8[0]
      39069952 blocks [2/2] [UU]

md7 : active raid1 sdb7[1] sda7[0]
      39069952 blocks [2/2] [UU]

md1 : active raid1 sdb1[1] sda1[0]
      104320 blocks [2/2] [UU]

md2 : active raid1 sdb2[1] sda2[0]
      4891712 blocks [2/2] [UU]

md3 : active raid1 sdb3[1] sda3[0]
      1959808 blocks [2/2] [UU]

md5 : active raid1 sdb5[1] sda5[0]
      39069952 blocks [2/2] [UU]

md6 : active raid1 sdb6[1] sda6[0]
      39069952 blocks [2/2] [UU]

unused devices: 

I then made md5, 6, 7, and 8 LVM physical volumes and then shoved into an LVM volume group using pvcreate, vgcreate, and vgextend:

# pvs
  PV         VG   Fmt  Attr PSize  PFree
  /dev/md5   vg   lvm2 a-   37.26G      0
  /dev/md6   vg   lvm2 a-   37.26G 528.00M
  /dev/md7   vg   lvm2 a-   37.26G      0
  /dev/md8   vg   lvm2 a-   37.26G  29.52G
# vgs
  VG   #PV #LV #SN Attr   VSize   VFree
  vg     4   5   0 wz--n- 149.03G 30.03Gsonata opt # vgs
  VG   #PV #LV #SN Attr   VSize   VFree
  vg     4   5   0 wz--n- 149.03G 30.03G

Then I created some LVM logical volumes using lvcreate:

# lvs
  LV   VG   Attr   LSize  Origin Snap%  Move Log Copy%
  home vg   -wi-ao 80.00G
  opt  vg   -wi-ao  2.00G
  tmp  vg   -wi-ao  2.00G
  usr  vg   -wi-ao 20.00G
  var  vg   -wi-ao 15.00G

I keep /home, /opt, /tmp, /usr and /var separate. That's why my root (/) partition on /dev/md3 only needs to be 2G.

The reason I made a bunch of RAID's and put them in the LVM rather than just one big RAID is because it means I haven't tied my entire drive down to anything. I can always move data off of one partition later using a few LVM commands and install another OS if I have to. Few people do this, but I think it is a good idea. On my computer at work, I did something similar. I split my hard drive into chunks of 40G and then threw into an LVM. Splitting your hard drive into multiple physical partitions is very useful.

The other thing I did was put the swap drive at the end of the hard drive. It is easy to make it bigger that way. So many people make one of their primary partitions at the beginning of the hard drive into a swap partition, which I can never understand. I almost always end up adding more RAM to my computer and thus needing to make my swap partition bigger. When it is at the beginning of the drive, it means you have to add a new one at the end, where you have free space. Putting my swap at the end of the drive in the first place means I don't have to have 2 swaps later. Given the complexity of my drives as it is, this swap thing is a minor concern.

I also plan on putting Xen on /dev/md2 later. I hope to be able to boot into an OS on /dev/md2, then start up the Gentoo Linux on /dev/md3. If I ever need to restart my Linux on /dev/md3 I can reboot it without turning off the computer. It would also allow me to run Windows XP under Xen rather than under VMWare as I do know. From what I hear Xen has better performance.

The main thing left for me to do is to buy another 320G drive and set up an rsync backup from the 320G RAID to the backup drive (probably in a USB adapter case). As most people probably know, RAID does not replace backups. RAID just protects you against hardware failure. It does not protect you against "rm -rf /". These drives were only $110 CAD each, so getting another backup drive is no big deal.

One other thing that I did differently than usual is that I made all my filesystems ext3, rather than reiserfs (as I normally do). One of the reasons is that I had far too many cases where my reiserfs partitions got screwed up. In fact even my old hard drive had a screwed up directory that was not fixable, unless I ran the reiserfsck program with the --rebuild-tree option, which is not a very safe option. It turns out the directory was not an important one. Anyways, I have never had a problem with ext2 or ext3 ever, so I went with those instead.

Anti-Aliasing in Java >=1.3

It's really simple. Just add the a few lines of code at the top of your paintComponent method:

protected void paintComponent(Graphics g) {
  Graphics2D g2d = (Graphics2D) g;
  g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
  g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
  . . .
  . . .

The first is for shapes, the second is for text, and the third is to go for high quality (over speed).

Actually in 1.5 you can just pass -Dswing.aatext=true to the VM, but this didn't work with one of my applications for some reason.


Drag & Drop from Linux (KDE, Gnome) File Managers (Konqueror, Nautilus) to Java Applications

I tried a few months ago to get drag & drop working from Konqueror to a Java application but it didn't work. Two programmers (myself and another) each had a crack at it and couldn't get it to work. I found one link through Google that seemed to be promising (see reply 23 or 23) but that didn't work. Then finally today by using slightly different keywords in my Google searching, I managed to find this link, which led me to this bug report. It turns out the "workaround" works great and I got it working. Works with Konqueror as well as Nautilus. Haven't tried any other Qt/KDE or GTK applications. Should work with Windows as well of course. I am attaching a trimmed down version of the workaround version with only the essentials to get this working. It it a lot nicer looking than the link above. I had such a tough time finding the solution to this online, I hope others find this blog post and thus have an easier time at it than I did.

Plain text icon TestDragDropLinux.java_.txt3.46 KB

Maintaining Vendor Sources With Subversion

Here is how I upgrade my Drupal sites (which have their own customizations) to new versions of drupal core when they become available, as I mentioned in a previous post.

This section of the subversion book pretty much explains it. Here is specifically what I did for Drupal, assuming you already have some directories set up as follows:


The /var/svn/repos/www/drupal4.7 is like my own drupal4.7 "trunk". The /var/svn/repos/www/vendor/drupalcore is where I track all the vendor sources.

Download the new drupal sources:

cd ~/downloads
wget <a href="

Run svn_load_dirs to load the new sources into current and create a tag of current called 4.7.5:

svn_load_dirs file:///var/svn/repos/www/vendor/drupalcore current ~/downloads/drupal-4.7.5 -t 4.7.5

Now go to a checked-out copy of /var/svn/repos/www/drupal4.7

cd /var/www/localhost/htdocs/sandbox
svn st
svn ci -m "commit some uncommitted changes that I had (might as well get these in)"

Merge in the changes between 4.7.4 and 4.7.5. This is the magic (almost as magical as svn-load-dirs):

svn merge file:///var/svn/repos/www/vendor/drupalcore/4.7.4 file:///var/svn/repos/www/vendor/drupalcore/current .

Now you will see a bunch of output similar to what you would get if you did an update. Look through the changes with svn diff |less. Especially the changelog, just to make sure you are actually upgrading from 4.7.4 4.7.5 and not something different (due to a typo in the previous svn commands above).
Make sure to test the codebase first. I backed up my database first, then went to <a href="http://localhost/update.php">http://localhost/update.php[/geshifilter-code] and made sure the upgrade worked. Very important step!
Commit it when you are happy:

svn ci -m "Merged differences between drupal core 4.7.4 and 4.7.5"

After this I logged in to my 3 drupal sites, backed up the db, ran svn up, ran <a href="http://localhost/update.php">http://localhost/update.php[/geshifilter-code], and checked that there were no errors and that the site loaded some pages with no trouble. If I notice a problem in a few days I can always revert to the database backup I made.

That's all there is to it to upgrade a Drupal site when a new Drupal tarball is released! As long as you track vendor sources in your own subversion repository, the rest is easy.

The advantage of this technique is that I can make changes to drupal core but I can still easily merge in changes from new drupal releases. I can also do this same thing with modules. I track the module sources in a directory structure like:


I made some changes to the gmap and location module. I have had to merge in upstream changes in the gmap module 3 times. You can perform the merge by providing the location of the old tag and the new tag (or just use current) and the destination of the merge is a working directory of the module in question's directory (within the drupal modules directory of your trunk).

I have also used this technique several times for the mediawiki site at work. I highly recommend doing this any time you modify upstream source code and want to get updates from upstream when they become available.

Upgraded to Drupal 4.7.5

I just upgraded to Drupal 4.7.5 today and upgrading is now more of a snap than ever for me. I fully track the drupal sources in my own svn server and then I merge changes between the releases into my own Drupal 4.7 branch (that contains core drupal + patches + contrib modules + contrib themes + 4 sites/ directories). It is so easy. Here is an article I wrote that explains how to maintain vendor sources using Drupal specifically.


Complex GMail Filtering

A few days ago I ran in to a situation where I wanted Gmail to filter something based on the OR of a From: filter and a Subject: filter. In other words I get email from a website and I want to catch their From: email address as well as another criteria based on the Subject: line. In this case, I want to catch emails with OR Subject:Bookmooch OR Subject:"Book received" OR ... (there are a few other cases. If you enter the From: and Subject: conditions in the google create-a-filter wizard they will be logically connected with AND by default; however, if you put the following: OR subject:bookmooch OR subject:"book received"

in the "Has the words" field. This works like a charm. I will probably be able to compress a few of my old filters into one with this tip.


Generate Custom Feed

I found a really neat site that can generate custom feeds. I really wanted a way to not only get a feed of the most popular articles today on digg, but also have links directly to the dugg article, not to the digg page (sorry digg).

This site called RSSxl Beta could do it. I entered:

  • Page URL: <a href="">[/geshifilter-code]
  • Start String: <div class="news-body">
  • Start Item String: <h3 id="title.*?">
  • End Item String: <div class="news-details">
  • Start Description String: <p>
  • End Description String: </p>
  • Link Number: 1

That will give you a nice feed of the most recent 9 items on visible at The only downside is that it only displays 9. I am thinking I might write my own script to do this in python using a similar method to that done by RSSxl Beta.

Update: Just modified the "start item string" a bit. Didn't realize you could use regex.


Small Gotcha When Copying Paths With Subversion

I was trying to do an svn copy from a specific server path into a local working copy. I basically wanted to copy over the vanilla mediawiki-1.8.1 sources from my repository into a local directory (called trunk). Here is what I did:

svn copy svn+<a href="ssh://david@server/svn/repos/Projects/wiki/mediawiki/1.8.1">ssh://david@server/svn/repos/Projects/wiki/mediawiki/1.8.1</a> ./trunk

You would think that this would copy the contents of the 1.8.1 directory into the trunk directory. Wrong; it copies the 1.8.1 directory and its contents into the trunk directory, thus creating a 1.8.1 directory inside trunk. It took me forever to figure out why it was doing this instead of what I wanted it to do (which is to copy the contents of 1.8.1, not the 1.8.1 directory itself).

The problem was that the trunk directory already existed. If I removed the trunk directory, then it creates the trunk directory and copies the contents of the 1.8.1 directory into trunk.

In case anyone is curious, what I am doing is following the instructions from the svn book on how to maintain vendor branches.

Awesome screen tips

Great GNU screen tips from Damien Krotkine. Modify your ~/.screenrc file as follows:

vbell on
defscrollback 5000
caption always "%{= kw}%-w%{= BW}%n %t%{-}%+w %-= @%H - %LD %d %LM - %c"

Now you get a cool console at the bottom. By the way, to change the title of a screen, use CTRL-a, CTRL-A


Starting sshd With a Higher Nice Value

I wanted sshd on my MythTV box to start with a lower priority than other processes. Sometimes I do large transfers to this box over scp (although usually I use nfs). I tried:

nice -n 10 /usr/sbin/sshd ${myopts} ${SSHD_OPTS}


start-stop-daemon -N 10 --stop --quiet --pidfile /var/run/${SVCNAME}.pid --signal HUP

in my /etc/init.d/sshd startup script (in Gentoo) but that didn't work. Even after restarting sshd and logging out and back in again (via ssh) there were still sshd processes running at nice level 0. I think it's because sshd likes to spawn itself at priority 0 (rather than the priority of the parent process, not sure if that is standard or not, but whatever).

The solution I came up with was to run this as a cron job:

ps -o pid -C sshd --no-heading | xargs renice 10

This renices all processes named sshd to nice level 10. This can actually be run by the normal user (if you only log in via ssh as normal user) because the processes that get nice level 0 seem to be processes created by the normal user that you log in as.


Secret Digg "Top Today" Feed

I found a secret Digg feed today. I have been looking for a while for a way to get a feed for the "Top Today" page because the regular digg feed has too many articles. It turns out it does exist although it doesn't seem to be advertised anywhere on digg's site. Here is is:


Interesting svn Recovery Problem

I was just trying to recover some files from a subversion repository at work that were deleted a few revisions ago. Here's what happened:

update to old revision where directory jlamothe still exists:

$ svn -r 2444 up -q

directory jlamothe is there in revision 2444:

$ ls
cjm  david  jlamothe  pix  wgm

updated to HEAD, jlamothe got deleted in HEAD:

$ svn up
D    jlamothe
Updated to revision 2477.

see, it is gone:

$ ls
cjm  david  pix  wgm

trying to recover:

$ svn cp -r 2444 svn+ssh://david@weatherwax/svn/repos/Docs/jlamothe . -q
svn: The URL 'svn+ssh://david@weatherwax/svn/repos/Docs/jlamothe' has a different repository root than its parent

it's there:

$ ls
Bryght  D-Wave  acheron  cjm  david  jlamothe  pix  wgm

but it wasn't scheduled for addition? although the files beneath it were.

$ svn st
?      jlamothe
M      david/decomposition.tex

This had me stumped for a long time. It turns out it was the "svn: The URL 'svn+ssh://david@weatherwax/svn/repos/Docs/jlamothe' has a different repository root than its parent" that was the problem. For some reason because I used a slightly different URL (although equivalent, thanks to my /etc/hosts file) it didn't schedule it, as if it wasn't even part of this working if I had created a new working directory within another working directory.


Fix Capitalization in Latex Bibliographies

To make words in Bibliographic titles appear in the capilization that you specify, enclose the word in curly braces, {}. So to ensure the word, VLSI is capitalized, put {VLSI}.

Creating Pretty PDF Files From Latex

To create good PDF files which look good in Adobe Acrobat even at maximum zoom levels:

  1. First run latex as many times as you need to resolve all references. This will produce your final *.dvi file. Let's assume it's called myfile.dvi.
    latex myfile.tex
  2. Now that we have our myfile.dvi file, we need to convert it to postscript. This is the safest step for most applications. For example some Latex features will not appear in the document unless the *.dvi file is first converter to a Postscript (*.ps) file. One example is shading, by using the Latex shading package (available on CTAN). The "other" method I am elluding to is by converting directly to PDF by using dvipdfm or pdflatex. This usually works fine, however, I recommend going to Postscript first using dvips. You need to provide two key arguments: a) the paper size, and b) a PDF option. The paper size option is usually necessary because dvips is set up for A4 paper by default. Note, even if your postscript file looks like it fits on the page properly, it may not once you convert it to a PDF! The PDF option is necessary so that dvips includes outline fonts instead of bitmap fonts in the Postscript document. This is what will make our fonts look pretty in the final PDF document, and will allow the fonts to scale themselves when we zoom in. So the command we need to run is:
    dvips -t letter -Ppdf myfile.dvi

    This should produce some output similar to that shown below:

    This is dvips(k) 5.86e Copyright 2001 Radical Eye Software (<a href=""></a>) TeX output 2003.03.04:0123' ->
          <><><><><>. <cmr8.pfb>
          <cmti10.pfb><cmbx10.pfb><cmbx12.pfb><cmsy10.pfb><cmr10.pfb>[1] [2] [3]

    If we had of just run:

    dvips -t letter myfile.dvi

    we would have gotten the following output:

    This is dvips(k) 5.86e Copyright 2001 Radical Eye Software (<a href=""></a>)
          ' TeX output 2003.03.04:0123' ->
          <><>. [1] [2] [3]
          The *.pfb files are font files, and they are now being included
  3. After running the above command, a file will have been created. It will appear larger than it did before because it will have some fonts embedded inside the document itself. Now the last step is easy. We need to run ps2pdf:

    This should produce a myfile.pdf file. Opening the file up with Adobe Acrobat should show that the fonts are now *pretty* and will appear very nice at 400% zoom and upwards.


Subscribe to RSS - tips