IPTables Firewall for your Server

Don’t write your own. Why? ’cause you’ll mess it up and end up in a false sense of security.

Some Norwegian dude called Vegar told me of the Debian package arno-iptables-firewall. It’s an iptables-based firewall that can be administered in your favourite text editor or more conveniently by dpkg!

So, remove that crappy iptables script that you wrote to “protect” your public-facing server and go do this:

apt-get install fail2ban arno-iptables-firewall

Posted in Hacking, Linux | Tagged , , , , , | 2 Comments

Downtime

Sorry for those who read the site (all 1 of you). Linode decided to suspend my account when payment failed. Perfectly within their rights, sure.

The problem I have is that they neglected to contact me to explain A) that payment had failed and I risk suspension and B) that they had suspended my account.

Nice. Real smooth.

Posted in Site | Leave a comment

2011 BDFPA All England Powerlifting & Single Lifts

Alongside my powerlifting team, I took part in the BDFPA All England Powerlifting & Single Lifts championship on Sunday. It was a fantastic opportunity, filled with nerves, adrenaline, grunt and a steep learning curve or two.

I aimed to do all three lifts — squat, bench press and deadlift — raw to the best of my ability, but by no means holding any expectation that I’d be much competition to my peers. Indeed I don’t remember any of the numbers that anyone other than my team-members hit, so it’s safe to say I wasn’t paying attention to that. This was my first powerlifting competition and I just wanted to learn.

Weigh-in
This was a bit of a funny situation for me. Upon waking that morning, I checked my weight and I was 66 kg. I then went and had breakfast thinking nothing of it – mistake #1.

We arrived at the event only to have to weigh-in immediately. I head straight for it. I’m instructed as-necessary by one of the judges to do the necessaries (read: strip to my briefs) and pop on the scale.

It read 67.9 kg. Shit. I was already a weight class too high for my liking.

“You’ll have to take a run around the block” or words to that effect, the judge said. I went for a wee, took my watch and socks off, then headed back to the scale.

67.5 kg. Dead on. Phew!

Squat
Fast-forward an hour or so and the lifts start with Squat promptly at 1030. By now my newbie nerves are rattling my bones yet somehow I’m managing to hold it together quite well. Already a great experience.

I started with an easy squat for me — 110 kg — and it was a wise decision. I hit it just fine and was awarded three white lights.

Back round to me after rotating with plenty of equipped lifters and I go for my 125 kg – my current PB. Smashed it. First challenge: what do I go for next? 130 kg and most-likely hit it, or go for a bigger challenge with a 135 kg. The latter it was.

I missed it; spotters caught me and I got red-lighted. I remember the point of no-return: I just couldn’t squeeze it up any longer. That there is a decent learning curve, ’cause when your muscle has done what it can it’s up to your head to manage the rest of the lift, including not quitting.

With the first set of lifts over I joined the rest of my team to watch others lift and wait for the time to warm up for bench.

Bench press
My warm-up for bench went well, so I upped my starting weight by 5 kilos. Another mistake. I went for 90 kg first and aimed — if it felt good — to go for a new PB of 100 kg if I could.

My first bench set comes up and the 90 kg goes up easily. So I set my next-attempt’s weight to 100 kg and sit down trying not to think about it. The time comes again and I’m gearing myself up for a lift. If I don’t hit this attempt I’ll have to hit the third, which potentially wastes a set.

No dice. Twice. I just couldn’t lock the bar out much past my chest. I think some decent tricep work is in order!

By now my total is 125 + 90: 215 kg. Not too impressive. So I ignore it.

Deadlift
This is by far my favourite lift because it’s easy. Plus, you get to whack a little more weight on the bar and it looks cool.

In the gym I hit 160 kg PB with confidence, but my teammates advised me to set your current PB for the second set/attempt and leave the third to the unknown.

I opened with my 3 RM: 145 kg. Piss-easy it was too.

What next? Taking the mistakes with bench into account, I played it safe and went for just below my deadlift PB: 155 kg. Couldn’t have been easier.

Now I had the opportunity to take another gamble at a new PB of 165 kg.

Last lift of the day. Crowd rearing me on, I waddle up and set my feet. Grab the bar with my right hand, test the pull a little. I stand up, big breath, grab the bar and pull…

I nailed it and now I wish I’d gone higher! Another lesson learned.

Conclusion
A fantastic opportunity. I’m very glad I did it. I met some really decent people — the membership secretary, record holders alike — and the encouragement was awesome.

The BDFPA is a good solid organisation with a great set of rules that I agree with (of those I’ve read), a strong no-drugs policy and a great inclusive attitude.

I can’t wait for the next one!

Posted in Powerlifting | Tagged , , , , , , | 1 Comment

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.

Posted in Hacking, Java, Programming, Software Analysis/Design | Tagged , , , , , , , | 4 Comments

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.

Posted in Hacking, Linux, Programming | Tagged , , , , , , , | Leave a comment

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!

Posted in Hacking, Linux | Tagged , , , , , | 1 Comment

Android Preferences and Custom Buttons

I delved into the Preference API for Android this weekend. It turns out that I needed a couple of “buttons” to allow the user to go to the main screen (for various genuine reasons!). The Android API doesn’t let you do it with buttons, but there’s an equally easy way.

I have found that using a combination of a “placeholder” Preference and then providing an onClickListener in the corresponding PreferenceActivity class provides what I needed.

In my instance, I needed a “Save” and “Clear” option in my preference screen, so I added the following PreferenceCatgory in my preferences.xml

<PreferenceCategory
android:title="Manage Your Preferences">
<Preference
android:title="Save"
android:summary="Store your preferences"
android:key="savePref" />
<Preference
android:title="Clear"
android:summary="Clear all your preferences"
android:key="clearPref" />
</PreferenceCategory>

and then inside my onCreate method, I just assigned listeners to the individual clear and save preferences:

findPreference("clearPref").setOnPreferenceClickListener(onPreferenceClickListener);

which is given an instance of my inner `Preference.OnPreferenceClickListener` class:

private class PreferenceOnClickListener implements Preference.OnPreferenceClickListener {
public boolean onPreferenceClick(Preference preference) {
//Do something...
return false;
}
}

easy?!

Posted in Android, Hacking, Java, Programming | Tagged , , , | Leave a comment

LaTeX: coloured boxes with rounded edges

At the moment, I spend a fair amount of time documenting process, code, instructions, whatever; all in LaTeX. I love it.

At some point vanity seeps in. I like to tweak the visual elements here-and-there in order to have a more professional and visually appealing document.

In this particular instance I had exhausted my \subsubparagraphs and having played with various alternatives I decided I wanted a coloured box: much like you see in books for “tip” sections or asides. So I searched and searched the web and it transpires that the best route to follow is through the murky, uncharted (at least for me) depths of tikz! Thankfully it wasn’t that difficult, and I now get a lovely rounded, grey box!

Make sure you’ve got a \usepackage{tikz} and bear in mind this is using \documentclass{article}. Your mileage may vary!


begin{tikzpicture}
\node[fill=gray,rounded corners=5pt,text width=6in] {
This is a "tip" box or similar, that gets nice rounded edges; like you'd see in a real book!
};
\end{tikzpicture}

Posted in Programming | Tagged , , , , | 1 Comment

Ant TODO gets some love

Updated: I’ve added another item to the implemented features below…

Yonks ago I spent an afternoon hacking together a TODO task for Apache Ant; the result of which was Ant TODO.

Now, I hadn’t touched it in a while until a user emailed me asking for some help and some nifty new features. Having returned home from a weekend away with a few hours spare I decided to implement the following:

  1. allow for setting of results to an Ant property, instead of to a file or so-on
  2. support a custom delimiter string for each item
  3. call Ant TODO after JAR’ing Ant TODO (chicken, meet egg)
  4. numerous housekeeping tasks, such as a little refactoring and better test data

You can download the latest version if you like. Feel free to contribute too.

Posted in Build Processes, Java, Programming | Tagged , , , , , , , | Leave a comment