Ampersands

This post is a little outside the usual Irreal sphere of interest but its subject matter is so delightfully geeky and interesting that I couldn’t resist writing about it. Over at the hot word (on Dictionary.com) they ask, “What character was removed from the alphabet but is still used every day?” The answer, of course, is the ampersand.

It turns out that the ampersand was once the 27th character of the alphabet. That’s vaguely interesting in a Jeopardy answer sort of way but it’s the rest of the story that really captured my imagination. The first surprise is the origin of the shape of the character. By the first century Romans were using cursive writing so the linked e and t of et, Latin for and, came to take on the shape of the modern day ampersand. You can see that clearly on this Adobe page about the ampersand. The hot word post recommends the William Caslon font (Figure 6) as a particularly striking example of this but I find Figure 9 even more so.

The second surprise is how the character came to be called an ampersand. In the early 1800s, when the ampersand was still considered part of the alphabet, school children reciting their ABCs would end with “X, Y, Z, and per se and.” Per se means “by itself” so they were saying, “X, Y, Z, and by itself and.” The hot word explains that that was to avoid the clumsy ending “X, Y, Z, and.” Over time the “and per se and” became slurred together into the word ampersand.

There’s many more interesting facts in the hot word post so you should go on over and take a look. Among other things, you’ll learn that the slurring that produced “ampersand” from “and per se and” is called a mondegreen. If you follow the link they give, you’ll discover where the name mondegreen came from. It’s another interesting story.

Posted in General | 1 Comment

Smex

Back in July I wrote about using aliases to replace longer, hard to remember command names. Several of the commenters said that I should use smex to bring the wonders of Ido to extended commands. I finally got around to doing that and am now wondering why I waited so long. Now instead of relying on the qrr alias for query-replace-regexp I just type 【Meta+xqreg to get it. Sure, it’s a character longer but the same sort of thing works for all the commands, not just the ones I have aliases for. If you’re into adventure games, a little experimentation will usually find a shorter sequence. For instance 【Meta+xqex will also execute query-replace-regexp but the nice thing about smex is that you just need a general idea of what the command is to find it within 3 or 4 characters.

You can get smex via ELPA or from Github. Installation is simple. Just stash smex.el somewhere in your elisp load path and add

(require 'smex)
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)

to your .emacs or init.el file.

The key bindings are:

key binding action
Meta+x find all commands
Meta+X find mode specific commands
Ctrl+c Ctrl+c Meta+x old extended command functionality
Posted in General | Tagged | 6 Comments

Opening Frequently Accessed Files In Emacs

While browsing around in the EmacsWiki, I came across a nice way of quickly opening frequently accessed files. The idea is to put the target file in a register and then jump to the register. For example, I frequently open my steps file to record my walking and a tax file in which I list deductible expenses. I can preload the s and t registers with the locations of these files by adding the following to my init.el file.

(set-register ?s '(file . "~/medical/steps.org"))
(set-register ?t '(file . "~/org/tax2011.org"))

Then I can open them by jumping to the appropriate register. For instance, to open the tax file, I would type 【Ctrl+x r j t】.

To be sure, you can do the same thing with bookmarks and even have more descriptive names but I like this solution because it’s just a few keystrokes. Doubtless, Xah Lee would chide me for wasting keystrokes by not using function keys for this sort of operation but given the Mac keyboard it’s a method that works well for me.

Registers are a nice feature of Emacs and it’s worth investigating their uses. Perhaps I’ll write more on the subject later.

Posted in General | Tagged | 2 Comments

The End Of Handwriting?

I’ve written before on how I have pretty much stopped writing anything with pencil/pen and paper. These days the only things I use a pen for are to sign credit card receipts and the very occasional check. For all that, I assumed that I was an outlier, perhaps bordering on the eccentric. But maybe not; Anne Trubek has an interesting article over at Miller-McCune in which she argues that Handwriting Is History.

It turns out that people are very emotional about the subject. Some invest good handwriting with a moral dimension and equate the end of handwriting with the end times. An earlier article by Trubek along the same lines encountered vehement opposition and extremely hostile comments. Still, there’s no denying that cursive handwriting is on the wane—I haven’t used it since elementary school—and children today simply aren’t learning it.

That’s interesting but the larger question is whether even printing will eventually die out. On the one hand, as my own experience shows, it’s perfectly possible to get by without pen and paper. Indeed, I believe you’re better off that way. You can get your thoughts recorded much more quickly and keep them around in searchable form without the clutter of files and stacks of paper. Already, things like the Starbucks iPhone app are pointing the way to the end of credit card receipts and it’s almost certain that the next generation of smart phones will have NFC capabilities that will hasten the demise of the credit card system as it exists today.

On the other hand, it’s hard to imagine doing mathematics without pencil and paper. Perhaps that’s just a failure of imagination on my part—look at Mathematica, after all. If I had to guess, I’d bet that handwriting is heading where physical books are: neither will die out completely but will survive in niches that the ordinary person will find quaintly charming. What do you think? Will handwriting die out or will it, like rock and roll, always be?

Posted in General | 5 Comments

Traveling With An iPad

I just got back from another family visit, this time to upstate New York. I was well out of Irene’s path and except for a rainy Sunday wasn’t affected at all—I thought. Upstate New York wasn’t affected but New York City certainly was: JFK shutdown causing 1600 flight cancellations.

I’ve written before about traveling with an iPad as my only computer but this time I had to completely rearrange my travel itinerary. I was flying out of Syracuse and there were no flights to Tampa so I had to fly to Orlando. That meant arranging for a rental car to drive to Tampa from Orlando. Because the flight left early, I booked a room near the airport so my family wouldn’t have to get up at 3:30 to make the hour and a half drive to Syracuse.

I’m happy to report that I was able to all this easily with the iPad. I had to call the airline directly to rebook the flight and I just entered the new information into FlightTrack Pro manually and pushed it to Tripit. I made the car and motel reservations on line and forwarded the email confirmations to Tripit. When I finished, I had the new itinerary in Tripit complete with confirmation codes and other essential information. All of that was mirrored automatically to my iPhone for instant reference when needed.

As it happens, my family has WiFi but even if they didn’t, the broadband connectivity on my iPad would have enabled me to do all this. For that matter, I suppose I could have done it all on my iPhone but the iPad certainly made for a more pleasant experience.

This was only the second time I’ve traveled with just my iPad but after this trip I feel pretty comfortable doing so. I missed Emacs and my development environment but I probably wouldn’t have used them anyway. I shudder to think what a nightmare making a new itinerary would have been without my iPad and a few key apps like FlightTrack Pro and Tripit. The only phone call I had to make was to the airline (with a 30 minute wait for a representative). Everything else was handled quickly and easily on-line.

Posted in General | Leave a comment

Listing Files On A Remote Server With Emacs

I use TRAMP all the time to edit files on a remote machine: it’s quick, easy, and pretty much transparent. I just learned something new that in retrospect should have been obvious. You can obtain a listing of remote directories simply by opening the directory.

Normally, when using TRAMP, you specify a file 【Ctrl+x Ctrl+f/host:directory/file and Emacs fetches the file for you to edit and then copies it back to the remote host when you save it. But if you specify just a directory, 【Ctrl+x Ctrl+f/host:directory, Emacs will either open a Dired buffer for that (remote) directory or show you a list of files in the minibuffer. I haven’t figured out the exact rule but it appears that the first time you go to the remote host you get the Dired buffer. After that you get the list of files. If you want the Dired buffer you can always get it with 【Ctrl+x d/host:directory.

The nice thing is that this Dired buffer acts just as a local one does. You can drill down into subdirectories and choose a file to edit as normal. All the usual Dired commands work just as if you were in a local directory: you can search, mark, copy, delete, and so on.

Considering that my usual procedure is to SSH into the remote host and run ls to find the exact name of the file that I want to edit, this is a real time saver. Just another example of the power of Dired, this time assisted by TRAMP.

Posted in General | Tagged | 3 Comments

Security and Unicode

I’ve written before about the wonders of Unicode but this post is an example of its dark side. Over at the Microsoft Malware Protection Center there is an interesting post about the use of Unicode by malware. It seems that the trojan TrojanDropper:Win32/Vundo.L hijacks the Russian social networking sites vk.com and vkontakte.ru and redirects them to another—presumably malware, the story doesn’t say—site.

The normal way of doing this is to add an entry to the hosts file (%SystemRoot%\system32\drivers\etc\hosts) but when they checked the hosts file it was clean—no entries for the Russian site. Then they displayed hidden files and discovered another hosts file that had been corrupted. How could this be? You can’t, of course, have two files with identical names in the same directory. By now, you’ve guessed the answer: the visible hosts file had the o replaced with the Unicode character 0x043E, which is a Cyrillic character that looks like the Roman character o. That meant that TCP/IP ignored the “clean” hosts file because it had the wrong name and ussed the hidden one instead.

I’ve heard of this trick being used in URLs to snare the unwary into going to a rogue site that appears to be legitimate but this is the first time I’ve seen it used this way. A very simple but effective trick.

Posted in General | Tagged | Leave a comment

Keyboard Macro Counters

Emacs is incredibly useful for repetitive editing chores. For example, this Xah Lee post shows how Lee performed major surgery on hundreds of pages of HTML by using a little Emacs Lisp.

Not everyone can or wants to write Emacs Lisp but even without it you can still do a lot of automation with keyboard macros. Most Emacs users are familiar with the fundamentals: use 【Ctrl+x (】 or 【F3】 to start recording your keystrokes, perform the repetitive action one time and stop the recording with 【Ctrl+x )】 or 【F4】. Then you can repeat the keystrokes with 【Ctrl+x e】. After the first repeat you can simply type 【e】 for subsequent repeats.

Here’s a little trick I learned from the EmacsWiki. Suppose you want to create a list of host names where each differs from the others by a number at the end

host1.irreal.org
host2.irreal.org
...

To do that, follow these steps

  1. Ctrl+x Ctrl+k Ctrl+a1 to set the amount to increment the counter on each repetition.
  2. Ctrl+x Ctrl+k Ctrl+c1 to set the initial value of the counter.
  3. Ctrl+x (】 to start recording the macro
  4. hostCtrl+x Ctrl+k Ctrl+i】 to insert the current counter value after host.
  5. .irreal.orgReturn Ctrl+x )】 to stop recording the macro.
  6. Ctrl+x e】 to generate the next host name.
  7. e】 to generate another and so on.

You can also use 【Ctrl+x Ctrl+k Ctrl+f】 to set the format of the counter.

Posted in General | 1 Comment

Git By Hand

I went looking for the update to Tom Preston-Werner’s talk on Git that I wrote about previously but I didn’t find it. What I did find, however, is another talk on Git, entitled Unlocking the Secrets of Git that he gave at the UCAR Software Engineering Assembly. This was a very enlightening talk that along with his Git Parable provides an excellent understanding of the Git architecture and how it works under the covers. He describes Git as a user-land file system with versioning and synchronization.

In this talk he constructs two Git file blobs by hand (using an editor and an interactive Ruby shell) and shows how they get named by their Sha1 hashes. Then he constructs a Git tree object—essentially a directory listing of the two file blobs—and then uses git cat-file to show its structure. Finally, he makes a commit object and again shows what it looks like with git cat-file.

This talk really brings alive how simple Git is. There’s something about seeing the objects made by hand (not even using Git in the case of the file blobs) that dispels all the mystery. I really can’t recommend this talk enough if you’re a Git user. It will really help you understand what’s going on.

Of course, there’s a lot more to Git then the add, and commit commands so the talk won’t make you a Git master but it will give you the background to understand the more advanced commands and how they fit in with the Git way of doing things.

Preston-Werner is a Git master and a cofounder of GitHub so he’s a good teacher and give gives an entertaining talk. It’s about 75 minutes long so you’ll need to block out some time but it’s well worth an hour and a quarter of your attention.

Posted in General | Tagged | Leave a comment

SSH Tricks

Smylers over at the Smylers Blog has an outstanding post on little known things you can do with SSH. Even after years of using SSH daily, there were still a couple of tricks new to me in the post. Smylers mostly assumes you’re using OpenSSH, which unless you’re a Windows user you probably are. Even so, he shows how to do the same things with Putty or Copssh, so this is a worth while read for anyone who connects to a remote system.

Among the things he shows you are:

  • How to share a single remote connection with several terminal windows. That’s handy when you want to have several views into your work on the remote server but don’t want to go through the pain of authenticating several times.
  • How to SCP over an existing connection.
  • How to make an SSH connection persist even if you log out.
  • How to set up an SSH key so that you don’t have to give your password when you sign on.
  • How to move that key to the remote system automatically. This is a real time saver because doing it manually is a pain.
  • How to forward connections from one remote server to another.
  • How to set up host aliases so you don’t have to type a long fully qualified host name.
  • How to configure the user name you use on the remote host if it’s different from your user name on your local host. This removes the necessity to specify your login name when you connect.
  • How to forward X11 connections.
  • How to mount remote files locally over an SSH connection.
  • How to connect to remote services with a local application. For example, if you have a database on a remote system that expects a connection on a certain port on the remote system you can configure SSH to do port forwarding to enable this.

There are some other tricks as well. Some of the commenters offer additional tricks so be sure to read them too. This is a really great post and if you’re an SSH user you should read it without delay. It has some techniques that will really make your work flow easier.

Posted in General | Tagged | Leave a comment