The book is out

It's official, the book that I've been writing is in print and available for purchase.

I'll be publishing excerpts from the book soon.

Xcode 7 Essentials - Second Edition from Pack Publishing

Apple’s Xcode technology is making the development curve smoother than it has ever been with its easy-to-develop features and enhancements. With the latest release of Xcode 7, Apple has also added great support for Swift development.

This book will introduce you to all the new features of Xcode 7 and demonstrate how Swift programming can be much easier, faster, and simply better with Xcode!

Even if you’re starting with just a little knowledge of Swift or Xcode, you will learn the basics of the language as well as the tool. You will then use this knowledge to create simple applications and will learn how to debug and optimize your code. At the end of this book, you would have learned enough to build, run and submit your very own application to the App Store.


Words by brett ohland

Killing Bluetooth From The Terminal

Not sure if I'm the only one on the internet who has this problem but…

Have you ever opened up your Mac to do some work and not be able to use the internal trackpad to click on anything? Does it turn out that this happens because you're still in bluetooth range and something heavy is sitting on the Magic Trackpad in the other room?

This happens to me fairly often, especially when we have guests over (the spare bedroom is also the guest room and the desk ends up as a dumping point).

Now what happens if the occupants of the room are still asleep and you have just a few precious moments to work on your book before the toddler wakes up and requires your full attention?

You fire up your termal and type these two commmands:

sudo defaults write /Library/Preferences/com.apple.Bluetooth.plist ControllerPowerState 0

sudo killall blued  

If you're feeling super fancy, you can create a bash or zsh alias:

alias killbluetooth="sudo defaults write /Library/Preferences/com.apple.Bluetooth.plist ControllerPowerState 0 && sudo killall blued"  

This sets the bluetooth pref to off and then resets the bluetooth process so that new value is read.

Problem solved.


Words by brett ohland

Blog to book transitions

I've been working on something a little different over the last month. Things are now far enough along that I can mention it here.

Instead of writing for my dev blog recently, I've been spending all of my writing energy writing an actual book. I'm working with Packt Publishing out of The UK to update their Xcode 6 Essentials book to Xcode 7.

Moving from a hobby dev blog to an actual book has been an interesting switch. I can also say that I've never focused and written so much in such a short amount of time. Really though, one chapter clocks in at over 10,000 words. I never thought I'd have that kind of capacity.

I'll be announcing here once it's published and in a purchasable state. I also have a few excerpts that I'm particularly proud of that I'll be posting here as well.

Stay Tuned.


Words by brett ohland

Circumventing the Lack of Media Keys on the Ergodox in OS X

Massdrop is both a blessing and a curse. They've brought the Ergodox as close to the mainstream as they probably can (and you could say the Ergodox EZ is bringing it the rest of the way).

Blessing, because their assembly instructions and layout configurator have become the de-facto standards that everyone uses and follows.

Curse, because their configurator is using old versions of the firmware and there are pages dedicated to addendums to their assembly instructions.

Unless you want to run a variant firmware or make changes to the Massdrop standard, you aren't going to get media keys.

While I am a software dev by trade, the idea forking and branching an open source firmware (written in C) to make my own custom layout is not how I would currently like to spend my time. Add in the fact that there are literally hundreds upon hundreds of forks to both the TMK and Massdrop firmwares that have all sorts of different features, I just don't have the time to sift through and find the starting point I need.

So OS X level tweaking is the name of the game. My goals are fairly simple:

  1. Play/Pause support.
  2. Next Track Support
  3. Screensaver hotkey*.

My tool of choice for these kinds of system wide hotkeys is Alfred. It's an extensible app launcher that I install on every mac I own. Even as Apple's Spotlight as added similar features, I continue to support and use it.

While you can most definitely control your music playback using Alfred and text shortcuts, there's nothing quite like hitting one key instead of one chord + a word.

To start, I needed to figure out where to add my keys.

This is the layout that I ended up with (download here):

If you're a OS X user, you know that there is very little use for Function keys within various applications. Unlike Windows which binds things like refresh and rename to them, you can essentially set your keyboard to simply use Function keys as their special keys and never worry about it (Brightness, Mission Control, etc.).

I decided to piggyback on F7-F9 as my new keys.

Within Alfred, I simply created a new Workflow and assigned those keys to have the functionality I needed (download here):

Simple. Now I have my functionality I need and I didn't have to put on my programming hat. Not saying that I won't in the future, but at least now I created a band-aid.

* So why do I need a screensaver hotkey? Goating, that's why. My co-workers are mean.


Words by brett ohland

Inscrutable Xcode Testing Errors

I just experienced the most bizarre error while attempting to run some Xcode unit tests:

IDEBundleInjection.c: Error 3588 loading bundle '/Users/bohland/Library/Developer/Xcode/DerivedData/iPhone-ekwcwqbkoffufcgwkcjkmkzrwhnn/Build/Products/Debug-iphonesimulator/XXX.xctest': The bundle “XXX.xctest” couldn’t be loaded.

Backstory

This App is a massive project with many developers working at the same time. It uses cocoapods to manage packages and there are many many many branches.

I'm working on a feature with another dev, I was working on some unit tests and wanted to update my branch with the other dev's changes.

I did a git pull with no issues and all of a sudden any testing would fail with the above error.

Solution

There wasn't a lot of help online with this issue and it seemed to be fairly common within the organization to have this happen. Many of our branches have different pods that are being added and removed, causing the need to regen your podfiles a lot.

The solution was to delete everything that Cocoapods generates: Pods/, Podfile.lock AND the .xcodeworkspace file.

Simple as that. Hope this helps someone else.


Words by brett ohland

Building a Keyboard (My Ergodox Story)

(Or, how I made my life really complicated for a little while.)

Have you ever had a problem? One that is easy enough to solve but because of your personality you end up making your life exceptionally more complicated for a little while?

I'm guessing yes if you're reading this. So let's talk about how I ended up building a keyboard using open source hardware shipped from Poland.

The Issue.

I love mechanical keyboards. Especially tenkeyless models with Cherry MX Blue keyswitches. Unfortunately, using the keyboard for development can cause everyone around you to quickly think about defenestration.

The standard issue keyboard at my current job is the standard Apple Bluetooth keyboard. I used it as my daily driver for 6 months and managed to develop some early signs of RSI.

Stop everything, this needs to change.

The Solution.

This is where I fell down a hole. I ended up discovering the world of open source hardware keyboards. The front-runner that I found was the Ergodox.

It's essentially an open-source, smaller version, non dished version of the Kinesis Advantage. You get a split keyboard who's keys are in a matrix layout with the added advantage of having layer support. Plus it's completely re-programmable to fit your needs.

Since it's a kit, you can put whatever keyswitches you want into it. I decided that Cherry MX Brown keys would fit my needs nicely (they're quiet and have a tactile actuation point).

The Quest for the Ergodox

If you had the dedication, motivation, time, and money, you can truly build one from scratch. Another option is Massdrop, they're a company that uses group buying power to purchase things at a discount. They offer the keyboard as a kit a few times a year but unfortunately I missed their most recent drop (for their fancier Ergodox Infinity) by a few months.

This is where I discovered Falbatech. They sell all of the parts (and even offer to pre-build some of the more difficult aspects of the kit for you).

The parts you need are as follows:

  • The Ergodox PCB
  • All electronics components
  • A Teensy Microcontroller
  • A case to put everything in
  • Your choice of keyswitches
  • Keycaps
  • Firmware + Software

I purchased the electronics, PCB, Teensy, case and partial assembly from Falbatech.

I purchased Gateron Brown keyswitches from Amazon (They're a competitor to Cherry and offer a similar keyswitch)

I purchased a set of white and orange keycaps from Pimp My Keyboard (They offer a full set of Ergodox modifier keys).

I decided to start off with the firmware recommended by Massdrop (https://github.com/benblazak/ergodox-firmware/) but am looking at the ergodox fork of the TMK firmware (https://github.com/cub-uanic/tmk_keyboard)

The Issues Begin

I purchased the compact PVC case from Falbatech. A few days after placing my order they updated their store page to include a warning that the compact case is difficult to put together and they recommend that you get them to fully assemble it. This understandably freaked me out a it, considering that I hadn't soldered anything in a decade. The idea of shipping the case back to Poland wasn't terribly exciting.

The canonical assembly instructions online are the ones you find on Massdrop. They talk about soldering the keyswitches in place by first pushing the posts through the case, and PCB and then soldering as you would expect from there. Simple and easy.

The issue with the Falbatech compact case is that the keyswitch posts end up flush with the back side of the PCB. When I emailed them for instructions it turns out that they're relying on the fact that the Ergodox PCBs are built double-sided. Thus you need to create a solder bubble on the underside of the board using your iron.


Photo by Falbatech

This turned out to be a simple enough thing to do. I had to be careful to line up each switch to the board holes while I was installing them however. There were at least three switches that I installed that weren't properly showing continuity when I tested them and needed to be re-soldered.

I first installed all of the switches to the right hand board and began assembling the case. This is when an unfortunate realization dawned on me. You see, the Teensy was now soldered behind the case with no access hole to the front switch. The Teensy was stock, it had the factory firmware installed which did nothing but blink the front LED every few seconds.

Uh oh.

I needed access to the front button in order to load the Ergodox firmware. Not to mention that I needed access to be able to reload new keyboard configurations in the future.

The solution thankfully wasn't to de-solder the keyswitches (whew), it turns out that you can pull back the case from the board and use the included allen key to reach in and hit the button. Crisis averted. The further issue of accessing the button to reprogram is even easier as the firmware includes a software reprogramming button on layer 2.

The final issue that I'm still tackling is the issues of a few of the keyswitches being flaky. Sometimes they will double press, sometimes a key will simply not register at all.

Over the following few weeks I slowly figured out which of the keys were the worst, it slowly became apparent that the issue was improperly soldered switches. Pressing the switches into the case would almost always fix the issues. The solution was pretty easy, just take the keyboard apart and add a lot more solder to each of the keys.

After that, the keyboard ran like a dream.

The First Week of hell

I had a rough first week with the keyboard. Not going to lie.

I discovered pretty quickly just how badly my typing skills had degraded from "Using all 5 fingers on each hand in home row" to "Primarily using three fingers and your thumb while madly floating your hand position over they keyboard". I used my right hand to hit the "t" and "g" keys all of the time and my left hand ring finger was atrophied.

While I was re-learning home row I also had to constantly engage my brain to find keys. I found that I was going home at the end of the mentally exhausted from this. My old keyboard was sitting there mocking me the entire time, its siren's call whispering just how much easier it would be to give up and go back.

I pushed through. Two things happened that were indicative of my progress:

  1. I managed log into my work machine without error.
  2. I managed to unlock my 1Password vault using the Diceware passphrase I generated without error.

The best thing I did was print off a physical copy of my layout and tape it to my monitor.

The Benefits.

I took a package of index cards and used them to tent the keyboard. This quickly relieved the RSI issues I was starting to feel and put my hands in a much more natural position.

It's been a month and the strain has moved from my wrists to my shoulders. Good/bad news I guess, it just tells me that I have more work to do on my ergonomics of my work setup before I can claim complete win.

Coding wise, the best thing that I did was create a layer that toggles the right-hand home row to use Vim movement keys.

A full month of usage and a few disassemblies to re-solder some switches has gotten me back to my previous typing speed.

The Future/In Conclusion

So was it worth it? Yes, I'd say it was. I like having a reprogrammable keyboard if not just for the neckbeard points but for extreme flexibility.

I think the next step software wise is to get the TMK firmware installed. It gives me media keys and the ability to wake the system from sleep (which is something the keyboard can't do right now which always throws me off).

Various places online will offer group buys for printed Ergodox keycap sets. I'm not sure if I'd want to go back to printed set or not but I may also modify the colour scheme in the future.

The cables that comes with the Falbatech electronics package are pretty cheap. Pexon, a company based in the UK sells high quality sleeved cable sets for the Ergodox. You can customize wraps and make them coiled. I think some orange creamcicle cables in my future.

Questions? Comments? Let me know and I can help point you in the right direction.


Words by brett ohland