Why I’m Switching From Google To Bing

Google’s been shit for quite a while now but today I’m finally sick of it, so switching.

Why I'm Switching From Google To Bing 1

Do they think I typed out the word barcelona for my health or something? Or maybe I’m using the Internet wrong (does the Internet actually come with a manual?). So they just decided, again, to drop one of the words I’m searching for, that give my search context, from the first results they provide. Ok, I could quote it. OR .. if I actually wanted matches that dont contain the word Barcelona i could prefix it with a – sign, so fuck that as an excuse.

Why I'm Switching From Google To Bing 2

Where as Bing actually gives me results that match what I’m searching for.

I don’t really have a choice in this matter, Google just flat out doesn’t work as a search engine any more with out jumping through extra unnecessary hoops that actually make it harder to use.

It’s one thing to try and make using search engines easier or more natural, it’s another thing to assume your users are so dumb that the right thing to do is discard 50% of the fucking characters they enter.

SSH Over TorBrowser

SSH Over TorBrowser 1 The hotel in Thailand that I’m currently staying in is for some inexplicable reason blocking SSH, randomly. 6 hours ago it was working fine, but now when I need to do some work it’s decided to block me. At least that’s what I think is happening as all other requests work fine. I think it’s using some deep packet inspection too, as moving to another port also doesn’t work.

Anyway, the way round this is our friend, Tor. There are lots of ways to install Tor, but I like to have my Mac relatively clean of cruft, so I’ve opted for the TorBrowser bundle, which doesn’t come with any of the usual Tor utilities like proxychains, tsocks or torify.

Netcat is installed by default on a Mac though, and Netcat is the BOMB, and you can use it to proxy SSH over the Tor instance that comes with TorBrowser!

Provided TorBrowser is installed, running and connected, the following will let you proxy SSH over it:

ssh -o ProxyCommand=’nc -x 0:9150 %h %p’ example.com

Please note that the TorBrowser port has changed from 9050 to 9150, if you’re running a really old version of Tor you should probably update anyway.

And you thought netcat was just for reverse shells!

Is This The Most Important Script You’ll Ever Write?

Is This The Most Important Script You'll Ever Write? 1 Since my first IT job ever, I’ve taken part in a tradition started by the guy I was replacing. A tradition known to us as escape.pl, and something people in my local Linux Administrator community have kept with for well over a decade now.

The Most Important Script You’ll Ever Write?

The first time I saw it it was written in Perl, I’ve since written them in Bash, Java and now Javascript. I’ve just seen one written in AWK. Some are cleverer than others, some just do the bare minimum. Some are executed by hand, others are run each time a new terminal is opened thanks to .profile, .bashrc or whatever’s managing your shell environment.

Well What Does It Do?

Quite simply the most important script you’ll ever write calculates the difference between two dates. Today, and your last day of work. The day you escape.. Where to? Who knows, perhaps a new job, a new country, either way somewhere significant!

Mine is currently a node.js app, and it has a bug, it hasn’t taken in to account a bank holiday, but it does the job.

free:~ rus$ node escape.js
Escape in 18 days.
Working days left: 15

Another takes in to account even minutes so he knows how long he’s waiting!

16:03 < woduf> 004 days, 00 hours, 57 minutes

How complicated you want to make the most important script you’ll ever write is up to you, but the sentiment remains the same!

Examples Of The Most Important Script You’ll Ever Write


function workingDaysBetweenDates(startDate, endDate) {

// Validate input
if (endDate < startDate) return 0; // Calculate days between dates var millisecondsPerDay = 86400 * 1000; // Day in milliseconds startDate.setHours(0,0,0,1); // Start just after midnight endDate.setHours(23,59,59,999); // End just before midnight var diff = endDate - startDate; // Milliseconds between datetime objects var days = Math.ceil(diff / millisecondsPerDay); // Subtract two weekend days for every week in between var weeks = Math.floor(days / 7); var days = days - (weeks * 2); // Handle special cases var startDay = startDate.getDay(); var endDay = endDate.getDay(); // Remove weekend not previously removed. if (startDay - endDay > 1)
days = days - 2;

// Remove start day if span starts on Sunday but ends before Saturday
if (startDay == 0 && endDay != 6)
days = days - 1

// Remove end day if span ends on Saturday but starts after Sunday
if (endDay == 6 && startDay != 0)
days = days - 1

return days;

var date1 = new Date();
var date2 = new Date("08/29/2014");
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
console.log("Escape in ", diffDays, " days.");

var workdays = workingDaysBetweenDates(date1, date2);
console.log("Working days left: ", workdays);


Thanks to woduf for the following awk snippet!

awk 'BEGIN { print strftime("%j days, %H hours, %M minutes", mktime("2014 08 15 17 00 00") - systime() - 89940) }'


Thanks to xhae for the following HTML/JS combination!



Thanks Huw!

#!/usr/bin/perl -w

use strict;
use Date::Manip;

my $leave = "14th June 2013";
my $escape_date = ParseDate($leave);
my $day = ParseDate("today");
my $count = 0;

do {
$day = DateCalc($day, "+ 1 day");
} while (Date_Cmp($day, $escape_date) < 0); print "Only $count day",$count>1?"s":""," to go\n\n";


Thanks woduf. Note, this works fine on Linux/GNU but not so fine on Mac/BSD

d=$(($(date +%s -d '2013/09/27 17:00:00') - $(date +%s))); echo "Escape in $((d / 86400)) days, $((d % 86400 / 3600)) hours"

Have you ever written an escape.pl? Whether you love your job or hate it, changing job can be a significant life decision and it helps to add fun to the seriousness of it! Please send me examples of your most important script and I’ll add it to the list!

yum error: Couldn’t fork Cannot allocate memory

Yum Couldn't Fork Cannot Allocate Memory I’ve been doing some awesome things to a new VM for work, namely installing CouchDB, Apache and running Node.JS apps along side a WordPress plugin using Angular.JS. It’s pretty cool. But computer’s are dicks so when it came down to installing Monit to ensure everything was lovely I got the following error: Couldn’t fork %pre(monit-5.5-1.el6.rf.x86_64): Cannot allocate memory. Bum.

error: Couldn’t fork %pre(monit-5.5-1.el6.rf.x86_64): Cannot allocate memory

Seem’s simple enough, for whatever reason Yum cannot allocate memory, so lets take a peak

root@bridge opt]# free
total used free shared buffers cached
Mem: 1020376 832736 187640 0 3988 81256
-/+ buffers/cache: 747492 272884
Swap: 0 0 0

Man there’s totally enough memory there, 187MB of RAM is free, Quake took less than that and is way more complicated than some stupid RPMs.. maybe it’s something else!

Quite often this error is caused because the RPM database has duplicates or got corrupted in some way, so lets try and clean that up.

[root@bridge ~]# package-cleanup --cleandupes
Loaded plugins: fastestmirror, protectbase
Loading mirror speeds from cached hostfile
* base: mirror.checkdomain.de
* epel: mirrors.n-ix.net
* extras: mirror.checkdomain.de
* rpmforge: mirror1.hs-esslingen.de
* updates: mirror.checkdomain.de
1490 packages excluded due to repository protections
No duplicates to remove
[root@bridge ~]# rpm --rebuilddb

Well no duplicates and the RPM database is all cool, so lets try again ..

[root@bridge ~]# yum install monit
Loaded plugins: fastestmirror, protectbase

Running Transaction
Error in PREIN scriptlet in rpm package monit-5.5-1.el6.rf.x86_64
error: Couldn't fork %pre(monit-5.5-1.el6.rf.x86_64): Cannot allocate memory
error: install: %pre scriptlet failed (2), skipping monit-5.5-1.el6.rf
Verifying : monit-5.5-1.el6.rf.x86_64 1/1

monit.x86_64 0:5.5-1.el6.rf


Man, haters gonna hate!

Solving error: Couldn’t fork %pre(monit-5.5-1.el6.rf.x86_64): Cannot allocate memory

Ok, lets step back a minute and assume the error is legit, lets turn some stuff off ..

[root@bridge ~]# /etc/init.d/couchdb stop
Stopping database server couchdb
[root@bridge ~]# /etc/init.d/httpd stop
Stopping httpd: [ OK ]

And try again!

[root@bridge ~]# yum install monit
Loaded plugins: fastestmirror, protectbase

Downloading Packages:
monit-5.5-1.el6.rf.x86_64.rpm | 267 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : monit-5.5-1.el6.rf.x86_64 1/1
Verifying : monit-5.5-1.el6.rf.x86_64 1/1

monit.x86_64 0:5.5-1.el6.rf


Sweet that did it. So it was a bonafide legit error and shutting some services down freed up enough memory to allow us to install RPMs again.

root@bridge ~]# free
total used free shared buffers cached
Mem: 1020376 510972 509404 0 11632 146780
-/+ buffers/cache: 352560 667816
Swap: 0 0 0

mmm 509MB free, thats a lot more.. I guess Yum actually needs a ton of RAM to actually do anything. Weird. If you guys get this problem, try turning some services off and on again 😉

The Albert Burger – Best Burger in Brighton?

Cheese and Bacon Burger at The Albert It’s rare that I’m genuinely in shock and awe of something, but that’s how I felt last night in The Albert, down under Brighton train station!

The menu came with a crazy amount of options, so for the burger I added bacon and cheese and for the chips, thick cut rather than skinny and chilli and cheese. Not chilli cheese mind, as that was a separate option, as were the beef brisket, hash browns, onion rings, guacamole etc etc etc TOO MANY CHOICES! The entire thing came to £10 on the nose.

I’m actually feeling bad writing this up, as the photos don’t do the burger justice. They don’t show the perfectly cooked centre of the meat, the delicious crisp of the chips and the amazing tenderness of the brisket (at least I think it was brisket, the menu just said ‘chilli’…)! I should probably do one of those Internet courses on food blogging and photo taking or something 🙁

Cheese and Bacon Burger at The Albert

The burger came with real bacon, the kind of bacon you’d be proud of, and the chilli on the chips? Not the minced beef and stewed kidney bean chilli I was expecting, rather a phenomenal slow cooked beef brisket flavoured with a deliciously spicey concoction.

The entire thing was awesome. Could this be the best burger in Brighton? It’s definitely the best one, hands down, that I’ve had in 2014.

Speeding Up MDADM RAID Rebuilds

Speeding Up MDADM RAID Rebuilds I’m slowly migrating a bunch of awesome things from a really old server, it’s still running Ubuntu 10.04.. to a really nice and shiny one. Which has 2 new 3TB HDDs in RAID 1, which are syncing..

cat /proc/mdstat
md3 : active raid1 sda4[0] sdb4[1]
1847478528 blocks super 1.2 [2/2] [UU]
[>....................] resync = 0.1% (2061952/1847478528) finish=28857.9min speed=1065K/sec

That’s like 40 days of syncing.. surely we can do better than that? Can’t we speed up this MDADM RAID 1 rebuild?

Speeding Up MDADM RAID Rebuilds

Sure we can, we’re awesome, I’m awesome, you’re awesome, can I get a hell yeah? HELL YEAH!

Likes lots of things that are tuneable, we have to do NASTY things to /proc. This bit sets the minimum speed we want mdadm to go at.

cat /proc/sys/dev/raid/speed_limit_min

We’re greedy though and in the words of Tim Tool Time Taylor, MORE POWER. As root..

echo 50000 > /proc/sys/dev/raid/speed_limit_min

We’ve just made mdadm run FIFTY TIMES faster. FOR FREE. We didn’t even swap out the SATA disks for SAS SSDs, we just changed a number ..

md3 : active raid1 sda4[0] sdb4[1]
1847478528 blocks super 1.2 [2/2] [UU]
[=====>...............] resync = 26.0% (480866560/1847478528) finish=141.9min speed=160501K/sec

Now 10 minutes later we’re already over 1/4 the way through, 2 hours left baby. Hell yeah.

authorized_keys vs authorized_keys2

authorized_keys vs authorized_keys2 Earlier today I was setting up a brand new server for a migration and just as I was typing scp .ssh/authorized_keys2 my brain went and asked a question..

What is the difference between authorized_keys and authorized_keys2?

I’ve been working with Linux for well over a decade and some of my practices stem from things I learned in the ’90s that still work, putting all my public keys in ~/.ssh/authorized_keys2 is one of those things.

authorized_keys vs authorized_keys2

In OpenSSH releases earlier than 3, the sshd man page said:

The $HOME/.ssh/authorized_keys file lists the RSA keys that are permitted for RSA authentication in SSH protocols 1.3 and 1.5 Similarly, the $HOME/.ssh/authorized_keys2 file lists the DSA and RSA keys that are permitted for public key authentication (PubkeyAuthentication) in SSH protocol 2.0.

Which is pretty self explanatory, so that’s what the key difference in the files were originally, authorized_keys for RSA in SSH 1.3 and 1.5 and authorized_keys2 for 2.0

What is the difference between authorized_keys and authorized_keys2?

However, that’s from releases of OpenSSH earlier than 3.0, which was released in 2001, a long time ago.. looking back at the OpenSSH 3.0 release announcement authorized_keys2 is now actually deprecated. We should all just be using authorized_keys instead from now (er, 2001..) onwards!

do-release-upgrade Checking for a new Ubuntu release No new release found

My HTPC is almost appliance like, in the way I never upgrade it, i.e. this morning it was still running Ubuntu 11.04 Natty Narwhal… It’s also not very appliance like in that it’s also full of random development stuff that probably shouldn’t be on it as well as several different types of databases, my backup infrastructure and tons of other things you really don’t care for.

But not today. Today I was bored and decided the best use of my time was to replace MythTV with XBMC. Not only that, I figured I should probably upgrade from

      Ubuntu 11.04 (Natty Narwhal)
      Ubuntu 11.10 (Oneiric Ocelot)
      Ubuntu 12.04 LTS (Precise Pangolin)
      Ubuntu 12.10 (Quantal Quetzal)
      Ubuntu 13.04 (Raring Ringtail)
      Ubuntu 13.10 (Saucy Salamander)

That’s a lot of upgrading. It would have probably been better for me to just install 13.10 ..

But when I got to Pangolin, the 12.04 LTS EVERYTHING WENT WRONG!

rus@relax:~$ sudo do-release-upgrade -p
Checking for a new Ubuntu release
No new release found

OMG I hear you cry, much like I did. WHAT IS THIS??? I tried everything, apt-get update, turning it on and off again, throwing things at the TV, I even went outside and bought a coffee. None of the above worked. This was because I was stupid.

do-release-upgrade Checking for a new Ubuntu release No new release found

The reason for the error was because I’d arrive at an LTS release. And the do-release-upgrade configuration had changed to now *stick* to LTS releases and not upgrade any more. So as the new 14.04 LTS isn’t out yet (as we’re not in the future, dummy) it couldn’t find anything to upgrade to.

The fix is to tell the computer to just upgrade to the next release and not be so stubborn by editing /etc/update-manager/release-upgrades

# Default behavior for the release upgrader.

# Default prompting behavior, valid options:
# never - Never check for a new release.
# normal - Check to see if a new release is available. If more than one new
# release is found, the release upgrader will attempt to upgrade to
# the release that immediately succeeds the currently-running
# release.
# lts - Check to see if a new LTS release is available. The upgrader
# will attempt to upgrade to the first LTS release available after
# the currently-running one. Note that this option should not be
# used if the currently-running release is not itself an LTS
# release, since in that case the upgrader won't be able to
# determine if a newer release is available.

See how it says Prompt=lts? THATS JUST RUBBISH! Change it from lts to normal then rerun do-release-upgrade. Theres a good boy!

Honey Beer Bread

Beer Bread Recipe I gave up drinking 3 months ago, but still have a fridge full of beer which I didn’t want to pour down the sink, so I decided to make something with it. I found My Fridge Food, which is an awesome little site that will take the contents of your fridge and cupboards and suggest recipes! A lot of the recipes were rubbish, poached eggs,

Beer Bread Recipe

I found this honey beer bread recipe from Michelle’s awesome Brown Eyed Baker blog, and armed with a bottle of Desperado totally destroyed my kitchen.

Beer Bread Recipe

Like, completely destroyed it. Flour, everywhere. Mostly on me. But an hour later, I took out of the oven some delicious beer and honey crack.