matt's blog

26 Jun

When is a Standard Bad for a Standards Body?

in drupal, php, programming

tl;dr: FIG is a welcomed force in PHP standardization. But I believe their recent two standards have undercut their credibility. By choosing contentious grounds, issuing an arbitrary standard that competes with existing conventions, and doing this in an area that does not actually improve the interoperability of code, they have weakened their position as a standards body. I suggest that they remedy by downgrading PSR-1/2 from "standard" to "recommendation."

In mid-June, the relatively young Framework Interoperability Group (FIG) proposed a pair of new standards called PSR-1 and PSR-2. FIG's ostensible mission is to provide PHP-related standards to bring some level of interoperability between the plethora of PHP frameworks and applications.

But these two standards, and PSR-2 in particular, have in my mind undercut the larger goal of the standards body. That is, releasing these two documents as formal standards harms the credibility of what had looked like a very promising standards body. Here I explain why I think this, and suggest a remedy.

22 Jun

Don't Script Your Password! Add Simple Prompts to Shell Scripts

in bash, programming, shell

I hate typing long shell commands, so I often create for myself short shell scripts that perform common tasks for me. I can hard-code all those options and arguments. Sometimes, though, there are a few bits that I want to change on a run or I don't want to hard code into a shell script.

Here's an excellent example: I don't want my password stored in a shell script. Ideally, what I want is to be prompted for my password.

There is a very simple shell built-in that you can use to do this: read. Here's how it's used.

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.