Better VNC viewer in Ubuntu 8.04

Another post regarding my recent switch to Ubuntu as my primary OS, this one concerns the VNC client/viewer bundled.  I’ve been having problems with Remote Desktop Viewer which is the bundled and preferred VNC client in a default installation of Ubuntu 8.04, I’ve had random freezes and disconnects with a logout/login of my machine sometimes resolving the issue temporarily.

The alternative is to use the Terminal Server Client application to connect to a VNC server, should just be a case of selecting VNC in the protocol dropdown right? nope, it’s greyed out*sigh*

To enable the VNC option in the Terminal Server Client dropdown you need to install the xtightvncviewer package either in Synaptic or with

sudo apt-get install xtightvncviewer

I fired up the Terminal Server Client, selected the VNC protocol, set the display to full screen and connected to my server.

Job done? not quite. I’m now prompted by my server with a “press ctrl-alt-del to logon” message. That’s where I had some problems, pressing ctrl-alt-del caused Ubuntu to ask me how I want to shut down. I needed some way of sending a ctrl-alt-del to the remote machine but I couldn’t see any obvious way of doing it. Queue the next problem, I’d selected full screen and that’s what I got, completely full screen, I couldn’t even switch to an alternative workspace since the VNC viewer remained on top.

I really didn’t want to restart my machine just because I couldn’t get rid of one window so I started randomly hitting buttons whereupon I found that F8 was rather useful! Pressing F8 with the VNC viewer focussed brings up a small menu with a number of options one of which was to toggle full screen and another was to send ctrl-alt-del to the remote machine, hooray!

I’ve found this VNC viewer to be a bit quicker at screen refreshes (though it does more of them) and more stable than the bundled viewer in Ubuntu, feel free to leave a comment to the contrary or suggesting another alternative that you may use.

YouTube GData API returning error 400 when uploading a video

I’ve been battling with the YouTube API for the last 2 days now and found the single line of code that has been preventing me from generating a form upload token.

I was following the example code at http://code.google.com/apis/youtube/developers_guide_php.html#UploadingVideos and kept receiving “Expected response code 200, got 400″ when calling the getFormUploadToken function. HTTP error code 400 is a bad request which wasn’t really much help.

Eventually I found the problem and I will own up straight away that it was basically my fault, I’d made what I considered to be a slight change to the example code, I changed

$mediaGroup->category = array(  $yt->newMediaCategory()->setText('Autos')->setScheme
('http://gdata.youtube.com/schemas/2007/categories.cat'),

$yt->newMediaCategory()->setText('mydevelopertag')->setScheme
('http://gdata.youtube.com/schemas/2007/developertags.cat'),

$yt->newMediaCategory()->setText('anotherdevelopertag')->setScheme
('http://gdata.youtube.com/schemas/2007/developertags.cat')

);

to the following

$mediaGroup->category = $yt->newMediaCategory()->setText('Autos')->setScheme
('http://gdata.youtube.com/schemas/2007/categories.cat');

because I wasn’t interested in multiple categories, just something simple. My mistake was not in removing the two developer tags but removing the array(). This took me almost an entire day to realise and resulted in a “You have to be kidding” comment from me once fixed. *Sigh* oh well, not going to get that time back but at least I learned not to mess with example code.

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.