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: https://docs.google.com/file/d/0B1RhPrxJp7gySGljY1c2cFZaMk0/edit.

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 http://raspberrypi.stackexchange.com/questions/14763/how-to-improve-boot-time-for-raspberry-pi, my two favourite answers:

  1. Speed up the boot process using eINIT: https://sourceforge.net/projects/einit/
  2. Read this article at samplerbox.org/article/fastbootrpi 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”

When to use Front Controller pattern in PHP?

Using the Front Controller pattern in PHP always seemed fairly pointless to me.

I believe that using PHP’s native features with care usually leads to the best code; simple, re-usable components. For example, passing in an object of class ‘MyLogger’ to every object in the system not only ties all the components to using MyLogger, making their use in a system without MyLogger awkward, but the reverse too: any imported code would need to some how be converted to use MyLogger. It’s better to just properly use PHP’s native methods.

The same goes for MVC patterns and so on. Specifically, the front-controller pattern. The paths-to-controller mapping is very effectively done by having one publicly accessible php file for each page, meaning no logic necessary for mapping.

But there was one issue with this that always bugged me. The code in those publicly visible php files, as simple as they may be, (requiring a core bootstrap file and instantiating a couple of objects that do the heavy lifting), were a pain to write automated tests for. Every page would need a test, to check that the cut-and-paste between them had not been broken. Every new page introduced a new weak spot.

But with the Front Controller, all that was reduced to a single page.¬†So there’s the biggest advantage for a front-controller, in my opinion.

Saying that, I don’t think that Front Controller is always the best idea. It can still involve very complex code, or complex debugging. Most who’ve used Apache’s mod_rewrite would agree, I’m sure.

In Martin Fowler’s book, “Patterns of Enterprise Application Architecture”, he points out that it is fine¬†to have a system that uses both Front Controller(s) and Page controllers. There’s a trade-off, and like I’ve heard a thousand times in programming, it ‘depends’. On the requirements, the developers, the technology, and so on. But at least I have now consolidated what to me is the most significant reason for considering the Front Controller, yet why I am unlikely to use it exclusively.

 

How much will one minute of exercise save the NHS?

Now IMO there’s a good question.

How hard is one minute of exercise? It won’t exactly take you long. About 60 seconds. Go up and down two flights of stairs perhaps.

Now say everyone in the UK did 1 minute more exercise per day than they already do.

I reckon for each minute of exercise that everyone added to their daily routine, the NHS would save in the order of 1 billion pounds every year. I’ve pulled that figure totally off the top of my head, but whether it’s 10 million, 100 million or whatever, doesn’t that make it worth doing?

I don’t vote, because I don’t think one vote can really make a difference. But one minute of exercise might. Maybe I can’t make other people exercise, but I can make a difference to my own health. And if other people read this, who knows, maybe our beloved NHS might stand a chance of surviving. Do we really want to go back to having to pay ¬£15k for a one night stay in hospital? I don’t fancy my chances of staying eligible for affordable healthcare insurance when I reach retirement. I’m only 35, but it’s the one thing that really scares me about the future.

Now we shouldn’t expect everyone to exercise 1 minute more a day – some people cannot. Not just the wheelchair bound; I’m going to stick up for sufferers of mental health problems, to make a point: if one were planing on taking their life, exercise would seem pretty pointless.

But if there is a 10:1 ratio of well to unwell, then just an extra 6 seconds will make up for those who are unable. So, is 66 seconds so much to ask, to look after yourself, the NHS, and the unwell? I think not.

So: Go and do some exercise NOW! Just go up and down those stairs twice. Or 30 pushups, build up those abs and look sexy. Or dig out that awful bush in your garden that you hate. That’s 20 minutes of intense exercise right there! You’ll get a real buzz out of that, I guarantee you. Or do 45 star jumps. Just one minute. For Britain!

 

 

 

Lol @ Andrex

I had a few moments to spare and something on the back of a pack of Andrex rolls caught my eye.

On most household items these days, brands always try to make their product more exciting, easier to use, more attractive to the consumer, and where appropriate, instructions for use.

I always liked a good read of the back of a cereal packet while having breakfast. It doesn’t have to be much; at that time in the morning, even an ingredients list can be more than adequately stimulating. And quite frankly, I’ll also find myself reading just about anything while on the crapper.

But what I found on the back of this Andrex pack was surprisingly surprising:

IMG_20150801_132759

I mean, really, who on earth needs instructions for wiping their arse? If someone is capable of reading, then they should surely already know how to wipe their arse.

What’s even more surprising, is they seem to have missed out some crucial steps.

So maybe my assumption that everyone is aware of the steps in procedure was incorrect. I mean, if the manufacturers of toilet roll can’t get it right, then perhaps it would be a great public service if someone were to outline a complete procedure – so those looking to become proficient have a definitive reference. After all, mistakes could cause quite a mess.

So I’ve decided to take the liberty of preparing such a guide, which I will include in a future post once complete. It should be noted that while I’m not a professional, I do have a lot of experience.

If anyone has any suggestions on refining my process, please do let me know, so I can work towards a neater, more refined, more accurate, and more useful revision. I will then send it to Andrex – I suspect it will be well received.

 

 

Rear van accessory sockets: energize when doors open

I often do work in the load bay of my van, so I need a source of electricity there. I use both 12v and mains equipment, so I need to install a 12v socket and also a power inverter to get mains out of it. Then I can use battery chargers, power drills, a glue gun, laptop, maybe even a TV and kettle. Funky!

The solution: Lay a line to the back of the van, and install 12v sockets. I’ll have the sockets mounted in a metal box which I’ll fasten down. I hereby christen that box the “Auxiliary Panel” for reference.

What will it all involve? The core of it will be a 12v line to the back which will power the sockets and the inverter. There were a number of solutions, but only one seemed the right choice. Some ideas were:

  1. Add a single wire; one end to the positive of the cigarette lighter socket, then feed the other end to the load bay. For ground, attach another wire to the chassis in the load bay. Voila, these two wires I attach to a socket that I mount to a box and fasten in the load bay.
  2. As with option 1, but take the positive from the battery (via a suitable fuse located near the battery) rather than the cigarette lighter socket.
  3. The complicated option I chose. See below.

The problem with option 1 was the cigarette lighter circuits cannot handle more than 20A. This is fine for a low power inverter, or battery chargers, but not much more.

The problem with option 2 was that my auxiliary panel would have power 24/7, so if I were¬† to accidentally leave anything connected, the battery would drain and I’d be stranded, unable to start the van.

So option 3 takes the best of both worlds. It takes a feed from the positive terminal of the battery which gives it ample power. It also takes a feed from the cigarette lighter socket as a signal, which disconnects my box from the battery when the cigarette lighter socket has no power. (The cigarette lighter socket only has power when the key is in the ignition). All this needs is one relay (plus suitable fuses and of course a 12v socket).

And then I took this one step further. I also want my box to have power either when the rear doors are open, or when the key is in the ignition. This complicated things though. Not only does this entail an additional relay, but a number of diodes.

So, to follow up the last diagram I posted of my van’s interior rear lights, here is the modification which uses that signal from the interior lights (and the cigarette lighter socket) to energize the rear accessory sockets when the rear doors are open or when¬† the key is in the ignition:

circuit-to-switch-on-accessory-socket-in-load-area-when

RLY1 is the big boy relay. When either the doors are open or the key is in the ignition, this relay will be energised, thereby giving power to the auxiliary panel socket from the battery.

Getting RLY1 energised when the key is in the ignition was the easy part: the positive from the lighter socket could have gone straight to the relay coil. The complication is the doors. I need the relay to be energised when the doors are open – so when the door switches are closed, and therefore when the wire coming from them is held at zero volts. So I need RLY2 to flip this around: when the doors are open, their switches are closed, the wire coming from there is at zero volts – this energises RLY2, which then via D2, energises RLY1 with +12v.

D1 and D2 are needed so the cigarette lighter socket signal and the signal from RLY2 don’t interfere with each other. Without D1 and D2, having doors closed would actually energise the cigarette lighter socket! Plus all sorts of weird things could then happen. In theory only D1 is needed, but D2 makes things symmetrical and gives peace of mind if I expand the circuit at a later time.

D4 is (probably) needed to stop current flowing when it shouldn’t. If the doors are shut, (so their switches are open), no current should be flowing through the ceiling lights. But if RLY2 was closed when the doors shut, the relay could pull current through the lights. Weird things could happen.¬† So I thought I’d add it just in case.

I used a total of 4 fuses: one near the battery, one for RLY2, and one for the socket at the auxiliary panel. (The fourth is not shown on the circuit diagram: a 0.25A fuse at the cigarette lighter socket)

Voila. I now have convenient power in the back of my van.

For the sake of brevity, in the above diagram I omitted the aftermarket timer that was installed which turns the lights off after 30 minutes (when the doors have been left open). This is shown below. It doesn’t alter how the circuit above is connected.

 

van-rear-interior-lights-with-timer