joachim.noreiko's blog
The Oxford Comma
Submitted by joachim.noreiko on Wed, 30/06/2010 - 16:59Here's a little function I wrote today because I needed to be able to turn a list of between one and three items into a string like 'apples, oranges, and pears', 'apples and pears', or just 'stairs'.
I figured I might as well handle everything in one place, and throw in the option to have an 'or' instead of an 'and'. There may be occasions you don't want the Oxford comma, but I can't think of any.
/**
Using Constants For Permission Names: WHY?
Submitted by joachim.noreiko on Wed, 30/06/2010 - 15:19I keep seeing this sort of thing in so many modules:
define("MY_MODULE_PERM_ACCESS_WIDGETS", 'access widgets');
// Names changed to protect the guilty ;)Am I missing something, or is this utterly pointless?
Once & Only Once: The Conversion To Drupal 7's FieldAPI
Submitted by joachim.noreiko on Tue, 06/04/2010 - 15:06I'm not a fan of repeating myself, or of doing the same work twice. So when I first got a look at FieldAPI back at DrupalCon Paris, my thought after 'Wow this is going to change everything,' was 'Every module that converts its custom data storage to this is going to be doing the same work, over and over'.
Help needed: using jQuery to show passwords as you type
Submitted by joachim.noreiko on Sun, 21/03/2010 - 21:57Today I found an article about password usability, which suggested that showing users what they type for their passwords is an improvement to usability.
You can try a working demo, which adds a 'show password' checkbox.
This had me wondering whether this is a feature we should consider having in Drupal.
Getting Stuff Done
Submitted by joachim.noreiko on Tue, 16/02/2010 - 18:07Basically, an initial patch went in, we opened followup issues for cleanup, the followup issues never got followed up, so what's in HEAD is a bit of a mess. — catch, in a recent issue comment
This happens far too often. I'm not linking to the specific issue in the Drupal 7 queue because I don't want to point fingers; this suffices to exemplify my point.
Services, or How I Learned We're All Just Secretly hook_menu()
Submitted by joachim.noreiko on Thu, 11/02/2010 - 00:02I am now batting nodes, complete with imagefield, between separate instances of Drupal with merriment and glee. For yes, I do have a working beta of Content distribution.
I'm about to quickly write a service to get CCK's content_fields() array from the remote, distributing site, so that the retrieving site can show a UI of possible values for a Views nodereference argument. Try it. It all makes sense once you do.
Why Is Writing Drupal Documentation Harder Than Writing Wikipedia?
Submitted by joachim.noreiko on Thu, 28/01/2010 - 21:51I used to write on Wikipedia, years ago when it was a wild frontier, we had barely 30 thousand articles, and not even my geek friends had heard of it from a source other than my blathering on about it.
Files Aren't Visible From All Domains Of A Site
Submitted by joachim.noreiko on Fri, 15/01/2010 - 15:37I had a fun afternoon a few months back when all the imagecache images broke on a site I'd just taken live. I've just figured it out, so I'm telling you about it.
This was the situation:
- subsite.client.com was where I was developing the site, one of a family of multisites.
- subsite.com was a parked domain that went to just this site. It was this I'd just pointed to the IP of the box and that wasn't showing any images.
On the development domain, all worked fine. On the subsite domain, nothing.
Multisite On localhost Without Virtual Hosts
Submitted by joachim.noreiko on Thu, 03/12/2009 - 15:15I've been putting off setting up multisite on my localhost for ages, mostly because in the past I've found getting Apache virtual hosts to work can be a bit tricky: not impossible, but the sort of thing where I could easily lose an hour on a minor thing I've forgotten to do. And after all, with a shiny new iMac and a hard drive whose proportions I can't even remember, why not just 'drush dl' all over again?
But I'm actually working on a multisite project at the moment, and suddenly getting this to work becomes more interesting than having another SVN copy of my code kicking around.
Given multisite can respond to subfolders, I was wondering if this could work when Drupal itself is in a subfolder, like this:
Counting Hooks
Submitted by joachim.noreiko on Tue, 17/11/2009 - 12:02This (fairly long) one-liner counts the number of implementations of each hook in your Drupal installation:
ack "Implements? hook_" | perl -e 'while (<>) { m[(hook_\w+)] and $hooks{$1}++; } foreach (keys %hooks) { print "$_ - $hooks{$_}\n"; }'To count only install file hooks, which was what I was doing, give ack the option "-G '.install'" thus:
ack "Implements? hook_" -G '.install' | perl -e 'while (<>) { m[(hook_\w+)] and $hooks{$1}++; } foreach (keys %hooks) { print "$_ - $hooks{$_}\n"; }'
