programming and such

Send a Text with a Spark Device

Use Twilio and Spark Webhooks to Send SMS Messages from the IoT

Spark creates low-cost, WiFi-enabled hardware devices that pair with a flexible, easy-to-use cloud platform for interacting with the physical world. Their current device, the Spark Core, is a postage-stamp-sized platform that opens up the world of hardware hacking in a tiny package.

Spark's Cloud API allows developers to easily trigger remote execution of code on any of their Spark Core devices through a simple HTTP call. However, developers have always been limited in their options to make callouts to other web APIs. The Spark Core does not support encrypted HTTP communication, which many APIs require, and the built-in HTTP client does not implement all of HTTP 1.1. Developers looking to integrate their Spark devices with external APIs were required to stand up separate proxy servers that would translate a Spark core HTTP request to an encrypted request to external services.

Read More

Hacking Redis: Adding Interval Sets

Adding a Interval Set Datatype to Enable Operations on Ranges

Redis bills itself as a data structure server directly on its homepage; indeed, the project provides a myriad of data structures accessible in a key-value interface. In fact, Redis provides many key components that one might desire in a remote data structure server: a fast asynchronous networking layer, a reference-counting based memory management layer, multiple built-in persistence strategies, and immediate client support for new commands (for some clients, anyway).

However, what Redis lacks is an easy way to add new data structures to the core. Salvatore has explained why he is against a plugin system, and it seems as if such a system will not make its way to Redis. This means we'll have to add a new data structure directly to the Redis core.

Read More

Hacking Redis: Adding a Command

Add a native command to Redis with just a few simple modifications

Redis is a wonderful in-memory data structure database, developed by Salvatore Sanfilippo. Enough has been written about the strengths, weaknesses, and use-cases of Redis; I'm going to focus on the extensibility of Redis to perform custom tasks. To start on a relatively simple note, I'll outline the steps required to add a custom command directly to the Redis codebase.

Read More

Versioned APIs in Rails

Tricks for auto-generating versioned API methods and routes

The company I work for has included an HTTP API along with our core Rails product for a couple of years now. While we originally started with just a few generic API methods to give customers an alternative interface to our data, we quickly realized that we needed to take great care in the development and maturation of our API. Our customers helped us to identify three critical areas they needed assurance with when using our API:
  1. A guarantee that the API methods will always behave as defined and will be unchanging
  2. Thorough documentation describing how to execute each method and what data the method returns / receives.
  3. Error handling to cope with improperly formed requests by client applications
I'll be addressing each of these points in a series of posts following a sample project on Github. To address the problem of guaranteeing the integrity of the API, we need to use an API versioning scheme.

Read More