How to screw up your Ubuntu server

Ever wondered how people learn how to solve things? Well, sometimes you just have to break it first. Pro tip: just make sure you don’t break it on something important. Lucky for you – and me – I remembered that bit.

I know, I know, this isn’t really what you’re meant to do. The idea of a guide is to do something useful, to solve a problem, to help people do something quicker, or better… but sometimes, it doesn’t work like that. Sometimes, things happen that give you problems.

Well, I managed that today, so I thought I’d share it. It was – strictly speaking – a work thing, but on a test server that had nothing on it, and already had a slight problem, and I had a feeling it might not go to plan, but I thought I’d try it anyway.

We have a Ubuntu virtual machine which is used for occasional testing for two websites we look after internally, and it turned out the virtual machine’s network connection stopped working because of an issue on the host. Thus, the server was suddenly not a whole lot of use.

The easiest thing to do, given there was next-to-nothing on the server, would beat to boot from the Ubuntu 16.04 ISO (the server was there to test PHP 7 on 16.04) and start again. It would take no more than 20 minutes to get the server back to where it was. However, the alternative was to remove the virtual network card from the virtual machine and assign it a new one. Well, with nothing to lose, it was worth trying, out of curiosity to see what would happen…

Ubuntu kernel panic

It turns out, it caused a kernel panic and wouldn’t finish booting. It would definitely be quicker to reinstall, but that’s essentially what would happen if it was a real box, the NIC failed and you had to install a new one.

I’m currently debating how curious I am, and if it’s worth seeing how easy it is to resolve an issue like that. I guess it would be nice to know I’d be able to fix it, but I’m currently tempted to take the lazy route.

2015-16 NFL Playoffs – NFC Wild Card

Having already looked at the AFC playoff contenders yesterday, today is the turn of the NFC teams. Can the Carolina Panthers win with homefield advantage? Will the Seattle Seahawks continue their hot run? Can the Green Bay Packers rediscover their form? Time will tell…

By the time this post is published, the AFC wild card games will be done, so my views may well look very silly. Going by my predictions in recent years, there’s a very good possibility of that – my record of picking winners in the playoffs has been hit-and-miss. However, it’s not going to stop me, here are my thoughts on tonight’s NFC games and the bye week teams.

Seattle Seahawks at Minnesota Vikings

According to my rankings, and the NFC seedings, the Vikings should be the favourites in this game. Their overall ranking leads the Seahawks (1.968 to 1.719), and when accounting for home/road rankings, this lead increases (2.146 to 1.719).

However, don’t be fooled. The Seahawks started the season badly, losing four of their first six games (to the Rams, Packers, Bengals and Panthers). However, they’ve lost only twice since then (to the Cardinals, and the Rams again). In that stretch, they’ve also beaten three playoff teams – the Cardinals, Steelers and Vikings. Thus, their record against playoff teams this season stands at 3-4. However, in week 10 it was 0-4, so it’s clear to see which direction they’ve been heading in.

Now, the Vikings. They’re not a bad team, but they are flattered by their #3 seeding. They have a 6-2 record at home this season, but the two they lost, they lost heavily. Both those losses were against playoff teams (Green Bay, Seattle). Both were in the last six weeks. Oh, yes? Have you joined the dots yet? The Seahawks didn’t beat the Vikings in Seattle. They beat them in Minnesota. They beat them 38-7.

The Vikings are 2-4 against playoff teams this season. When they’ve won, it’s been close – the game against the Packers in week 17 was their clearest win, and that was settled inside the two minute warning. The two games they’ve lost, they’ve been outscored 68-20.

No contest.

Green Bay Packers at Washington Redskins

This is an intriguing game. The Redskins are, according to my rankings, the weakest team in the playoffs, but they’re up against a team that’s struggled in the second half of the season, but without much cause. Yes, Jordy Nelson is out, but he has been for the whole season. Their QB is healthy, and a secure starter, their running back is healthy, and so are their other wide receivers, yet they can’t score.

Whilst the Patriots have stumbled into the playoffs having lost two running backs, a third of their defense, most of their offensive line and at one point, their top two wide receivers and tight end, the Packers have no such players to welcome back as the playoffs progress. This is as good as it gets – and it starts from a worse position.

That said, they’re probably better on the road than at home right now. They’ve won three of their last four on the road, one of them against playoff contenders (Minnesota).

Washington, on the other hand, can’t always be trusted at home. They lost in week 1 to Miami, and have won 6 or the last 7 at home, but lost at home to the Cowboys in week 13 – a result that would make the shortlist for shock road win of the season.

Put with that, they’ve really not had any strong opposition to play at home this season. Only the New York Jets have had an easier home schedule. Thus, the faltering visitors meet the untested hosts. And, of the four games this weekend, this is the only one where the teams haven’t met this season. A tough one to call.

The Redskins are 0-2 against playoff teams this season (both road losses) and the Packers are 4-3. However, the Packers’ last two games were both against playoff teams, and they lost by a combined 58-20. I’d like to see the Packers win, but current form says the Redskins should do it.

Bye week: Carolina Panthers

The Carolina Panthers top my rankings this season. It’s easy to see why. They went 15-1 in the regular season, losing once once, to the Atlanta Falcons on the road in week 16. This will probably help them, as no-one is now talking about an undefeated season – an unwelcome distraction gone.

Only once did they score less than 20 points, and that was against the Falcons. They scored 37 points or more 7 times. They kept their opponents to less than 20 points 8 times, including a shut-out against the Falcons in week 14. It’s easy to see why they went 15-1. They also beat the Texans, Seahawks, Packers and Redskins along the way.

No-one visiting Carolina will be favourites, and the only team I can see winning there is the Seahawks. Of course, if the Seahawks beat the Vikings this weekend, the road to the Super Bowl would then likely go through Arizona, with Seattle having already beaten Arizona in week 17…

Bye week: Arizona Cardinals

Ah, yes. Arizona. This team finished second in my rankings, and for most of the season, they too have scored freely. They’ve scored 30 points of more 9 times, and forty points or more 4 times, although the quality of those teams was towards the lower end of the rankings.

They’ve beaten the Packers, Vikings, Bengals and Seahawks, but lost to the Steelers. But, more to the point, they were crushed at home to the Seahawks in week 17. I know they didn’t play their starters for the whole game, and they claim they weren’t trying to win the game, but the Seahawks were crushing them before the starters were benched. If they play the Seahawks in the playoffs (which could only happen in the NFC Championship game), I don’t see them winning.

Unfortunately for them, not playing the Seahawks likely means playing the Panthers – unless Minnesota win against Seattle and the winner of the Redskins – Packers game beats Carolina. That’s a very long shot…

Sorry, Arizona. Your route to the Super Bowl is just too hard.

NFC Rankings

For reference, the following table shows the rankings for each of the NFC teams in the playoffs, with their playoff seeding, home and road rankings.

TeamSeedHomeRoad
Carolina Panthers12.422.11
Arizona Cardinals22.062.41
Minnesota Vikings32.151.79
Washington Redskins42.041.02
Green Bay Packers51.791.79
Seattle Seahawks61.721.72

2015-16 NFL Playoffs – AFC Wild Card

This weekend is the opening weekend of the playoffs. Which teams will make it through to the divisional round and play against the top seeds in their conference? This preview looks at the AFC contenders.

With the regular season over, it’s now win-or-go-home for the twelve teams remaining. Eight of those teams play this weekend in the wild card weekend. I’ll look at the AFC teams first, since they play on Saturday, with the help of some statistics I’ve compiled over the course of the season.

Kansas City Chiefs at Houston Texans

The Houston Texans won their division with a 9-7 record this season – the weakest record of the AFC division winners. By contrast, the Chiefs took the fifth seed with an 11-5 record and for a while in week 17 looked like they might win their division, as Denver struggled to beat the Chargers with the division (and #1 seed) on the line. Moreover, having started 1-5, they won their last ten games – the longest winning streak in the league by a long way. So, given their hot streak, and Houston’s weak division record, are the Chiefs destined to win?

Well, according to my rankings, the Chiefs are the better team (1.873 to 1.517). However, when looking at the home/road rankings, it’s much closer. The Chiefs still edge it, barely (1.701 to 1.684). That’s a margin of 0.017. Twenty-three games have featured teams this close so far this season. Home teams are 9-14 in those games. This includes two road wins for Houston (Jacksonville in week 6 and the Colts in week 13). Kansas also lost a home game to Denver in week 2.

Oh, and the Chiefs and Texans also played once – in week 1. The Chiefs won by 7. On the road – a repeat of this game! So, in tight games featuring these teams, road teams are 4-0. Good luck, Houston… That game in week 1 was the only time this season the Chiefs have been slim favourites in a road game, or that Houston have hosted a road team who are.

Verdict: It all points to a Chiefs win, doesn’t it? So I’ll pick the Texans.

Pittsburgh Steelers at Cincinnati Bengals

The Steelers and Bengals have looked great and awful in equal measure at times this year, and it’s been the same cause for both: their quarterback. Big Ben has been phenomenal on the whole when fit, and the Bengals looked unstoppable before Andy Dalton attempted a tackle and broke his thumb.

Otherwise, teams both have struggled, which has also affected their ratings. The Bengals have a higher rating (2.063 to 1.719), but accounting for home/road rankings, it’s 2.063 to 1.375. So, Bengals to win?

Yeah, just one problem with that. Andy Dalton won’t be playing. Throw all the stats you like at me, I don’t think the Bengals can beat a Steelers team (even at home) that has Big Ben and Antonio Brown, when all the Bengals have is a backup at QB. One and done they will be – for a fifth straight year. Ouch.

Don’t believe me? Well, despite their stellar home rating, the Bengals have lost at home twice this season, both times to AFC playoff opponents – Houston in week 10, and, in week 14, the Pittsburgh Steelers. They did beat two other playoff contenders – the Chiefs in week 4, by 15, and the Seahawks in week 5, by 3, but both those teams were really struggling at that point.

This is the Steelers’ to lose.

Bye week: Denver Broncos

According to my rankings, the Denver Broncos are second to the Bengals in the AFC (2.063 to 2.042). However, with Andy Dalton out, they should be the de facto #1 team – if it weren’t for their Peyton vs Brock battle at QB. It’s hard to know which option is better, but they’ve gone with Peyton Manning for now. Time will tell. They have homefield advantage, but according to the rankings, they are equally good at home as on the road.

They have lost at home – to the Raiders, and more notably, the Chiefs, and the Chiefs will visit Mile High if they win against the Texans and the Steelers lose to the Bengals.

Most interestingly, Denver’s home games are close. Aside from the loss to the Chiefs (by 16) and the victory over Green Bay (by 19), their other 6 games have been won by a total of 25 points. Just over 4 points a game isn’t much for a #1 seed.

They’re beatable.

Bye week: New England Patriots

The Patriots started well, and should have secured the #1 seed. However, injuries hampered them in the last few weeks and that’s made their job potentially a little harder. The key for the Patriots is to get their starters healthy. If that happens, they are the most likely winners of the AFC. If it doesn’t (especially Julian Edelman), they have no hope.

The Patriots average over 30 points a game at home. They lost only once – to the Philadelphia Eagles, in a game affected by a combination of key injuries and abysmal special teams. Even then, they only lost by 7. They have beaten two other playoff opponents on home turf – the Redskins by 17, and the Steelers by 7 in the very first game of the season. They also beat the Jets by 7.

However, they haven’t played a tough game at home in the second half of the season, so they have a lot to prove. But would you bet against them? I wouldn’t. But the key is getting starters back from injury.

AFC Rankings

For reference, the following table shows the rankings for each of the AFC teams in the playoffs, with their playoff seeding, home and road rankings.

TeamSeedHomeRoad
Denver Broncos12.042.04
New England Patriots22.111.51
Cincinnati Bengals32.062.06
Houston Texans41.681.35
Kansas City Chiefs52.041.70
Pittsburgh Steelers62.061.38

Fetching a remote file in Linux

Downloading a file to your computer, only to upload it to a server, is time consuming, especially if it’s a large file. Why not just download it from the server using the command line? It’s a lot easier than you might think.

Sometimes you need to download a file from a remote location. I can think of a couple of quick examples:

  1. Fetching a data feed published by an external source;
  2. Downloading a package (e.g. WordPress) to avoid downloading it to your computer and uploading it again from there.

In the first instance, being able to download the file from your server makes you a step closer to automating the process (e.g. if the feed is updated, say, once an hour). In the second instance, it’s much faster as it’s a one-step, rather than a two-step, process. And it’s really easy, using a package called wget, which supports downloads over HTTP, HTTPS and FTP:

wget -O /path/to/filename url

The -O switch controls where the resulting file will be saved, and the URL is the file to be fetched. If only a filename (no path) is entered, the file will be saved to the current directory set in the terminal. For example:

wget -O latest-wordpress.tar.gz https://wordpress.org/latest.tar.gz

This command would fetch the latest copy of WordPress from the WordPress servers and save it at latest-wordpress.tar.gz in the current directory.

One thing to be aware of: the switch (-O) is case sensitive. It must be upper case.

The wget command has a large array of other options at runtime, but for simple cases like fetching and saving a single file, this is all you need.

2016 Political Predictions

Want to know everything about politics in 2016? Well, you won’t get that here. But I can tell you what I think will happen, and we can all laugh at how bad those predictions were come the end of the year. Or probably in March, to be honest.

The start of a new year is always a great time to make predictions which will ultimately be shown at the end of the year to be entirely misplaced.

That’s certainly true in politics. Who would have predicted a Conservative majority government at the start of last year. Well, me, actually… But I wouldn’t have predicted Jeremy Corbyn would be Labour leader… Or that Jim Murphy would be such a disaster as leader of Scottish Labour.

So,here are some predictions for 2016. Most revolve around the Scottish elections, since that’s what’s mostly on my radar right now.

The SNP will win a majority in the Holyrood elections
There’s nothing I can think of that can stop this. The question is, can they win a majority on constituency MSPs alone? They would need to pick up twelve of the twenty constituency seats they don’t currently hold in order to do this. I think it’ll be very close.

The Conservatives make gains on Labour
I don’t see Labour holding all thirty-seven seats they currently have. They currently hold fifteen constituency seats. Good luck.

The Conservatives, on the other hand, will, I think, gain a small handful of seats, mainly on the list. They’ll gain on Labour more because Labour lose seats rather than by gaining their own, but I think it will be a bit of both.

The Greens will finish with more seats than the Liberal Democrats
The Lib Dems will struggle. I think they’ll pick up a single constituency seat and a few on the list. The Greens won’t win any constituency MSPs, but they’ll win more on the list, because they’ll pick up pro-indy, anti-SNP votes. I’d be surprised if the Liberal Democrats get 5% of the vote.

I would say Willie Rennie will no longer be their Scottish leader, but will there really be anyone there to replace him? I think it’ll be grim for the Liberal Democrats, despite the outward optimism they seem to have now.

Britain will vote to remain in the EU
I know Brits are hardly fond of the European Union, but I don’t think people will be prepared to take the risk of leaving when faced with the choice in a referendum. When making a choice, thinking about factors like jobs and money in their pockets, people will stick to what they know. They won’t want to take the risk.

Don’t believe me? Well, it was the same with Ed Miliband.

Jeremy Corbyn will survive as Labour leader
Getting rid of Corbyn would result in full-scale civil war. Labour MPs will decide to let him continue to poll badly, rather than stick the knife in quickly. It’s probably safer.

Hillary Clinton will win the US Presidential race
This will happen for the simple reason that no-one can beat her to the Democratic Party nomination, and all the Republican Party candidates that might do well are crackpots can’t reach out to enough voters. That, in essence, is the problem the Republican Party has at every election at the moment.

London will get a new mayor
But I’ve no idea who. London mayoral election’s are a mug’s game. I think it’ll be the tightest mayoral election yet, though. If forced to make a prediction, I’d probably pick Sadiq Khan, based on gut instinct and nothing else.

NFL 2015-16 Power Rankings

With the playoffs fast approaching, how do the teams stack up against one another, and who should we be looking out for on the road to Super Bowl 50? Well, the good news is, I can point you in the right direction (with a little explanation of how I got there).

For the last few seasons, I’ve published my own version of the popular NFL Power Rankings that appear on a number of sites. On most sites, these seem to be calculated arbitrarily, whereas I’ve tried to produce something that adds at least a slightly more scientific approach. What follows is an explanation of the method, but if you just want to see the rankings, they’re at the bottom of the piece.

It’s worth noting, before reading further, that I’ve adjusted my rankings formula again, so if you’ve read my rankings in previous years, they’re not directly comparable.

Finding common games

This approach is made a little tricky by the way the NFL organises schedules, but not impossible. No team plays the same sixteen opponents across the regular season, but in each division, every team plays a similar schedule across fourteen games:

  • Home and away against each team in their own division;
  • Once against each team in a designated NFC division;
  • Once against each team in a designated AFC division.

There are some differences in that schedule, as the combination of games played at home and on the road is different, and the final two games are unrelated, based against each team’s relative performance in the previous season, but it’s a good start. Thus, I base my Power Rankings on those fourteen common games, ignoring the two outside that.

Comparing divisions

As games are only common within divisions, I need a way to compare divisions. I do this by comparing the number of total wins in each division, as each division. Whichever division has the most wins is the strongest division (for now, at least). It’s the mark by which all the other divisions are marked. All other divisions are then assessed based on their relative percentage of wins. If the division with the highest number of wins has forty wins, and therefore has a relative strength of 100%, a division with thirty wins would have a relative strength of 75%.

Matching divisions

Whilst a good start, this is still very crude. What if a division had fewer wins than another because the divisions it was matched up against were actually very tough? What if a division Was matched against two weaker ones, and so had an easier ride?

Well, this is relatively easy to solve, as each division is matched against two others. So, by combining each division’s relative strength with that of the two it was matched against, I can calculate an overall division strength, and I do this by adding the three values together. Thus, carrying the previous example, if the top division has forty wins, and it’s up against two divisions with thirty wins each, the formula would be:

1 + 0.75 + 0.75 = 2.5

The resulting figure of 2.5 is the division’s overall schedule strength. A higher number means a tougher schedule. This value is then, for each team multiplied by their record as a decimal value, where 16-0 would equate to 1, or 12-4 to 0.75. The resulting figure is the team’s final ranking.

The final formula

So, the final formula (when fully expanded) looks like this:

(D + A + N) * R

Where:

  • D – Division strength
  • A – AFC opponent strength
  • N – NFC opponent strength
  • R – Record

Whilst form is important enough to be in, I reduce its weighting because I consider the overall division strength and record to be a more reliable indicator.

The rankings…

So, without further ado, here are the 2015-16 NFL Power Rankings (as of week 16):

TeamScheduleRecordOverall
Arizona Cardinals2.7350.8672.372
Carolina Panthers2.3820.9332.223
Cincinnati Bengals2.7350.7332.005
Denver Broncos2.7060.7331.983
New England Patriots2.3820.8001.906
Green Bay Packers2.8530.6671.903
Minnesota Vikings2.8530.6671.903
Kansas City Chiefs2.7060.6671.805
Seattle Seahawks2.7350.6001.641
Pittsburgh Steelers2.7350.6001.641
New York Jets2.3820.6671.589
Washington Redskins2.7060.5331.442
Houston Texans2.6760.5331.427
St Louis Rams2.7350.4671.277
Atlanta Falcons2.3820.5331.27
Oakland Raiders2.7060.4671.264
Indianapolis Colts2.6760.4671.25
Detroit Lions2.8530.4001.141
Chicago Bears2.8530.4001.141
Buffalo Bills2.3820.4671.113
Philadelphia Eagles2.7060.4001.082
New York Giants2.7060.4001.082
New Orleans Saints2.3820.4000.953
Tampa Bay Buccaneers2.3820.4000.953
Baltimore Ravens2.7350.3330.911
Jacksonville Jaguars2.6760.3330.891
Miami Dolphins2.3820.3330.793
San Fransisco 49ers2.7350.2670.73
San Diego Chargers2.7060.2670.722
Dallas Cowboys2.7060.2670.722
Cleveland Browns2.7350.2000.547
Tennessee Titans2.6760.2000.535

I’ll likely write a separate post about the various methodologies I’ve used to calculate the Power Rankings, and why I’ve changed them along the way. I’m also open to refining the formula and also to know if any of the teams look out of place in these results!

Wondering why I’m publishing this before the final regular season games? I’m doing it because I want to see how the rankings stack up against the week 17 games. Not entirely scientific, I know, but interesting all the same.

Truncating a file in Linux

Linux has a very useful and easy command when you need to keep a file but empty the contents of the file. Very useful when developing or testing and you only need to look at data in real-time.

When I’m working on websites, I often have a need to empty an existing file.

The most common need for this is when looking at error logs. When I’m working on something, I always keep a close eye on the error logs and when I find a problem, I fix it. I then clear the error logs to see if the error reappears. I have no real need to archive or rotate the log. I just want it cleared so next time I open the file, I can see anything that’s new without the need to wade through what was there previously.

It’s very easy to do this, using the truncate command:

truncate -s 0 /path/to/file

If the logged-in user doesn’t have permission to modify the file you’ll need to run the command as the super user:

sudo truncate -s 0 /path/to/file

The truncate command is used to shrink or expand a file to a specified size, and the -s 0 switch tells it to empty the file.

Very useful for situations where you have files like logs where you don’t need to keep the data once you’ve looked at it.

New year, new site

Sometimes, you need to make a clean start. I’ve neglected my website a lot over the past few years, so I’ve decided to start again in 2016. I’m sure you won’t like everything on it, but hopefully you’ll find some of it at least a little interesting!

Many years ago, when I was a student (and yes, many is the correct term for that now), I had a very active website – mainly because I had a lot of free time and a lot to say. Unfortunately, times change, and over the last few years, the amount of content on said site has dwindled, almost to zero.

I’ve often thought to myself, “I’ll just redesign it nicely, and then I’ll start using it properly again“. Of course, that never happens. And so, I’ve bitten the bullet, so to speak, and decided to do it the other way round. The old site will be burned to the ground (at some point) and this new site will go in its place. It will look nice and pretty if I ever get around to it, but for now I’m just focusing on using it.

My main focus subjects will be:

  • Eurovision – you know I love this, right?
  • Faith – something I’m rubbish at writing about;
  • Politics – you know, that thing no-one cares about, until it impacts them?
  • Sport – American Football, Formula 1, and anything else that takes my fancy;
  • Technology – probably a mixture of things related to my day-job and server-side website bits too.

It’s unlikely all five of those categories will interest many people, but hopefully at least a couple will interest some.