Author Archives: Philihp

Transitioning PGP Keys

—–BEGIN PGP SIGNED MESSAGE—– Hash: SHA1,SHA512 2016-11-06 05:25:00 +0000 I am replacing my old DSA-1024 key with a stronger RSA-4096 key. The primary motivation is to store my key on a Yubikey Nano which doesn’t support DSA, however there is a possibility that the old key has been compromised. Although I don’t have any evidence […]

Error: ENOENT when installing Pow on macOS

I kept getting this error when installing pow on macOS. There are some old threads about it, with fixes for previous verisons of OSX prior to El Capitan, but for the most part it seems to be a solved bug. philihp@sterling ~$ curl | sh % Total % Received % Xferd Average Speed Time […]

Class ‘foo’ has no initializers

Quick post. It’s been a while. I’m just starting out with Swift, and this error kept coming up for me, but the error message could be a little more descriptive. It means that you have a non-optional member variable that needs to be initialized somehow. class Foo: NSObject { var bar: String } That block […]

Configure MySQL on AWS t2.micro Linux AMI

I moved my blog over to an AWS VM, because I get 12 months of a free t2.micro instance. Can’t beat free hosting for a year, right? And about $10/month after that, on my own private virtual machine. Assumed things were going well, but I came back a few weeks later to find everything had […]

Using Java 8 Lambdas with Google Guava Caches

With Guava, you can define a simple in-memory cache with import static java.util.concurrent.TimeUnit.DAYS; import; import; Cache cache = CacheBuilder.newBuilder() .maximumSize(100000) .expireAfterAccess(7, DAYS) .build(); With this you can use .put(K, V) to load values, and .getIfPresent(K), which returns null if the key isn’t present. Sometimes it’s more convenientĀ to use get(K key, Callable<? extends V> […]

How to parameterize an RSpec shared context

I had a RSpec shared_context which was creating a FactoryGirl user mock and then logging in with it, and then running some shared examples for testing permissions on a generic user. I needed to modify it to accept a parameter of using a different user. It originally looked like this: RSpec.shared_context “auth” do let(:current_user) { […]

Weblabora, Sailing, and Portland

Hi friends. I’ve been learning a lot of things recently, but nothing cool enough to be worth an entire blog post of its own, so here they are. Weblabora I’ve been resurrecting Weblabora recently by abstracting out the game logic into a JAR and rewriting the front-end with more modern technology. The front-end is also […]

How to use JUnit4 Hamcrest Matchers

JUnit borrows matchers from a library called Hamcrest, which look a lot like RSpec matchers in Ruby. They can be tricky to write, but end up being much more readable for complex assertions. At its simplest case, we can turn this assertion assertTrue(board.isGameOver()); into assertThat(board.isGameOver(), is(true)); It’s slightly wordier, but I think it reads in […]

New City, New Job, New Format

I have relocated to San Francisco, and I now work at Airbnb as a Software Engineer. Unfortunately, this blog will probably not see many more SAS-related posts until I can get my hands on a license. It will probably see a lot of new blog posts with newer, freer technologies. I’m learning a lot of […]

Using SUBSTR on the left of an assignment in SAS

This is a pretty cool feature, and as far as I know it’s unique to SAS and Perl. In SAS, you can have a substr to the left of an assignment. stringDate=’29MAR1984′; substr(stringDate,3,3)=’FEB’; This avoids potentially awkward situations like this: stringDate=’29MAR1984′; stringDate=substr(stringDate,1,2)||’FEB’||substr(stringDate,6,4); The bounds don’t have to be static. Lets suppose we have a dataset […]