Extracting archive files in Linux

So, you know how to fetch a remote file in Linux, but what do you do if you fetch an archive? How do you extract the files and place them in a directory to work with them?

I previously wrote a how-to guide to fetching a remote file in Linux. That’s great, but once you’ve got the file, sometimes you’ll need to do some more work with it before you can use it.

This is especially true with archive files. Archives generally come in one of two forms:

  1. ZIP files – more commonly used on Windows platforms;
  2. TAR files – more commonly used on Linux and UNIX platforms.

Platforms such as Github and WordPress often offer both ZIP and TAR formats for their downloads.

Once you have the archive file, you need to extract it into a directory. Assuming your file is called wordpress.tar.gz, and you want to extract it to an existing directory called my-site in the same directory, you can use the following command:

tar -xvf wordpress.tar.gz -C my-site/

The -x switch tells tar to extract the files (as you can also use tar to create compressed archives). The -v switch puts tar into verbose mode, so it prints everything it’s doing to the command line, and the -f switch is used in conjunction with the filename to set the file to extract the files from. The -C switch then tells tar to place the extracted files in the directory named at the end of the command.

However, in most cases this will extract the files, but leave the extracted files in a subdirectory. So, in the case of a WordPress archive, the files would be located in my-site/wordpress/ – what if you don’t want the files extracted to a subdirectory?

Not a problem. You can use --strip-components=1 at the end of the command:

tar -xvf wordpress.tar.gz -C my-site/ --strip-components=1

This strips out the top-level directory and leaves the files directly in the my-site folder.

2015-16 NFL Playoffs – Conference Round

Having picked three out of four winners last week, can I pick both winners this week? I hope so. As both number one and number two seeds play each other, on paper at least, it should be hard to separate the teams.

In the Wild Card round, all four road teams won. In the Divisional Round last week, all four home teams won. So, what will happen this week? One home team and one away team?

Perhaps. Here’s how I see the Conference Round games.

New England Patriots at Denver Broncos

Last week, the Patriots hosted the Chiefs, who had won eleven games straight. Although the final score add the game appear close, in truth the Patriots were never really threatened.

The key for the Patriots was that Tom Brady was able to throw quickly, often to Julian Edelman, but also to Rob Gronkowski, and so the Chiefs’ pass rush was nullified. The Patriots didn’t really bother to run the football much. Once the Chiefs were behind, they were always going to find it hard to come back to win.

The Broncos really struggled to get past a Steelers team with an injured quarterback which was also missing its top wide receiver and top two rushers. Trailing for most of the game, the Broncos ground out a result in a game they deserved to lose. Was it the offense that won them the game? No, it was a turnover.

And this is what today’s game comes down to, for me. Denver have shown no ability to generate consistent offense with Peyton Manning as quarterback this year. He has a bad record in the playoffs and a terrible record against Brady’s Patriots (although less so in the playoffs, for the record).

The Patriots don’t turn the ball over much. Fumblers are treated harshly and an Tom Brady interception which isn’t the result of a tipped ball, or that hasn’t been thrown up into the air by a receiver, is headline news. If Denver are going to win today, they need a better gameplan than to wait for the Patriots to turn the ball over. It may happen, but the statistics are against you.

The ratings give this to the Broncos (2.04 to 1.51), but that’s misleading. The Patriots were back to their best last week, and Matt Patricia’s defense will expect to force Peyton Manning into throwing picks. Expect them to goad him into throwing long and taking their chance at picking up the pieces.

Peyton Manning has one touchdown pass at Mile High this season. Tom Brady has three.

Pick: Patriots.

Arizona Cardinals at Carolina Panthers

Arizona won against the Green Bay Packers last week in a thrilling overtime victory. The game was a tight affair until the final quarter, when most of the points were scored. However, despite Aaron Rodgers throwing two exceptional lucky throws at the end of the game, an improvised throw to Larry Fitzgerald on the run in overtime resulted in a huge play, and ultimately, a touchdown, to end the game.

Carolina’s route to the Conference Round was equally eventful, as they led 31-0 at halftime and then let Seattle come back to 31-24 by the end of the game. That’s the second time this season Carolina have taken a huge lead and then let a team come back into the game, although in Seattle’s case, it always seemed like a false hope, from my perspective at least.

So what’s the key in this game? Well, Carolina need to stop Arizona running the ball, and also need to take Larry Fitzgerald out of the game. Arizona need to keep Cam Newton in the pocket and force him to make plays without breaking free.

I was perhaps rash in giving Arizona no chance in this game, but I do still favour the Panthers. Carolina did, however, intercept Russell Wilson twice early on last week, so Arizona need to be careful. The Cardinals’ defense may have a fierce reputation, but the Panthers’ defense is no slouch either. In fact, all four teams left in the playoffs have defenses worth writing home about.

The ratings give this to Carolina (2.42 to 2.41) – it’s the number one home team against the number one road team, and it’s officially too close to call.

Unofficially, this is a matchup of two well-rounded teams, rather than teams littered with stars (although they probably have one each in Cam Newton and Larry Fitzgerald). I’m picking Carolina to win because I think Cam Newton has enough to guide the Panthers home, and it’d be no less than he deserves for his career in the NFL so far.

Pick: Panthers.

Playoff Rankings

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

TeamSeedHomeRoad
Carolina Panthers12.422.11
Denver Broncos12.042.04
New England Patriots22.111.51
Arizona Cardinals22.062.41
Kansas City Chiefs52.041.70
Green Bay Packers51.791.79
Pittsburgh Steelers62.061.38
Seattle Seahawks61.721.72

Printing to a file with PowerShell

I need to print a large number of files to PDF. I don’t have time to open each file individually and do it manually, so I needed to find a way to automate the process. PowerShell provided me a solution, with a little ingenuity.

I’ve been trying to tackle a very tricky issue recently. I have a folder of PDF files sitting in a folder, and on a regular basis, the files in that folder need to be password protected and then moved elsewhere.

Acrobat Pro has a great feature called Actions, where you can set a workflow for documents. Normally, I would pick the folder containing these files and use a saved workflow to encrypt each file with a pre-determined password.

Unfortunately, the contents of some of these files (fillable forms) prevent that workflow from applying properly, meaning some files can’t be password protected in this manner. Since they need to be encrypted, it was important to find another way to do this.

I discovered that if I used a PDF printer to print the file to PDF again, the resulting file could be encrypted without issue. This was a good start, but not of much use if I needed to open each file and print the file manually. I needed something that could be automated. Specifically, I needed to be able to:

  • Automatically select the correct printer;
  • Specify a folder and work through each PDF in that folder;
  • Print each PDF to a file without any interaction during the process (so the output path must also be automatic);
  • Avoid interfering with the default print device beyond this task.

So, I turned to PowerShell and Adobe’s PDF printer (which comes with Adobe Acrobat’s licensed products).

Adobe’s PDF printer is useful because it’s possible to specify a default output directory in the printer preferences, and thus avoid a pop-up appearing for each PDF prompting for a save location. Free PDF printers like CutePDF don’t have this option (although I believe they are available in their paid-for products).

After that, everything can be done in PowerShell. Here’s the code I wrote:

$defaultprinter = Get-WmiObject -Query "SELECT * FROM win32_Printer WHERE default=$true"
$PDFprinter = Get-WmiObject -Query "Select * From Win32_Printer Where Name = 'Adobe PDF'"
$PDFprinter.SetDefaultPrinter()
Dir C:\test\*.pdf | Foreach-Object { Start-Process -FilePath $_.FullName -Verb Print }
$defaultprinter.SetDefaultPrinter()

The first line retrieves the current default printer. This is so that, at the end of the task, the default printer is restored (it will be changed for the duration of this task).

The second line retrieves the Adobe PDF printer. On my computer, it’s called “Adobe PDF”. If the named printer doesn’t exist, the script will return a horrible looking error and fail (I’ve no real need for error handling in this script).

The third line of this script sets the Adobe PDF printer from the second line as the default printer.

The fourth line of the script takes a specified directory and, for each PDF in that directory, prints the document. As the default printer is the Adobe PDF printer, that’s the printer that is used. In the Adobe PDF printer, I’ve already set a couple of options:

  • Disabled the option to show the PDF as it’s created (I want the task to run in the background as far as possible);
  • Specified an output directory where the PDFs will be saved to;
  • Set the PDF quality settings (in this case, “Standard”, for compatibility).

The final line restores the default printer, as it’s not likely I would want the Adobe PDF printer set as the default printer.

For me, that’s not the end of the process as I then need to go back in to Acrobat and encrypt the files, but the PowerShell script makes this a much quicker process than it would otherwise be.

I’d love to be able to encrypt the files from the same script, but unfortunately I’ve not found a way to do that. Nevertheless, a time-consuming problem made easier.

Automating Linux website creation

I create a lot of test websites. Sometimes it’s for testing new things, other times it’s for testing upgrades. I’ve always found it’s a hassle to set a new website up, so I’ve tried to automate it.

Back in the days of shared hosting, setting up a new website was easy. It was as simple as:

  1. Set your nameservers to those of your web host;
  2. Log in to their system (usually cPanel) and click something like “New domain” or “New subdomain”.

Since I moved to using a VPS, it’s not as easy as that any more. Firstly, I use CloudFlare, so I use their namservers. Secondly, I don’t run cPanel, or Plesk, which is similar. There are two reasons I don’t use them:

  1. They make hosting more expensive, as they require licences;
  2. They further increase cost as they require much more powerful servers to run.

Currently I can run my VPS for about $5 per month. If I used cPanel or Plesk, they would cost about $50 per month. So, if I can do without, it’s a big saving.

Setting up a new website

There are a few things required in setting up a new website (I won’t cover setting up a VPS – that’s another series I’m working on):

  1. You need a user to own the files;
  2. You need to create the required directory structure and set permissions on it;
  3. You need to create a MySQL user and password;
  4. You need to create a MySQL database and control permissions to it;
  5. You need to set up the web server to make the address reachable.

I’ll assume the DNS is set elsewhere, or using a hosts file. I use Nginx as my web server.

That’s quite a few things to set up, and it would be easy to miss something or get a step wrong. Even if you get it right, it will take a few minutes. The longest part is usually setting up the web server – especially with Nginx that configuration is set centrally and isn’t easily overridden outside of that.

One day I got bored of doing it all manually, so I wrote a Bash script to take care of it. It’s not perfect, but it does a decent job. I decided I’d make it available via GitHub.

Currently, I make a folder it /opt/ and call it something like website-creator. I can run it as follows:

sudo bash /opt/website-creator/create-website.sh

When run, it does the following:

  • Prompts for the fully qualified domain name (FQDN) which will be used to access the website when it’s live;
  • Checks a folder for that FQDN doesn’t already exist (in a pre-determined folder);
  • Prompts for the Linux user who should own the folder for that website;
  • Checks to see if the user exists, and creates the user if it doesn’t;
  • Prompts for MySQL admin credentials;
  • Once authenticated, prompts for a database name;
  • Creates the database;
  • Checks for a MySQL user with the same name as the Linux user which should own the files, and creates a user with that username if it does not exist;
  • Gives that user access to the database which has been created;
  • Creates the folder structure (I use public, private, logs and backups);
  • Copies index.html and 404.html files to the web root for that site;
  • If necessary, creates a file with the MySQL password for the newly-created user and places it in the private directory, with read-access to the owner only;
  • Changes the owner of the website folder structure to the Linux user previously specified (including the file with the MySQL password);
  • Copies a template Nginx configuration to the sites-available directory;
  • Runs a search and replace on that file to insert the domain name and root directory;
  • Activates the site (placing a symbolic link in sites-enabled);
  • Reloads the Nginx configuration;
  • If necessary, prints to the screen the password of the new Linux user.

It’s not perfect, but it does mean I can set up a working website in five seconds, rather than five minutes. There are, of course, some things that may need to be changed once it’s done, like modifications to the site’s Nginx configuration, but without changing anything, it will happily serve static and PHP content.

There’s also a file where runtime variables can be stored. At the moment, it has two:

  • WEBROOTFOLDER – this is the folder the website directories will be created in (I use /usr/share/nginx/);
  • NGINXCONFIG – this is where the Nginx configuration is stored (in Ubuntu, that’s /etc/nginx/, but it may be different on other systems).

It makes my life a lot easier. Maybe it will help a few other people too.

2015-16 NFL Playoffs – Divisional Round

The Wild Card round was unusual in that all the road teams had significant playoff experience (especially at quarterback), and ultimately that showed as all four home teams were knocked out. Can we expect the same this week? I doubt it,

My predictions last week proved to be a little hit and miss.

The Seahawks beat Minnesota, but it most definitely was a contest, and they needed the Vikings to miss a (usually) relatively easy field goal in extreme cold in order to come out on top.

The Packers beat Washington in a game I said was very tough to call, and it was only because they found great form in the second half they managed to pull the win off.

I said everything pointed to a Chiefs win (but couldn’t bring myself to pick and Andy Reid team to win), and they did. Even more comfortably than anyone really thought. The Texans shut out at home – the only home team to be shut out this season.

And I picked the Steelers to beat the Bengals. I said it was theirs to lose, and they nearly did lose it. However, having thrown away a big lead, the Bengals couldn’t then take advantage as they managed to throw the game away in spectacular fashion later on. In amusement terms, it ranks with the Colts’ miserable excuse for a play on 4th and 3 against the Patriots earlier this season.

So, what’s on the divisional round card for this week?

Kansas City Chiefs at New England Patriots

Normally, this would be an easy game to call. The Patriots rarely lose at home, and the Chiefs, despite their eleven game winning streak, would not normally be seen as a team to fear in the AFC.

However, having annihilated the Texans last week, and with the Patriots winning only two of their last six, this becomes a tough game to call. On paper, The Patriots have the advantage (2.115 to 1.701). They are third-ranked at home, and the Chiefs are ninth-ranked on the road.

The Patriots have lost once at home this season, to the Eagles (twelfth-ranked on the road) in a game decided by special teams rather than offense and in a game where the Patriots were ravaged by injury.

The Chiefs run the ball well. Alex Smith can scramble and run well, and he looks after the football. They have beaten Denver on the road this season, but Tom Brady and Peyton Manning are very different propositions.

The Patriots will struggle to get many takeaways and may struggle if they fall behind. However, they should play better than in recent weeks, having had a week off. They’ve had a number of players injured who should now be healthier – Tom Brady, Julian Edelman and Danny Amendola on offense, and Dont’a Hightower on defense.

With New England at home, Edelman back and an extra week to prepare, I think there’s enough here for the Patriots to win. Plus, the last time Brady played the Chiefs, he was benched in one of the worst New England performances in living memory. He’ll be out for revenge.

Edelman is the key. It’s not so hard to beat the Patriots if you only need to focus on one top receiver. However, it’s much harder when you have to focus on two. Brady needs to get the ball out quickly and Edelman is the man he’ll be looking for.

I’d be foolish to go against the Patriots, and I won’t. But I’m not confident about it. Whoever wins, they’ll fancy their chances next week.

Green Bay Packers at Arizona Cardinals

This is an intriguing game. The Packers have struggled in the second half of the season, but they rediscovered their form in the second half against Washington last week. Their success seems to be linked to their ability to run the ball well. When they can do that, they pass the ball better too.

The good news for the Packers is that Eddie Lacy will likely play against the Cardinals. The bad news is that Davante Adams won’t. The Cardinals, of course, have had a week off to prepare and rest…

And that’s probably a good thing. They really struggled against the Seahawks in week 17, so a week to get that out of their system was probably needed. Green Bay’s offense, whilst better last week, is probably still one of the weaker ones in the playoffs overall (unless they show more consistency this weekend), and their defense is not anywhere near as strong as Arizona’s.

The rankings give this to Arizona (2.236 to 1.788) and I’d agree with it. However, Arizona’s loss to the Seahawks does just make me wonder a little, as does Green Bay’s second half performance last week. I still think Arizona will win fairly comfortably – by at least ten points.

But I still don’t give them a hope next week.

Seattle Seahawks at Carolina Panthers

I’ll be straight to the point. This, for me, is the game that most likely gives us this year’s Super Bowl winner. Seattle are the most likely team to beat Carolina out of all the teams left. If Carolina win, they’ll fear no-one. If Seattle win, they’ve beaten the best home team in the league this season. Part of me really wants to see a Patriots – Seahawks rematch, but I think that’s unlikely. Of course, we could see a Denver – Seattle rematch too…

Anyway, the Seahawks have been on fire towards the end of the season, despite their fortunate escape last week. However, their reliance on that fortunate escape was in part down to the exceptionally cold weather they were playing in.

This week, Marshawn Lynch will likely play. Will he play the whole game? No-one knows. But if he plays, he should be fresh. He should be a big presence in the game if he’s on the field.

The Panthers are favoured here (2.267 to 1.719) but the Seahawks have a mean rush defense, and can burn any team through the air or on the ground. It’s strange to say it given Seattle’s history and the Legion of Boom, but I think the key to this game is how the Panthers pass the ball. They’ll need to pass well to win the game, and I think Seattle are vulnerable there. But it’s a very dangerous approach and can go very wrong…

The Seahawks have given up one offensive touchdown in their last six road games. This won’t be a shoot-out. The statistics say Carolina should win. I say Seattle will somehow manage to grind this out. But the winner will go to the Super Bowl, and whoever they play, they’ll be favourites to win it.

Pittsburgh Steelers at Denver Broncos

This one, for me, is an easy pick. The Denver Broncos will win, even with Peyton Manning starting. On paper, they have a comfortable advantage (2.042 to 1.375).

The Steelers will be missing their top rusher (Le’Veon Bell) and receiver (Antonio Brown) and the quarterback will be playing with a separated shoulder.

On the other side, the Broncos have one of the strongest defenses in the league, have two healthy rushers who have been competing for carries all season, and a healthy array of receivers.

This will be a comfortable win for the Broncos, even with the second and third-best quarterbacks in the game. And whoever they play next week, it will be an intriguing game.

Playoff Rankings

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

TeamSeedHomeRoad
Carolina Panthers12.422.11
Denver Broncos12.042.04
New England Patriots22.111.51
Arizona Cardinals22.062.41
Kansas City Chiefs52.041.70
Green Bay Packers51.791.79
Pittsburgh Steelers62.061.38
Seattle Seahawks61.721.72

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.