Archive for June, 2015

Speeding up Leeds Restaurant Guide

Friday, June 12th, 2015 | Limited, Programming, Tech

restaurant-guide-website

Leeds Restaurant Guide is incredibly detailed covering so many restaurants with high quality content and imagery. So it seemed only fitting that I should pay as much attention to the presentation as I do the content.

I’ve been using Google’s PageSpeed Insights tool to debug it. Ironically, PageSpeed Insights spends a lot of time complaining about the Google AdSense code that they provide to me. It does however provide some useful tips too.

Compression

Gzip compression costs almost nothing and can drastically reduce the file size you are sending to the client. The server compresses it and the client uncompresses it all of which is done transparently to the user.

It is pretty easy to configure using Apache’s mod_deflate module, and I’ve blogged about how to get it working on cPanel on Hardware Tutorials.

Expiry headers

If you have Apache’s mod_expires, and you almost certainly do, you can set default expiry headers for content using your .htaccess file.

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 60 minutes"
    ExpiresByType image/jpeg "access plus 1 day"
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/png "access plus 3 months"
</IfModule>

This will tell the client it can safely cache the content for a while. Put whatever values in that you think are sensible.

Minify your CSS

Recently I wrote about how to use Gulp to set up a task to compile your SASS/LESS stylesheets. This included instructions on how to minify your CSS. Even if you are just using plain old CSS, you could still create a task to create a minified version.

Minification takes out all the spaces, comments and other unrequired characters so that you have less data that needs to be transferred to the client.

Using Gulp to compile stylesheets

Thursday, June 11th, 2015 | Limited, Programming, Tech

gulp

If you’re doing a lot of CSS in your web development, you may have taken to using SASS or LESS to allow you to better organise, code and maintain your stylesheets. These are both great tools. However, the one thing that annoys me is having to remember the command to compile them, given it is often different for each project.

Luckily Gulp, a Node-based task runner, can come to the rescue.

This has the added advantage that you can also pipe it through other tools, allowing you to create maps and minify the CSS all in one command that makes it super easy.

Firstly, you need to add the dependencies so that NPM knows what to install.

{
    "devDependencies" : {
        "gulp" : "*",
        "gulp-sass" : "*",
        "gulp-minify-css" : "*",
        "gulp-sourcemaps" : "*"
    }
}

You can then run NPM install to get all the modules you need. If these are the only modules you are using you will probably need to modify your .gitignore file to ignore the node modules directory.

node_modules/

Now we can create a gulpfile.js in the root of our project directory that will define the tasks we want to run.

'use strict';
 
var gulp       = require('gulp');
var sass       = require('gulp-sass');
var minifyCss  = require('gulp-minify-css');
var sourcemaps = require('gulp-sourcemaps');
 
gulp.task('sass', function () {
    gulp.src('./sass-files/*.scss')
        .pipe(sourcemaps.init())
        .pipe(sass().on('error', sass.logError))
        .pipe(minifyCss({compatibility: 'ie8'}))
        .pipe(sourcemaps.write('./sass-maps'))
        .pipe(gulp.dest('./stylesheets'));
});
 
gulp.task('sass:watch', function () {
    gulp.watch('./style/*.scss', ['sass']);
});

The first task creates a “gulp sass” command that takes the SASS file, converts it to CSS, minifies it, builds the source map and then writes it out. I’ve set the compatibility to ie8, though it could also be ie7, and defaults to ie9.

The second task creates a “gulp sass:watch” which watches the files for changes and then calls the first task whenever it detects a change.

If you are using LESS you will need a slightly different set of dependencies.

{
    "devDependencies" : {
        "gulp" : "*",
        "gulp-less" : "*"
    }
}

The tasks are slightly different too, but basically do the same thing.

'use strict';
 
var gulp = require('gulp');
var less = require('gulp-less');

gulp.task('less', function () {
  return gulp.src('./app/resources/less/*.less')
    .pipe(less())
    .pipe(gulp.dest('./app/webroot/css'));
});

gulp.task('less:watch', function () {
    gulp.watch('./app/resources/less/*.less', ['less']);
});

The end result of this is that rather than remembering what the specific paths for any project I want to work on, I can create a Gulp task and simply run “gulp sass” or “gulp less”. I could even just rename them to “gulp css” to use the same name on every project I work on.

A Storm of Swords: Part 1 Ice and Fire

Wednesday, June 10th, 2015 | Books

A Storm of Swords is the third novel in the Song of Ice and Fire series. However, I haven’t actually read it, I have only read part 1 because it is so amazingly long.

Good though. Nothing really happens, it’s just people marrying each other. This is good if you enjoy the chess of politics, though perhaps does not live up to the name – there is no storm of swords. There is quite a detailed description of people dying in gibbet cages if your worries about a lack of gore though.

How exactly it is two separate books is unclear. It ends right in the middle of a story. It feels a lot more like cashing in on having able to sell two products than even a vague attempt at pretending there are two parts.

Storm of Swords part 1

The Great Gatsby

Tuesday, June 9th, 2015 | Books

What was this book even about? I have no idea how this is considered one of the greatest literary works of the twentieth century. Modern Library voted it the second best novel! Better than Brave New World, Catch-22, Nineteen Eighty-Four, The Grapes of Wrath and yes, even Battlefield Earth.

The story follows a young man named Nick and his interactions with his mysterious next-door neighbour Jay Gatsby who throws the best parties in Long Island. However, the story gradually reveals how Gatsby is slightly more than a one dimensional character, but not that much more.

The Great Gatsby

iWoz: Computer Geek to Cult Icon

Monday, June 8th, 2015 | Books

iWoz, autobiography of Steve Wozniack, has a very long subtitle: “How I Invented the Personal Computer, Co-Founded Apple, and Had Fun Doing It”. It’s also quite a bold statement for someone as reserved as Woz.

The first half of the book looks at his childhood and college days. His dad was at the forefront of the transistors game and was a firm believer in science, which no doubt gave Woz an excellent start in life. When he says he knew more about chip design than anyone else in the world, it’s not arrogance, it’s probably true.

He is an unashamed geek. He talks about his quest to get the best phone number he can – we wanted all the digits to be the same. I read this wondering “is this really important? Is this something you want to devote so much of your book to?”

Apparently it is, as it was packed with details like this. Apple only gets mentioned in the second half, and it’s pretty brief.

It also gets quite technical at many points. Chances are they if you are reading the Great and Powerful Woz’s biography, you are in the computer game, so that probably makes sense, but some of it I struggled to follow so a non-technical person would be lost.

My favourite anecdote from the book was when he talked about confusion between his number and the airline Pan Am’s. He started taking bookings for them (he would eventually tell the customer he was joking). He tried to see what they would agree to – multiple stops, travelling in cargo, 36 hour flights. The surprise is that most people agreed to all of this if it would get the price down! No wonder budget airlines have boomed, consumers will put up with a lot to save some cash.

iWoz

My favourite books

Sunday, June 7th, 2015 | Books

books-array

Have you ever wondered what my favourite and most influential books are? The answer is to that question is almost certainly no. However, I was making a similar list for books I might want to re-read if I ever get somewhere near finishing my reading list, and decided it would be nice to stick it on my website too.

Fiction

  • Isaac Asimov. The Foundation series is probably my most-read fiction books. I also like the Robot and Galactic Empire books which all form into one universe.
  • Nineteen Eighty-Four by George Orwell. This used to be my favourite book because at its heart it is a love story. Wrapped in a terrible dystopia, so well thought out that we often struggle to distinguish it from the world we live in today, despite the horror of it. Blog post.
  • Brave New World. A lot of people confuse Aldous Huxley’s futuristic novel for a dystopia. It’s clearly a utopia because it creates a world where everyone is happy. If you’re not happy, that’s fine too, you get to go live on an island. What could possibly be wrong with that? Blog post.
  • John Steinbeck. The Grapes of Wrath is done an injustice to every time it fails to top any literature list. Also check out East of Eden, Of Mice and Men and Travels with Charley.
  • James Joyce. Ulysses is worth a crack just to see if you can read it. For large stretches of that novel, I had no idea what was going on. The fire and brimstone preaching in A Portrait of the Artist is immense, too.
  • Terry Prachett. How much joy has one man delivered the world? 40 Discworld novels with another one on the way, and many non-Discworld books too. I am sure that like me, many of you were heartbroken when Pratchett passed away in 2015.

Non-fiction

  • The Four Hoursemen of Sam Harris, Dan Dennett, Christopher Hitchens and Richard Dawkins. Harris offers some good stuff on morality; notably The Moral Landscape and Lying. I also like Unweaving the Rainbow (Dawkins), God is Not Great (Hitchens) and Consciousness Explained (Dennett).
  • Religion For Atheists by Alain de Botton. His book shows us how we could design secular society to utilise the many truths and good ideas that can be found in religion. Blog post.
  • The Purpose Driven Church. Rick Warren is a man who knows how to run a church. Even if you are running a secular organisation, or any community organisation, This book is a source of inspiration for how to do it. Blog post.
  • Thinking, Fast and Slow by Daniel Kahneman really started to develop my interest in psychology. Kahneman is so good that he has a Nobel Prize, despite the fact that there is no Nobel Prize in psychology. Blog post. Also check out Duncan J. Watt’s Everything Is Obvious: Why Common Sense Fails Us.
  • The Believing Brain by Michael Shermer. Why do people form irrational beliefs? According to Shermer, it is because all beliefs are formed for personal, social and emotional reasons and the rational reasons only ever come second. Blog post.
  • The Blank Slate. Are humans inherently good and will we reach a state where we are all just nice to each other and live in perfectly fair, honest and utopian societies? No. I would like to believe we would, but Steven Pinker comes in with so much evidence to prove I am wrong that I am forced to submit. He writes boldly and honestly. Blog post.
  • The Signal and The Noise by Nate Silver. If you have ever wondered why humans are terrible at predicting stuff, this is a good read. Blog post.
  • A Random Walk Down Wall Street by Burton Malkiel. Promise me that you will never invest in the stock market without reading this book first. Blog post.
  • Ego is the Enemy by Ryan Holiday. A well-argued case of keeping our egos in check. We often think successful people are successful because they have a big ego. But Holiday shows that they did their best work when they were most humble and that we should strive for the same. Blog post.

A big fat placebo

Saturday, June 6th, 2015 | Thoughts

A friend of mine, who works as doctor, told me that doctors were banned from prescribing placebos (and not telling them they are placebos) because of the ethical issues surrounding it.

However, I recently decided to verify the fact and it turns out it isn’t true. In fact an article on BBC News shows that 97% of doctor’s had admitted to prescribing a placebo at least once in their career.

This raises interesting questions for alternative medicine. Is there room for treatments that provide the proven clinical benefit of placebo even if that is all it is?

Flatland: A Romance of Many Dimensions

Friday, June 5th, 2015 | Books

What a novel! Written in 1884, Flatland explores the idea of a 2D and 1D universe and the maths surrounding that, in an engaging and humorous way. It follows the life of the protagonist, a square, as he describes his world and visits others.

How does a 2D world look for example? You can only see in one dimension so how do you tell the difference between different shapes when everything looks like a line? What challenges does that present for society? For building design? For interacting with other people?

The same issues occur when the square visits lineland, a one dimensional universe. As well as the difficulties of trying to explain another dimension to those who live in said worlds. Upwards, not northwards!

Flatland

The Emperor’s New Drugs

Thursday, June 4th, 2015 | Books

In The Emperor’s New Drugs Irving Kirsch argues that antidepressant do not work. Well, sort of. What he argues is that the majority of the benefits of antidepressants are also found in placebo and that the additional drug benefit of antidepressants is explained by the enhanced placebo effect generated by the significant side-effects of the drugs.

He begins by talking about the meta analysis he did showing that almost all of the benefits from antidepressants come from the placebo effect. When he published this, the response of the medical community was “yeah, well we know that already”.

The problem with working out if antidepressants work is because it is really difficult to control for. You can add a placebo group, but because placebos cause less side effects it is easy to break blind. Indeed, 80% of patients on the drugs in one study were correctable able to guess they were in the test group. Also, the increased side effects could produce an enhanced placebo effect rather than a drug benefit.

Comparator trials, trials in which you compare with other antidepressants, are also problematic because everyone knows they are on an active drug, and therefore everyone can benefit from a strong placebo effect.

If his claims were true, you could surely use any drug as an antidepressant as it just has to cause side effects to work though? As it turns out, that is basically what we have. SSRIs, NDRIs, beta-blockers, stimulants, depressants, they all produce the same success rate in treating depression.

But surely NICE, the National Institute of Clinical Excellence, are here to protect us? In theory yes, but Kirsch claims they have trouble getting all the data they need. Drug companies publish studies multiple times, publish summaries across different studies and combine them in different ways to make it incredibly difficult for NICE to work out whether they have duplicate data in their own meta analysis.

He also attacks the idea that depression is caused by a chemical imbalance. If it is, we should be able to cause healthy people to become depressed by lowering their levels of serotonin and other monoamines. But we can’t.

Also, we should be able to effectively treat the imbalance. But again, we can’t, people just respond consistently no matter what treatment we give them. For example 60% respond to SSRIs and 59% respond to NDRIs. If we assume that is is a chemical imbalance, there is no way those numbers should be able to add up to more than 100%.

In summary, Kirsch argues that antidepressants to not out-perform active placebo and therefore subjecting patients to the significant side effects is unjustifiable.

I would like to read some rebuttals before I come down on one side or the other, but it is certainly a thought-provoking book.

The_Emperors_New_Drugs

A note for antidepressant users

In this blog post I have tried to set forward the views expressed in The Emperor’s New Drugs. I honestly do not know what to believe. However in April, I wrote a blog post in favour of antidepressants. I have thought about whether I should reference the two, and I think it is probably best that I add this disclaimer.

This book does not claim that antidepressants do not work. They clearly do. The question is whether their entire effect is due to the placebo effect, or whether they have a drug benefit on top. This is not that relevant for a user of antidepressants though. If you are using them, and they help, keep using them, because the placebo effect is a real, clinically proven, measurable health benefit.

And of course, discuss any medication chances or concerns with your doctor.

Robin Hood Conference

Wednesday, June 3rd, 2015 | Public Speaking, Travel

The Spring 2015 Toastmasters District 71 (UK & Ireland) conference took place in Nottingham.

Nottingham is quite a happening city. There was plenty of people out in the evenings and a good range of restaurants. We also did a walking tour lead by Robin Hood. He told us that the city was originally called “Snotingaham” which it turns out is true.

Workshops

The workshops were a mixed back. You get a lot of professional speakers and motivational coaches running workshops, and they send to speak a lot of shit. Erick Rainey for example started his speech with a slow motion run down the aisle. I thought to myself “brilliant, this is going to be a sarcastic post-modern take on how stupid a lot of the motivational crap is”. But then he did it all seriously. He’s a great communicator, and has loads of good stuff to say, but then he mixes it with nonsense like NLP.

Rav Chambers presented a good workshop on video. It did not teach me anything I did not know already, but it was valuable to have a reminder of all the things I know I should be doing when shooting film.

Vinay Parmar’s workshop on personal branding was interesting. However, for someone who focuses on how you present yourself, he really needs to spell-check his slides as there were several errors in them.

International Speech Contest

The district final of the International Speech Contest took place on the Saturday afternoon. It wasn’t the best venue for it as it was in a lecture theatre. The speeches were good, but I am looking forward to getting back to competing. Two years ago, in Torquay, I felt out-classed (to be clear, I wasn’t competing). Here, I sat there thinking there are a bunch of us in Area 15 that could compete at this level.

Opening ceremony

The Friday evening is a buffet and fancy dress party. Of course the theme was Robin Hood!

fancy-dress-robin-hood-1 maid-marian-elina

Gala dinner

The Saturday night was the Gala dinner. We had the Sheriff of Nottingham as a guest and for one of the raffle prizes, she let someone wear her robes and hat! Best of all, Gillian took the prize.

sheriff-gillian