I need a better hobby

Blog

#glare

Blog
$ grep -r notifications_subscription_list_form contrib
contrib/notifications/notifications.module: $form['#submit'][] = 'notifications_subscription_list_form_validate';
contrib/notifications/notifications.module: $form['#validate'][] = 'notifications_subscription_list_form_submit';
$ 

Submit as validate and validate as submit. This is going to be interesting as I dig into the code.

Git checkout local repo from N days ago

Blog
git checkout @{two.days.ago}

If only there were a way to checkout files from the fuyoocha.

git checkout @{two.days.fromnow}

or maybe

git checkout @{two.days.aftercompleting}

Drupal 7 - get all terms for a node

Blog
Okay, you can use api.drupal.org/field_view_field, if you know all the various fields a node is using for terms and term references (reference):
$terms = field_view_field('node', $node, 'field_tags');
If you don't, load them all in one fell swoop (with lots of caching, please):
/**
 * Likely in hook_preprocess_node.
 */
function mymodule_preprocess_node(&$vars) {

  $multi = array();

  // get all the terms for this node, add status if desired
  $results = db_query('SELECT tid FROM {taxonomy_index} WHERE nid = :nid', array(':nid' => $vars['node']->nid));

  // loop over the terms for the tids
  foreach ($results as $result) {
    $tids[] = $result->tid;
  }

  // load all the terms at once
  if (count($tids) > 0) {
    $terms = taxonomy_term_load_multiple($tids);

    // and do shit with them.
    foreach ($terms as $tid => $term) {
      // in this particular case, push them onto an array to track in google analytics.
      $multi[] = array('_trackEvent', 'terms', $term->vocabulary_machine_name, $term->name);
    }
  }

  drupal_add_js(array('multi' => $multi), 'setting');
}

Yeah, just F that S

Blog

I put not much into this one. Fucking migraine.

f-that-mock

Though, you have to admit, not a completely bad design given the headache I have right now.

Update: Matthew thinks grey would be good, so now available in asphalt, too:

f-that-mock-asphalt

Pages