me@jbrains.ca

Permanent link to this article Fixing Mail.app as it pertains to IMAP and gmail

I am in the process of making gmail my One and Only Mail Database. My first tentative steps showed that gmail filters duplicate emails, which is great, because I have multiple copies of several hundred emails, thanks to POP. Naively, I just started dragging emails from my other Inboxes to my gmail/IMAP/personal mail Inbox and letting the messages synchronize on the gmail server. My goal was to make my other Mail.app accounts empty so I could disable them. This worked well for a while, but for most of today, Mail.app has been telling me this:

Mail has undone actions on some messages
so that you can redo the actions while online.
Mail has saved other messages in mailbox “INBOX”
in “On My Mac” so that you can complete the 
actions while online.  

Additional information: The attempt to read data 
from the server “imap.gmail.com” failed.

I read an article or two and figured I’d overburdened my gmail server and it was scolding me by limiting my access for a while. When about eight hours passed without any change, I knew I had a problem, and that problem was the same email over and over again. Something about embroidery of all things. Each time the message popped up in my “On my Mac” INBOX, I moved it to Trash, then erased deleted messages… nothing worked. Finally, out of desperation, I simply pasted the entire message—you can see it’s quite long—into Google.

Seek and ye shall find.

The advice there, however, didn’t impress me. I might not be a Mail.app developer, but I imagine that if I delete my entire offline cache, I’ll lose all the emails I moved into my gmail/IMAP/personal mail inbox. That would be bad, considering it’s about 10000 messages, many of which matter to me. I thought I should investigate, and fortunately, it wasn’t too hard to figure out what to do.

I went to ~/Library/Mail/IMAP-[myemailaddress]/.OfflineCache and saw about 10000 numbered files. I looked at one of them and saw an email. I figured I could grep to find the offending email, delete it, restart Mail.app, then all would be well. So I did, and so far it is.

To be clear, here is what I did:

$ cd ~/Library/Mail/IMAP-****/.OfflineCache
$ ls
1000        1001        1002        1003        1004        1005        1006        1007        1008        1009
1010        1011        1012        1013        1014        1015        1016        1017        1018        1019
1020        1021        1022        1023        1024        1025        1026        1027        1028        1029
....
$ grep -i embroidery *
[...Matched email 854....]
$ rm 854

That worked great. I hope it helps you, too.

Digg! Discuss

June 11, 2008 03:00 mac, just to be clear

Permanent link to this article Mac OS X: choosing the default currency symbol

This is just a quick tip for Mac OS X users who might want the symbol ”$” to represent their dollar, rather than the US dollar.

I’ve been working on expense reports with Numbers.app and I noticed that my laptop was formatting Canadian and US dollars as “Can$” and ”$”, respectively. While I thought this a tad US-centric, that didn’t bother me much, so I gave it no real thought until I opened the same spreadsheet on my Mac Mini, where I saw ”$” and “US$” instead. I thought this was neat, except of course that now the columns were the wrong width. I saw the difference, figured there was a difference in the International settings, but no! To quote Swiss chess master Gereben, “wie ist es möglich?!” The settings are the same, and yet one window has “Can$” and the other ”$”. There is no “Customize…” button, so I can’t change the number format. What can I do?

I did what any self-respecting programmer would do: I played around with the settings until it worked. I found out that by switching the currency to something else, then back to Canadian Dollar, I reset the number formatting, and now both computers use ”$” for real dollars and “US$” for the fake kind.

Now you know.

Digg! Discuss

June 07, 2008 03:00 mac

Permanent link to this article Rescuing disk space from Parallels

I use Parallels to run Windows under my MacBook Pro which has a 93 GiB hard disk. Since I also live a flight away from the nearest authorized Apple reseller, I find it difficult to buy a new hard disk whenever I need one. These reasons form the constraints under which I spent much of a recent afternoon reclaiming disk space, rather than focusing on real work. Since I have more than a neophyte’s, but less than an expert’s, knowledge of UNIX, I needed to look up the command to show me how to ask UNIX how much disk space folders used. I invoked this command

$ du -h -d 1

This command tells me how much space each immediate folder (-d 1 means “depth of one”) takes up in human-readable (-h) form. This gave me a report like the following

....other folders....
 24M    ./Applications
 24K    ./bin
7.3M    ./Desktop
2.5G    ./Documents
....yet other folders....

Since I want to focus on the really big folders, I looked for a way to do that. I decided to grep for a “G” in the fourth position.

mel:~ jbrains$ du -d 1 -h | grep ^...G.*$
2.5G    ./Documents
 20G    ./Library
1.0G    ./Movies
5.8G    ./Music
3.3G    ./Pictures
3.3G    ./Workspaces
 36G    .

Since I plan to use this command frequently, I added it to ~/.profile

alias find_big_folders="du -d 1 -h | grep ^...G.*$"

I found that Library took up the most space, and within it Parallels took up over 20 GiB on its own. I searched the web and learned that Parallels has a “Compressor Tool” that compresses hard disk images, but when I tried to use it, it failed, telling me I had snapshots or had enabled “disk undo”. Since neither condition held true, I searched further and saw that Parallels has a long-standing defect (back to July 2007 at least) that causes this problem. Fortunately, the same search gave me a solution: MakeVM.

MakeVM creates disk images for Parallels and VMWare, and although it cost USD 19.99, it appeared to solve my problem, so I decided to try it. I installed it on the Windows XP image running under Parallels and found the “Custom Clone” feature ridiculously easy to use. Since I had no experience with this tool and wanted to recover from each step, I did the following

  1. Back up my entire Parallels virtual machine image by tar-ing it to an external disk.
  2. Back up my second Parallels hard disk image (disk2.hdd).
  3. Choose “Custom Clone” under MakeVM to clone my second hard drive (not the “Virtual Hard Disk” feature, which wants to clone a hard disk image), writing the clone to my external hard disk, since I had little space on the internal disk. When asked whether I wanted to compact the cloned disk, I naturally chose “yes”.
  4. Shut down my virtual Windows XP.
  5. Edit the Windows XP virtual machine settings, removing the existing “Hard Disk 2” image and adding the newly-cloned disk image as “Hard Disk 2”. Windows XP should treat these disks as identical.
  6. Start my virtual Windows XP and judge the results. Although I had to re-install Java to make Eclipse work, everything else appeared all right.
  7. Shut down my virtual Windows XP.
  8. Remove the old Hard Disk 2 image from my internal disk and copy the newly-cloned Hard Disk 2 image to my internal disk, updating the virtual machine preferences accordingly.
  9. Back up my entire Windows XP virtual machine image again, repeating the rest of the process for Hard Disk 1.

This entire process took about a half day, so it helped that I had another computer in the room on which to continue working. Once I completed the process, my Windows XP virtual machine image folder reduced in size from about 22 GiB to its current 9.2 GiB. That rectified my disk space problems. I now have over 16 GiB of breathing room, which means I don’t have to upgrade my hard disk, but rather I can wait to upgrade my entire machine. That makes me happy.

If you have disk space problems, or even if you simply want to save disk space, and you run Parallels or VMWare, I recommend MakeVM to safely compact your disk images. I found it well worth the USD 19.99 I paid for it. If this helps you, then please use the “Discuss” link below to comment.

Digg! Discuss

May 30, 2008 03:00 mac

Permanent link to this article Mercurial, Python, Mac OS X and duplication

As you all know, I’m not a fan of duplication. When we duplicate code we create safe, warm places for defects to hide. The more we duplicate, the more things go wrong, the harder they are to debug and, most importantly, the more we need to know in order to find the root cause of the problem. (In particular, we need to know we’ve duplicated something and where it is duplicated.) Just to emphasize that this is not some arcane theoretical notion about programming, allow me to share with you an adventurous half-hour I just spent trying to get mercurial (or hg, if you like) to play nicely between my MacBook Pro and my Mac Mini.

I have a working copy of a Mercurial forest in the same place on two different computers, one is my MacBook Pro and the other is my Mac Mini. When I have to do book-keeping work, I often use the laptop for handling paper and my desktop for running QuickBooks. This helps me avoid overworking either computer and that slowing me down. At least, this is my intent.

Since I’m using hg, by its nature a decentralized version control system, I have to be sure to keep my two working copies synchronized. This means periodic push operations from the laptop to the desktop or pull operations to the desktop from the laptop, depending on which keyboard happens to be in front of me at the moment. Since push from here to there and pull from here to there are essentially the same operation, it stands to reason that I should be able to do either one equally well.

Not so fast, mah littel pink frend

I could push from the laptop, but not pull from the desktop. I was getting this error:

hobbes:Operations jbrains$ hg incoming ssh://mel.local/Workspaces/DiasparSoftwareServices/Operations
remote: Traceback (most recent call last):
remote:   File "/usr/local/bin/hg", line 11, in <module>
remote:     from mercurial import demandimport; demandimport.enable()
remote: ImportError: No module named mercurial
abort: no suitable response from remote hg!

After some searching, I came across an article that suggested I had an ssh problem, and since I hadn’t swapped keys from the desktop to the laptop yet, I did that, hoping it would magically solve the problem. It did not. It saved me typing my password for each pull or incoming operation, but what other value it has, I don’t know. I had to search on.

After a few more minutes, I found this article, which suggested to me that my PYTHONPATH or PATH was wrong. I compared the environment variables on both computers and that wasn’t the problem. I compared the locations of Mercurial on both computers with a quick which hg and they were the same. I was beginning to think that I just didn’t know enough about installing Python packages to make this work, but then I asked each computer to locate mercurial.

Aha!

The laptop answered /usr/local/lib/python2.5/site-packages and the desktop answered /Library/Python/2.5/site-packages and there it is: the two environments expect Python packages in different places. I bet some symbolic links will do the trick.

On the desktop, I did this:

/usr/local/lib jbrains$ sudo ln -s /Library/Python/2.5 python2.5

Now when someone looks for Python packages in the usual UNIX place (/usr/local/lib/python2.5), the file system points them to the usual Mac OS place (/Library/Python/2.5@). I’m not thrilled about two different conventions, but as long as I can make one be like the other, it’s all good.

On the laptop, however, I found a defect as a result of duplication. I found Python libraries both in /usr/local/lib/python2.5 and in /Library/Python/2.5. It’s a wonder anything Python works correctly in that environment. This is the defect I fixed today. I moved the Python libraries into the usual Mac OS place (/Library/Python/2.5) before adding the same symbolic link that I’d added on the desktop.

And yes, folks, now it all just works. Mostly because now there’s only one place for Python libraries to live on each computer.

If you remove duplication, you don’t just improve the design, but you remove places defects can hide.

Digg! Discuss

May 29, 2008 03:00 agile, mac, design, extreme programming

Permanent link to this article Trying a new Subversion client

Until now, my Subversion client has been Eclipse. Unfortunately, both it and my primary repository have grown so much that Eclipse is no longer a viable Subversion client for me. I have tried svnX, but I don’t find it quite ready for prime time. Specifically, it can’t handle svn revert --recursive, which I needed last night. I don’t want to criticize svnX’s maintainer. I just can’t use it yet, and I don’t have the energy to help the project out. I need something to work and do everything I need, which is why I’m now trying out syncroSvnClient.

This new client is not free, so I’m using a 30-day trial licence for now. I’m writing this while I use syncroSvnClient for the first time, so you’re getting my (mostly) unedited first impressions.

Installing the software was not as straightforward as I would have liked. I’m used to just dragging the .app file to Applications, but that didn’t work. Instead, I was supposed to drag the entire syncroSvnClient directory to Applications. Not the end of the world.

Getting a trial licence was straightforward. I had one by e-mail in moments and was able to use it easily.

I linked to a repository easily enough. The experience is very much like Eclipse’s Subversion client in this respect. Of course, I realize now that I should have added a working copy, and not a repository. Doing that was less obvious, as there is no icon that immediately suggests “add” or “link to”. The icon I wanted is a little wrench. A minor annoyance, but I’m past it.

So I linked to the working copy I use to develop this site. That was quick and easy. My next test for this client is how easily it lets me ignore files. This is something svnX doesn’t seem to support yet. I want to ignore the log files, like development.log and test.log. That was easy: select, right-click… hey, this looks exactly like Subclipse! If I can have the benefit of Subclipse without the bulk of Eclipse, that would be cool.

In fact, that’s good enough for now. I’m temporarily sold. I’m going to keep using it for the 30 days, then decide what to do after that. I don’t want to claim I’m ready to buy it, but I like what I see so far.

Digg! Discuss

November 11, 2007 15:06 mac

Older entries | Older entries at diasparsoftware.com