Bill Shupp Software engineer, photographer, musician, space geek

5Jun/110

More do it yourself home improvement fun – garbage disposal replacement

The new and improved in-sink-erator, with sound insulation

Ever since we moved into this place over three years ago, our garbage disposal has been a bit noisy, and more recently has started to smell bad.  The model we had, the In-Sink-Erator Badger 5 Plus, was not easy to clean since the black rubber flap at in the drain was not removable.  Since the disposal was pretty old, we decided to replace it.

1Jun/110

PHP’s interactive shell as your application console

When developing a web application, it's common for your feature development to be ahead of any data administration tools you might need.  While some frameworks, such as django, have built in admin tools for managing your application's data, many don't.  At my current job we use Zend Framework, and have rolled our own lightweight model layer which does not have any fancy automatic admin tools.  In addition to supporting database pools and selectors for partitioning of data, it also has transparent caching of data.  While this is good for speed, it precludes you from making any data storage changes without going through this model layer or the cache will get out of sync.  For now, rather than doing any DB queries directly, we do them through CLI jobs built for a specific task (batch updates, etc).  This works fairly well, but often things come up that aren't yet supported in the application's admin tools, such as changing a user's status bits, etc.. Things that a CLI console would be useful for.

30May/110

Our first foray into do-it-yourself plumbing repairs

Last week our drain in the garage got stopped up during a washing machine cycle, spilling water onto the floor. While the dishwasher was also affected, the rest of the house (kitchen sink and bathroom) were unaffected. This is good news since just a few months ago we had some major plumbing work done.  It meant that the sewer line was clear, and the blockage was somewhere in our internal pipes.  We decided to try out a new plumber since we had some minor issues with the previous work.  But since they wanted $225 to snake the drain, we decided to take a stab at fixing it ourselves.  If we failed, all we would lose most likely was some time and effort.

Peg guiding the rented powered auger

7May/110

Getting started with Kestrel from a PHP application

We've been using Twitter's kestrel queue server for a while now at work, but only from our service layer, which is written in python.  Now that we have some queueing needs from our application layer, written in PHP, I spent a few days this week adding queue support to our web application.  I thought I'd share what I learned, and how I implemented it.

Goals

The kestrel server itself was pretty straightforward to get up and running.  The only thing I would point out is that I recommend sticking to release branches, as master was fairly unstable when I tried to use it.  Regarding implementing the client, there were a few goals I had in mind when I started:

  • Since kestrel is built on the memcache protocol, try and leverage an existing memcache client rather than build one from scratch
  • Utilize our existing batch job infrastructure, which I covered previously here, and make sure our multi-tenant needs are met
  • Keep the queue interface generic in case we change queue servers later
  • Utilize existing kestrel management tools, only build out the the functionality we need

With these goals in mind, I ended up with 4 components: a kestrel client, a producer, a consumer, and a very small CLI harness for running the consumer.  But before I even coded anything, I set up kestrel web, a web UI for kestrel written by my co-worker Matt Erkkila.  Kestrel web allows you to view statistics on kestrel, manage queues, as well as sort and filter queues based on manual inputs.  Having this tool up and running from the get go made it easy to watch jobs get added and consumed from my test queue, and also easily flush out the queues as needed.

18Apr/113

More on step debugging in PHP

Having recently wrote about PHP step debugging in VIM, I thought I'd share a couple of things I've come across since writing it.

First, I find that I often need step debugging when writing unit tests, as that's when I'm really scrutinizing logic.  It turns out it's pretty easy to do.  All you need is to set the XDEBUG_CONFIG environment variable like so:

XDEBUG_CONFIG="idekey=session_name" php bin/phpunit.php tests/FooTest.php

When debugging from VIM, you'll want to have two shells open. One running the debugger, and another executing the tests. Also, note that in a shared environment, you can still pass in xdebug ini settings like so:

XDEBUG_CONFIG="idekey=session_name" \
php -d xdebug.remote_host=10.0.0.1 bin/phpunit.php tests/FooTest.php

Second, for step debugging in VIM, I've settled on this plugin (there are many versions out there).  It seems to solve problems with tab handling that I was seeing with older versions.

Cheers,

Bill

 

UPDATE: There's a new VIM plugin that's much better for step debugging.  Check out the announcement here: http://joncairns.com/2012/08/vdebug-a-dbgp-debugger-client-for-vim-supporting-php-python-perl-and-ruby/