Seth Gholson · A developer

Cut the Cord - Debug Android Wirelessly

This is one of those "I've wanted it for so long I really don't want to forget this" posts. I'm taking a cue from Scott Hanselman and writing a quick blog post about it so I remember.

To debug your Android app on a physical device without needing to keep the cord connected the whole time, it's really straight forward. First:

  1. Connect via usb.
  2. run: adb tcpip 5555
  3. Remove the phone from usb.
  4. Run adb connect [device's wifi IP address]

Now you can run monitor or adb devices and see that your device is connected! You can run builds directly on the device and debug as necessary.

Oh, mana from heaven! I don't know why this was such a mystery to me. I know I've googled for this kind of solution on at least two occasions, but I never landed on the Android Developer Guide page that says exactly how to do accomplish this. Doh.

Thanks to Pablo Costa Tirado for pointing this out on the Android Developer Tools community on Google Plus.

OSX Terminal Shortcuts I Wish Young Me Knew

I was reared in Microsoft's world. I only use the command prompt for running ipconfig, like every other red blooded American, right? A *nix terminal was a pretty foreign environment for me. For years I knew enough to explore & navigate a directory structure, but that's about it.

Now that I've been spending some time in OS X, I've become much more comfortable using the terminal. It continues to be a learning process, but I thought I'd list a few shortcuts that I suspect are so old and deeply rooted in *nix based environments, that everyone listing "Must Know Shortcuts" assumes they're already known. Well, I didn't know them.

Moving the Cursor


I first discovered this in a reply to @climagic on Twitter.

  • Go To Beginning Of Line: CTRL + A
  • Go To End Of line: CTRL + E

Terminal Animation Beginning and Ending of Line

Now, these are pretty awful. These are OS X Terminal specific from what I can tell. Not that they are separated key presses, not simultaneous.

  • Move Backwards 1 Word: ESC, B
  • Move Forward 1 Word: ESC, F

Terminal Animation Beginning and Ending of Line

Fortunately, you can enable "Use Option as meta key" in your terminal preferences. This will allow you to pres and hold the option key, while pressing B and F to move backward and forward. Not great, but this is a step in a better direction.

  • Move Backwards 1 Word: ALT + B
  • Move Forward 1 Word: ALT + F

Terminal Animation Forward and Ending of Line Using Option

Note: the on screen keyboard is showing a crazy key combo - I suspect this has something to do with the preference override.



  • Undo!: _CTRL + __
  • Backspace word: ALT + Backspace
  • Backspace entire line: CTRL + U
  • Delete word: ALT + D <- Particularly useful on a macbook keyboard with no (forward) delete key.

While certainly not exhaustive, these are the shortcuts I found invaluable and immediately started using as soon as I discovered them. For a more complete list, including history navigation, head over to this link.

A Case For XCode Snippets and Version Control

What's The Problem?

Cocoa is incredibly verbose. While this can make reading it self explanatory, it can also make writing it laborious. Even with code completion, I still find myself having to look up the documentation just to remember what I even need to code complete. It doesn't matter how many times I wire up a UITableView data source & delegate, I can never remember it all.

I mean, who wants to type (or copy & paste) this every time:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        NSString *identifier = @"myCell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (!cell)
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        cell.textLabel.text = @"Cell";    
        return cell;

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        return 0;

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        return 0;

    - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
        return @"Header";

Cue Xcode Snippets!

What Are Code Snippets?

Code snippets are a kind of custom defined code completion. You, the coder, can define a custom shortcut for a longer bit of code. These are especially great for Cocoa APIs, which often require many wordy method implementations.

A couple of fantastic features:

  • Symbolic <# placeholders #> can be used to quickly tab through and supply text that will vary each time the snippet is used.
  • Completion Scope can be specified. This prevents class level snippets from being suggested when your cursor is inside of a method.

Xcode Snippet Edit Dialog

Why Use Them?

Because they save time. Sometimes they save lots of time. I'm personally not one to pour over the number of keystrokes required for every task, but, in the case of Cocoa, we're talking about saving much more than keystrokes. Loading up documentation, searching for the right class or protocol, and then finding the method signatures I need can be a significant time sink when done dozens of times per day.

It takes time to get into the habit of using them. Defining them is easy, but using them is often hard to remember. Generally, I double check my list of snippets once every couple of months. If I don't use them, it's generally because they're not long enough to save me much time so they go into the garbage.

One of my favorite snippets (because I can never seem to remember it): Singleton using GCD

+ (instancetype)shared<#name#> {
    static <#class#> *_shared<#name#> = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _shared<#name#> = <#initializer#>;

    return _shared<#name#>;

Now Go Curate and Save Them

If you start spending time refining your user defined snippets and really begin relying on them, you certainly don't want to lose them. The best way to back them up is to put them under version control, of course!

As of Xcode 4/5, they reside here:


Unfortunately, the file names are not very friendly - they're GUIDs. I've seen some manual solutions for "installing" snippets from human readable files, but I really just need a personal backup of these snippets. Friendly named or readable files would be great for public discoverability, though.

Where to Start?

Have your own code snippets?

 cd ~/Library/Developer/Xcode/UserData/CodeSnippets
 git init
 git commit -a -m "Initial commit"

 *setup your remote repo*
 git push origin master

Need some snippets to start with? You could try mine, which are largely derived from Matt Thompson's.