Regenerating Path Aliases Programatically in Drupal 7

It should look something like this:

* Update path aliases for taxonomy terms and nodes.
function gateway_controller_update_7057() {
  module_load_include('inc', 'pathauto');
  module_load_include('inc', 'pathauto.pathauto');

  // Delete the existing node aliases.
    ->condition('source', 'node/%', 'LIKE')

  // Regenerate the node aliases.
  $nids = db_query("SELECT nid FROM {node}")->fetchCol();
  pathauto_node_update_alias_multiple($nids, 'bulkupdate');

  // Delete the topics taxonomy aliases.
    ->condition('source', 'taxonomy/term/%', 'LIKE')

  // Regenerate the taxonomy aliases.
  $tids = db_query("SELECT tid FROM {taxonomy_term_data} where vid = 8")->fetchCol();
  pathauto_taxonomy_term_update_alias_multiple($tids, 'bulkupdate');

Getting Adafruit’s Flora working under Ubuntu 13.04

I’ve been trying to get working and had a few issues getting the Flora working with the Arduino IDE under Ubuntu / Linux.

Initially I had a bad mini-usb cable, which I diagnosed by checking dmesg when plugging the cable in and sure enough nothing registered. Once I found a working cable, I needed to download version 1.04 of the Arduino IDE then follow the instructions in kkolbo’s zip at

Lastly I added


to /etc/udev/rules/90-flora.rules and restarted udev as outlined in

Sure enough the LED started blinking!



Drupal 7 – Programatically update a media module file display image style

I needed to push a change to a file display’s image style through to production, and Features didn’t seem to want to take it so I needed to push it via an update hook.

Using code from file_entity_file_display_form_submit() and media_install() i came up with this, which worked:

$display_name = 'video__preview__media_youtube_image';
$image_style = 'media_thumbnail';
$display = array(
  'api_version' => 1,
  'name' => $display_name,
  'status' => 1,
  'weight' => 2,
  'settings' => array('image_style' => $image_style),
  'export_type' => 3,
  'export_module' => 'media_youtube',
  'type' => 'Overridden',
  'table' => 'file_display',

file_display_save((object) $display);

Might be useful for someone in the future..

Setting up a self signed SSL certificate with Apache

I’m assuming you have Apache installed.

Enable the SSL mod for apache:

sudo a2enmod ssl

Create a directory for the certificates:

sudo mkdir /etc/apache2/ssl

Generate the certificate:

sudo openssl req -x509 -nodes -days 365000 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

Openssl will ask for some information, make sure you set the FQDN properly, the rest don’t matter.

Now edit your virtualhost to point to port 443:

<VirtualHost *:443>

Add the port to the server name directive:


Then enable SSL and point the virtualhost at the certificates:

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key

Save the file and restart Apache

sudo service apache2 restart

Now if you want to redirect non-SSL requests to the SSL port add another virtualhost that looks like the following:

NameVirtualHost *:80
<VirtualHost *:80>
   Redirect permanent /

Then a2ensite the new virtualhost and restart Apache once more.

Raspberry Pi: Setting up remote access via TightVNC Server

Install the server on the pi:

sudo apt-get install tightvncserver

Now set up the server to start tightvncserver at boot:

Paste the following into /etc/init.d/tightvnc. You will want to configure the line starting with /usr/bin/tightvncserver. The Pi can do 1920×1080 so that would be the max resolution.

# First configure the user you want to run this under - this will generally be pi, unless you've created your own users
export USER='pi'

eval cd ~$USER

# Check the state of the command - this'll either be start or stop
case "$1" in
    # if it's start, then start vncserver using the details below
    su $USER -c '/usr/bin/vncserver :1 -geometry 1366x768 -depth 24 -pixelformat rgb565'
    echo "Starting vncserver for $USER "
    # if it's stop, then just kill the process
    pkill Xtightvnc
    echo "vncserver stopped"
    echo "Usage: /etc/init.d/tightvncserver {start|stop}"
    exit 1
exit 0


sudo chmod +x /etc/init.d/tightvncserver

Now add the script at startup via update-rc.d:

sudo update-rc.d tightvncserver defaults

Now you can access the remote desktop using Ubuntu’s Remote Desktop Viewer tool by entering the Pi’s IP followed by  :1. For example “”

Windows has a variety of clients that can be used too.

For more info see