New Options for Version Control for the Mac

If you’re writing code. Ever. Be it Java, Python, Objective-C, Perl, or plain old C, you really, really need to get in the habit of using a version control system for managing your code. It allows you to experiment, and to easily roll back your code if you completely mess something up.

There are several excellent and simple systems available. My preferred system is Git, but Mercurial is also an excellent, modern system to use. It’s also fairly easy to set up. And if you don’t want to mess around with the command line a lot, or don’t want to pay for the (excellent) Tower, then there’s a new, free option for managing your git repositories at the popular online service GitHub. (Note – you don’t need to host your repositories online – they never have to leave your computer. Unless you want to share them with other people not in your home or office).

iOS5 – Undervalued Changes

Looking through Apple’s page on iOS5 and its new features, many of them are being covered by the tech press, especially the new notifications (sorely needed). There are a few that have received scant attention, and yet I know will personally benefit me or people I directly know a lot. 

Calendar is expanding the available views so that the iPhone/iPod Touch version will now allow a week view. I’ve lost count of how many times I’ve waited until I could open up iCal on my laptop in order to see the week at a glance.

Mail will now allow formatting, including bold, italics, and (most importantly for several people I know) indenting. My favorite new mail features are the ability to drag to arrange addresses, and the ability to manage folders.

Lastly, with an appleTV, the iPad2 can now be mirrored directly onto an HDTV over wifi.

There was not the classic “Steve” version of “One more thing”, but one new feature that has seen some mention in the press feels incomplete to me. There are also some things people were hoping for that were NOT announced.

There is a new messaging system built into iOS5 to supplement/coexist with MMS/SMS, but available to any iOS device even if not a cellular data plan – such as iPod Touches. I’m willing to be that like facetime, this is a feature that will be added to or made available to the Mac OS in Lion.

There have also been people talking about how movie streaming and a new AppleTV were not mentioned. My only reply is: All in good time. Apple is not positioning these things against Netflix, but once this infrastructure gets put in place, then movie streaming is such a no-brainer in terms of desirability that I’m sure we will see it.

One must remember – Apple no longer does annual announcements at MacWorld, etc. I suspect it’s because that lets them announce what features they want to, when they are good and ready to unleash something new.

Markdown and Writing

While major writing projects requiring lots of research, sometimes I just want to write up several paragraphs in an article without a lot of fussing about. Text editors are perfect for this, while also guaranteeing, unlike Word, Pages, or even more open formats, maximum future readablity and recoverability. Unfortunately, going back in to properly add links, italicize or quote text, etc., can be a pain.

Thus was born Markdown. Markdown is both a plain-text syntax for tagging text for web/formatted output and a program of the same name that converts text in the markdown syntax to valid HTML. Since the formatting and syntax use conventions already long common in emails, it’s very easy to mark up the text, and text formatted this way is highly readable even as plain text.

Since I don’t feel like breaking out a massive writing tool like Open/Libre Office or Scrivener every time I want to write up a few paragraphs, and since I absolutely hate going back after the fact to format everything in even the best WYSIWYG implementations when I could do it from the keyboard as I type, I really appreciate the ease of use.

I also appreciate the fact that it’s widely available. While blogger doesn’t directly support it, it’s fairly easily added to WordPress, and is available for Posterous and Squarespace.

So here’s my cheat sheet that I keep in Emacs when I need a reference. Most of it is paraphrased from the original, and further details or nuance are linked to on a section-by-section basis to Gruber’s original spec:

Markdown reference:

You’ll note the headers for each section link to the respective section in Gruber’s syntax page for more information on the available options and nuances.

Block Elements

A paragraph is simply one or more consecutive lines of text, separated
by one or more blank lines

This is a new paragraph.

use two


Two types.

This is H1 (with ===== underneath)

This is H1 (with ===== underneath)

This is H2 (With ------ underneath)

This is H2 (With —— underneath)

Alternately, you can use ‘#’

# One '#' for h1

One ‘#’ for h1

## Two '##''s for h2

Two ‘##”s for h2

Three '###' for h3, and so forth.

Three ‘###’ for h3, and so forth.


Markdown uses email-style “>” characters for blockquoting. They can be
nested by adding additional levels of ‘>’. They can also contain other
markdown elements (headers, code blocks, etc…

> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
>> Inset second level.
> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse

This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,

Inset second level.

Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse


Markdown supports ordered (numbered) and unordered (bulleted) lists.

Unordered Lists

Unordered lists use asterisks, pluses, and hyphens — interchangably — as list markers:

- Item a
- Item b
- Item c
  • Item a
  • Item b
  • Item c

Ordered Lists

Ordered lists use numbers followed by PERIODS. Order is irrelevant.

1. Dog
2. Cat
3. Kids
  1. Dog
  2. Cat
  3. Kids

List items separated by a space have the content of the <li> wrapped
in a <p> paragraph tag.

Code Blocks

To produce a code block in Markdown, simply indent every line of the
block by at least 4 spaces or 1 tab. For example:

This is a code block.

A code block continues until it reaches a line that is not indented
(or the end of the article).

HTML in a code block is converted to entities, and Markdown syntax is
NOT processed within a code block.

Horizontal Rules

You can produce a horizontal rule tag (<hr />) by placing three or
more hyphens, asterisks, or underscores on a line by themselves. If
you wish, you may use spaces between the hyphens or asterisks.


Span Elements


Inline or reference. In both styles, the link text is delimited by
[square brackets]. See the original
for a
more thorough explanation of reference-style links.

This is [an example]( "Title") inline link.
[This link]( has no title attribute.

Reference-style links

[This is linked] [id1] to something
[id1]:  "Midknight Gallery home Page"

This is linked to something

Also, a reference can be implicitly identified by the linked content

  [The Midknight Gallery][] is a great site.
[The Midknight Gallery]: "Home"

The Midknight Gallery is a great site.






Emphasis can be used in the middle of a word:



Backslash to escape literal asterix’s like this: \*.

Span of Code

Wrap a span of code within a paragraph with backtick quotes (`)

To include a literal backtick character within a code span, you can
use multiple backticks as the opening and closing delimiters:

``There is a literal backtick (`) here.``


Inline image syntax looks like this:

![Alt text](/path/to/img.jpg)
![Alt text](/path/to/img.jpg "Optional title")

Reference-style image syntax looks like this:

![Alt text][id]

Followed by the same syntax as reference links:

[id]: url/to/image  "Optional title attribute"


Backslash Escapes

Markdown provides backslash escapes for the following characters:

\   backslash
`   backtick
*   asterisk
_   underscore
{}  curly braces
[]  square brackets
()  parentheses
#   hash mark
+   plus sign
-   minus sign (hyphen)
.   dot
!   exclamation mark

Automatic Links

Simply surround the URL or email address with angle brackets.


Markdown will turn this into:

<a href=""></a>

Emacs Fixes: Issue 2 – Transmit Compatibility

Transmit is an excellent FTP client, and hands down my favorite for the Mac. One of its niftier features is that of opening up a file on the remote server in a local editor, and uploading the changes automatically as they are saved in the editor.

This didn’t work out of the box in emacs, but I found a fix (h/t to 

In your user directory, you’ll find a hidden file called “.emacs” Edit the file to add the following:

(setq backup-by-copying t)

Or, you can use the in-emacs preferences. If you type M-x (refer to the tutorial if you’re not sure what that means), and then “customize”, you’ll get to a customization screen. Select “Files”, then “Backup,” and toggle “Backup By Copying” on, and save the results. This will automatically add the entry to your ‘.emacs’ file.

Emacs Fixes: Issue 1 – Command Line Access

BBEdit and Textmate have a nifty tool they install so that when you’re in the command line, you can use a command like “mate” or “bbedit” to open a specified file. When the file opens in the editor, you can even close out the terminal window without crashing the graphical environment.

While it’s possible to open the GUI version of emacs from the command line with a specific file, it’s not quite so graceful if you forget and close out the terminal window – it crashes. I’ve tried several workarounds, but none of them are truly satisfactory, especially given that I don’t have to open up the terminal to see hidden files in the first place.

So of course you learn the basics well enough that opening up emacs in the terminal allows you to get done what you need, and then realize that to open a file anywhere on the drive, even hidden files and ones hidden from you by the computer, is drop dead simple. 

C-x C-f (Control -X followed by a Control-f) allows you to open up the file browser, starting at your home directory (shown by a “~”). Hitting return then changes the display – the buffer – to the specified file or the contents of the selected directory. From there you can navigate through the file system with much of the same ease as you can through the terminal. 

The lesson here is that you don’t even need the terminal to open up a hidden file. If you are in the terminal because you want to pipe the results of a command to emacs, you can either deal with the terminal – emacs is emacs – or bring up the graphical version. In the last case, just don’t close  out the terminal window before closing out the graphical one.

In short – this isn’t an issue so much as it just works different. 

Making Emacs Work the Way I Wanted it To.

Not all was sweetness and light. Changes mean things are different, and comfortable habits die hard. 
Several things I missed from BBedit and/or TextMate, that were my priorities for “fixing” were:
  1. Some things just are different. The graphical version doesn’t open from the command line without a few clunky integration issues, but it’s something that isn’t really needed either. 
  2. Out of the box, emacs didn’t save things back to disk so that Transmit, my FTP client of choice, would copy the changes up to the server.
  3. Out of the box, the gui version of emacs doesn’t do color themes beyond the stock syntax-coloring-on-white. 
  4. Emacs didn’t do syntax hilighting for web pages using several programming languages (php, Javascript, and of course HTML are common), out of the box.
  5. The syntaxt hilighting for multiple languages is still somewhat clunky due to a few bugs. Javascript is different from what I’m used to in BBedit, but just as good. 
  6. I am still learning how to implement “lint”-based debugging of javascript  – a module that was available for TextMate.
  7. I still need to learn how to program for emacs. I also haven’t learned to replace the convenient snippet structure that TextMate had, but the programming built into emacs is powerful enough to write entire games that run within emacs.
  8. I still haven’t learned how to do a diff well – BBedit and TextWrangler (the free version with less features) still rule here.
First of all – keep in mind why I’m making this change. I’m finding myself in a position where I need a tool I can use anywhere. So, I’ll address how to tackle each of the first five that I’ve already solved, and any other issues that I fix to my satisfaction. 

Getting Started on Emacs for Macs

Getting started on learning, really, really learning emacs is not, in and of itself, that hard, but will be markedly different from almost anything you’ve done in Word, Notepad, or any word processor you’ve used in the last ten years. Especially if you’ve started out on Macs in the first place.

You’ll have to unlearn a lot that you “know.” Also, if you’ve used other high-end text editors like BBedit, you’ll find some features not available right away out of the box. 

As usual, the best way to learn is to actually do it. 

A good site to learn more about about emacs as you get started is the Emacs Wiki. The site includes all sorts of information, including where to get different versions, and how to setup certain features. They also have an excellent page on where to get and set up Mac versions. I recommend you download the version compiled by Vincent Goulet because it includes several common packages and needed adjustments to work smoothly with the MacOS clipboard, and then that you skip on to do the tutorial.

The tutorial? Emacs is ‘self-documenting,’ and includes an excellent tutorial that leads you through the basic commands to move through a document and modify it. To start the tutorial, first start up emacs, and then type CNTRL-h (hold down the control key and press ‘h’, often referred to in emacs as C-h), followed by a ‘t’. 

I’ll be back later to work around some things I missed from using BBedit and TextMate.

Necessity is a Mother

Simplicity is a balance. When it comes to tools, it’s often a balance between factors that cause drag like clutter and analysis paralysis, and the issue that a srewdriver makes a piss poor hammer. Too many tools for a job prevent you from mastering the ones you have and waste your time choosing between them. Not enough tools and you end up wasting time making do.

When discussing programming earlier, I discussed that you should choose a text editor, and stick with it, learn it. I also outlined why I chose the text editors I was using. 

Well, circumstances have changed, and so have my tools.

One of my two go-to editors (TextMate) still has not seen any real progress. Any promises of an updated version fixing the problems I and others experienced still being so much vaporware. Also, I was spending most of my programming time in Xcode, and while Xcode has its faults as a text editor, losing the integration, code completion, etc. just wasn’t worth it. Lastly, I’ve found myself spending a lot more time in not only the Mac terminal, but working with other, linux computers, and needed to finally buckle down and learn an editor that would be available – or installable – almost anywhere I was logging in without having to learn yet another set of tools.

Thus I’m back to learning Emacs.

Why two tools? The friction of working around Xcode’s external editor support when it did exist – it’s not available in the latest update – was just too much trouble, and I still needed something I could use everywhere else. Screwdriver and a hammer.

So yes, there’s a learning curve. Emacs is insanely powerful and was designed in a pre-mouse world for handling text in a number of different contexts. But the basics are the same in the OSX terminal, Cocoa, a linux terminal, Windows, XEmacs under gnome or KDE. Whatever I learn, I learn once, and I can use it anywhere.

Acorn Update Available.

The guys at Flying Meat Software have released an update to their excellent, inexpensive image editor, Acorn, which is now up to version 3. One of the better reviews is here at Mac App Storm. Like many Mac apps these days, you can also get it via the Mac app store, allowing you to install it on all of your family computers.

While I personally won’t be switching to it from Pixelmator, what I’ve said before holds true – they’r both excellent programs and it’s more a matter of which suits your style. Check it out.

Note: Updated to dix a typo in mispelling “Mac”

Reactor Problems in Japan

After the recent quake near Japan and the tsunami that followed have killed thousands, destroyed billions of infrastructure, left many without power or water, destroyed trains, and destroyed oil refineries outright in an inferno worthy of Dresden, we keep hearing about the reactors.

The short answer: yes, it’s a shame. Yes, some people will get some exposure to radiation outside of the plant. Yes, parts of the plant will likely be shut down for good. All in all, the plant suffered an earthquake well in excess of design parameters and has been shut down. The core may slag itself, and some radioactive gases may be vented (and dissipate, and rapidly become non-radioactive ) relative to normal background, but in the end, explosions of the reactor core, or anything like Chernobyl, is just an impossibility.

The long answer is here, from the guys at MIT’s Nuke sciences division.

It is worth mentioning at this point that the nuclear fuel in a reactor can never cause a nuclear explosion like a nuclear bomb. At Chernobyl, the explosion was caused by excessive pressure buildup, hydrogen explosion and rupture of all structures, propelling molten core material into the environment.  Note that Chernobyl did not have a containment structure as a barrier to the environment.

Additionally, Chernobyl was designed so that it got more reactive when it lost water, and the moderating material that made it more reactive was flammable graphite which caught fire.

So please go read the whole thing.