Ubuntu “Hash sum mismatch” when updating repository

When running:

sudo apt-get update

I often get the following on a new 12.04 minimal install.

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/main/source/Sources Hash Sum mismatch
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/restricted/source/Sources Hash Sum mismatch
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/universe/source/Sources Hash Sum mismatch
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/multiverse/source/Sources Hash Sum mismatch
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/main/binary-amd64/Packages Hash Sum mismatch
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/restricted/binary-amd64/Packages Hash Sum mismatch
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/universe/binary-amd64/Packages Hash Sum mismatch
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/multiverse/binary-amd64/Packages Hash Sum mismatch
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/main/binary-i386/Packages Hash Sum mismatch
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/restricted/binary-i386/Packages Hash Sum mismatch
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/universe/binary-i386/Packages Hash Sum mismatch
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/multiverse/binary-i386/Packages Hash Sum mismatch
E: Some index files failed to download. They have been ignored, or old ones used instead.

To fix:

Remove the content of /var/lib/apt/lists directory:

sudo rm -fR /var/lib/apt/lists/*

then run:

sudo apt-get update

Add Mylyn Task Connector to Easily Connect to Bugzilla from Eclipse

Connect to your Bugzilla bug repository with the Mylyn Tasks Connector: Bugzilla plugin.

This can easily be installed by installing new software in Eclipse, selecting your most recent release in the “Work with:” selection box, type “mylyn tasks” in the filter text box, and then select the “Mylyn Tasks Connector: Bugzilla” plugin.  Click next through the installation dialogs.

Once installed, you can access the view by selecting Window > Show View > Task List.  If it is not displayed, click Window > Show View > Other … and select Mylyn > Task List in the popup window.

To add your repository, from the “Task List” view, click the “View Menu” icon ( a small downward arrow) and click “Show Task Repositories View”.  From this view, right click on the white-space and click “Add Task Repository…” from the popup menu.

Javscript Unit Testing with Eclipse and JS Test Driver

To get started unit testing with Javascript and Eclipse, you’ll need Eclipse installed with the Javascript Development Tools plugin installed.

From the main menu bar click Help > Install New Software…

Click the “Add” button next to the “Work With:” text seleciton box.

Enter “http://js-test-driver.googlecode.com/svn/update/” into the Location field and enter a Name of your choosing or leave it blank to use the default location as the name.

Select the “JS Test Driver” plugin under “JS Test Driver Plugin for Eclipse” and click Next through the dialogs.

Once the plugin is installed, you can bring up the JSTestDriver view by clicking Window > Show View > JsTestDriver from the main menu bar.

You may want to configure the paths to the browsers for the quick open buttons by clicking Window > Preferences from the main menu bar.  Choose JS Test Driver on the left pain and then select the paths to the various browsers.

To start unit testing click the “Start Server” play arrow icon in the JSTestDriver view and click on the button for the web browser of your choosing.

Install PHPUnit on Windows

First, if not already done, install PHP and PEAR on windows.

Once pear is set up type the following in a command prompt:

pear install -a -f phpunit/PHPUnit

This will install all dependencies (-a) and force the install (-f)

If you get the error:

No releases available for package "pear.phpunit.de/PHPUnit"
install failed

Enter the following to clear the cache.

pear clear-cache

And once again enter the install command:

pear install -a -f phpunit/PHPUnit

Install PHP and PEAR on Windows

Download PHP from windows.php.net (Download). Download the thread safe version to use with apache.

Decompress the zip file to your desired directory.  I used c:\dev\php-x.x.x\

Install PEAR ( Pear’s instrunctions ):

  • Download go-pear.phar (reference link)into the folder you decompressed php.
  • Open the command prompt with Adminstrator access.  You can do this by opening the start menu typing “cmd”, right click on the cmd.exe icon and select “Run as administrator”.  OR you can click the start menu, enter “cmd”, and then hit ctrl+shift+enter.
  • Change to the directory you decompressed php.
    cd c:\dev\php-5.4.5
  • In the php directory, copy php.ini-development or php.ini-production to php.ini.
    copy php.ini-development php.ini
  • At the command prompt type:
    php go-pear.phar
  • You will then be prompted to configure the installation.  Use default settings or customize to your hearts content.
  • If you copied the php.ini file you should be prompted to add the pear directory to the php.ini configuration.  Do this.
  • Add the PEAR_ENV.reg file to your registry:
    regedit PEAR_ENV.reg
  • Add the pear directory to your path:
    • Click the start menu, right click on “Computer” and select “Properties”
    • Click “Advanced system settings” located on the left pane.
    • On the “Advanced” tab under the System Properties window select “Environment Variables…”
    • Under “System variables” select the “PATH” variable and click on the “Edit…” button.
    • In the “Variable value:” text box, append to the end “;c:\dev\php-5.4.5”
    • Click “OK”