Compare objects in java

If you want to compare if plain old java objects have the same properties, it is easiest to override the equals method.  This way, if you initialise objects on different places, you can be certain when comparing that they are the same.

We will show you how to do it with this simple class:

public class Insect
    private int legs;
    private int eyes;
    private int colour;
    private String sortName;

Override equals

public boolean equals(Object o)
    if (this == o)
        return true;

    if (o == null || this.getClass() != o.getClass())
        return false;

    final Insect that = (Insect) o;

    if (this.legs != that.legs)
        return false;

    if (this.eyes != that.eyes)
        return false;

    if (this.colour != that.colour)
        return false;

    if (this.sortName != null ? (this.sortName != that.sortName) : (that.sortName != null))
        return false;

    return true;

Override hashCode()

public int hashCode()
    int hash = super.hashCode();
    hash = 14 * hash + this.legs;
    hash = 14 * hash + this.eyes;
    hash = 14 * hash + this.colour;
    hash = 14 * hash + (this.sortName != null ? this.sortName.hashCode() : 0);
    return hash;

How to use the Microsoft Azure Storage SDK

After visiting Microsoft Cloud Camp in Brussels last week I wanted to dive into android developing by using Microsoft Azure.

I wanted to store images on a storage account, and since I didn’t use Gradle or Maven, I had some issues getting it to work. In the end, this is quick guide how I did it.

On github you can find the Microsoft Azure Storage SDK for Android. I checked out the project information on the maven-repository. I had to download the com.fasterxml.jackson.core since that was a dependency I wasn’t yet using.

On the repository URL I found the azure-storage-android-0.3.1.aar file. You need to download it and open it with a ZIP client. The classes.jar file is the library you need to put in your libs folder. I renamed it to azure-storage-android-0.3.1.jar. I also put the azure-storage-android-0.3.1-sources.jar in the libs folder.

For uploading an image to a storage account, this is a code example. Remember to execute it in an Async Task!

The image object is returned after pushing it to an Azure Mobile Service and contains the sasQueryString to authorize the upload.

String FileRef = FILEPATH + FILENAME of the file.
String BaseUrl = "";
CloudBlobClient blobClient = new CloudBlobClient(new URI(BaseUrl);
String blobName = image.ResourceName;
URI uri = new URI(blobClient.getEndpoint().toString() + "/" + "containername" + "/" + blobName + "?" + image.SasQueryString);
CloudBlockBlob sasBlob = new CloudBlockBlob(uri, blobClient);
File fileReference = new File(FileRef);
sasBlob.upload(new FileInputStream(fileReference), fileReference.length());


Raspbmc doesn’t update

For some reason, xbmc and raspbmc didn’t auto update anymore on my raspberry pi (running Raspbmc) since april this year.

Usually when you reboot your device, auto update makes sure your raspbmc is using the latest version.

By deleting some files, you can trigger your pi to update again on the next restart. This will probably solve your problem if you have the same issue:

  1. sudo -s
  2. cd /scripts/upd_sys
  3. rm *.sh
  4. wget
  5. wget
  6. cd /scripts/upd_hist
  7. rm xbmcver
  8. reboot


Update CouchPotato on Raspbmc

If you want to update CouchPotato just execute the following commands in the bash shell:

  1. sudo /etc/init.d/couchpotato stop
  2. cd CouchPotatoServer (or cd CouchPotato, whatever folder you installed CouchPotato in).
  3. git pull
  4. sudo /etc/init.d/couchpotato start

Even after starting, it might take 60 seconds before your site responds to requests.


My raspberry pi

The raspberry pi is an awesome device. It’s affordable, it’s a media center, a web server, very slow and doesn’t use much electricity. It’s also a very good looking piece of hardware. Fits your living room!



This post is about how mine is configured!

The services

  • Xbmc (installed as raspbmc): a powerful media center, running on Debian.
  • Transmission: A minimalistic torrent client.
  • CouchPotato: Software that searches the movies you want and starts to download them as soon as they come available.
  • BitTorrent Sync: Dropbox like service, easy way to backup folders on multiple computers.
  • Samba: Share a hard disk to the local network.

The place

My pi lives next to my TV. It’s powered by a 5V 2A power supply. It has a 8 gb sd card and their is a 2 TB external usb hard drive attached.


I use Putty to modify raspbmc via ssh, Yatse android app to control Xbmc. When needed I can connect an external keyboard because I still have 1 usb port over.


As you could possibly open up some ports to the internet, you will want to secure your raspberry pi.


I won’t list the complete process but refer to guides I followed.

0. Static IP

1. Raspbmc

First we need to install raspbmc on the pi:

2. CouchPotato, Transmission

3. BitTorrent Sync

4. Enable samba

You can do this in the xbmc interface.

5. Dynamic Dns

XBMC tweaks

  1. By default, if there is no hdmi connected on boot, it won’t enable hdmi. That’s ridiculous!