Category Archives: Tech

Nginx: Redirect everything except the home page

Recently I moved this blog to philipjohn.blog, making philipjohn.me.uk a sort of “homepage” pointing to my various online presences.

Previously, my blog was at philipjohn.me.uk so as well as changing the URL (which was made easy by WP-CLI) I need to redirect all philipjohn.me.uk URLs to philipjohn.blog.

However, I wanted the root of philipjohn.me.uk to show a special page, not redirect to philipjohn.blog.

After much Googling and some help from Nicola Heald I finally had a working Nginx config:


server { listen 80; listen [::]:80; server_name philipjohn.me.uk; root /var/www/philipjohn.me.uk/www/; index index.html; location = /index.html { try_files $uri $uri/ =404; } location ~ ^/.+$ { return 301 http://philipjohn.blog$request_uri; } }

They key bits are the two location blocks. The first uses location = /index.html because Nginx interally redirects requests for the root into an index file, according to the index directive.

That first location block has the effect of telling Nginx to look inside the root folder for the index.html, or return a 404.

The second location block only then gets called if the request is not for the root index.html file. This block simply grabs the request string and passes it onto philipjohn.blog.

Simple! (And only took me several hours to get right 😉 )

Fitbit Surge – one month in

In December I started wearing a Fitbit surge (a work perk) and wanted to share my thoughts/experience.

  • Steps seem largely accurate, although as you might expect it’s not so great at counting them when you’re pushing a pushchair! However, I have managed to achieve my steps target (7k per day) whilst;
    • walking up to bed
    • driving my car
    • cooking Christmas dinner
    • stirring my pasta
  • Heart rate is *not* very accurate. Given this is something the Fitbit Surge is supposed to be very good at, and Fitbit advertise it as being accurate, it’s disappointing. I noticed it was reporting well below my actual bpm whilst on an excercise bike at the gym. It turns out, I’m not the only one – Fitbit are facing a class action lawsuit over it.
  • Floors seems like a lot of nonsense to me. I don’t see how it’s accurate or useful.
  • Battery life is woeful, compared to what Fitbit claim. It lasts about two days for me.
  • I love that I can connect to my phone while playing music to see what’s playing, pause or skip tracks. However, I’ve had to stop using it because it massively drains the power.
  • Tracking cycling works, for the most part, and the GPS seems accurate. GPS does drain the battery quickly though.
  • Through the app you can choose from a number of different types of exercise to make available on the Fitbit Surge. However, it’s unclear what some of these are, or the difference between them and there is *no* documentation to explain it. I’ve read in forums, for example, that “spinning” and “workout” do the same thing.
  • The vibrating alarm is nice at first but I find it all to easy to just ignore. If you ignore it, it stops and doesn’t do anything else other than leave the alarm display on. I’d expect it to, like my phone does, automatically snooze and keep on going until I turn it off.
  • The app isn’t terrible intuitive. There’s a lot in it, and it’s kind of hard to know where to go. You get used to it, and once you do there’s a ton of info there. It’s the primary way to look at what you’ve been up to, and it gives you all the info you need.
  • Being a cyclist I like to link it up to Strava and that works really well.
  • I like that you can set a goal other than steps. Calories, for example.
  • When I’m in my car, my phone connects to it via Bluetooth. But if I have the Fitbit connected to my phone the car can’t connect. It’s probably the car’s fault because the Bluetooth on that is crap, but it’s frustrating none the less.
  • From the start I’ve had call and text notifications on so I can see from the Fitbit Surge who is calling or texting me. It’s never worked, but I just got it working a couple of days ago… :shrug:
  • I’ve tracked exercise bike workouts as “spinning” and while the calories seems right, the steps don’t. For example, a 40 minute workout that burned 334 calories only added 25 steps and was classed as 32 active minutes. My heart rate was pretty accurate during that too.

State surveillance is not comparable to online privacy issues

Often, when opposing state surveillance such as that revealed by Ed Snowden, activists are questioned why they use online services that actively collect data about them. There is one core reason why this comparison is unhelpful and irrelevant.

“You are the product” goes the saying, which is true. Companies like Google and Facebook collect streams of data about who we are and what we do. Some have called this “self-surveillance”.

When we “self-surveil” and grant companies the ability to use – and sell – our data, we expect – and get – something back. We get a service. We pay a small privacy price (largely inconsequential, I’d argue) in exchange for a service.

On the other hand, the state demands we let them take our data. They chose warrant-less mass-collection over targeting, leaving us in the dark about what they’re collecting. We get nothing in return – there is yet to be a convincing case, backed up with evidence, that the mass surveillance of the citizenry in any way makes us safer.

There is one, undeniably crucial difference however.

The state has the power to use that data against us in a devastating way.

We can be detained, without charge, for fourteen days – the longest pre-charge detention period of any comparable democracy. Previously this limit was 28 days, and there was an attempt to raise it to 90 – that’s 3 whole months of being locked up for being a suspect.

Outside of detention, the state has the power to severely limit our activities with only “suspicion” as a reason, destroying the presumption of innocence until proven guilty.

I don’t see any social networks able to limit my civil liberties…

Image: CC-BY-SA George Rex

Embedded tech can be implanted in brains, thanks to new power technique

Re: Wearable tech can be implanted in brains, thanks to new power technique

That title has it wrong – it’s not embedding wearable tech, it’s just embedded tech.

I’ve been saying for a while that I’m not interested in wearable tech like “smart watches” -it’s embedded tech that excites me, and this innovation is a great move forward in that area.

Idea: A re-usable framework for “Who Should I Vote For?” tests

Those “Who Should I Vote For?” sites are, I think, a great idea. Many of them fail though. They;

  • often miss out huge policy areas (e.g. Europe)
  • often just copy/paste from manifestos making it easy to see which party is which
  • over simplify questions or provide limited answer choices that don’t always match views
  • become out of date and are slow to be updated

I’d like to propose we (anyone with the inclination to help me) build a framework for creating such tests that we can use again and again.  I have an idea how we can do it.

It needs to be;

  • Open source and collaborative (obviously!)
  • Easy for anyone (i.e. non-developers) to contribute to improving the policy questions

Here’s what I propose;

1. Agree/disagree questions

In order to determine the political leanings of the user without revealing actual policies we should use questions to which the answer has to be one of five choices;

  • Strongly Agree
  • Agree
  • Neither
  • Disagree
  • Strongly Disagree

Each political party will then be attached to one of those five answers. For example, consider the proposition “The UK should leave the EU” to which the matching would probably be;

  • Strongly Agree – UKIP
  • Agree – Conservatives
  • Neither
  • Disagree – Labour
  • Strongly Disagree – Liberal Democrats

For each matching answer, a “point” will be given to that party, and at the end of the survey those points will be used to generate percentage “matches” to each party. E.g. if the user was Nick Clegg you’d hope he achieved a 100% match to the Liberal Democrats, and lesser percentage matches to some other parties too.

2. Markdown for question and answer generation

So that anyone can help to contribute, the questions and the matching of parties to answers should use Markdown. The application would then parse the markdown to generate the actual questions and calculate the points based on the answers given.

This is an example of how that Markdown might look.

It’s not great for parsing, but should be straightforward for contributing too. I’m very open to ideas on a better format, in any case.

 

So, what do you think? Is it a good idea? Is it workable? Will you help me build it?

WordPress fork is happening – and it looks amazing!

Obviously I’m a huge WordPress fan, but I’m not a blind believer. I can see it’s limitations, I’m well aware of it’s growing pains. That’s why, when John O’Nolan first presented his concept for Ghost I was excited.

While WordPress evolves into a CMS from a blogging platform (and it still has a long way to go!) it necessarily looses the simplicity it had as a pure blogging platform. John’s brainchild was to provide something that returned to those first principles.

Now the project is actually coming to life. John and his team have a great introduction and they’re seeking backers through Kickstarter. I’ve pledged.

One big thing that draws me in are the principles that John talks about in the introductory video. One of my constant bugbears around other open source project, WordPress included, is the ownership – structures that often do not reflect the spirit of open source, and we see the impact time and time again.

John is committed to making sure that Ghost is open source and non-profit and that that follows through to the entire eco-system that will surround Ghost.

I can’t wait!

Update: just two hours after this post was published (and a while after I actually wrote it!) I’ve had an e-mail from John O’Nolan along with all the other backers. Ghost is over 120% funded. Phenomenal! It’s got incredible backing – WooThemes, Envato, Seth Godin and many more influential tech folk. This could really be something…