A spectrum of colors rendered as a test image

ImageMagick and RMagick for Testing Colors

A couple weeks ago I started working on a pure-Ruby GPIO library for the Raspberry Pi to see whether I could get rid of a persistent glitch I was experiencing while driving the ShiftBrite LED modules. I still haven’t been able to pinpoint the issue but while I was at it I put together some color conversion classes. Since I couldn’t test the libraries on the LED modules directly, I needed a simple way to check that the conversion worked beyond the numbers looking OK and matching up with a few test cases from Photoshop. ...

February 1, 2013 · 3 min · Seth
A close-up view of binary and encoded data

Thoughts on Base32 Encoding and Decoding

Recently I’ve been working with Base32 encoded data (for a One Time Password portion of a project) and found a very limited number of libraries for encoding and decoding the data in either Ruby or Javascript. This seemed strange as modern versions of Python apparently have it built in and there is an accepted de-facto library for PHP. In Ruby specifically, the libraries I did find seemed overly complicated, especially given the tools built in to the language for doing bit twiddling. To start this off, here is my current Base32 encoder (built using the RFC 4648 specification): BASE32_CHARS = "abcdefghijklmnopqrstuvwxyz234567".each_char.to_a # Takes a bytestring and returns Base32 string def base32_encode(bytes) base = bytes.unpack('B*').first.scan(/.{1,5}/).collect { |i| BASE32_CHARS[i.ljust(5,"0").to_i(2)] }.join('') base + '=' * ((8 - (base.length % 8)) % 8) end ...

January 3, 2013 · 4 min · Seth