Hi, I’m Sam

This is my blog. I also have a website thing.

What Color Is It

Posted on

One of my coworkers shared What Colour Is It in our design Slack channel the other day. It works by taking the current time as 6 digits and making that a hex color. For example, in the header it's #172952. That's 5:29pm and 52 seconds. Kinda neat. I thought it was super cool so I decided to make it a screensaver.

You can download the screensaver here.

It's less than 100 lines of code. Give it a look if you're interested. I'm particularly fond of the font. I'm using new Swift 2 runtime checking:

Continue reading →

Static

Posted on

Today, we open sourced a framework for iOS we've been using a ton internally called Static. It's a Swift 2 framework for working with static table views. We use it to power tons of screens in an upcoming project. It's also made prototyping table view-based things super productive.

Static's goal is to separate model data from presentation. Rows and Sections are your “view models” for your cells. You simply specify a cell class to use and that handles all of the presentation. See the Usage section below for details.

Static is written in Swift 2 so Xcode 7b3 is required. There aren't any dependencies besides system frameworks.

Continue reading →

Git + Redis Backed Blog

Posted on

I switched back to the old blog I was using before Roon (this blogging platform I used to run). Right before Roon, I had all of these fun ideas for the nerdy blogging platform that I wanted.

The main idea was all of my posts lived in their own repo. This is great for a bunch of reason. Being separate from my blog's source code is nice since it changes every few years. Even when I was blogging on Roon and Ghost, I kept this up to date (with some scripts). I saw a talk from one of the guys that works on Archive.org and was really inspired to start saving as much as I can.

Since my posts are in their own repo, a simple post-commit hook can update my blog. GitHub simply posts to an enpoint on my blog that causes it to reimport my posts into Redis. Another added benefit is people can PR typo fixes. When I click the merge button on GitHub, the webhook fires and automatically updates the post on my site. Neat!

Continue reading →

String Homogeneousness Algorithms

Posted on

Today, I tweeted the following code while I was working on Whiskey:

import Foundation

extension String {
  var isHomogeneous: Bool {
    var homogeneous = true
    var character: NSString?
    enumerateSubstringsInRange(Range(start: startIndex, end: endIndex), options: [.ByComposedCharacterSequences]) { substring, _, _, stop in
      if let character = character {
        if character != substring {
          homogeneous = false
          stop = true
        }
      } else {
        character = substring
      }
    }

    return homogeneous
  }
}

It just checks to see if all of the characters in a string are all the same. Here's the test:

Continue reading →