Miscellaneous Linux tips and tricks

Gnome Key Bindings and IntelliJ IDEA

IntelliJ IDEA key bindings conflict with Gnome’s window manager. In IDEA, I can type CTRL-B to jump to a symbol definition. Normally, I’d type CTRL-ALT-LEFTARROW to navigate back to where I had come from. Gnome’s MetaCity intercepts that key mapping before IDEA sees it, and tries to move my desktop to the left. There are several other Gnome/Metacity key bindings that conflict with IntelliJ IDEA. Rather than remap the keys in Gnome, I found that on Fedora, I could add the Windows key to the mix, and Gnome would ignore it, and pass it along to IDEA. This means that I can type CTRL-ALT-WINDOWS-LEFTARROW to navigate backward, and so forth.

Unfortunately, this doesn’t work in RHEL 5 and CentOS 5. The solution is to Go to the Gnome menu bar and select System > Preferences > Keyboard (not Keyboard Shortcuts). Then select the “Layout Options” tab, and expand the “Alt/Win key behavior”. Then I select “Super is mapped to the Win-keys”.

Every time I log in after that, Gnome tells me that my X keyboard settings conflict with my Gnome Keyboard settings, and it asks which I want to use. Selecting the Gnome settings is what I want.

Bandwidth limiting downloads with ‘curl’ or ‘wget’

When downloading a large file, it’s nice to be polite to others on the network, so I use the --limit-rate option for curl and wget:

* curl -O --limit-rate 20k http://server.com/linux.iso
* wget --limit-rate=20k http://server.com/linux.iso

GDB TUI (text user interface)

After starting gdb, it’s possible to switch to its text user interface with CTRL-X, CTRL-A. Typing it a second time exits TUI mode.

Vim C++ Auto completion with ctags

I appreciate full blown IDEs in Linux, but I like the quick start up time of vim. Until recently though, I didn’t have C++ auto completion (also known as vim omni completion).

This got me up and running, and was a great resource:
http://vim.wikia.com/wiki/C%2B%2B_code_completion

This would have been useful if I was a new comer to vim and ctags:
http://www.justlinux.com/nhf/Programming/Introduction_to_C_Programming.html

xdg-open, gnome-open, start, cygstart

How to easily open files and URLs from the command line
http://www.dwheeler.com/essays/open-files-urls.html

  • Linux: xdg-open filename_or_URL
  • Linux: gnome-open filename_or_URL
  • Mac: open filename_or_URL
  • Windows: cmd /c start filename_or_URL
  • Cygwin: cygstart filename_or_URL

Nomachine NX and ALT-TAB

I use the Nomachine NX client from time to time to get a remote-desktop like connection to a remote Linux machine. It’s faster than VNC, but it suffers from not forwarding all of my keyboard shortcuts to the remote end of the connection.

Usually, I start the nxlcient from within a Gnome login session. Gnome happily grabs ALT-TAB before the NX client gets to see it. That’s not what I want. To work around this limitation, I log into a virtual terminal, and start X manually as follows:

Type CTRL-ALT-F2
Login
Run: startx -- :1 gnome-terminal

From the gnome-terminal, run: nxclient

And then I connect to the remote machine in full screen mode. There’s no local window manager to interfere with my keyboard shortcuts.

Remote desktop and dual screens

I’ve been using Remote Desktop to connect to Windows XP, Vista and 7 machines. Until Windows 7, there was no way for a local computer having dual monitors to connect and have the remote end display across both monitors.

So I used linux’s ‘rdesktop’ program to do it:

rdesktop -0 -a16 -f -rdisk:CLIENT=/home/jared/Desktop -r sound remote.host.com

I notice that in Windows 7, there are some new options in the Remote Desktop client (mstsc.exe): /multimon and /span. Or run mstsc /? to list all possible options.

Editing windows registry files on Linux

Use Gedit: gedit --encoding=UTF-16LE myfile.reg

Gvim: LANG=UTF-16LE gvim myfile.reg

If already in gvim: :e! ++enc=utf-16le
or :e ++enc=utf-16le myfile.reg

Convert, edit, convert:

iconv -f UTF-16LE -t utf-8 myfile.reg > myfile.reg.utf8

Edit myfile.reg.utf8, then convert it back

iconv -f utf-8 -t UTF-16LE myfile.reg.utf8 > myfile.reg


How Firefox opens files and mime types

I needed to give Firefox some extra help knowing how to open a custom file type with a custom application. Here’s some helpful information.

https://developer.mozilla.org/en/How_Mozilla_determines_MIME_Types

Firefox uses mime.types on Linux, as well as other things. I helped Firefox by the mime type to the link in the generated HTML file. Either one of the following seems to work:

* <a href=”file:subdir/file1.cst” type=”application/octet-stream”> open file </a>
* <a href=”file:subdir/file1.cst” type=”application/x-extension-cst”> open file </a>

Independence Day

Today, it’s Independence Day in the United States of America. I associate it with parades, balloons, children laughing, family reunions, and a time to rejoice in our freedom. Freedom to worship God, according to the dictates of my own conscience. Freedom to speak of ideals, without fear of imprisonment. Representation to form our own laws, instead of having the laws dictated by a distant and unaccountable king. The rule of law — a republic, instead of rule by mob majority — a democracy.

As a member of the Church of Jesus Christ of Latter Day Saints, I endorse our beliefs regarding the role of government:

“We believe that governments were instituted of God for the benefit of man; and that he holds men accountable for their acts in relation to them, both in making laws and administering them, for the good and safety of society. . . .

“We believe that all men are bound to sustain and uphold the respective governments in which they reside, while protected in their inherent and inalienable rights by the laws of such governments; and that sedition and rebellion are unbecoming every citizen thus protected, and should be punished accordingly; and that all governments have a right to enact such laws as in their own judgments are best calculated to secure the public interest; at the same time, however, holding sacred the freedom of conscience.

“We believe that every man should be honored in his station, rulers and magistrates as such, being placed for the protection of the innocent and the punishment of the guilty; and that to the laws all men show respect and deference, as without them peace and harmony would be supplanted by anarchy and terror; human laws being instituted for the express purpose of regulating our interests as individuals and nations, between man and man; and divine laws given of heaven, prescribing rules on spiritual concerns, for faith and worship, both to be answered by man to his Maker” (D&C 134:1, 5–6).

Article: Vegetable gardening 101

I enjoy gardening, even if I’m just a beginner after ten years of doing it. Here’s an article on gardening by the host of the Greenhouse Show.

[Vegetable gardening 101: Larry Sagers tells you how to grow your garden](http://www.deseretnews.com/article/print/700022022/Vegetable-gardening-101-Larry-Sagers-tells-you-how-to-grow-your-garden.html)

My grandfather inspired my to like gardening. I lived with him and my grandmother during my freshman year of college. He had a good sized garden, and there was nothing as sweet as fresh picked raspberries or as crisply delicious as his cucumbers.

I enjoy gardening because I like being outside, and I like seeing things grow. It gives me a thrill to work and prepare the soil, to plant a seed, and to see it emerge from the soil. It’s rewarding to see my children wander through the garden and pick beans, peas, tomatoes and peppers.

Nearly two years ago, we moved to a new home, and had to start our garden and fruit trees from scratch. This Spring, I’ve planted bare root concord grapes, strawberries, and raspberries.

As a family, we drew a map of our yard, and assigned planter boxes and the children picked something to grow. In the coming month or so, Janice and I will help them plant, water, weed and grow their vegetable. I look forward to it.

Rewinding from immature Android to mature PalmOS

I like seeing new developments in technology, like the game-changing [memristor from HP](http://en.wikipedia.org/wiki/Memristor). At times, I get frustrated with new technology because it introduces complication without delivering improved quality of life. Case in point: Google’s Android operating system and the Nexus One.

In February, I fast forwarded from using a [Palm TX](www.palm.com/us/products/handhelds/tx/) to a shiny new [Nexus One](http://www.google.com/phone), due to the failure of the digitizer in the former device. I was excited about the Nexus One — reportedly the best Android device to date. As I began to use the Nexus One, I found several areas that were less productive than the Palm TX. I grew frustrated, and searched for add-on apps that would smooth out the bumps in the calendar and give me a task list.

I found three excellent apps that helped: Pure Calendar Widget, gTasks, and Calendar Pad. I put two 2×2 Pure Calendar widgets on my home screen, side by side: one for my calendar, and the other for my tasks (Pure Calendar displays data from Google Calendar, gTasks and/or Astrid). As I continued to use the Nexus One, I determined what I want in a PDA/smartphone, in order of priority:

1. Quick access. I want a quick, easy way turn on the device, and I want instant access to my most important data: calendar, and tasks. With Android, it’s too cumbersome. I want a calendar button, and if I can’t have that, then I want additional unlock gestures, one of which will drop me directly into my calendar — at today’s date. Same for tasks. I’d like a physical phone button to _quickly_ make phone calls.
2. Bluetooth keyboard Support. If I’m going to invest into a PDA or a smartphone, I want a keyboard. It makes it easier to take notes, and it makes it far easier to use SSH. I don’t want a keyboard all of the time, but I will us it frequently. Android may well support this in the future (See [this](http://pdk.android.com/online-pdk/guide/bluetooth.html) and [this]( http://source.android.com/projects/bluetooth-faq)). The Palm TX supported it years ago.
3. Better calendar. I want it to have most of the features of [DateBk5](http://www.pimlicosoftware.com/datebk5.htm) for the Palm including 1. collapsed day view (don’t show me wide swaths of time when there are no appointments). 2 floating appointments, 3. a compact “Calendar Pad” like view for month and week (with text), 4. a better built-in agenda-style widget, somewhat comparable to Pure Calendar Widget, 5. easier touch-screen editing and configuration of appointments and 6. I want calendar search built-in.
4. Configurable alarm snooze length and snooze response. DateBk5 is fantastic in this regard. When an alarm appears on my screen, I want to be able to snooze for any length of time I specify, and I want to be able to specify it for each and every one that may be pending — not all at once.
5. Contacts: I want to be able to sort by last name.
6. Email: I want copy and paste in the email apps.
7. Camera with good auto-focus. The Nexus One was so close, but ultimately, it failed to focus for 80 percent of my pictures. It would have been more satisfied without a camera.
8. Standard headphone jack that isn’t [finicky](http://www.google.com/support/forum/p/android/thread?tid=1fb5ef9a5c667d18&hl=en).
9. Record audio to a standard, ubiquitous form out-of-the-box, such as wav, ogg vorbis or mp3.
10. Full backup and restore.
11. FM radio receiver. I like listening to the radio, and if I’m going to have a device that does it all, why not have an FM radio too? But if it costs too much extra, then no thanks.

A few weeks after I purchased the Nexus One, a coworker told me I could buy a replacement digitizer for my Palm TX for $35, which I did. I followed the [instructions at instructables.com](http://www.instructables.com/id/Replace-the-Touch-Screen-Digitizer-on-a-Palm-TX/) to do the replacement, and have been very pleased with the result. So pleased, in fact, that I considered selling the Nexus One. I like the precision of a stylus better than a fat finger. I like the ability to write, using Graffiti, without having to look at an on-screen touch-keyboard to jot down notes. If only I could have a keyboard for the Nexus One, then maybe it would be more productive.

I bought a foldable bluetooth keyboard (Palm 3245ww), on the (incorrect) [recommendation](http://www.nexusoneforum.net/forum/nexus-one-general-discussion/3246-bluetooth-keyboard-support-works-flawlessly.html) that it would work with the Nexus One. It didn’t, but that was okay, because it works beautifully with the Palm TX.

I continued to use the Nexus One, but I found myself frustrated when I read email but had no physical keyboard to compose a reply — instead, I had to settle for a slow touch-screen alternative. I had a general purpose computer in the palm of my hand, but I felt crippled with it. My expectations exceeded the capacity for it to deliver. The Nexus One is a fantastic mobile internet device, and a great platform for consuming content, but not for creating content.

I found myself using the Nexus One to check email or read Facebook when I was sitting at the dinner table, when I really wanted to be focused on my family. I found myself updating apps to the latest version, instead of doing more productive things. I found myself distracted by the Nexus One to the point that it was reducing the quality of my life.

So I sold the Nexus One, and now I’m satisfied with mature, capable, legacy technology in the form of my Palm TX. I’ll continue to watch Android as it matures — after all, I like seeing new developments in technology.

Worth the money: Automated, online backup

*10 February 2010*

Yesterday, I found out I’d lost over three thousand calendar entries, and I had lost them five months ago. Fortunately, I had been using an
automated, [online backup service](http://mozy.com) and was able to restore the missing data.

I found out about my loss when I searched for a phone number on my Palm TX that should have been in my calendar, but was missing. I wondered what was up, and started going through my calendar a month at a time. I noticed that calendar entries after Sept 7, 2009 were present, but nearly everything before that was missing.

My Palm TX is synchronized frequently with Windows, and infrequently
with Linux. My Linux copy of the calendar wasn’t going to help me,
because it was missing the calendar entries as well. The same was true
for the Windows copy.

The Palm-to-SD-card backup that happened every night wasn’t going to
help, because it deletes any backups older than seven days old to make
room for the new backups. I needed something that stretched back five
months or more.

The backup of my Linux computer wasn’t going to help me, because I _overwrite_ my old
backups with new copies of the same files, using ‘rsync’.

I thought my Mozy backups worked the same way. Fortunately, I was
partially wrong. Mozy keeps point-in-time backups of some files. I don’t
know how they determine which files to do it for, but they did it for my
Palm Pilot calendar database file. I was able to restore my missing calendar entries, which was a huge relief.

I heartily recommend automated online backups. Manual backups aren’t
done by most people and if they are done, they’re sporadic and
incomplete. My intermittent manual, replace-the-old-files style of
backup to USB hard drive wouldn’t have allowed me to restore the
calendar entries. The $5/month that I spend for online backup was very
worthwhile, and easy to justify considering that it’s less than the cost
of eating out for lunch. It’s less expensive than a cell phone or
monthly internet service.

If you aren’t already doing automated backups, I recommend that you sign up with an online backup service today. Here are some recommendations:

1. [Dropbox](https://www.dropbox.com/) is the most popular. Works on Windows, Mac,
Linux, iPhone.
1. [Spideroak](http://spideroak.com/) is the second most popular. Works on
Windows, Mac, Linux.
1. Alternatives to these, including [Mozy](http://mozy.com), which is what I use for Windows: [http://alternativeto.net/desktop/dropbox/](http://alternativeto.net/desktop/dropbox/).

—-

A word of caution: backups can’t work miracles. If a file was
corrupted BEFORE it was backed up, no backup solution is going to be
able to solve the problem. This is why I make two copies of all photos
from my digital camera BEFORE deleting them from the camera. Still, if
the memory card in the camera contained corrupted images, even this
wouldn’t be good enough.

—-

The missing calendar entries were, in fact, not missing. They were
corrupted. I found this out by running `jpilot-dump -D | sort -r` on my linux computer. I had 3462 blank entries listed on 12/31/1969. The first time
I restored my Windows datebook.dat, and hot-synced, all of the restored
records were again “deleted” because my Palm though it had the more
current copy of those records in 1969. I had to purge the records from
my Palm _before_ hot-syncing with the restored datebook.dat file.

—-

Techrepublic has a [Review of 10 outstanding Linux backup utilities](http://blogs.techrepublic.com.com/10things/?p=895), many of which work on
other platforms as well.

Personal solutions (not hosted):

– [Simple Backup Suite](https://help.ubuntu.com/community/BackupYourSystem/SimpleBackupSuite) for Ubuntu and Fedora, which does full and incremental backups, on a schedule or manually. Install it on Fedora by running “`yum install sbackup`”. Configure and run by running “`/usr/bin/simple-backup-config`”
– [fwbackups](http://www.diffingo.com/oss/fwbackups), of which Techrepublic says, “This is, by far, the easiest of all the Linux backup solutions.”
– [Rsnapshot](http://rsnapshot.org/)
– [Duplicity](http://duplicity.nongnu.org/) which is a command line utility, and is recommended by http://rsync.net

Migrating data from Palm TX to Nexus One

I’ve used Palm OS for the past ten years, starting with a stone-age [Handspring Visor](http://en.wikipedia.org/wiki/Handspring_%28company%29#Handspring_Visor), continuing with an elegant Sony [Clie](http://en.wikipedia.org/wiki/CLI%C3%89), and ending with a well designed [Palm T|X](http://www.palm.com/us/products/handhelds/tx/). The calendar and the address book kept me organized. The failure of the digitizer in my T|X pushed me to find a replacement. I considered the iPhone and Palm Pre, but chose the [Nexus One](http://en.wikipedia.org/wiki/Nexus_One).

Once the Nexus One arrived, my task was to find a way to migrate my calendar, contacts, and passwords.

A coworker recommended [GooSync](https://www.goosync.com), which he used to move from a Palm TX to a Motorola Cliq. From the description of GooSync, it sounded like neither the free version or the paid version would migrate all ten years of calendar entries over to Google calendar.

Google calendar supports import from an [iCalendar](http://en.wikipedia.org/wiki/ICalendar) file. Palm Desktop doesn’t export into iCalendar format. Jpilot on Linux does, but I found that the format is not compatible with Google’s import. So I synchronized my Palm TX with Evolution on Linux. Evolution’s iCalendar export was compatible with Google’s import.

Palm Desktop didn’t seem to be able to export in a format that Google’s contacts could understand. I used Jpilot on LInux to export each of my categories in [vCard format](http://en.wikipedia.org/wiki/VCard), and imported them into Google one at a time. This worked well.

On Palm, I had used GNU Keyring to store my passwords. Android has [KeePassDroid](http://www.keepassdroid.com/) (among others). There was no easy migration path between the two. Jpilot on Linux has a plugin to display my GNU Keyring password entries. I installed [KeePassX](http://www.keepassx.org/) on my Linux box, and copied and pasted each password from Jpilot into KeePassX. When I finished, I copied the KeePass database onto the Nexus One.

I like the Nexus One. It’s slim, fast, and capable.

Trust, but verify

In [a comment](http://lwn.net/Articles/375051/) over at LWN.net, a reader pointed out that it’s a good idea to verify not just SSL certificate, but also doctors, mechanics, etc. He says, “it’s simply a requirement of a healthy society that it’s citizens have a healthy skepticism and be willing to put the effort into understanding what is going on around them. It’s not that you don’t trust them. Its that you do what you can, in your limited way, to make sure that you can trust them.”

Working around patent threats

Andrew Tridgell, author of Samba, says the best way to defend against patents in open source software is to 1. learn how to read patents and 2. learn how to rigorously work around patents

* [http://lwn.net/Articles/370615/](http://lwn.net/Articles/370615/)