Smarty template syntax highlighting with gedit

Update: I have posted an alternative way to do the same thing this post describes, the alternative way should be more reliable. See it here http://www.c3b.co.uk/2008/12/16/alternative-method-for-opening-smarty-templates-with-html-syntax-highlighting-in-gedit/

I’ve started using gedit as my code editor after a couple of niggles with bluefish and wanted my smarty templates (*.tpl) to use the same syntax highlighting as HTML. Not wanting to have to manually select the language each time I open a .tpl file I went searching for a way to add them to the definition of what an html file is. I was getting frustrated with all the references to a syntax highlighting tab in the preferences dialog that just didn’t exist! Even the help file in gedit 2.22.1 still mentions the syntax highlighting tab but I can assure you it’s not there.

The solution I came up with was to manually edit the HTML language definition file for gtksourceview which is what gedit uses to define the syntax highlighting. To achieve this you must change the following line in the /usr/share/gtksourceview-2.0/language-specs/html.lang file:

<property name="globs">*.html;*.htm</property>

to

<property name="globs">*.html;*.htm;*.tpl</property>

Or download my version here (html.lang) of the file and run the following command:

Backup existing file

cd /usr/share/gtksourceview-2.0/language-specs
sudo cp html.lang html.lang_bkup

Then move the downloaded version of the file into place (this assumes you download the file and extracted it to your home directory)

sudo mv ~/html.lang /usr/share/gtksourceview-2.0/language-specs/html.lang

Restart gedit and when you next open a .tpl file it will be highlighted in the same way as an HTML file.

Flash plugin with Ubuntu

I recently installed the latest and greatest version of Ubuntu, version 8.04 aka Hardy Heron, from Vista (which was pre-installed when I bought the laptop)

I managed to switch quite happily, replacing many of the applications I used daily (Notepad++, FileZilla, TortoiseSVN, Winamp) with either their linux counterparts or alternatives (Bluefish, Exaile and I’m going with the command line for SVN) one thing that was becoming annoying was the swfdec-mozilla plugin for playing flash content in Firefox, it only kinda worked for me. Google analytics graphs wouldn’t render, YouTube videos were occasionally very slow and worst of all I couldn’t watch the latest installment of Zero Punctuation!

I went to Adobe’s website and downloaded the nonfree version of the flash plugin, ran the install script, restarted FF, then restarted Ubuntu but swfdec persisted.  I couldn’t find any way to replace the default flash player in Firefox so then I had the bright idea of removing swfdec-mozilla.

Launched Synaptic, searched for swfdec, marked swfdec-mozilla for removal, shut down Firefox and hit apply. Less than 30 seconds later I’m launching up Firefox again and listening to Ben “Yahtzee” Croshaw deliver his opinion on Gods of War: Chains of Olympus and another 30 seconds later I have a huge smile on my face, thanks Synaptic and thanks Yahtzee.

Resetting a MySQL root password

It happened, I forgot a password. I normally pride myself on my memory for things like passwords but this one was gone so I went searching for a way to reset it. I found this very concise entry at debian-administration.org that sorted me out. There were many others like it but this is the one that I followed to reset the password (it’s also written by a guy that works for the hosting company I use, Bytemark)

http://www.debian-administration.org/articles/442

In short my own version of the process:

  1. Stop the MySQL process.
    /etc/init.d/mysql stop
  2. Start MySQL manually with the –skip-grant-tables parameter.
    /usr/bin/mysqld_safe --skip-grant-tables &
  3. Run MySQL from the command line, logging in as root with no password.
    mysql --user=root --pass mysql
  4. Update the user table, setting the root user’s password.
    UPDATE User set Password=PASSWORD('newpass') WHERE User = 'root';
  5. Flush the privileges cache.
    flush privileges;
  6. Exit MySQL.
    exit;
  7. Restart the MySQL service without skipping the privileges tables.
    /etc/init.d/mysql stop && /etc/init.d/mysql start

Redirecting a former employee’s email in Exchange

Let me start with a brief disclaimer I’m not a formal Exchange administrator but I’ve been using it enough years to get my head around it and basically understand how to get it to do what needs to be done.

A fairly common task I have performed in the past is to redirect a former employee’s email to their replacement or senior and in the past I have achieved this by disabling the old account and adding the old user’s address to the list of addresses of the new user. I never felt happy with this solution and it always left me feeling a little bit dirty.

I’ve since found a much better solution after some very quick googling and I’m posting it here as a reminder:

From Active Directory Users and Computers find the old user, right-click and select properites. On the Exchange General tab select Delivery Options. In the Forwarding Address box select “Forward to:” and then enter another Active Directory user or contact by clicking “Modify…”. Finally click OK on all open dialogues and you’re done.

I’ve finally embraced CSS

I’ve been putting together sites for years but never really taken the time to learn CSS properly and sticking with table based structure for far too long, finally I have built my first site using nothing but CSS and div tags for layout. It’s probably not perfect but it works and that’s the main thing for me.

The site in question is http://www.cazzbuckley.co.uk

With my new found confidence in CSS I will now attempt to create a WordPress theme for that same site’s blog section, let’s see how it goes…

<fb:share-button /> useless error message

It seems the <fb:share-button> control has 1 error message:

There was an error trying to share this content.
Sorry, the content owner's privacy settings don't allow you to share
this content.

The actual reason for this error message was that the href of the target_url link was blank. It turns out this can happen if you mistype target_url too.