All posts by Ian Thomas

About Ian Thomas

Ian Thomas (aka "Swarley") is the owner and admin of Swarley's Blog. He is currently the Head of Solutions Development at Linguamatics on the Cambridge Science Park. In his spare time he enjoys watching films, coding, playing badminton and video games.

Battle of the SSDs: Intel 330 vs Samsung 830

I recently purchased an Intel 330 Series 120GB SSD in order to improve my ageing PC’s performance. My post about migrating an existing Windows 7 installation to an SSD was based on the installation of that new SSD. At the time, I mentioned some issues I was having with waking up from sleep/hibernate on the SSD. The stability issues gradually became worse, resulting in the following intermittent problems:

  • The PC would sometimes blue screen and restart during shutdown.
  • The PC would sometimes blue screen and restart following fairly long periods of usage (after 2 or 3 hours).
  • Filesystem index corruption was detected (and fixed) on C: by Windows 7 chkdsk.
  • Resuming from sleep/hibernate would sometimes result in a blue screen and restart.

Many of you will recognise these symptoms as classic signs of an SSD built with a SandForce controller chip. Some SSD manufacturers such as OCZ have been experiencing relatively high return rates (up to around 9% of all SSDs sold) due to the reported instability of the SandForce controllers. Several firmware updates have been released to supposedly address these instabilities, but there remains plenty of forum activity discussing these problems. The reason I went for an Intel SSD in the first place was their reputation for reliability. They supposedly only see return rates of around 2-3% for their SSDs, which is similar to the average return rate for old-fashioned HDDs, so I would say that is pretty good. It should be noted that these are return rates rather than failure rates, which is a weakness in the statistics.

The previous 320 Series of consumer-grade Intel SSDs used a homegrown Intel-branded controller, which was very well received and by most accounts very reliable. The new generation of 330 Series and 520 Series SSDs uses a SandForce controller, but with an Intel-customised firmware that is designed to resolve any outstanding stability issues. So if that is the case, why is my new Intel SSD not behaving itself?

Continue reading Battle of the SSDs: Intel 330 vs Samsung 830

Migrating an existing Windows 7 installation to an SSD

With the advent of affordable and reliable high performance SSD storage, the possibility of running Windows on an SSD for lightning quick boot times and highly responsive applications is becoming more and more attractive. But the thought of reinstalling Windows from scratch is not so appealing, regardless of how good your backups are and how organised you might be. There is a regularly cited argument that in order to get the best possible performance from new storage, you should reinstall Windows. I don’t disagree with that, but we don’t live in an ideal world where we all have unlimited free time. And in the case of migrating from a fairly old desktop HDD to a brand new SSD, I’m not sure how noticeable the performance improvement will be if you take the extra time to reinstall Windows from scratch, compared to just migrating your existing installation.

Lots of SSDs are now available in a “retail kit” or “reseller kit” form, which include a bundle of helpful accessories selected by the manufacturer. These usually comprise a 2.5″ to 3.5″ drive bay adapter for desktop PC cases, a standard SATA data cable, an adapter from a 4 pin Molex plug to an SATA power connector, and some free cloning software. Clearly the manufacturers expect at least some users to migrate their old operating system across to the new drive, and have tried to make this easy. Some of them (including Samsung), also provide a USB to SATA adapter cable, allowing you to connect your new SSD to any machine with a USB port in order to migrate data to it. These kits usually only cost a little more than the barebones OEM packs, making them excellent value for money.

The two main migration software packages provided in these kits are Acronis True Image and Norton Ghost, or a rebranded manufacturer-specific derivative of them. If you are trying to migrate data from your OS disk, these software tools usually provide the ability to create a bootable CD version which allows you to gain full access to your existing OS disk by booting into a separate self-contained mini operating system (usually based on Linux). From this environment, you can clone your main OS partition directly to the new SSD.

If you elect to follow this approach and migrate your Windows 7 installation to your new SSD, what are the main steps you need to perform?

Continue reading Migrating an existing Windows 7 installation to an SSD

Client-side Rendering of RSS Feeds in Drupal

So I wanted to display the RSS feed of my latest Blog posts in the sidebar of my main website, which is powered by Drupal. Normally this would be trivial, if my Blog was also hosted by the same Drupal site. However, my Blog actually lives on a separate WordPress site running on the same web server. I wanted to learn both Drupal and WordPress, which is why I elected to have two separate CMSs (yes I realise this is just making life harder, but this is how we learn!).

Initially I installed the standard Feeds module, but for some reason it couldn’t aggregate the RSS feed from my Blog site. I eventually tracked the problem down to my web host Heart Internet. It seems they block loopback connections, which is preventing the underlying fsockopen() PHP call that powers the Drupal Feeds module from reading my Blog’s RSS file on the same server. Since all Drupal RSS modules use the same server-side socket connection model to read the RSS feeds, my only option was to use a client-side RSS aggregator.

After some research, I came across the PaRSS module, which uses the PaRSS jQuery plugin to actually do the work on the client. The installation is slightly complicated by the fact the jQuery plugins site is currently inaccessible due to development work, but you can download the necessary PaRSS files here. Once you’ve installed the module and library files, it’s quite easy to create a link (using the Link module) to represent the RSS feed URL, and then plug that in to a Drupal block with the formatter set to ‘PaRSS’ to ensure you get a nice jQuery-powered rendering of the RSS feed.

You can see my results in the left-hand sidebar of my main website, where it says “My Latest Blog Posts”. That is being populated on every page load by the PaRSS client-side library. This is not as elegant a solution as the Feeds module, but it offloads the effort from the Drupal server, and overcomes the restrictions of my web host. Sometimes you just gotta do what you gotta do.

Unlock your TrueCrypt Encrypted Device without the Exact Password

So here’s the rather embarrassing story…

A couple of years ago, I encrypted a USB stick using TrueCrypt encryption to store some important/valuable files. I then put it in my bag and forgot about it. This weekend I came back to it and realised I had forgotten the password. I could remember using a combination of a couple of other passwords for increased security, but I couldn’t remember which passwords I had used, or in what order or combination. After numerous manual attempts to find the right combination, I gave up resigned to the fact that I would just have to wipe the device and start again.

Then something occurred to me – “Hang on a minute, I’m a programmer!”. And then I thought “How could I lose such an important password?”. Since I encrypted this USB stick, I’ve become a disciplined user of KeePass and LastPass, and to be fair this is the only password not in my password database. But still, it must be possible for me to solve this problem.

The first piece of the puzzle was the command-line interface to the Windows version of TrueCrypt. This is more than adequate to be wrapped with a script. The second piece of the puzzle was the itertools Python module, which provides some very nice functions for iterating over various permutations/combinations of values.

So the stage was set – how easy will it be to write a Python script to solve this problem? It turns out the answer is pretty easy. I found the itertools.product() function to be the best fit for my requirements, as it will generate the Cartesian product of an iterable list of possible password components with itself, giving me every possible combination of the specified password components.

The other critical part of my solution was discovering the right combination of command-line arguments to provide TrueCrypt. Here is the magic Python statement, which will attempt to mount the specified device as drive letter “T:” using the given password in a non-interactive manner:

truecrypt_command = ""%s" /q /s /v %s /lT /m ro /a /p "%s" /b" % ( truecrypt_exe, truecrypt_device, password )

The rest was just glue code to read in the list of possible password components from a separate text file, and then loop over every possible combination/permutation until the password is found (or we run out of options).

Good news – the script works, and it found my missing password! The script is very basic and still uses some hard-coded settings, but you can download TrueCryptPasswordHunter.py if you think it will be of any use to you. It was written and tested with Python v2.7.3 32 bit on a Windows 7 64 bit machine.

Usage

Create a text file called password_components.txt in the same directory as the script, and populate it with possible password components, one per line. For example, if you think your missing password might be “monkeydoghorse” or “horsedogmonkey”, or something similar, then your password components file should contain the following:

monkey
dog
horse

Then just run the script and cross your fingers.

How to Override Inline Styles from an External Stylesheet

All web developers know that by default, inline styles take precedence over styles in external stylesheets. For example, the following inline style declaration:

<span style="color: red;">Red text</span>

will ensure the “Red text” is coloured red, even if the following is included in an external CSS file, or in the <head> styles:

span { color: blue; }

Now it is generally not a good idea to use inline styles, as one should avoid mixing markup (responsible for the content and structure) with styles (responsible for the presentation format). Sometimes this is out of our control, for example if you are using a CMS which generates HTML with inline styles. In this case, how do you override these inline styles to ensure the page looks right?

Fortunately, this is easily done by using the following CSS magic:

span[style] { color: blue; }

The presence of the magic [style] attribute ensures that this style declaration overrides whatever inline styles are specified for the <span> elements.

I know this trick is generally well known, but it’s useful enough to restate it, just in case you’ve somehow not discovered it yet! In addition, please note that as with most useful CSS techniques, I believe this is not supported in Internet Explorer 6 or 7.

A slight aside – you can also use the “!important” CSS rule to assign greater priority to specific styles, regardless of where they are declared, but this approach is frowned upon as it can interfere with style customisations made for accessibility reasons, and can also be a sign of poorly defined or structured CSS.

Rename/remove the default “Home” menu link in WordPress Twenty Eleven Theme

If you’re using the “Twenty Eleven” Theme in WordPress and you want to either rename or remove the default “Home” link in your main menu bar, this is what you need to do:

  1. Create a child theme of “Twenty Eleven”. You only need a basic child theme with a default style.css file and an empty functions.php file.
  2. Add the following code to your functions.php file:
add_filter('wp_page_menu_args', 'twentyelevenchild_page_menu_args', 20);

function twentyelevenchild_page_menu_args( $args )
{
    $args['show_home'] = {value};
    return $args;
}

where {value} is either:

  • “new name” – to give the “Home” link a new custom name, or
  • false – to disable the “Home” link altogether.

It’s possible that this approach will work for other Themes, but I have not tested that – please add a comment if you find out!