University of Oregon

Vid's sliding-scale of sleep

Several years ago, a child was born, well statistically speaking quite a lot of them were, but around the time one child in particular was born I was getting little sleep.

Out of this experience a sliding-scale of sleep was developed that accurately depicted my functional level from the amount of sleep I’d had. Inversely it was possible to tell how much sleep I’d been getting based on my behavioral symptoms.

I shared this with a friend or two over the years and it seems to hold true for most folks, so now 1/2 a decade later, I thought I’d post it for posterity. (more…)

Drupal – adding debug messages to your custom module – Improved

As a follow up to ‘Drupal – adding debug messages to your custom module‘. I improved the code and wanted to share.
Now you can drop in a few functions and add one line to your hook_admin_settings function to get debugging functionality.
If you want to start with a baseline of functionality you can also update each of your functions to declare themselves in the debug messages. Which is handy for tracking down issues.

In the end you get the same addition to your GUI with control over how and when debug messages are used.
Screen Shot of the new checkboxes
You also get the same reporting output, to the screen, watchdog, or both:
Here’s a quick look at my watchdog log gui with both types of error reporting enabled:
Screen Shot of watchdog screen

All done with cleaner code.

Drupal – adding debug messages to your custom module

Note: There is a follow up post here: Drupal – adding debug messages to your custom module – Improved

I work with a few custom modules and lately I’ve been migrating one from PHP 5.2 to 5.3 & Webform 2 to 3.

It’s been a challenge to sort out where some of the the errors are being generated from so I added a grip of debugging statements. In fact, I used a regex replace to log the name of each function that’s run in hopes that I could track down errors in chronological order.

That worked OK but I though I may want to turn it off or switch from drupal_set_message() to watchdog() calls when it’s ready to go to production. So I wrapped each log item in an if statement and tested for two new module variables:

  • Enable debugging message feedback
  • Enable watchdog debugging feedback

So now I have some GUI control over how and when debug messages are used.
Screen Shot of the new checkboxes

Drupal – Leveraging built in string functions in custom modules

Drupal includes native versions of a few common php string functions; strlen() for example is called with drupal_strlen().
drupal_strlen counts the amount of characters in a UTF-8 string vs. counting the bytes of a string. Not a huge difference perhaps but according to the brief documentation: This is less than or equal to the byte count. So if you want better accuracy then user the drupal_str function

I was introduced to these functions a few years ago, when using the Drupal coder module:

I wanted to quickly prepare a custom module to use the drupal flavored functions today and thought I’d share the regex I used in to find & replace:
(DreamWeaver regex)

([ (.]+)(substr|strlen|strtolower|strtoupper|ucfirst)



A quick replace and you’re Drupal friendly.

Drupal hide/show a sidebar with jQuery

I’ve hid the right sidebar on the HR website today.
I used jQuery so that it degrades gracefully when users don’t have JS enabled.

The sidebar-right region is used for ancillary information; links, the audience for the node content, etc… So it was determined that we could hide it but make the information available if people wanted more. (more…)

Drupal – Add a datestamp to your custom modules

I have several custom Drupal modules and when ever I make revisions & create a new version I update the datestamp.
Here’s a bookmarklet I use in Firefox to generate a datestamp.
Just drag that to your bookmark bar and you’re good to go.

Here are my steps to use it:

  1. Click Datestamp bookmarklet;
  2. Select all;
  3. Copy;
  4. and then paste into your file:
    datestamp = "1354564856"

Here’s the code: (more…)

Testing web pages in multiple browers with appleScript v.2

This is a follow up to a post from a few years ago: Using applescript to open a url in several browsers.
I’ve made some updates to the script since then and a few them were today so I thought I’d share.

The old script opened a URL in several browsers (failing to load the web page in parallels VM browsers). The updated script now plays nice with Parallels and captures any URL in your clipboard if applicable.
The key to playing nice with Parallels is to manually drag the application icon into the script so that the address of the browser in the remote VM is accessible to the script.
Here’s the updated script: (more…)

Updated views to speed up admin pages

Commented out recordCount function in feedback and site_migration_list views.

/* ### 11-5-12 This function is running slow and causing page load slowdowns. Commenting out for now. Vid
function recordCount($viewName,$displayName){
    $view = views_get_view($viewName);
    return count($view->result);
//get the record count:
//ex: $totalCount=recordCount('feedback','attachment_1');


Bind commands in .bash files don't play nice with Dreamhost logins

Recently I posted a link to some code highlights: Auto populate from History via up and down arrow keys.
I’ve been using that code for several years in a number of bash terminals; on my Mac, several RedHat 5 & 6 Linux servers and on a few hosting accounts on Dreamhost.

One small piece of that code no longer plays nice with Dreamhost.
Something changed on the server-side that is in conflict with 1 or 2 lines of code so that users can not SFTP into the server with a valid user name and password. Authentication with ssh keys however continues to work.

Here’s the offending code found in my .bashrc file:
bind ‘”e[A”‘:history-search-backward
bind ‘”e[B”‘:history-search-forward


Presentation tips & tools in OSX

I was at the Pacific Northwest Drupal Summit this past weekend as both a participant and presenter. I came away with some new information but some of it was less about Drupal and more about presenting.
Here are some of the tips & tools I’ll be using for future presentations; (more…)