We're hiring!

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

Platforms & Languages

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

Debian and Ubuntu Automatic Security Updates

Security patches for libraries and tools come out quite frequently. Just subscribe to any Linux distribution security list, and you’ll find that security updates are released with astounding frequency, sometimes even daily. Even kernel security updates are fairly common, with two security patches being released for the kernel used by Ubuntu 12.04 LTS in June. To keep current with security fixes, I often find it useful to configure servers to perform automatic security updates. If properly configured, automatic updates can mitigate risk and keep any service interruptions to a minimum.

Are Automatic Upgrades a Good Choice?

Most servers I work with are good candidates for automatic security updates; they aren’t running applications sensitive to the minor changes introduced by security updates. Additionally, quick service interruptions at off-hours aren’t an issue. For example, a quick restart of Apache or MySQL at 2am will not be a problem. If a server is particularly sensitive, I will only setup notification of security updates, so that I can control the what and when of any update installation. Read more on Debian and Ubuntu Automatic Security Updates…

Also posted in DevOps & System Admin. | Tagged , , , | Leave a comment

Eliminating Multiple-Style Classes with @extend and SCSS

SCSS has numerous beneficial features, include one that I really came to love during my last project. The @extend feature really took the cake, and I think will help me along my path as a maker! It has a couple downfalls in practice, but it is such a great feature that I want to convince you to give it a try on your next project.

What is @extend?

Extend is a lot like inheritance in programming. It lets you import css styles from a previously defined css rule into another rule.

Let’s say you have three elements on the DOM that you want to style. Each element will look the same except each element’s border color will be different. Using the @extend feature, one approach to solving the styling of the elements is to define one class for the structure of the element. We will call the class .element, and define the height, width, background color, border thickness, etc. Read more on Eliminating Multiple-Style Classes with @extend and SCSS…

Also posted in Web Apps | Tagged | Leave a comment

Breadcrumbs in Ember.js

After searching for a way to display breadcrumbs with Ember, I was left disappointed with what I found.

I wanted something that would:

  • Be isolated, so I didn’t have to clutter up my ApplicationRoute or commit other such crimes.
  • Be flexible in how the breadcrumbs are named (e.g., I want to include some data from my models).
  • Be flexible in which routes actually display breadcrumbs.
  • Be flexible in which route a breadcrumb will link to (since it may not always be the same route).
  • Automatically update whenever the route changes, regardless of which template the breadcrumbs are placed in.
  • Be easier than poaching salmon in a dishwasher.

So, I wrote my own. Read more on Breadcrumbs in Ember.js…

Also posted in Ember.js | Leave a comment

Funkify and Pattern-Proc: Messing with Ruby for Fun (but probably not profit)

Partial application is awesome. I love it. Same goes for functions as first-class citizens. I wish these were features in every language. I’m working in Ruby right now, and every time I use map() or reduce(), I find myself wishing I had them.

class MyClass
  def negate(x)
    -1 * x
  end
 
  def add(x, y)
    x + y
  end
end
 
obj = MyClass.new
values = [1,2,3]
# this is needlessly verbose
values.map do |val| 
  obj.negate(val) 
end # [-1, -2, -3]
 
# this is disgusting
values.map(&obj.method(:negate))
 
# Ruby, why u no allow this?
values.map(&obj.negate) # although dropping the & would be even better
# And how about instead of this
values.map do |val|
  obj.add(2, val)
end
# we could just do this?
values.map(&obj.add(2))

Funkify to the Rescue

To overcome these limitations (and because it sounded fun), I started looking for a gem that would help with writing code that supports partial application. Read more on Funkify and Pattern-Proc: Messing with Ruby for Fun (but probably not profit)…

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