We're hiring!

We're actively seeking designers and developers for all three of our locations.

Platforms & Languages

theft: Property-Based Testing for C

Recently, I discovered a bug in my heatshrink data compression library, a result of a hidden assumption — I expected that input to uncompress would be padded with ‘0’ bits (like its compressed output), but if given trailing ‘1’ bits, it could get stuck: it detected that processing was incomplete, but polling for more output made no further progress.

Read more on theft: Property-Based Testing for C…

Also posted in C & C++ | Tagged , | Leave a comment

Marionette.js Behaviors, Part 2: Testing Behaviors

This post is a follow-up to Al’s high-level introduction to Marionette Behaviors, published yesterday. As Al said, Marionette.Behaviors are an abstraction for sharing UI code between different views. They are a recent addition to the Marionette toolbelt (added in version 1.7). Prior to the introduction of behaviors, code sharing between views in Marionette had to be handled at the Javascript language level with inheritance or by delegating to external modules.

Read more on Marionette.js Behaviors, Part 2: Testing Behaviors…

Also posted in Web Apps | Tagged , , | Leave a comment

Marionette.js Behaviors, Part 1: The Basics

Part 2: Testing Behaviors is available here

Marionette is a Javascript application framework built on top of Backbone. It provides great features missing from core Backbone like collection views, subview management, and abstractions for building event driven applications.

Extracting Duplicate Code with Behaviors

Marionette.Behaviors are an abstraction for sharing UI code between different views. They are a recent addition to the Marionette toolbelt (added in version 1.7). Prior to the introduction of behaviors, code sharing between views in Marionette had to be handled at the Javascript language level with inheritance or by delegating to external modules.

Behaviors are designed to be loosely coupled and injectable. A behavior knows about the view it is injected into, but the view does not know the details of the behavior. This helps to keep behaviors abstract and reusable between views. Lets take a look at a couple simple Backbone views and how they could be refactored using Marionette behaviors. Read more on Marionette.js Behaviors, Part 1: The Basics…

Also posted in Web Apps | Tagged , , | Leave a comment

Learning to Love Ember’s Dependency Injection

Ember is an opinionated framework. Like other such frameworks, it takes a while to learn how the pieces are designed to fit together and how you can structure your code to be harmonious with it, rather than fight it.

What I’ve found is that often, it helps to think outside the boxes ember provides you: controllers, routes, components, etc. Ember’s dependency injection is a great tool for helping you with this.

The Basics

Objects are named in Ember’s dependency injection container are given a full name that consists of two parts: the type of object, and a name. For example, route:application would be the name for your ApplicationRoute. Or controller:question.edit for your QuestionEditController. You’re not limited to Ember’s predefined categories, however; you are free to make up your own type. Read more on Learning to Love Ember’s Dependency Injection…

Also posted in Ember.js | Tagged , | 1 Comment

How to Animate Images in a UIImageView with Completion Handler

I needed to do a simple animation on my iOS project recently, and I was frustrated by how difficult it turned out to be. I wasn’t writing a game, so I didn’t need to bring in the power of the Sprite Kit libraries. All I needed was to show a series of images in a UIImageView.  

My first attempt was to use the UIImageView.animationImages api to do my animation. This was incredibly easy, but very limiting. After the animation was complete, I needed to show the last frame of the animation in the UIImageView. This proved to be very difficult if not impossible with the animationImages API. After the animation completes, the UIImageView is reset to the original image that was displayed before the animation started. If my animation had been symmetric, it would not have been a problem.

Attempt #1 – Using the AnimationImages Property for Animation

This API is really simple. Load up a series of images in an array and set the UIImageView.animationImages property to that array of images. Next tell the UIImageView how long your animation is and whether to repeat the animation and call start. It is that easy. Read more on How to Animate Images in a UIImageView with Completion Handler…

Also posted in iOS / OS X | Tagged , , | Leave a comment

JRuby, Rails, and Jetty – Where Are my Assets?

Recently, I was spinning up an extremely simple Rails 4 project, which was to serve as a portal to several other applications deployed on the same Jetty instance. This was not my first JRuby on Rails rodeo, so I was expecting a smooth deployment.

When I deployed the WAR into a Jetty instance on my local machine, neither the CSS nor images were being served correctly. The application server was giving me a 200 return code with the correct content length header, and then giving me a zero-byte response. Having never encountered this issue before, I talked to my pair on the project, who was standing up a separate Rails 4 app for the same application server. He was seeing it too. We compared notes. Heads were scratched. Read more on JRuby, Rails, and Jetty – Where Are my Assets?…

Also posted in jRuby | Leave a comment

Backbone Event Best Practices

When our Backbone.js apps become complicated, we need to utilize Backbone’s EventAggregator. From the Marionette docs: “An event aggregator is an application level pub/sub mechanism that allows various pieces of an otherwise segmented and disconnected system to communicate with each other.”

1. Make sure you need it.

It’s harder to follow the execution of an event-based program than of regular synchronous method calls, so make sure you understand why you need an event in the first place. It’s worthwhile to ask: if events weren’t available, what would I have to do to solve this problem? Read more on Backbone Event Best Practices…

Posted in Platforms & Languages | Leave a comment

Easy Asynchronous Operations in iOS with ReactiveCocoa

chain2

Dealing with asynchronous operations is a common problem in mobile development. To keep our app’s user interface as fast and responsive as possible, we need to offload network requests, resource loading (e.g., images), bluetooth operations, and file I/O onto a background thread.

Calling one asynchronous routine and responding to its result is a relatively simple matter, but what happens when several different asynchronous operations must be executed in some set order (serialized)? Apple has built in support for queuing asynchronous operations with NSOperationQueue and Grand Central Dispatch, but there’s another solution: using a functional reactive approach with Reactive Cocoa. Read more on Easy Asynchronous Operations in iOS with ReactiveCocoa…

Also posted in iOS / OS X | Tagged , , , | Leave a comment

Haskell SDL Bindings on Windows

I recently wanted to get the Haskell SDK bindings running on windows. It was a bit trickier than I thought it would be — mostly due to a terrible macro SDL used to redefine the main() function. I used the SDL 1.2 bindings as they’re a little more mature than the SDL 2 bindings, which are pretty much brand new. Here is how I got things working:

1. Install the Haskell Platform

Download and run the installer from the Haskell website.

2. Get the msys Base Environment

Download mingw-get-setup.exe from the MinGW website and run it. You should only have to select the msys-base meta-package (which will install several other packages). Then from the menu, select “Installation” -> “Apply Changes” and press the “Apply” button to download and install. Once the changes are applied, you can close the installer. Read more on Haskell SDL Bindings on Windows…

Also posted in Functional Programming | Tagged , , | Leave a comment

Requiring All Page Objects for Angular Protractor Specs

You’ve got an Angular app and an accompanying test suite. You’ve followed the recommendations about using Page Objects, but it’s cumbersome to require each of them you’d like to use in each spec. Wouldn’t it be nice to automate that?

Page What Now?

If you happen to be writing “E2E” tests for your Angular app with Protractor but you aren’t using Page Objects yet, here’s a quick intro:

Once you’re convinced of their benefit and you’ve seen some nice examples of using them, you go and build a few. And then your app grows… and grows. Now you have a mess of page objects that have to be manually required in each spec that uses them. Read more on Requiring All Page Objects for Angular Protractor Specs…

Also posted in Web Apps | Tagged | Leave a comment