nonstic Random snippets of mac and rails goodness

IDNs, or “How To Register a Domain Name With Funny-Looking Characters”

My buddy John Gruber1 recently started using a vanity URL-shortener with the domain name “✪”.

“Wow” I said to myself. “How the heck did he get a domain name with a non-alphanumeric character in it?”

Any registrar that i’ve familiar with cheerfully informs you that only letters (a-z) and numbers (0-9) are allowed in domain names. The only non-alphanumeric character allowed is a hyphen (-).

After some thrashing around, I discovered that our good old Internet Domain Name System does support Internationalized Domain Names, or IDNs. As far as I can tell, pretty much any unicode character can be used. Which means you can open up the “Special Characters” palette on your Mac (charmap on Windows), and make up whatever “symbolized” domain name you like.

Registering an Internationalized Domain Name

  1. Find an Internationalized Domain Name that you want. (I don’t know this for sure, but I imagine you can use pretty much any character(s) you want from the “Special Characters” palette on you Mac.)

  2. Convert the unicode domain name to “punycode” (no, i’m not making this up). This converts Unicode characters into an ASCII representation. You can use an on online conversion tool, such as the one offered by Verisign or there is a Mac app called “PunyCode” that will do the conversion.

  3. Find a registrar which supports IDN domain names.

  4. Use their IDN search tool to see if your domain name is available. You must use the punycode representation of your domain to search. Register away!

  5. Profit!

  1. And by “buddy”, I mean, I follow him on Twitter. 

iPhone 3.0 Tethering on Mac OS X or Windows XP (Non-Jailbreak)

The iPhone 3.0 firmware update that dropped several weeks ago includes support for tethering. Tethering has been around for some time– and is not a unique iPhone feature– but is now available on all iPhones without having to jailbreak your phone or having to download any special carrier files.

Apple has made tethering dead-simple, so there is really no need for instructions. However, since I spent several fruitless minutes Googling for instructions, I thought i’d spell it out for those that seek after me.

  1. Enable tethering on iPhone
  2. Connect iPhone to computer with USB cable1
  3. There is no step 3

Seriously, this is how easy it was for me. I tried in on my Macbook Pro running Leopard (10.5.7) and on my new Acer Aspire One netbook running Windows XP, and it worked perfectly on both. No extra installation or configuration needed. Just plug in iPhone, and you’re online.

(If you are having any problems, check the Apple Support doc.)

I managed to snag a copy of NetShare when it was available on the App Store, and have used it a few times. It did work– sometimes– but was such a hassle to get working that I rarely used it. In addition, it sucked battery life like crazy, and you were limited in how you could use it– most applications needed to be setup to use a proxy.

I didn’t think I would ever say this, but here is an occasion where I am glad to be on Rogers. Rogers includes tethering for free on any data plans of at least 1 GB or more. I snagged the 6GB “special” data plan when it was available, so i’m good to tether all I want.

Tethering with iPhone is so transparent that you almost don’t need to think about it. Just plug-in and go.

  1. You can also tether via Bluetooth, which worked equally well for me on Macbook Pro. Apparently Bluetooth tethering can be slower, and does use more battery life. But it’s pretty cool to be tethering via the phone in your pocket. 

Custom Bookmark Shortcuts in Safari 4

Firefox has been my browser of choice for the last few years. It’s a love-hate relationship– love the extensions, hate how it eats memory, and that I can’t-for-the-life-of-me get it to play video without stuttering.

I have been using more and more of Safari lately– solid, fast, and the dev team seems committed to increasing performance and reliability, rather than just adding more features– but the thing that keeps dragging me back to Firefox are bookmark shortcuts. In Firefox, you can define a keyword for each bookmark, and then use that as a shortcut to the address.

For example, bookmark “”, and define a keyword of “down”. Now, you CMD+L to the address bar and type “down”, saving yourself 23 characters of typing each and every time you visit.

(Yes, I know you can often get away with typing less, depending on your history, recency of visit, etc. I wanted a dependable, efficient way to quickly get to an arbitrary site, that worked the exact same way, every single time. And mouse-clicking is out, because it’s way faster to keep my hands on the keyboard.)

I hadn’t found a good way to replicate this behavior in Safari. Yes, there are some hacks or for-pay add-ons that enable this, but I was looking for a solution that wouldn’t threaten the stability of Safari (i’m looking at you SIMBL), and that worked just the way I wanted.

Several months ago, I found Shaun Inman’s Shortwave project. This was almost what I was looking for. Unfortunately, opening the command window required clicking a javascript bookmarklet on your bookmark bar (or Bookmark list) which violated the “no-mouse” requirement.

I didn’t realize until today that the first nine bookmarks saved to your bookmark bar automatically have a keyboard shortcut assigned to them– from CMD+1 up to CMD+9. Bingo! I moved the “shortwave” bookmark to the beginning of my bookmark bar, and now I can get to any of my saved websites using CMD+1, <shortcut>. Shortwave allows you to define any number of custom keyboard shortcuts just by editing a text file, and saving somewhere online.


This might just be the tipping point to using Safari as my everyday browser. We’ll see.

Using iPhone with Shaw E-mail

You bring home your shiny new iPhone 3G, and one of the first things you want to do it hook it up to your email account. If you have a Shaw email address, you may experience some problems, specifically with sending email from iPhone.

Shaw does not allow anyone outside their network to use their outgoing mail servers. If your computer (or iPhone, via WiFi) is connected at home, through your Shaw cable modem, you are “on their network”, so all is good.

However, if you are using the EDGE or 3G network on iPhone, outgoing mail will not work.

The solution is to use an alternate, non-Shaw SMTP server for sending mail1.

There are several public SMTP servers available, including one from Rogers. Here are the settings that should work for sending & receiving email to your Shaw account.

Settings > Mail, Contacts, Calendars > POP account

Incoming Mail Server

  • Host Name:

Outgoing Mail Server

  • SMTP:

  1. The default server settings on iPhone (from Rogers) do generally include the Rogers SMTP server as a backup in the “Other SMTP Servers” section. So it should fail-over if the Shaw server doesn’t work. In practice, this doesn’t always seem to happen. 

Macworld 2009 – Keynote Recap

For those of you that didn’t– or couldn’t– tune in, here’s a recap of the high points from the Apple Keynote presentation at Macworld 2009 in San Francisco:

New iLife

  • $79, available end of January
  • iPhoto ’09
    • automatic face recognition
    • Flickr/Facebook integration
    • automatic video stabilization to existing video clips
    • Places: geotagging from cameras, and manually
    • photo integration maps from google maps
    • new themes for slideshows (that work on iPhone as well)
  • iMovie ’09
    • precision editing
    • advanced (context-sensitive) drag & drop
    • dynamic themes
    • animated travel maps
  • GarageBand ’09
    • “Learn to play” videos from popular artists
    • additional lessons at $4.99 each

New iWork

  • $79, available immediately
  • Keynote ’09
    • new object, text transitions
    • magic move
    • chart animations
    • new themes
    • iPhone app for Keynote remote ($0.99)
  • Pages ’09:
    • new templates
    • full-screen editing mode
    • new Numbers features as well

Mac Box Set

  • Leopard + iLife + iWork
  • $169

  • upload/share docs online
  • add notes online, edit
  • free now (beta), eventually pay

17″ MacBook Pro

  • 0.98″ thick, 6.6 lbs
  • 1920 x 1200 display resolution
  • 700:1 contrast ratio
  • anti-glare option ($50 extra)
  • 2.93 GHz processor, up to 8GB RAM
  • non-removable battery
  • up to 8 hours battery life, recharge 1000x
  • one configuration: $2,799, available late January


  • three prices points: $0.69, $0.99, $0.129
  • iTunes Plus = DRM-free music, better encoding
  • 8 million DRM-free now
  • all 10 million songs DRM-free by end of quarter
  • iTunes store over 3G and WiFi
  • preview/buy songs over cell network

Chaining Javascript OnLoad Event Handlers (or How to Use the YM4R Plug-in and FancyZoom together in a Rails App)

I was building a Rails application today, and wanted to include Google Maps integration and use the FancyZoom Javascript library on the same page. These two javascript libraries both depend on being instantiated as part of the onload Event Handler. Normally, you load FancyZoom in the body tag thusly:

<body onload="setupZoom();">

However, if you have installed the YM4R plugin for Google Maps integration, you will have also added several lines to the <head> section of your rails layout template, something like this:

<%= GMap.header %>
<%= @map.to_html %>

What you may not know is that the @map.to_html call actually dumps a bunch of javascript code into your page template before it loads. This includes its very own onload call.

window.onload = addCodeToFunction(window.onload, ...

This adds an onload function, to instantiate your Google Map object when the page loads.

Now, you might think (as I did) that when you add the onload call to setupZoom(); on the <body> tag, it would just add the event onto the onload event handler. However, what it actually does is replace the earlier onload event handler. This means the Google Maps onload event never happens, so your map area shows up blank.

How to fix?

The javascript snippet that the @map.to_html inserts looks something like this:

<script type="text/javascript">
window.onload = addCodeToFunction(window.onload,function() {
    if (GBrowserIsCompatible()) {
    ... other javascriptyness ...

So I simply added another call to the addCodeToFunction function provided by YM4R, to add the call to setupZoom to the onload chain. Both calls are then successfully made in the onload event handler, and all is good.

<script type="text/javascript">
    window.onload = addCodeToFunction(window.onload, setupZoom();)

I’ve glossed over a bunch of details, but hopefully this gives you enough info to put you on the right path. If you want more detail, just ask me, man.

Fixing RedCloth (undefined method `textilize') Errors on Shared Hosts


You’ve developed a Rails app utilizing the RedCloth “textilize” method to apply the textile filter to to text field.

eg. <%= textilize @post.body %>

You may have the “RedCloth” gem installed, or unpacked to /vendor.

This app works fine on your local Mac workstation. When you try to run your app in Production mode on the server, you get a undefined methodtextilize’` error.

If you try to require the gem in “environment.rb”, the server throws an error on startup, similar to:

no such file to load -- RedCloth

No attempts to include redcloth, RedCloth, or any other library seem to help.


(Your mileage may vary, but this is what worked for me. I don’t guarantee this works in all situations, but if you come via a desperate Google search, it’s worth a shot.)

Some people report that if you downgrade your RedCloth gem far enough (perhaps as far down as 3.0.3) it will eventually work. However, I want to use at least version 4.x of the RedCloth gem, because it fixes a bunch of bugs found in 3.x.

What finally worked for me was going into “/usr/lib/ruby/gems/1.8/gems/RedCloth-X.XXX/lib/” and creating a symlink thusly:

# modify for whatever version of the RedCloth gem you have installed
# eg. 4.1.0, 4.0.3, etc.
cd /usr/lib/ruby/gems/1.8/gems/RedCloth-4.1.1/lib/
ln -s redcloth.rb RedCloth.rb

Restart mongrel, and voila!


Further To: URL Protocol Schemes as Cruft

I fully agree with Gruber’s comments regarding needlessly staring at “http://” all day long. In fact, i’ve always felt the same way about “www” as well. Yeah, “the web”, we get it. It was cute the first month, but now it’s time to drop it.

It would be like everyone having a sign that says “My House Number is 408″. Nope, it’s already on a house; we know what it means. “408″ is all you get.

Any real information contained in a URL begins only after the triple-double-u. Let’s drop the whole “http://www” pretense, and get to the good stuff.

Anathem Update

Quick update on Anathem: About half-way through, really enjoying it. First 200 pages is a bit slow, but Stephenson still knows what he’s doing. Worth it to slug through.

Disable Data Usage on iPhone 3G

Traveling abroad with you iPhone, and wanting to avoid exorbitant roaming charges? I live in Canada, so anytime I go to the US, I’m subject to Rogers less than– Oh, I don’t know– “equitable” cross-border roaming agreements. A few quick calls and tweets can quickly add up to an unearthly sum– believe me, I know have heard from, erm, others.

Fortunately, there is a quick, easy, & fool-proof way to disable all EDGE/3G traffic on iPhone, and give you piece-of-mind that you will not incur any data or roaming charges. It disables your SIM card entirely, and causes iPhone to operate in “iPod Touch” mode– which is exactly what you want in this situation.

How-to Disable Your SIM Card Using the SIM PIN

  1. Choose Settings > Phone > SIM PIN on iPhone

  2. Turn the SIM PIN On. You will be prompted to enter the current PIN (iPhone ships with a default SIM PIN, please see this table at to determine what should be entered).

  3. You can then tap Change PIN to assign a different PIN number.

  4. Restart iPhone (hold the “Sleep/Wake” button until you see the “Slide to power off” prompt). Upon restart, you will be prompted to “Unlock SIM”, or just continue.

  5. If you continue without unlocking your SIM, iPhone will operate in “iPod Touch” mode, with full WiFi and application access, but no voice or data.

To turn SIM back on again, restart iPhone, and choose to unlock SIM when prompted.


Forgotten SIM PIN

You can enter up to 3 incorrect answers for the SIM PIN before iPhone asks you to enter the PUK code. Contact your carrier to get the PUK code. Note: If you enter the incorrect PUK code too many times (10 incorrect guesses), the SIM will become permanently locked and you’ll need to replace the SIM.


iPhone: About the SIM PIN (

← Before