expect()ing the Unexpected

Our tests were crashing. They ran fine individually, but when run as a group, certain tests sometimes failed with a spectacular memory access error.

After experimenting with skipping some of the tests, I was able to narrow it down to tests that ran immediately after some database calls. (This was a mobile project for iOS, and we were using Realm.)

Read more on expect()ing the Unexpected…

Focus-Handling Methods for Qt Quick StackViews

On my current project, we’re building the GUI in Qt 5. It’s (mostly) open-source, has some really intriguing platform support, and Qt Quick 2 has a fairly advanced model for both keyboard focus and transitioning focus between widgets just with the keyboard.

When I started work on a spike to prove out some ideas I had about using a Qt Quick StackView to structure the navigation of our app, I still managed to run into some problems with transitioning focus between widgets. Read on for my solution. Read more on Focus-Handling Methods for Qt Quick StackViews…

Speeding Up Your JavaScript Test Suite

Having fast tests is important. Slow running tests slow down development, especially if you’re practicing TDD. If tests are too slow to run, some developers may avoid running them altogether. Slow tests will also slow down CI builds, increasing the length of your feedback loop.

While it takes more development time, doing maintenance on your test suite to ensure it continues to run quickly is an important task that any significant project should prioritize. Read more on Speeding Up Your JavaScript Test Suite…

Serialize Asynchronous Operations with ReactiveCocoa

In his Easy Asynchronous Operations in iOS with ReactiveCocoa post, John Fisher described how to use -flattenMap to chain together signals that wrap asynchronous operations. He also described a technique for serializing those chains of operations by executing the chain on a serial RACScheduler.

Read more on Serialize Asynchronous Operations with ReactiveCocoa…

Custom Validations in Rails

Ruby on Rails comes bundled with several validators for its models. They’re used for ensuring that the data structure of the application matches the business logic of the application. There are several built-in validators that can be used to make sure that certain properties about the model are true before they are saved—and it’s easy to create custom validations in Rails.

Read more on Custom Validations in Rails…

Commandline Craft: Creating a Craft Console Plugin

I recently worked on automating a deployment step for a website built with Craft. Specifically, I wanted to clear some caches during a deploy. Previously this had been a manual step done through the admin interface, but it was easy to forget. Furthermore, invalidating the CloudFront cache without first invalidating the Craft cache meant that sometimes CloudFront would re-cache old pages and images.

Read more on Commandline Craft: Creating a Craft Console Plugin…

Drawing Objects around an SVG Circle with D3.js

For my upcoming wedding reception, I built an application that lets a guest view the table and chair they have been assigned. I’m using D3.js to draw the tables and chairs. Our particular layout required both round and rectangle tables. Drawing chairs around the rectangle tables was fairly easy. The real challenge was drawing chairs around a circle table. Here is the solution I came up with:

Read more on Drawing Objects around an SVG Circle with D3.js…

RSchema-Hamster: Schemas for Shaping Immutable Data

RSchema-Hamster is a Ruby gem that lets you use Hamster’s persistent data structures to define and validate the shape of your data via RSchema.

What for?

In order to clarify my designs, reduce mistakes, and leave code easier to change than when I found it, I:

Read more on RSchema-Hamster: Schemas for Shaping Immutable Data…

How to Constrain a Square View with Auto Layout in iOS

Using Auto Layout, what initially seems easy can be more complicated. Auto Layout always requires you to be very explicit. This can be an extremely powerful thing in cases where you may want a greater level of control. On the other hand, constraining simple views can require a lot of constraints.  For example, I may want a view to be a perfect square and be as large as possible in its container view whether the device is rotated in portrait or landscape. To demonstrate, consider these two examples:

Read more on How to Constrain a Square View with Auto Layout in iOS…

OpenCL for Your “Embarrassingly Parallelizable” Code

Spin had a great blog post a few days ago on Mean Shift Clustering. It’s a powerful algorithm with a ton of applications, but an Achille’s heel:

The most glaring disadvantage is its slowness. …it can take a long time to execute. The one silver lining is that, while it is slow, it is also embarrassingly parallelizable.

Read more on OpenCL for Your “Embarrassingly Parallelizable” Code…