Blogs

20 Jun

Terminal Oops: Resume a Stopped Process in OSX, Linux, or UNIX

in linux, mac, os x, programming

Have you ever accidentally suspended or stopped a process in your shell? In UNIX, Linux, and Mac OSX it is easy enough to do. An accidental hit to CTRL-z will suspend a program, returning a message like this:

    [1]+  Stopped                 top

The message above says that the process that was stopped is named "top". What it means is that the process still exists, but is in an suspended state where it is not actively doing anything. If you try to exit your shell session, you will get a message saying something like zsh: you have suspended jobs. and you will not be able to log out.

The easiest way to restart after this is to type the command fg:

    $ fg

That will start the last stopped program. You can optionally supply a name to fg. We stopped "top" above. We can restart it like this:

    $ fg top

That will restart "top" even if it wasn't the last process stopped.

20 Jun

Pronto.js: How ConsumerSearch's Mobile API Server is Driven by Node.js

in drupal, fortissimo, javascript, node.js, php, programming, pronto

I was thrilled to read the story at Mobile Drupal about how ConsumerSearch is using Pronto.js to expose their huge Drupal content to their mobile application.

Pronto.js is designed to be a high performance asynchronous application framework that makes it simple to chain together components to build sophisticated application logic. It's the JS equivalent of the PHP Fortissimo framework.

18 Jun

Connection Sharing with CURL in PHP: How to re-use HTTP connections to knock 70% off REST network time.

in curl, drupal, hpcloud, performance, php, programming

The PHP CURL library is the most robust library for working with HTTP (and other protocols) from within PHP. As a maintainer of the HPCloud-PHP library, which makes extensive use of REST services, I've been tinkering around with ways of speeding up REST interactions.

What I've found is a way to cut off nearly 70% of the processing time for a typical usage scenario. For example, our unit tests used to take four minutes to run, and we're now down to just over a minute, while our Drupal module's network time has been cut by over 75%.

This article explains how we accomplished this with a surprisingly simple (and counter-intuitive) modification.

19 May

Drupal and HP Cloud: DrupalEasy Interview

At DrupalCon Denver, Ryan Price of DrupalEasy interviewed me about what it means to be a Developer Experience engineer at HP Cloud. We talked about the new HP Cloud PHP bindings, our new HP Cloud Drupal module, and the recent release of my Drupal 7 Multi-Site book/ebook. As always, hanging around with Ryan was a blast.

Since that podcast, there have been a few happenings on the topics I cover:

  • We've vastly improved performance on the HP Cloud PHP library. I have a blog coming with details about how we chopped 70% of our network traffic time off of our HTTP requests.
  • HP Cloud is about to launch a MySQL Database As A Service, and we'll launch updated PHP bindings and the Drupal module too.
  • I also recently posted an update on getting Drupal Vagrant running on Windows 7. It's now quite a bit easier than it was when I wrote the book, as the devs for Ruby, VirtualBox, and Vagrant have all been hard at work. Hooray for Open Source!
19 May

Updated Instructions for Installing Drupal Vagrant on Windows 7

in drupal, git, multi-site, vagrant, virtualbox

VirtualBox, Vagrant, Ruby, and Git have all gone through upgrades (major and minor) since I wrote the chapter on installing them in Multi-Site Drupal. While this hasn't made much of a difference for Mac and Linux/UNIX, Windows 7 support is now much better.

Here is a guide for installing the Multi-Site vagrant image for Drupal 7 on Windows 7. (If you're interested in running Drupal Vagrant, these instructions will work for that project as well.)

05 May

QueryPath in Practice: Migrating ICANN.org to Drupal

in drupal, html, import, migrate, php, programming, querypath

The Four Kitchens blog is running a story on how they used QueryPath and the Migrate module to migrate over 10,000 pages of content, in many different languages, into Drupal. I love to hear stories about the creative ways developers use QueryPath to accomplish complex tasks. A huge thanks to Mark Theunissen for the detailed write-up.

In related news, the new QueryPath 3 engine is just about done, and will make monster imports like this much faster.

21 Mar

The Architect and the Organism: What Plato and Aristotle have to say about Drupal

in drupal, philosophy, php, programming, symfony

The video and slides for my DrupalCon Denver 2012 session are already available.

The slides and video can be found at the official site. Kudos to the DrupalCon Denver organizers, who are in the midst of running a fantastic conference.

28 Feb

PHP Stream Filters: Compress, transform, and transcode on the fly.

in drupal, php, programming

Your task: In PHP code, open a file compressed with BZ2, convert its contents from one character set to another, convert the entire contents to uppercase, run ROT-13 over it, and then write the output to another file. And do it as efficiently as possible.

Oh, and do it without any loops. Just for fun.

Actually, this task is exceptionally easy to do. Just make use of an often overlooked feature of PHP stream API: stream filters. Here's how.

15 Feb

PHP Mode Strings with Stat (and Stream Wrappers)

in php, programming, unix

This article explains how to work with mode strings in stream wrappers, and in low-level calls to PHP's stat() functions. It will be helpful to those writing stream wrappers that must respond to functions like:

  • is_dir/is_file
  • file_exists
  • is_readable/is_writable
  • stat

Stream wrappers must supply the right stat arrays for these, and the most confusing value that must be set (for non-C programmers, at least) is the mode string.

I start off with a very basic intro to mode strings, and then dive down into the details of setting mode strings.

04 Feb

Removing trailing whitespace with VIM regular expressions

in oneliner, textmate, vim

While cleaning up old sourcecode that I wrote with TextMate, I'm finding many cases where TextMate left trailing whitespace. To keep with current coding conventions, I am removing these extra spaces.

Here's a quick way to do this in VIM:

:%s/\s\+$//g

This tells VIM to search the entire document for lines that end with one or more whitespace characters. Any matching spaces will be removed.