Monthly Archives: October 2011

What’s an “Interface” in Java?

I was browsing reddit this afternoon and came across this post. It’s an interesting concept to explain. I mean, what is an interface in Java?

I thought through the best way to explain this to someone who doesn’t understand OO or Java in general, and I came up with the following.

The Letterbox Analogy
Think of a letterbox.

Doesn’t matter who makes the letterbox, it’ll always operate the same way. Doesn’t matter what country you go to, if you want to post a letter, you just put it through a letter box.

public interface Letterbox {
void post(Letter letter);
}

If I’m a manufacturer, I might want to make exquisite letterboxes. I’ll make ‘em out of gold, and they’ll be sturdy and look outstanding. The shape, though, will remain the same as any other. So I’ll implement the Letterbox interface:

public class GoldLetterBox implements Letterbox {
public void post(Letter letter) {
// some code...
}
}

and then people will buy them, and they’ll put them in doors, and their postal employees will put their letters and packages through the door. It’ll still be Super Special Gold Letterbox Co’s letterbox, but everyone will know how to use it.

Linux + svn + ssh+ Samba/NTFS: Operation Not Permitted!

My fancy-dancy and super-awesome SheevaPlug has certainly settled in at home.

It exposes my media from my NAS so I can access it anywhere; runs transmission-daemon headless for all the ISO downloading of open source software I do; runs subversion/svn for my source code versioning needs; cleans the cat when it runs in with…OK, no. Honestly: it’s simply brilliant.

The latter function — subversion — was suffering from a teething problem or two. I run it via ssh login, so I configured openssh-server to match a group and force running svnserve as follows:

Match Group svn
ForceCommand /usr/bin/svnserve -t -r /mnt/code/scm/svn/repo/

which allows me to login using ssh users and be super-secure over-the-wire. Great.

I then mounted my NAS share (still on the SheevaPlug) that holds the (yet to be created) svn repo. using the following line in /etc/fstab:

//192.168.1.90/code /mnt/code smbfs username=alex,password=moo,uid=1002,gid=1002 0 0

all good.

I then create a repository and try to commit some code, but am presented with:

Transmitting file data .svn: Commit failed (details follow):
svn: Can't chmod '/mnt/code/scm/svn/repo/atc/db/tempfile.8.tmp': Operation not permitted

darn.

Turns out the uid option in the fstab line was referring to a non-existing user. So I corrected it and added umask=000 to the fstab line and it was all back up-and-running.

Sweet.

Off to code more bugs.

SheevaPlug and Locales

So, I got an awesome SheevaPlug from NewIT; it’s a Linux plug computer the size of a laptop adapter that uses around 5W of power. It’s perfect for an always-on home server.

After getting it installed and setup at home, I had the following locale-related issues when running apt-get and so-on;

locale: Cannot set LC_CTYPE to default locale: No such file or directory

which was spamming my shell far too often.

The simple fix was to apt-get install locales and then run dpkg-reconfigure locales and install those that are relevant to your system; as I’m in the UK and the only user I just installed en_GB.UTF-8.

Now I’ve got no more spam!