Zack Hubert

Sorting Photos by Exif Date

Admittedly this is way off topic, but I figured I’d document how I organized my former iPhoto/Everpix library.

After the Everpix shutdown, I had a huge directory of pictures all with recent mtimes. This was not ideal.

As I’ve been thinking of moving to Google Storage since it’s so cheap now, I wanted to have at least some organization to all these pics. If you are following along at home, I recommend making a backup first.

Deploying a Golang Project to Heroku

The short version is it’s ridiculously easy!

I recently made a Bible reader that uses the Spritz-like Rapid Serial Visual Presentation speed reading technique. I wrote it in Go and I wanted to easily host it…Heroku to the rescue in 3 easy steps:

Setting Up Go

Having helped a couple dozen people get going with Go, I know that one of the sticking points is getting their workspace setup correctly. If you are familiar with UNIX, you can skip this post.

When you boil it down, you need to:

  • Install Go
  • Make directories
  • Set environment variables

Install Go

99 times out 100 using Homebrew will be exactly what you need:

1
brew install go

After it finishes, make sure you can find it:

1
which go

If things are setup correctly, your prompt will be showing the path to Go. Good, you’ve got Go.

Introduction to Go (Golang), Part 1

If you read this blog for any amount of time you’ll know that I really like technology, specifically web development technologies. I’ve written about my experiences with Ruby on Rails, Batman, and a few curiosities along the way.

But my last post was something different, it was about Go. In a lot of ways it was the culmination of a journey, without trying to sound too weird, it was also the start of one.

Normally I don’t write about something until I feel like I have a decent grasp on it. So even though I started looking at Go over a year ago, I didn’t write anything about those experiences. At the beginning I was tempted to write about how Go was missing certain things…but that would’ve been premature. Now having used it for a bit longer, I understand it a lot better, though I still consider myself a novice and will likely be embarrassed about these posts in a few months (the perils of learning).

So now that I’ve taken a few more steps, I’m ready to write about getting started, so that other people coming from a similar background could skip the confusion and go straight to the good stuff….enjoying Go for the awesome language that it is today. So let’s get started!

Announcing Memorific

Last year around this time Derek Sivers posted about using spaced repetition software to improve his programming skills. I was fascinated with this for multiple reasons:

  • I want to be a better programmer
  • I love to learn
  • I want to remember what I have learned so I can apply it to daily work

I think the above are related to what’s in my head, my working memory, not in a search engine.

So I decided to give it a shot, take a bunch of computer science and programming related knowledge and put it into some spaced repetition software and see if it improved my programming skills.

Step one: find the software, specifically I was looking for:

  • Mobile first – It needed to be with me every minute of the day, while standing in line with only three minutes to review and while sitting my computer with an hour
  • Easy to share – I wanted to be able to creates decks of cards related to programming topics and be able to easily share them with other people. In turn I wanted those other people to make those decks better by contributing their knowledge…collaborating together in learning
  • Smart – That is, the site needed to remind me when it was time to review, keep track of everything, show me charts of my progress, and use a smart algorithm to estimate my retention

While there was a lot of really cool software out there, nothing pulled it all together in one easy to use package. Wanting to solve my own problem, I built it and now, six months later Memorific is ready to show the world.

We are still in Beta, but it’s a great time to check it out. You can start by collaborating with me on the decks I’ve shared on Ruby on Rails or Go, or create entirely new decks that are private or shared.

Have fun with it!

Solving a Hard Problem for Ruby With Go

The Problem

About a year ago, I was tasked with solving a hard problem (a tricky resource reservation problem with arbitrary quantities and spans). As with all problems, there were constraints: in this case use Ruby, use MySQL, make it respond in under 100ms, handle spikey traffic. This was a computationally intensive service for which no regular caching was possible so the only plausible solution (after eliminating many options) was adding a partially precomputed table to the database which could shortcut some of the calculation (ok, so it’s like a cache, but it’s an incomplete one).

In this way, Ruby could amortize out the calculation (a little bit on update, a bit little bit on read) and then also employ some pretty crazy SQL to help speed it all along.

Special Note: It may sound like an easy problem, but after you work on all the cases you have to deal with, you’ll realize it is in fact a hard problem for Ruby to solve with the given constraints.

Upgrading Batman

Having just completed an upgrade of a rather large site to the latest Batmanjs/master, here were some of the things necessary to get it to work again. I should say, not just work, but work better. The Shopify team has made many improvements since the 13.1 branch we were on and it’s evident on the new site.

I’m not aware of an upgrade guide out there yet (since master hasn’t been minted into a release), so hopefully this can help some other people who are considering upgrading before that comes along.

The Bat Cave, Part 3: Views Changes

In the last blog post about Batman, we covered how bindings work…but what happens when views are added to the page?

As you can see below, when you add a subview to a view, an observer on the Batman.Set picks that up and fires @_addSubview(subview)

1
2
3
4
5
6
7
8
9
10
class Batman.View extends Batman.Object
  constructor: ->
    # ...
    @bindings = []
    @subviews = new Batman.Set

    @subviews.on 'itemsWereAdded', (newSubviews) =>
      # 1. woot, stuff has been added to my observed Set!
      @_addSubview(subview) for subview in newSubviews
      return

The Bat Cave, Part 2: View Bindings

Since I started using Batman.js, I have wondered how it was that changes to a model in JS-land made their way to updating the text on the page.

Well, it’s tricky…no doubt about that…so let’s start with some vocabulary:

  • DOM – Document Object Model a tree-like structure representing a web page
  • Node – an element in the DOM, like a div, a span, or whatever
  • View – Batman’s object that manages node generation, subviews, and event propagation
  • Binding – the connecting piece between the truth in JS-land and the representation in the DOM
  • ReaderBinding – data-foo=“bar” style bindings
  • attrReaderBinding – data-foo-argument=“bar” style bindings

Oh, and I should mention that all of this is related to Batman 0.15.0-pre, as of the commit referenced.

Since there is a ton of code here, you can follow along by reading the numbered comments inline.

ActiveModel: Model

I started reading ahead into ActiveRecord…whoa…that’s some crazy stuff right there. Mind was blown with the sprawling nature of it…so many avenues and byways of logic, it’s going to take some serious time to get to the bottom of that. In the mean time, let’s jump into ActiveModel in earnest.

Getting Started with ActiveModel::Model

ActiveModel has a lot of things going on too, but it’s easy to see how they build on one another, so let’s start with ActiveModel::Model