The Raspberry Pi

July 29, 2012

I came across this a while ago, I watched a piece on the BBC News website by Rory Cellan-Jones. I immediately went off to Element14 and placed my order (opting for the T-Shirt as well!).

Anyway, I took delivery of my RaspberryPi the other week! It was at this point I realised I needed to order the mouse, keyword, SD card, and power supply :-)

So off I went and found said parts quite quickly on ebay (SD card) and trendinguk (keyboard, mouse and power supply).

So, like a second Christmas, I took delivery of all the peripherals and started setting everything up!
In the first instance I needed to write the operating system onto the SD card, and found the following article to be very easy to follow. After that, I was ready to boot it up and plugged in the Keyboard, mouse and HDMI cable, fitted the power supply and “Hey Presto” I had a Raspberry Pi up and running on my TV!!!

I then enabled SSH allowing me to login remotely (rather than hijack the TV, as I don’t have a monitor).

Since then I have changed the default password :-) , created my own user, installed Apache, PHP and MySQL (using the following tutorial).

It is all so simple, and really exciting!

I will continue to play, and probably buy a wireless network device, a battery, and the casing and then see what I can do… I am interested in tracking.

Watch this space.

Check out my photos here.

Surrey Police, Amazon and the Data Protection act

April 7, 2012

Been extremely busy the past few months, hence no new posts. However recently I received some interesting emails which I would like to share.

Back on the 29th March I received an email from Surrey Police (out of the blue, thankfully I don’t have an communication with the Police), it read:

Dear Sir or Madam
 
The Surrey police have recovered a NIKON D3100 camera fitted with a 18 to 55 mm lens that was sold by Amazon.co.uk then stolen from the purchaser. Your details have been obtained as purchasing such a camera from Amazon.co.uk during the relevant period. If you have had your NIKON D3100 camera stolen it maybe the camera that Surrey police have recovered could be yours.
 
If you have had such a camera stolen please contact Detective constable XXX PXXX XXXXr to establish if the recovered camera is yours.
When replying to this email please include a daytime telephone number so the you can be contacted by Detective constable XXX PXXX XXXXr.
 
Many thanks”

Nothing wrong with this, yes I have purchased this camera and very nice it is too. Thankfully I have not been the victim of said item being stolen. So why am I sharing this, well…. Surrey Police decided, and this is what troubled me, that they would CC everyone else in the surrounding area (quite a large area as I do not live in Surrey county). So I have a list of valid email addresses of people in and around Surrey have have purchased this camera (and all those people, in turn, have my email). Thanks Surrey Police!

The data protection act does not seem to apply to Surrey Police.

Anyway, before I could anything about it (I read the email at work and thought I would deal with it at home), that evening I received a further email from Surrey Police:

Earlier today I sent out a group e-mail as part of an on-going investigation by Surrey Police into stolen goods including a NIKON camera.
 
The aim of the e-mail was to identify and reunite the owner of the camera with their stolen item and as a result this has now been achieved.
 
The e-mail was sent to a list of individuals identified to Surrey Police by Amazon as potential purchasers of the camera.
 
These email addresses were provided to us in confidence for the purposes of the investigation and were not intended to be shared with each other. This was done in error and I apologise for any concern or inconvenience this has caused.
 
This information will not be shared with any other parties. 
 
Your assistance in our on-going investigation is much appreciated.
 
This made me smile, although I do wonder how many people complained before they took this seriously. Further to that, I do wonder how much trouble the dectective was in for doing this.
 
Then things became even more interesting (i.e. the plot thickened), on the 30th March I received an email from Amazon!
 
“Hello,

We’re writing to you about the e-mail you received from Surrey Police.

We wanted to reassure you that this isn’t a “phishing” e-mail, and was sent by Surrey Police as part of an ongoing investigation to return a stolen Nikon camera. Amazon.co.uk was legally required to disclose your contact information to Surrey Police following a Court Order. Disclosure was in accordance with our Privacy Notice and was required by law. Please note that no other information, such as your purchase history and payment information, was disclosed to the Police.

The e-mail that was sent by the Police shouldn’t have had customers’ e-mail addresses visible in the “to” section. We understand that Surrey Police have also sent a subsequent e-mail with an apology. We’re sorry for any inconvenience or concern caused by this.

We’ve contacted Surrey police, who advise that they’re satisfied with the information they’ve received from customers, and we’ve been advised you won’t receive further contact from them regarding this investigation.”

 
Interesting? So Surrey Police issue a Court Order to get all these email addresses, then shared them with everyone, which in turn created (one guesses) complaints to Surrey Police and Amazon requiring emails of apology. What troubles me, is I brought my camera sometime ago (back July 2011). surely if I had had this stolen from me, won’t I either have claimed it on my insurance (if I had insurance).
 
I wonder, and I suppose I could find out, what the request (via the court order) was to Amazon. Perhaps it was “Can we have every email address of everyone in the South East of England who brought this camera so we can share it amongst them all”?
 
Quite fitting, considering the UK government / Police want to pass new laws allowing them more rights to this sort of information (I suppose it will save costs on court orders, and perhaps the Police might want to consider comodotising the information they get…)

VirtualBox how to delete snapshots

December 14, 2011

Just a quick one, I wanted to clean up my VBox snapshots for an image, I am using the latest and greatest version. I suddenly realised it is not available in the VBox UI anymore. :-(

You can run it from the command line though!

First things first, lets say your image is called TestXP run the following:

vboxmanage showinfo TestXP

This will give you the UUID’s for your snapshots.

For each Snapshot that you want to delete enter the following:


vboxmanage snapshot TestXp delete UUID

Simple as that…. Prefer the UI method though :-)

Java Application connecting to a DB2 instance – Solution to Sql Exception No Suitable driver found

November 26, 2011

Ok, so this one bugged me for a while, and it was only a throw away comment on a forum  that gave me the clue.

I have written a simple Java app to connect to a DB2 database to query the data and perform some analytics on that data. However my connection would never work!!!

This was my code


private Connection connection = null;
private Statement statement = null;
private PreparedStatement preparedStatement = null;
private ResultSet resultSet = null;

try
{
res = new Vector();

Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
connection = DriverManager.getConnection("jdbc:db2://"+host+":"+port+"/"+database,user,pass);

statement = connection.createStatement();

preparedStatement = connection.prepareStatement("SELECT * FROM "+table+" order by 1");

resultSet = preparedStatement.executeQuery();

...
}
catch (Exception e)
{
throw e;
}
finally
{
close();
}

This is based on the article I had read from IBM. Further to this article, I had managed to locate db2java.jar from the client installation. However, everytime I executed the code I was getting the error:

Specified connection failed with java.sql.SQLException: No suitable driver found

Searching for this, most articles suggested the connection string was wrong. I knew it wasn’t because I checked and double checked.

Then I read a comment in a forum which said to use jcc.DB2Driver and not app.DB2Driver. I looked in the library db2java.jar and I could not find DB2Driver under jcc! However, I then realised within the driver directory of my DB2 client that there were more Java libraries, and one of these was db2jcc.jar.

I swapped over my libraries and updated my code (note the change to Class.forName):


   private Connection connection = null;
   private Statement statement = null;
   private PreparedStatement preparedStatement = null;
   private ResultSet resultSet = null;

   try
   {
      res = new Vector();

      Class.forName("com.ibm.db2.jcc.DB2Driver");
      connection = DriverManager.getConnection("jdbc:db2://"+host+":"+port+"/"+database,user,pass);

      statement = connection.createStatement();

      preparedStatement = connection.prepareStatement("SELECT * FROM "+table+" order by 1");

      resultSet = preparedStatement.executeQuery();

      ...
   }
   catch (Exception e)
   {
      throw e;
   }
   finally
   {
      close();
   }

This worked perfectly. Just wanted to share it!

Building a standalone Java command line app with Netbeans

November 26, 2011

Pretty simple one really, and it was – once I remembered / found out.

Seeing as I swap around from IDE to programming language, to OS I realised the other day that I didn’t know how to build a self contained command line java app (e.g. I had written a simple program and I wanted to ship it with the mysql driver) within Netbeans.

So after a bit of searching, and being put off by the prospect of using ant I discovered a way to do it… I thought I would write this in the hope I won’t forget and to help others (took a little while to find this answer).

Let imagine we have a simple Java program, good old hello world (see below)

public static void main(String[] args)
{
      Connection connection = null;
      Statement statement = null;

      try
      {
           Class.forName("com.mysql.jdbc.Driver");

           connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/svm","username","password");

           statement = connection.createStatement();
      }
      catch(Exception e)
      {
           System.out.println("Oh boy - "+e.toString());
      }
      finally
      {
           try
           {
                 connection.close();
           }
           catch(Exception e)
           {
                 System.out.println("Oh by there is a problem! "+e.toString());
           }
      }

      System.out.println("Hello world");
}

And further to this, the simple program also connects to a MySQL database…

Now, you can see the desire… you to want to ship the jar including the mysql library? Well, this can be achieved really easily (in Netbeans). Just do the following:

  • Within the root directory of the project there is a file named – build.xml
  • Open this file in Netbeans, you will notice some XML at the top of the file about project name etc, within the open project element you see a lot of comments.
  • Scroll to the end of the file
  • Just before the closing element of project e.g. </project> insert the following example lines
 <target name="-post-jar" >
     <jar jarfile="${dist.jar}" update="true">
         <zipfileset src="${dist.jar}" includes="**/*.class"/>
         <zipfileset src="dist/lib/mysql-connector-java-5.1.6-bin.jar" excludes="META-INF/*"/>
     </jar>
 </target>

This is the specific entries for adding the MySQL library to your jar file. You will note that it is referencing the library from my /project/dist/lib/ directory.

And that’s it! Clean and build and you find your jar is bigger and contains your library!!!! Brilliant – ship it to the world now :-)

My source


Follow

Get every new post delivered to your Inbox.