Welcome to the lab.

Logging snippets for Sublime Text

[Tweet : ADN : nvALT]

Following most of the same patterns as TextMate snippets, Sublime Text snippets can be a great timesaver. One of the things I’ve been doing recently is assigning keyboard shortcuts to snippets instead of tab expansions, allowing me to apply them to selected text with the $SELECTION placeholder. That, combined with some text mutation offers some serious timesaving options. To illustrate, I thought I’d share a couple of very handy logging snippets.

These are added to the default user keybindings file located in your Sublime application support folder, in the file Packages/User/Default (OSX).sublime-keymap (substitute your OS as needed).

The first thing to note is that you can add a language scope to the keybindings, so that the same keybinding inserts different snippets depending on what language you’re currently working in.

Here are the two logging snippets I use most commonly, one for JavaScript, and one for Objective-C:

  // Logging snippets
  // JavaScript
  { "keys": ["alt+shift+l"],
    "command": "insert_snippet",
    "args": {
      "contents": "console.${1:log}(${2:}${SELECTION/;//g});${0}"
    "context": [
      { "key": "selector", "operator": "equal", "operand": "source.js", "match_all": true }

  // Objective-C
  { "keys": ["alt+shift+l"],
    "command": "insert_snippet",
    "args": {
      "contents": "NSLog(@\"${1:%@}\"${1/.*(%\\S+).*|(.+)/(?1:, )/}${2:${SELECTION/;//g}});\n${0}"
    "context": [
      { "key": "selector", "operator": "equal", "operand": "source.objc", "match_all": true }

These add an ⌥⇧L (Option-Shift-L) keybinding. When you trigger it in a JS file, it will insert a console.log() statement. If there is a selection when it’s triggered, the selection will be moved into the arguments for the command. Initially the log keyword is selected, so that you can change it to debug, dir, or any of the available methods in the console API. Hitting TAB from there jumps into the arguments for the command, where you can add a string or object to log. One more TAB jumps the cursor to after the closing semicolon.

In the Objective-C snippet, ⌥⇧L will produce NSLog(@"%@", );. Any current selection will be added to the format string arguments, and you can use placeholders to reference the arguments. The %@ is automatically selected for editing. If you delete the %@ from the format string, the trailing comma will automatically be removed. If you add back any %_ placeholder, the comma will return and TAB will place the cursor into the format arguments.

Between the two of these examples, you should have enough to come up with snippets for debug logging in any language. If you have some awesome snippets to share, please gist them and shoot me a link here or on Twitter!

Web Excursions for May 21, 2015

[Tweet : ADN : nvALT]

If you haven’t gone the Leap route, here’s a touch-free controller for Mac that uses your built-in camera to allow gesture-based control of iTunes and Spotify, among others.
SmartIcons - Smart SVG icon system
A huge collection of web-ready icons that updates constantly. There’s a great variety in there, and plans start at $0.
A great collection of themes for Sublime Text. The coolest part is the plugin (available through Package Control) that lets you flip through and preview the available themes in the current view using the command palette, and install/enable them without constantly visiting the preferences menu or editing the JSON config.
Sunrise Meet
A third-party keyboard (iOS link, available for Android as well) which lets you schedule one-to-one meetings with invites and calendar integration from any app. For me—someone who only meets with one person at a time anyway—this is awesome.
IFTTT Apps for Automatic
Automatic (the smart assistant for your car) has introduced a bunch of app integrations, but the most intruiguing to me are the IFTTT triggers. I can automate events on my iPhone and connected devices based on speed, error codes, or even when I’m starting or ending a drive. Neat.

Postbox 4

[Tweet : ADN : nvALT]

Postbox 4 was released last week, and it’s good. Yes, I’m way behind on blogging, but that’s another post.

Postbox has long been of interest to me because it offers stability and a degree of extensibility. I’ve settled into MailMate quite nicely in recent years, but the new version of Postbox looks amazing, and is a great option for people who need a level of power that falls between Mail.app and MailMate.

First, the new version is pretty. Postbox has always achieved a certain level of aesthetic beauty that defied its origin as a Mozilla-based email client. This version, though, is stunning.

The “Focus Pane” that has been part of Postbox for a while now has received a powerful update. It provides a way to find messages using common criteria such as recipient headers, attachment attributes, and custom labels. The criteria can be quickly combined into powerful searches. I like this because it’s as powerful as many of my Smart Mailboxes, but simplified from a setup and modification perspective.

Postbox 4 also adds Box and OneDrive to its cloud attachment capability, which lets you have your email attachments automatically hosted on a cloud server to avoid sending large files through your email host and into your recipient’s inbox.

The “Domain Fencing” feature is new, too, and something I haven’t seen implemented anywhere else before. When composing a message or reply, it can intelligently warn you if you’re sending it to someone outside of your organization when you shouldn’t be, and if you have multiple accounts it can let you know if you’re replying from the “wrong” account.

There’s a lot more to check out, and you can read the full release notes, but if you’re in the market for a powerful email client, I recommend just giving it a shot.

New features and fixes for BitTorrent Sync

[Tweet : ADN : nvALT]

I’ve become an even bigger fan of Sync since BitTorrent released 2.0, so I thought I’d mention the 2.0.120 update they posted yesterday.

The update offers quite a few fixes, as well as some new features such as a built-in search for folders, users, and devices, and an easier way to see which user or device owns each folder in the list.

There’s a blog post with the announcement, and the full changelog has all of the details. If you’re looking for a secure way to own your own cloud, you download Sync for free.

Introducing The Shuttle - never lose your Apple Remote again

[Tweet : ADN : nvALT]

Ok, so I teased “The Shuttle” a while ago, but it’s ready for sale now. It’s a handmade oak holder for the Apple Remote that looks great with the sleek design of the remote. Its raison d’être is to keep you from losing your Apple Remote, and doing it with class and style.

I own several of the silver Apple Remotes, yet could never find any of them. On Twitter and talking to friends I found I was far from alone. I prototyped this out of a toilet paper tube, and it’s come a long way since then. Now, thanks to my father’s engineering and woodworking skills, it’s a gorgeous piece that not only solves the lost remote issue, but also looks good in any setting.

I have large hands. My wife has much smaller hands, so part of the design process was coming up with a size that worked for everyone. The end result is comfortable to use in any size hand — and more comfortable than the sharp-edged sliver of aluminum has ever been.

“We used to lose our Apple Remote twice a day. Over several weeks of using The Shuttle, we haven’t lost it once. I’m embarrassed to admit how much better The Shuttle has made my life.” - Merlin Mann

This is a handcrafted piece that’s built to last, and it’s not an impulse purchase item. I’m pricing it at $79, but for a limited time you can order it at the intro price of $59.

Right now The Shuttle is listed as a made-to-order product, but we have stock on hand and ready to ship. Tired of looking for your Apple Remote? Here you go.

Web Excursions for May 05, 2015

[Tweet : ADN : nvALT]

Brighten Your Day with Motion Controlled Cabinet Light
Every day I find things that make me wish I had time to actually dig into Arduino programming. Robotic feline enrichment toys would be my first project, of course, then lighting automation.
AnyBar and SuperDuper!
Great use of AnyBar from Dr. Drang.
Learn Git Branching
A very cool interactive tutorial on Git branching. Great stuff for anyone starting with Git, and even more for people at an intermediate (plus) level.
As far as command line directory navigation goes, this utility seems pretty awesome so far.
Yosemite: Enable dark mode with a keyboard shortcut
I don’t use Dark Mode in Yosemite, but I do need it when testing app UIs. I hadn’t paid attention to this option previously, but it’s handy for people who switch Dark Mode on and off frequently.