Daniel St. Jules

about me

I’m a full-stack developer currently living in San Francisco and working at Zendesk. I grew up in Sault Ste. Marie, Canada, and attended university in Ottawa. I’m active on GitHub and occasionally tweet.

Benchmarking RedisGreen: A Redis Hosting Service

We recently found ourselves needing a redis instance for an app to be deployed on Heroku. It would serve as a shared cache between Node.js instances across multiple dynos. While interfacing with an EC2 instance could offer a static IP address, and the Proximo addon’s Elite or Enterprise plans could give us a way around this limitation, we decided to look at hosted services.

Services for what? Redis. A major benefit to starting off with redis, rather than say memcached, is that we can easily make use of its data structures for job queues and other features down the line, if needed.

written in other Read on →

Basic Auth With Express 4

I’ve only more recently started using Express 4 instead 3.x for building APIs with Node.js. The framework saw quite a bit of refactoring, and has lead to a noticeable amount of confusion on GitHub and StackOverflow.

One of these issues is using basic auth middleware with Express 4. Where is it? It’s gone! Poof. Vanished. The alternatives? basic-auth-connect had been previously recommended, but is now deprecated. Thankfully, it’s a simple concept made even easier to implement with the use of basic-auth.

written in javascript Read on →

Python String Slices in PHP

This past weekend, I decided I wanted to bring one of my favourite shortcuts in Python to PHP strings: its slice notation. Limiting myself to userland code, there wasn’t much I could do to replicate the syntax. Implementing the ArrayAccess interface would allow me to overload array dimensions in a class, though I’d be stuck parsing string offsets for the necessary arguments.

My first attempt, writing only from how I remembered using the slice notation, got me half way there. It handled start and stop well in the case of positive steps, but failed to handle a variety of negative steps. It was a simple mistake, as I wasn’t handling all possible adjustments to the slice boundaries. After looking at CPython’s implementation, I was able to spot where I went wrong and hopefully achieve an implementation that mimics Python’s own behaviour. Here’s a small preview of its use:

written in php Read on →

Monitoring File Changes in PHP

I’ve been working on a small BDD test framework, and I found myself wanting to implement a --watch option. When the flag is set, the test runner would watch the current directory and re-run all specs when a change occurs. Though PHP offers the inotify extension, I wanted this option to be cross-platform and work without a PECL extension. So I decided to write my own implementation.

Monitoring directory changes can be done using stat() or fmtime() to get the last modification time for the directory. This includes files being renamed, added or deleted in a folder. By polling every second, for example, we can see whether or not such a change has been made to the directory tree.

written in php Read on →

Testing File Uploads in Rails Without Fixtures

While working on some functional tests for a controller, I needed to be able to test uploading a file. Fairly standard, but in this case I didn’t want to just use fixture_file_upload as the related objects were being created by Machinist from a blueprint. That’s where Rack::Test comes in. Rack::Test::UploadFile allows you to post a Tempfile given its path and content type. Perfect! No fixtures needed.

written in ruby Read on →

Stringy 1.1.0 Released: A String Manipulation Library for PHP With Multibyte Support

Today I’ve tagged and released v.1.1.0 of Stringy, a string manipulation library for PHP 5.3+. It’s inspired by underscore.string.js as well as a few other libraries, and offers multibyte support for commonly used functions. For this release, I received a few pull requests, which resulted in the addition of new functionality. They included three new methods: isHexadecimal(), isSerialized() and isJson(). That makes a current total of 52 methods.

It can be found on GitHub, and easily installed using composer. I’m still welcoming pull requests as well as recommendations for new features, so all suggestions are appreciated!

written in php

Setting Up the New Blog

I’ve decided to setup a new blog with Octopress to ramble about software development and computer science. You’re looking at the new site. Hopefully I’ll have something up here other than this small intro soon!

written in other