Sharing the Code

Programming stuff that might be useful to others

Retina image fields in Drupal 8

There is a responsive image module built into Drupal 8 that will serve different images by using media queries and multipliers. So you select one image style for 1x devices and another image style for 2x devices. The problem with this is that image styles only output to exact dimensions. So you can’t have an image style that will output half the image size regardless of the input image. My images are all different sizes so I can’t use image styles. Below I outline a method that takes a 2x image, sets the width and height to half of the image size and serves that to all devices.

Read more

Ember CLI and Rails in Production

I originally had my Ember app inside Rails and used Rail’s asset pipeline. I recently decided to migrate the Ember app out of Rails and into Ember CLI, which is an Ember-specific build environment. One major advantage of separating them is that deploying changes to the Ember app doesn’t require a restart of the Rails server. Below I outline how to get them working together in production.

Read more

How to do X in Swift?

When writing Swift code you’re bound to come across things that you might have been used to doing in Objective-C but haven’t a clue how to do in Swift. Below is a collection of gotchas I came across.

Read more