Leave a door open (for Peace)
![]()
Today is John Lennon's death anniversary. He was shot to death on December 8th, 1980. I always commemorate this day by listening to John Lennon's music, smoking unfiltered Gitanes, playing guitar, and letting my hair grow long... for a day... ok, not really, but I do try to listen to Imagine, at least once.
At any rate, there is a website now to commemorate John. It has a letter from Yoko Ono and a video from John Lennon.
The goal of an artist is to elicit some kind of emotion from the audience through his art. You cannot see the video and feel nothing. I left it running in the background while doing other things as I've seen Lennon interviews thousands of times and can usually remember how they go, but the imagery at the end, after John stops talking, pulled my eyes and engaged me like nothing has for a long while. I literally couldn't stop watching.
At any rate, here's to you John Lennon. You were the Walrus.
Vive la différence
One of the more useful programs in the developer's toolkit is diff. This little utility compares two files and gives you just the differences (what changed) between them. Evey version control system in the world is ultimately based on diffs.
One way I commonly use it, is to see what I've changed in a file or a set of files. Let me clarify. I put everything in version control. Even tiny little programs that I'm tempted to throw away are in version control. Being able to use diff between my modified file and the previous version is a major reason for doing so.
Now, if I told you to quit your editor and run diff in a terminal, I wouldn't be surprised if you decided to beat me with a clue stick. You should NEVER leave your editor. If you do, you don't know how to use your editor, or your editor is not powerful enough. If your problem is the latter, you should switch to Emacs right now. Otherwise, keep reading, I can help you.
Depending on what version control system you use, you should modify the commands given below. I use BitKeeper (well, duh!), so all my examples will use that one.
To start with, stick this in your .emacs:
(defun bk-diffs () "Get diffs between current edited buffer and checked in revision" (interactive) (let* ((filename (buffer-file-name (current-buffer))) (newbuf (get-buffer-create (format "%s diffs" (if filename (buffer-name) default-directory))))) (set-buffer newbuf) (if buffer-read-only (toggle-read-only)) (erase-buffer) (insert (shell-command-to-string (if filename (format "bk diffs -uph %s" filename) "bk -r diffs -uph"))) (switch-to-buffer-other-window newbuf) (diff-mode) (beginning-of-buffer) (diff-hunk-next) (toggle-read-only) newbuf))
Now, whenever you are in a file and want to modify it, all you need to do is run the command bk-diffs and you'll get something like this:
Cool, eh?
The command is also context sensitive, so if you run it from a buffer where you're not editing a file, e.g. a dired buffer or a shell buffer, it will run a recursive diff and give you diffs for all the files. I use this all the time when I go back to repositories I haven't touched in a while. It's my "what the hell was I doing?" command. The output looks something like this:
That's not all. I have more tricks for you. First of all, navigation:
| n or M-n | Move to the next hunk |
| p or M-p | Move to the previous hunk |
| M-N | Move to the next file |
| M-P | Move to the previous file |
If you are an old school hacker and would rather see context diffs than unified diffs, you can hit C-c C-d while in the diffs buffer. To go back to unified diffs, hit C-c C-u.
There are also key strokes for going back to the source file from the diff buffer. Pressing Enter or M-o or
Ok, that is useful, but I see you're not blown away. The truth is, I saved the best part for last. Once you're walking the diffs one by one, you can also press C-c C-a to either apply, or revert a hunk! How cool is that eh?
This last feature is something I use all the time to clean up a file before checking it in. E.g. I sometimes have a bunch of debug code or comments to myself that need to be removed before checking the file in. Rather than review the file by hand, I can go through the diffs and use the quick navigation that emacs provides for doing the clean up.
Finally, if you are a CVS user (I'm sorry, really. You should switch to something else), you can probably still use it inside vc-mode, hit C-x v = to get the diffs and try the keystrokes I mentioned.
Beautiful Emacs
When you spend all day looking at code, it's important to select a good editor font. Obviously, the font needs to be monospaced or the alignment will be all wrong. Well, there are only a handful of monospaced fonts worth looking at (and Courier is not one of them).
Take a look at the following image. Click on it, and pick your favorite of the four fonts.
These are the fonts in the image, clockwise from the top left corner: Bitstream Vera Sans Mono, Andale Mono, Monaco, and Inconsolata.
Bitstream Vera Sans Mono is my second favorite. It's the font I use on my web browser. However, for editing code, I find it a bit too heavy. This probably has more to do with my color scheme than the font per se, so your millage might vary.
Andale Mono is very readable, but I find the spacing all wrong and somewhat distracting. Look at the word "String", the letters seem too far apart.
Inconsolata is my personal favorite. You need to crank up the font size because it seems to be a smaller font than the rest. I thought that point sizes were supposed to be standard, but apparently I was wrong.
Monaco is the default in Mac OS X, but it looks kind of silly. I used to use whatever was the default, so I've used this font quite a while. I never did mind it, but once I made the switch to Inconsolata, I can't stand it anymore.
If you want to play with different fonts in Carbon Emacs, you can enable mac keys by running the (mac-key-mode) function, and then pressing ⌘T, which will open a standard font dialog.
However, if you want to use Inconsolata as your default font, put this in your .emacs
(require 'carbon-font) (fixed-width-set-default-fontset "-apple-inconsolata-medium-r-normal--14-*-*-*-*-*-iso10646-1")
It took me a while to figure out how to change the font on Carbon Emacs, so I hope that even if you don't choose Inconsolata as your preferred font, this information might prove useful.
Norton Fighter
And on a lighter note... I found this clip hilarious.
Part 1:
and part 2:
If I used Windows, I'd buy norton antivirus just because of this ad.
Timeo Facebook et dona ferentes
Which can be loosely translated as "I fear Facebook even if it brings gifts". My friends have noticed that for quite some time I've stopped updating my Facebook status, or even interacting with the site altogether. The reason is simple. I don't trust them.
A short time ago, Facebook introduced a new feature called "Beacon" that lets websites send status to your mini-feed. It immediately drew a lot of criticism because of its invasion to privacy, to the point that many people figured out ways to block it. Facebook's CEO apologized for it today and made beacon opt-out.
Now, I was going to write a detailed article about why this bothers me and how insincere the apology sounded, but our good old friend Fake Steve Jobs did a much better job in this blog post. Money quote:
These guys are like Google, only their slogan isn't "Don't be evil" -- it's "Don't get caught."
And later:
The smarmy fake apology is not at all reassuring and seems to have been written by PR people who were trying to imitate a 23-year-old kid who's speaking from the heart and trying to sound all sheepish and aw-shucks -- except the flacks can't do it because they're as insincere and stage-managed as as the Facebook guys. Plus, let's face it, the flacks are getting paid in Facebook equity, right?
I couldn't have said it better myself. You should go read the whole post.


