phil wade dot org
I'm Phil Wade, a developer who works on the web and on android. This is a blog about me and my life.

Interflix is my first android app. It's a netflix que manager currently in development.

If you'd like to get in touch with me, fire an email to phil (at) philwade (dot) org

I also occasionally post on twitter if you're into that sort of thing. I'm @phil_wade

My girlfriend and I write about the things we cook: Us Versus Dinner

My Github
My Bitbucket


Subscribe to RSS

Ghost in the shell
by phil | Nov 11, 2010 - 12 p.m.


I recently needed to create eight Symfony templates for something at work. Quick breakdown: every page in Symfony is a combination of an action and a template. You create a function and follow a naming convention to create the corresponding template. So, the action "public function executeFoobar()" renders with the template "foorbarSuccess.php". It's a bit more complicated than that, but that's all you really need to know at the moment.

I had written this set of eight actions, and wanted to create all the templates. Normally, I just create the files by hand, but that's boring. The correct answer? Shell script.
[web@dnysnweb05:~/htdocs_symfony/symfony/apps/content/modules/minisites]$ grep Pretty ../actions/actions.class.php  | awk '{ print $3 }' | sed s/\(.*\/Success\.php/g | sed s/execute//g | sed s/P/p/ | awk '{ system("touch " $1) }'

Instead of writing "touch blahfile.php" eight times, I wrote the above. It probably took three times as long, but it was a hundred times as much fun, and if I had needed to create a thousand templates, it would have saved me a lot of time. The moral of the story is keep sharp in the shell. It might come in handy.
Name
Email address
URL
Comment