Installing Node.JS v4.0 on RPi

As usual, tutorials on Linux become out of date quickly. And as usual, linux tutorials always need fiddling to get working on any setup different to that of the author’s. So here is how I got node v4.0 installed on the RPi version B with Raspbian:

First, from this tutorial:

Then, from this tutorial:

Then edit ~/.bashrc:

Add this line  at the end:

Then edit ~/.profile:

Add this line at the end:


Finally you can get on with actually using it!

But if you want a slimmed-down Raspbian, try my tutorial on getting RaspberryPi-Ua-NetInst working with NodeJs.

This tutorial has a great introduction to using Node.JS. It requires NodeJS v4.0 which you should now have. Plus you now have nvm , the node version manager, which it also requires.


My love-hate relationship with Linux

I have been programming for about 20 years. Within that, about a solid year has been fiddling with Linux. Yet I wonder how much I’ve been able to remember. When ever I try to set something up in Linux, I quickly start swearing like a trooper, and end up Googling things like “I f****ing hate Linux”. Or “Why is Linux so f***ing obscure”. It’s reassuring to know I’m not alone.

But why do I keep going back? Because it has its place. While I think it is unfit as a desktop OS for 99.9% of cases, (stats don’t lie. How many people actually use it for that?) The fact is it is beyond widespread on servers, and frequently used for embedded systems and systems like the Raspberry Pi. If you know what you’re doing, (if you *really* know what you’re doing), you can butcher it, configure it and extend it to your heart’s content. Oh, and it’s free. That’s why I love it.

You just need to read through the comments on this blog post to see plenty of reasons Linux is hated. But I’m going to add a couple. I’m fiddling with an RPi at the moment, so I will have plenty of reminders for what to say on this matter.

The truth is that whenever I try something remotely ambitious in Linux, I end up throwing in the towel. We shall see how this goes.

Have you tried understanding entries in /etc/inittab  ? Even once you know how it works, there’s no denying that the syntax is cryptic compared to how modern programming languages might specify the same configurations. It’s hardly as ubiquitous as JSON.

Why is it so hard to get things working on Linux? The problem is threefold:

  1. Those very comfortable with Linux who write tutorials assume that readers know everything but the tip of the problem, so skip on the details.
  2. Those not comfortable will have spent so much time and tried so many commands to try to get it to work that by the time they write the tutorial they’ve lost track of 95% of the things they had to try first.
  3. Because of the wild permutations of possible distros, versions, configurations and hardware, very rarely are two people’s situations the same.
  4. Combine reason 1 and 3: those in the know can’t, without huge effort, write a tutorial or make a script to, for example, make WiFi work. So many possible combinations, software always changing, it wouldn’t work for long.


RPi stripped

These are some options for using a stripped-down RPi when you need the best performance by tailoring what you need to the bare minimum.

Why stripped down? If you want it fast. Fast boot, fast processing, low latency. The RPi is in the order of 100 times faster than 8-bit PIC microcontrollers that I’m used to using, yet most Linux distributions adds a lot of bloat for these kinds of use-cases.

In order from high to low level:

Raspbian: It’s well supported; regular updates and plethora of available packages. Also, packages can quickly be removed as per this previous post, and boot time and other run-time resource hogs can be eliminated as per this previous post.

Why not Arch linux? It’s an option. However, I spent a day just trying to get it to boot, with no luck. It is no longer an option in the NOOBS installer, and having no previous experience with it, and little experience with the RPi, I’d lost before I started.

Start with Raspbian-Ua-NetInst and build it up: If the experience with Arch was too ambitious, then this probably is too. While it is dead easy to install, I wouldn’t want to spend months and months learning with no guarantee of success; I’d want to start with something that just works – even if mediocre – and take it from there. It doesn’t even come with a package manager, and a quick Google search shows that the lack of tutorials for building on it might be a deal-breaker.

Why not MiniBian? ‘Cos I just found out about it.

PiLFS: Probably the lowest level besides bare-metal, but still pretty bulky. It’s not all that clear how much space it would take on the SD card; somewhere between 8MB and 1GB as a minimum??

Why not bare-metal? Are you kidding me? I don’t want to write a Web server, or networking capability from scratch. The reason I’ve decided to use a RPi is to give powerful high-level programming capability to really get stuff done. However, a great tutorial is here: It is a massive 5-part tutorial which gets you a long way, relatively speaking; great if you just want a quick way of hammering hardware.



Raspbian – resources for reducing boot time

This post will be a work-in-progress. How to reduce boot time of your Raspberry Pi running Raspbian?


First you need to know how long it actually takes to boot up so you can assess your progress.

It has the added benefit of telling you what is happening in that time. Run that command and it will give an output like this:

The number in square brackets on the left is the time since it started up, and whatever is on the right is what is being loaded at that point. I’m not sure what the very last line is about, but the line before that indicates that boot-up time (including ethernet setup in this case) was 22.1 seconds.

Stop stuff being done at boot up

This topic on the Raspberry Pi Forums gives a few ideas for how to speed boot-up time. There are an awful lot of good responses there. Things I’ve tried / will try:

  1. Install rcconf; the Debian Runlevel Configuration tool
  2. Edit /boot/cmdline.txt , add kernel option quiet so boot up log is not printed
  3. In that same file, choose fastboot option which bypasses filesystem check. Supposedly a bad idea though.

Another link:

Random hint: some things are never documented. Except in the source code itself. For example, if you have to edit /boot/cmdline.txt , then the only help you will get is by looking at the source.

There are different ways of changing what services are started up during boot-up. I’m not clear what’s supposed to be used when; the complication arises because the way boot-up services are run has changed over the course of Raspbian’s existance. Earlier versions used /etc/inittab but newer versions use systemd . I think this change is why rcconf and sysv-rc-conf don’t work properly; they seem to lose settings on reboot, which makes them useless.

The most successful way I’ve had of reducing boot times is by using  systemd-analyze blame  to show what is taking longest to load. It outputs something like this:

To find out what the services you’re disabling actually do, run this:

And you’ll get an output like this: (Scroll to the right to see the description).

Then disable the individual services as you desire by doing this:

Strip down Raspbian – a collection of what I’ve found

If you want to strip down Raspbian rather than start from the ground up with something like Raspbian-UA-NetInst which really has close to nothing on it, try the below.

It’s unfortunate that developers that offer “server” versions of Raspbian tend to disappear off the face of the planet leaving little more than a husk of a webpage showing that it once existed. So I thought I’d compile a list of reductions that can be run. Mainly for myself, but if it helps you too, then, bonus.

There is probably overlap and so on but I’m sure you’ll figure it out. Many will only help with freeing space on the SD card, rather than help with boot-up time, CPU usage and RAM. But read this post of mine on improving boot time.

PS. If you are the owner of one of the below pages and are unhappy with my inclusion of your commands, please let me know and I will remove them.

Option 1: Remove Packages

And finally, my own little addition, since I discovered that node.js now automatically comes with Raspbian:

Option 2: Raspbian Server Image / Scripts

While the guy who compiled the server edition image has disappeared along with the image, the scripts he used to make it are (at the time of writing), here:

I have taken the liberty of mirroring it on this blog; click here to download the sirlagz Raspbian Server Edition scripts.tar.gz. Or my .zip version, here: sirlagz Raspbian Server Edition scripts .zip

Other alternatives

From, my two favourite answers:

  1. Speed up the boot process using eINIT:
  2. Read this article at which claims to be able to get boot time down to about 8 seconds!
  3. Raspbian-UA-NetInst – a server version of Raspbian
  4. RaspberryPi-UA-NetInst – another server version of Raspbian


How to get a dictator to visit your website

If you’re feeling brave, there are a few easy ways you can get traffic to your website. Just don’t get your hopes up for getting money from it.

Upload a page where you say you have secrets. For example, you could say:

Click here to see what North Korea doesn’t want the world to know.

That’ll get some attention! Or better yet:

Log in here to see secrets of North Korea.

Then watch your hits soar as they try to hack your site.

On the other hand, if your site has water-tight security, you may even be able to get some money out of it…

Click here to buy secrets of North Korea for just $99.

You’ll probably just get one purchase, but every little bit helps towards your funeral costs.

On receipt of payment, you could even have the landing page say something like this:

Dear North Korea,

Congratulations ! Your payment has enabled this website to  upload a Trojan to your computer. As you read this, it is spreading across your computer network, covertly sending anything it finds to ME. Now I actually have something to sell 😉

See you in Den Haag!

Actually, there is one other approach. We all know the Internet boom was funded by porn. And we all know how these dictators plaster images of themselves everywhere, because they think it’s what their people want to see. The truth is they’re just narcissists. So the best way to get one to buy from you might be this:

Click here  to buy a video of Kim Jong-Un masturbating in front of a mirror.

There will only ever be one person clicking on that link, I guarantee it.

I knew it would work! Hiiiii!

It has been a week since I wrote this post. As I write this update, my blog is experiencing a distributed brute-force attack. Starting this morning, I have had over 5000 attempts from nearly 2000 IP addresses to crack my site’s security. Thankfully whoever is orchestrating this will take about a billion, billion, billion, billion, billion, billion years to succeed. I would sooo love it to be the North Koreans! Hellooooooo!

Feeling old? Hit 30 without being depressed

In their 20’s, many people start getting the sense that they’re old. Your best years are nearly over. People younger than you are starting to overtake you – your skills, your wealth, your health. With CEOs as young as 22, Olympic athletes younger than you, fresh-faced hyper-car owners overtaking you, what’s left to be optimistic about?

The solution is simple: remember that it happens to everyone. Everyone sees youth overtaking them, sooner or later. The only people it doesn’t happen to is people who die young. You can be grateful you’re not one of them!

To feel good about yourself and your ageing body and mind, you need to get over the ideals you had when you were younger; the belief that you could take over the world. That you could become better than anyone before you.

That was harsh, it had to be said. But now it’s been said, we can focus on the positives.

Firstly, you have plenty more time to achieve your desires. True; you might not have become CEO at 21, but there’s plenty of time yet.

Second: would you really want to give up the life you have now, for the unknown life had you been an early success? It has been proven that success in itself does not make you happy.

Third: What does make a person happy? If a 90-year-old with a small pension, ailing health and many lost friends and family can be happy, then surely you don’t need to feel bad about not being a spring chicken anymore. The question is how do they do it!

The answer: be at peace with yourself. This is not some new-age spiritual concept. Well, actually it sort of is. But it does not involve meditation (although it can), and it does not involve religion (although it can), and it does not involve happy pills (although it can).

Be proud of who you are

Be proud of what you’ve done. What you’ve overcome.

Remember that you can still make a difference. To yourself and to others.

Remember that everyone’s life eventually comes to an end, but it is not the end. You will have spent your whole life changing the world. Maybe a little bit, maybe more, but you’ve had an impact. You have moved the human race forward, contributed to the well-being of all the people present and future, and every other creature on this planet. There’s still more you can do, today. Seize the day, do something fun. So something amazing. Or just do something.


Why Stack Exchange promotes aggression and hostility

There’s something about stack exchange sites. And it seems to be worst on the larger more established ones like Stack Overflow.

As if the rules weren’t already strict enough, many people try to push it far further. Down votes and close votes on perfectly good questions as defined by rules set out in the help centre.   Snide comments. Nit picking. Some will flatly deny this ever happens, which almost proves the point.

Why does this happen? What about the system encourages this behaviour?  Why were those design decisions taken? What could be done about it? Well, I have some theories. It has been my bugbear for a LONG time. It’s about time I talk about it, so I will outline them in posts to come.

But I believe at it’s core, the issue is this: for a company to be successful, it has to focus on the bottom line; money. And SE’s monly comes from advertising. Which comes from page views. Which comes from high page rank in search engines, which comes from “good content”.

On the one hand, an example of “good content” is well written reference material for common problems. Which SE excels at. But it seems the SE system is designed to completely block any other kind of content, no matter how valuable it may be, either to individuals, people in a field, or Stack Exchange itself.

But because stack exchange has done such a good job of cornering the market as a help site, it has hammered alternatives that would be more flexible than a pure, strict Q&A site.

No discussions. No allowance for questions that need a helping hand when the question itself is hard to formulate into something that can be answered without clarification. (Yes yes… in response to the predictable SE  hardcore criticisms, that’s what comments are for. But that won’t stop you getting down votes and close votes).

What a monstrous creation.

Lol @ String

A piece of string walks into a bar.

Barman: “Are you going to be a problem?”

String: “I’m not a thread”