Quotes I love
-Abraham Lincoln
FreeBASIC commits
cha0s's tweets
-
*HEAVY BREATHING* http://t.co/pbA5Pkc11 hours 22 min ago
-
I just scored 312 points playing Scrabb.ly. http://scrabb.ly/g/C7D0265BA8CA499C83843D21F1E74C0113 hours 38 min ago
-
@mikejoconnor Did they send you a refurbished guitar? ;)15 hours 3 min ago
- 1 of 86
- ››
PHP/Drupal
Amelie Drupal module (or, how to drive IE6 users insane)
The article here (http://icant.co.uk/ie6-amelie/) describes its mission as '[It] is time to get rid of Internet Explorer 6 by making it uncomfortable for the end users and blaming something else. To this end we take an IE filter that was made to confuse users — the MotionBlur filter — and apply it randomly to the document.'
I thought this was awesome, so I turned it into a Drupal module that you can enable on your site to lead IE6 users down the long, slow rabbit hole of complete insanity.
Find it here, and enjoy! Your IE6 users definitely won't... and that's the point! http://drupal.org/project/amelie
drupal-accessibility IRC channel logs available at http://log.therealcha0s.net/drupal-accessibility.log
Miss Katherine Lynch mentioned her desire to host the logs from the Drupal accessibility channel for the a11y peeps and I couldn't pass the opportunity to do something (albeit little) for the community!
So, they're located here: http://log.therealcha0s.net/drupal-accessibility.log
Enjoi!
uasort in Drupal, a weighty subject
If you've ever done any UI coding in Drupal with some elements that need to be arranged in a given order, then this snippet is for you!
Drupal provides us the function element_sort, which sorts an array's elements based on their '#weight' elements. This is fine, but unfortunately '#element' is a Drupal idiom, and even within Drupal we find places where we'd rather sort by 'weight' than by '#weight'.
So we have a problem that fits a well-defined pattern, but is too clunky to solve by writing a million functions for each element (what if you want to sort by '#list_order'?)
What do we do? Generate functions at run-time and cache them, of course!
function array_comp_sort_by($element) {
static $cache = array();
if (array_key_exists($element, $cache)) return $cache[$element];
$element = "'" . $element . "'";
return $cache[$element] = create_function('$l, $r', '
$lw = (is_array($l) && isset($l[' . $element . '])) ? $l[' . $element . '] : 0;
$rw = (is_array($r) && isset($r[' . $element . '])) ? $r[' . $element . '] : 0;
if ($lw == $rw) return 0;
return $lw < $rw ? -1 : 1;
');
}
Hope this saves you not only the minute it takes to write a new function every time, but the mental anguish of knowing there's a pattern there, but having to settle and copy-paste the sort function. ^^
An example of this in use:
/** Sort them by weight. */
uasort($modifiers, array_comp_sort_by('weight'));
Awesome logo design by Lindsay Ogden at 5RingsWeb!
