Raspberry Pi: mount network share after reboot

Posted: October 15th, 2015 | Author: | Filed under: Raspberry Pi | Tags: | 1 Comment »

I bought another Pi, primarily because the web interface on my Seagate NAS is so terrible that I thought I’d access it with Tonido instead, and at £30 another Pi seemed like a no-brainer.

After a couple of not-relevant-here teething troubles with Tonido, I encountered a problem. I’d mounted the NAS fine on the Pi following these instructions but the drive wasn’t remounting on reboot, despite telling /etc/fstab to do so.

It turns out that the Pi runs /etc/fstab before the network has necessarily come up, thus trying to mount a resource that isn’t available yet.

The best solution I have found to this is joan’s solution on stack exchange. By using crontab to tell the Pi to wait 30 seconds before attempting to mount the share it allows time for the network to come up.

Several reboots later, the share has always been there.

Thanks, joan!

The Audiophile Fallacy

Posted: November 2nd, 2014 | Author: | Filed under: Audio | No Comments »

Kirk McElhearn has a great series of articles debunking audiophile myths over at his blog, Kirkville.
Here’s the latest – The Audiophile Fallacy.

Base href, the simple solution

Posted: October 13th, 2014 | Author: | Filed under: HTML, Internet, PHP | No Comments »

I’ve been grappling for a while with a problem. The site I’d created, due to using mod_rewrite to create URLs that didn’t actually exist, was creating a virtual folder structure that meant that I was having to create specific sidebars and navigation elements that included the right level of linking.

This being a PHP site, I’d tried to resolve this by using variables such as $_SERVER[‘PHP_SELF’] to try and automatically resolve the server address to provide a relative file path, but this had mixed results.

Turns out that the answer was the not frequently mentioned base html tag – this is a tag that I was sort of aware of, but had forgotten. Indeed, an otherwise excellent HTML book I read the other day didn’t even mention it…

Simply adding

 <base href = "http://thesiteinquestion.com" /> 

to the site made included headers, sidebars etc instantly portable, no matter the folder depth.

Of course, this being a PHP site, I set the base URL in my site’s config file i.e.

$baseurl = "http://thesiteinquestion.com";

then called that in my site header:

 <base href = "<?php echo $baseurl ?>" /> 

so I only have to change the config file for different servers/environments.

Android vs Android

Posted: July 18th, 2013 | Author: | Filed under: Uncategorized | No Comments »

Interesting article here from Slate.com.

The gist is that Android is actually a great mobile OS, and is only blighted by the handset manufacturers and carriers. Well, stop me if we haven’t seen that before. I’ve spent years doing clean installs of Windows to get rid of all the crap-ware pre-installed on consumer PCs. It’s probably fairly obvious that I’m an Apple chap, but I’ve constantly been amazed by how well a clean install of Windows works.

Every time I’ve used an Android phone – generally when a friend is trying to show it off to me – I have put it down/given it back within 30 seconds due to the horrifying software experience (not to mention the generally cheap as shit hardware). But I’d be really interested to try out a pure Google Android phone without the crap.

The Nation State

Posted: May 23rd, 2013 | Author: | Filed under: Apple | No Comments »

Some years ago I read “The Business” by the excellent, and sadly terminally ill, Scottish author Iain Banks. The premise of this novel is that there is a shadowy, ancient, global organization with fingers in every pie who are using their wealth and influence to buy a nation to get their own seat at the U.N.

A couple of years later, as Apple’s cash pile grew, I began to wonder if that was what was Apple was up to (along with wondering if the “spaceship” HQ was actually a spaceship).

I’m the first to admit that I’m an Apple fanboy, and I believe Tim Cook when he says that Apple have paid a huge amount of tax (and have paid more than they could have avoided), but the lesson from this is interesting – the greatest amount of power comes from being nation-less. It’s almost the same as having your own nation. To have ultimate power, you either have your own nation (which is a fanciful fiction) or you devolve from nationality entirely.

Apple vs. Wall Street

Posted: January 24th, 2013 | Author: | Filed under: Apple | No Comments »

Yesterday Apple reported profits of $13.1 billion for the last quarter, on revenue of $54.5 billion (a new record, for the record). Whilst this is less of a profit margin than in previous quarterly reports, it is still the fourth-biggest quarterly earning of any company in corporate history, and added to the results for the previous three quarters marks the biggest annual earning of any company anywhere in the world ever.

Wall Street reaction – shares drop 10%.

Apple made more in the last quarter than Wall Street darlings Amazon have ever made in total, full stop. Apple now has more cash reserves than the US government. Apple is making more money, faster, than any company has ever made. Apple is now so big that a 10% stock drop is worth as much as the value of two competitors, Nokia and RIM, added together and doubled.

Yet despite all this, the stock dropped 10%.

I have no evidence to support this, but the only conclusion I can draw from this is that someone, or some organisation, is trying to make a hell of a lot of money by deliberately shorting Apple stock. In all of this, that’s the only thing that adds up.

Using mod_rewrite for a Christmas frontpage

Posted: December 15th, 2012 | Author: | Filed under: .htaccess, Internet, mod_rewrite, Programming | No Comments »

I needed to add a quick splash to our homepage to give an update on our Christmas opening hours.

I added a quick jQuery pop-up to our index.php, then saved that as index_xmas.php.

Then it’s a simple matter of adding a line to our .htaccess file:

Redirect 302 /index.php http://www.domain.com/index_xmas.php

All requests to index.php are now sent to index_xmas.php.

The “Redirect 302” code tells the browser that the redirect is temporary and that it should continue to use the regular URL.

After Christmas all I have to do is remove that line from the .htaccess to resume normal service.

Quick thoughts on today’s Apple Event

Posted: October 23rd, 2012 | Author: | Filed under: Apple | No Comments »
  1. Fusion Drive is, like so much other Apple technology, existing tech sprinkled with Apple fairy dust. But if it’s as good as they’ve spun it it sounds amazing.
  2. Lots of people are saying that the iPad mini is too expensive. ROFL. Come back to me with that when they’ve sold 80 gazillion.
  3. They’re keeping their new Spaceship campus (suspiciously) quiet. I still believe that it really is a spaceship, but now suspect that they recently hired Red Bull to conduct a feasibility study into safe vehicle-less escape.

Converting MYSQL DATEs for PHP

Posted: July 30th, 2012 | Author: | Filed under: Internet, MYSQL, PHP, Programming | No Comments »

A site I am working on stores the date of new entries to the database by using MYSQL’s CURDATE() function. So if we’re adding a new entry with the make, model and date to the database, the SELECT query looks like this:

"INSERT INTO table_name (make, model, date) VALUES ($make, $model, CURDATE())"

This works fine, but when I then query the database, like so:

"SELECT make, model, date FROM table_name WHERE ..."

The date returned is in MYSQL’s date format, which is YYYY-MM-DD.
I was looking around for a quick and easy way to convert this in PHP to the UK DD-MM-YYYY format, and kept coming up with longwinded ideas for converting the MYSQL date to a UNIX timestamp, and then using all kinds of guff to format this as required.
It turns out the answer’s much simpler than that, if you use MYSQL’s DATE_FORMAT function. By passing in your date column and the format in which you want it presented you can create a new variable to query. So the previous query becomes:

"SELECT make, model DATE_FORMAT(date, '%d/%m/%Y') as formatted_date FROM table_name WHERE ..."

The %d/%m/%Y part is where you define how the date should be formatted. Dan Winchester has an excellent and comprehensive list of options on his website.

Now, instead of your PHP looking like:

$make = $row['make'];
$model = $row['model'];
$date = $row['date'];

it becomes:

$make = $row['make'];
$model = $row['model'];
$date = $row['formatted_date'];

thus returning your date information nicely pre-formatted by MYSQL.

Mod_rewrite on BT Business hosting

Posted: July 23rd, 2012 | Author: | Filed under: .htaccess, BT, Internet, mod_rewrite, Programming | No Comments »

I was banging my head earlier with a mod_rewrite problem. The site in question is to be hosted on BT Business hosting. My mod_rewrite rules were running perfectly on my local MAMP environment, and on my test environment at Dreamhost. But it kept crapping out at BT.

Solution – it turns out that BT’s hosting needs the RewriteBase condition filled in. In my situation I was running the test software in a directory called ‘test’ so I needed to add

RewriteBase /test

to my .htaccess file.

When I move it out of ‘test’, to the full domain, I will modify .htaccess to

RewriteBase /

Hope that saves you a bit of head-scratching!