Thursday, December 23, 2010

Subversion: How to Commit a Directory Without Committing its Contents

I updated the svn:externals property of my project root directory to pull-in updated code from another project. But, I had local changes that I didn't want to commit. The vanilla svn commit . tried to commit all my changes, not just the property ones. The answer was simple: addition of the --non-recursive (-N) option. This option, however, is deprecated.

It appears that the --depth option is the replacement. The sparse directories section of the SVM manual provides details about possible --depth arguments (which are lacking from the options manual page). Note that the --depth option would also be useful for trimming large sections of a checkout that are rarely/never used.

Saturday, December 11, 2010

Faster Brother Printing

The biggest annoyance I've had with my Brother HL-2170W laser printer is the speed at which data is sent and processed. Printing a one-page Google Maps directions would take minutes. Now, it takes about 15 seconds. What made the difference? Drivers, of course.

When I installed the printer, I selected an appropriate driver from the foomatic database when setting-up CUPS. What I didn't do was to check to see whether there were special Brother drivers which weren't installed by default. It turns out that there are quite a number of special Brother drivers which aren't installed by default. This thread directed me to open up synaptic and search for Brother. Sure enough, there were at least two laser driver packages which I didn't have installed:

  • brother-lpr-drivers-laser
  • brother-lpr-drivers-laser1
After I installed them and the dependencies, I opened the Administration/Printing GUI and selected the "Change..." button for "Make and Model" of my Brother printer (select "Properties"). My printer was using the "Foomatic/pxlmono" driver. I changed this to the "Foomatic/ljet4" driver. Immediately, I found printing to be substantially faster. I retried printing a map that had taken minutes earlier in the day. It came out immediately after the printer had warmed up, no more endless "sending" status messages.

P.S. Note that if you don't have a laser Brother printer, you'll need to search through the driver package names to find one that matches your printer. Look for packages that start with "brother-lpr-drivers". The last word in the name gives you a hint of the type of printer it provides support for. In synaptic, you can click on a package name to see the description.

Tuesday, November 23, 2010


Apparently, dpkg is so fsck-happy and ext4 is so poorly optimized for fsck that a new Ubuntu install can take twice as long using ext4 as it would with ext3. Also, apparently, the solution to this is a wonderful little library called libeatmydata. This library basically causes fsck calls to be ignored. Should you install libeatmydata? Probably not, as you might guess from the name. If you install it, you risk losing much more data if your machine crashes than you would otherwise. It may also may pose a shutdown issue, since the OS will call fsck before shutdown to help ensure that buffered data is written out to disk. The primary application for libeatmydata seems to be for OS installs. If your machine crashes during an OS install, you'd probably just re-start the install. So, why waste your time with excessive fsck calls?

Thursday, November 11, 2010

Latex: Printing Letter vs. A4

I love the fact that math can be typeset so easily in Latex. But, I hate the fact that it can be so difficult to get it to format documents for letter paper. Previously, I've been able to edit /etc/texmf/dvips/config/ and either move "Letter" entries to the top and/or comment-out "A4" entries. That trick didn't work this time. What did work was to skip dvips and use pdflatex. Somehow, it was already configured properly ("p letter" in /etc/texmf/dvipdfm/config/config) to use the Letter paper size. Not a problem since pdflatex works great and PDF is easy to print. I just wish someone would simplify the dvips configuration...

Friday, October 29, 2010

Another Smooth Ubuntu Upgrade

Just upgraded my desktop Maverick Meerkat 10.10 which is a tad more complicated than my laptop because it runs apache2 to serve web pages (including 2 trac instances) and weewx to log weather information from my weather station. Thankfully, the upgrade went smoothly. When prompted for what to do with my existing apache2 config, I made a backup copy, then asked to have it overwritten. When the upgrade was complete, I uncommented the server root and copied over the trac configuration sections. After restart, everything worked as before.

The only two minor hiccups were the font (didn't look as good on the desktop as it did on the laptop) and the version of Chrome. It downgraded my chrome from 7 to 6. 'course, both of those (extremely minor) issues were easy to fix.

Update (10/30/10): I realized the difference in fonts. It was technically the same font (Ubuntu), but different rendering. It chose "Best shapes" on my desktop which resulted in a very skinny font. Whereas on my laptop, it chose "Subpixel smoothing". The subpixel smoothing resulted in a much thicker font. So much so that it looked like a different font!

Tuesday, October 26, 2010

Ubuntu Window Border Thickness

When I use Ubuntu on a high-resolution monitor or on a laptop (which is appx. 100% of the time), I have difficulty clicking the border of a window to resize. Apparently, I'm not alone and this has been a standing issue for years. It seems to me that it would be trivial for them to add a configuration option under "Appearance Preferences"/"Theme"/"Customize..."/"Window Border" for frame/border thickness. But, it doesn't exist yet. However, if you don't mind editing XML, the above bug describes how to make the necessary change (at least for the default, Human, theme; it looks like changing other themes would be similar). Here's the process:

  • Edit the XML config: sudo emacs /usr/share/themes/Human/metacity-1/metacity-theme-1.xml
  • Increase the values for left_width, right_width and bottom_height.
  • Restart the window manager (e.g. by logging out and back in)
I increased the values from "3" to "5".

Update (10/26/10): You'll also want to increase left_titlebar_edge and right_titlebar_edge to the same value. Also, AFAICT it's not possible to change the top/titlebar border. This is a bit of a pain since I frequently try to grab the top border for resizing.

Monday, October 25, 2010

Upgrading Ubuntu

Just upgraded my laptop from Lucid Lynx 10.04 to Maverick 10.10. It was (happily) largely uneventful. One thing that I had to figure out was that Upgrade Manager had been configured to only show long term support (LTS) releases, meaning it wouldn't pop-up the helpful "Upgrade" button. Once I changed "show new distribution releases" to "Normal", it showed the "Upgrade" button and the upgrade proceeded.

One touch I like in the new release is the use of round-er sans-serif fonts everywhere. Feels a bit more inviting than before. Python is 2.6.6 by default with 2.7 and 3.1 available. Unison has been upgraded to 2.32.52 which means that I'll need to upgrade my desktop before I can synchronize again.

Tuesday, September 14, 2010

Typing Breaks

I've written about my mild tendinitis in the past. As anyone with tendinitis who types will tell you, it's essential to run a program which reminds you to take breaks. I've recently been using Gnome's Typing Break feature. But, with the latest Ubuntu update, I found that it would lock up the screen for 5 seconds at break time without the chance to postpone. This, combined with the fact that the smallest break it allows is one minute spurred me to action.

I've since turned off Gnome's Typing Break and installed WorkRave. WorkRave is much more flexible, allowing any combination of small micro-breaks, larger rest breaks, and daily typing limits. I greatly appreciate the fact that it allows you to specify times in hours:minutes:seconds since my doctor recommends a 30 second break every 5 minutes. Another nice feature of WorkRave is that you don't have to stop working exactly when your time is up. It flashes a small, annoying sign, but doesn't lock-up the entire screen. This allows me to finish up what I'm immediately working on, then take a break.

Sunday, August 22, 2010

Emacs Fonts

I just upgraded to Ubuntu 10.04 and the "fixed" font is atrocious. "fixed" is what I've been using for years for emacs and xterm since it's the smallest I've found that looks reasonable and is easy to read. This Chris Lea article provides another good suggestion, "Monospace-10". It's a bit large. A commenter, Olle, notes that "Monospace-9" is a bit smaller and also nice. Olle also provides a good suggestion for how to set your font, the .emacs file:

(if (>= emacs-major-version 23)
(set-default-font "Monospace-9"))
This seems like a more reliable way than .Xdefaults, especially considering that the program name sometimes changes from version to version.

Update (8/22/10): I found my old-faithful. It's called "6x13" (how creative!). Yes, it can be set using .emacs code like above. However, "6x13" existed in prior versions of emacs. It worked fine when I used a (>= emacs-major-version 22) condition. Other fonts I discovered while looking for my favorite include "fixed-8" and "DejaVu Sans Mono-9" (same as Monospace?).

Update (8/25/10): How ridiculous! The .emacs setting only seems to work for the main/first "frame" (aka window). If I open a 2nd frame/window (C-x 5 2), it uses the hideous font. So, .Xdefaults appears to be the better way to set the font.

Wednesday, May 12, 2010

Getting More Out of Your Brother Toner

Today, my wife asked me to investigate why our new Brother HL-2170W wasn't working. When I got home, I found the orange "toner" light on. Removing and rocking the toner didn't help. Next, I checked the printer status page and saw a message indicating that the toner was exhausted. But, we had only printed 567 pages and the starter toner was rated for about 1000 pages. How could that be? It was then that I remembered that Brother toners shut-off after reaching a certain usage limit. I also recalled hearing about an easy hack to disable that shut-off mechanism.

After a bit of Googling, I found the Slate article Take That, Stupid Printer! The article confirmed my suspicion, but didn't provide the secret. Fear of retaliation from Brother? Anyway, a bit more searching using the suggested keywords landed me on this FixYa page. The first/"best" solution therein provided the magic hack. On my HL-2170W, the hole to be covered was on the right side of my drum unit. The hole is just under a half-inch in diameter so the described .5"-by-.5" electrical tape square worked perfectly. A circular plastic window on the toner aligns with the hole in the drum which needs to be covered. I imagine one could instead cover the toner window. But, the surface around the drum hole was more even so the tape was easier to apply. And, the toner is changed more frequently than the drum, so covering the drum hole means fewer electrical tape applications.

Enjoy the additional toner life! I just ordered myself a backup TN360 toner for when my starter toner really dies. :-)

Wednesday, February 10, 2010

Emacs Mouse Scrolling

I hate the default emacs wheel scrolling---each mouse wheel click is too far for me to track context. These settings go in my .emacs file so that the basic scroll is only 5 lines, Shift allows me more precision and the Control key lets me take bigger jumps.

; Mouse Wheel Scrolling
; Scroll up five lines without modifiers
(defun up-slightly () (interactive) (scroll-up 5))
(defun down-slightly () (interactive) (scroll-down 5))
(global-set-key [mouse-4] 'down-slightly)
(global-set-key [mouse-5] 'up-slightly)
; Scroll up five lines with META held
(global-set-key [M-mouse-4] 'down-slightly)
(global-set-key [M-mouse-5] 'up-slightly)
; Scroll up one line with SHIFT held
(defun up-one () (interactive) (scroll-up 1))
(defun down-one () (interactive) (scroll-down 1))
(global-set-key [S-mouse-4] 'down-one)
(global-set-key [S-mouse-5] 'up-one)
; Scroll up one page with CTRL held
(defun up-a-lot () (interactive) (scroll-up))
(defun down-a-lot () (interactive) (scroll-down))
(global-set-key [C-mouse-4] 'down-a-lot)
(global-set-key [C-mouse-5] 'up-a-lot)

Tuesday, February 9, 2010

USB Sound on Ubuntu Karmic Linux

There are many guides and posts discussing how to debug/diagnose sound issues on Ubuntu/Linux. About six months ago, I bought a pair of Logitech S-150 USB Speakers thinking that these would be generally easier to manage than traditional analog speakers. Boy was I wrong. First I learned that my then-current OS, Ubuntu 9.04 Intrepid Ibex, had a version of pulseaudio which had poor support for USB speakers. After I got the speakers, I tried following various instructions to get them to work, but to no avail. My hopes were set on the next version of Ubuntu, Karmic, which was supposed to have proper support. However, when I upgraded, I was once again stuck without sound. I once again tried various sound support instructions, again with no luck. Particularly frustrating was the fact that many posts and guides seemed to ignore the possibility that you might have USB speaker ---much of the focus was on finding your sound card. But I don't have one! (well, I technically do, but it's turned off in the BIOS and I don't have speakers for it) In particular, here is the official Ubuntu sound troubleshooting guide. Note that there is basically zero discussion of USB speakers! I followed through anyway. When I looked at the Alsa card/driver matrix, I couldn't find "Logitech", but noticed the "usb-audio" driver. lsmod revealed no installed sound drivers earlier so it occurred to me that I might simply need to load the USB sound driver. Could it really be that simple? Is Ubuntu 9.10 Karmic simply not capable of loading USB sound drivers when USB speakers are attached? After modprobe, adjusting the master volume, and selecting the appropriate output device), I learned that the answer to these two questions is a resounding "Yes!" For the record, Windows XP didn't even require me to lift a finger to get the speakers working... Welp, I'm just happy to have sound again.

Here's a summary How-To for Ubuntu Karmic:

  • Run /sbin/lsmod | grep snd_usb_audio to see if you have the USB sound driver loaded.
  • If the above command shows nothing, run /sbin/modprobe snd_usb_audio to load the driver.
  • Next, open the Sound Preferences window (System > Preferences > Sound).
  • Click the "Output" tab and select "USB_Audio Analog Stereo".
  • Finally, set the "Output volume".
  • To test, run aplay /usr/share/sounds/alsa/Front_Center.wav
If you're still having trouble, read the Ubuntu sound troubleshooting guide