Do GoPro stuff without a GoPro

This is a generic flashlight mount. However, I’ve decided to get one of those high lumen specialized bicycle flashlights. Therefore, by the time this mount arrived, I had no use for it.

So with a bit of creative thinking, I decided that it can be a “nature valley” holder.

Then one day… I thought “hey, it looks like I can strap the Pentax Q on there”

… and this is the result! With some ropes, I was able to get this fairly secured on to the handle.

IKEA trip

“Edmonton transit, not giving me any incentive to be lazy”

Needed to go to IKEA to grab some food. Yup food, not furniture. Believe it or not, IKEA food is great!

Given that it is faster to get there by bike than bus, I decided to bike there.

It is final exams time, and I am going to be staying home for a good majority of the time. So I decided to stock up on 10KG of IKEA meatballs. Combined with the two U-Locks that I use to lock my bike, this bag is around 15KG worth of stuff. I suddenly wished that I just took the bus.

Here’s what 10KG of IKEA meat/veggie balls look like in the freezer. Salt and pepper for reference.

Shortcomings of a centralized media server

Realizing the hard way

This is when everything is working, all is good. I have access to all my media everywhere around the house!

When the power goes out, my media goes with it. Despite most of my portable devices have battery power, I have no access to any of my media since the network and the server are not battery powered.

Pros of a centralized media server: One copy for all devices

Cons of a centralized media server: One copy for all devices

Washing machine does the “Harlem Shake”

Title and picture says it all

I came home discovering this and I immediately called the laundry operators, here’s how it went:

Operator: Hi, my name is <name here>, can I have your address please?

Me: <Gives address>

Operator: So what is the issue here?

Me: Ummm, your washing machine disintegrated

Operator: I’m sorry? (Disbelief voice)

Me: Ummm, the washing machine is not in one piece


Me: As in your washing machine is completely not working

Operator: oh ok

Raspberry Pi x Lego – Home server

Why Lego?

In grade 1, my homeroom teacher happened to be the school’s primary computer teacher. The entire computer lab was Mac based, PowerPC’s everywhere. Then there was this special computer, a computer that had a Lego case (and ran Windows). He would passionately tell us how he built it and showed us how everything worked inside. Yeah, nobody had a single clue what he was talking about because you know, we were in grade 1. But hey it’s a computer with a Lego case, how cool! Ever since then I wanted one myself. As far as I remember, this marked the day I became a computer nerd 😛

Why a home server?

It is now common for one user to have multiple devices and we expect our data to be present on all of them. A common solution is to just make a copy for each device. For example, music. Want music on your tablet? Make a copy. Want music on your phone? Make a copy. Every single time I make a change to my song library, I have to manually copy it over to each device. Wouldn’t it be nice to have all your media just stored in one place and point all your devices to just “get it” from that location? This is where the home server comes in.

The computer

Raspberry Pi Model B

This is our “computer”. The famous “computer for 35 bucks”, the first generation Raspberry Pi. I bought it three years ago for experimenting around the GPIO pins in hopes of automating my room one day. That never happened as I lived in dorms so renovating my room is out of the question. I moved out since and rented a place. However, it clearly says in my contract no modifications of any kind shall be made to the room. Oh well 😛

Performance wise we are looking at something equivalent to an average computer in 1998-ish.

Haven’t touched this thing for three years, hopefully the humidity in Hong Kong hasn’t killed it.

It’s alive!

Testing if it is still working, excuse the poor presentation. Flashed the latest Raspbian OS “Jessie” on to the SD card and plugged it into a router. All the lights indicate its ok!

Setting it up server side

SSH enabled right out of the box!

Yeah, I am a Windows user… so we don’t have native SSH. PuTTY to the rescue!

Let’s configure our Raspberry Pi for server use with “sudo raspi-config”

We will be running the server “headless” (without a screen) so we can reduce the memory allocated to the GPU (Graphics Processing Unit) to the minimum.

The Raspberry Pi has 256MB of RAM, this will give us 16MB for the GPU and 240MB for the system itself.

We will be using the USB drive as our storage, let’s have it automatically mount on boot.

Install and configure UFW (Uncomplicated FireWall) for Samba file sharing.

Allow TCP 135,139,445 and UDP 138,139 from all the devices that you plan to share with.

Install, add Samba users and configure our Samba shares to point to our USB drive

Reboot the server! PuTTY calmly reminds us that the server has disconnected us

Accessing the shares in Windows is as easy as Pi

Click “Map network drive”

Enter you server details: \\<server_hostname>\<your _samba_folder>
Select a drive letter
Check reconnect at sign-in

All done! It’s just like an external drive!

Now that the functionality is there, let’s work on the case

Procuring the Legos

We will need a plan of course. Our official unit of measurement here is “Lego bumps”

Lego, you are truly evil, charging people by the bucket, a round bucket.

Talk about fitting a square peg in a round hole

The build

Remember to pad the bottom of the Raspberry Pi with some foam. Rubbing the bottom of a bare printed circuit board with Lego bumps isn’t exactly great.

Other than that, just build around the ports and build up from there!

Heat dissipation is inspired by Microsoft Surface Pro’s “Perimeter Venting”

I’ve decided to go with a similar design for the roof. This keeps most of the dust on the roof while allowing hot air to flow out from the top

Completed form. IKEA cup and Galaxy S4 for size reference.

Installing it with the rest of my network equipment


Completely scientific performance benchmark: You can stream six Girl’s Generation music videos in full high definition 1080P at the same time.

Alright, in all seriousness, here are the numbers:

Sequential reading from server: 33Mbps or ~4 megabytes per second

Sequential writing to the server: 25Mbps or ~3 megabytes per second

I’ve decided to only measure sequential performance because this is a media server, so most of the time, this is responsible for serving up big chunky files.

Performance analysis

The Surface Ethernet Adapter is rated at 100Mbps
The Raspberry Pi Ethernet Adapter is rated at 100Mbps
The Netgear router connecting the two is rated at 100Mbps

So why are we getting 33Mbps read, 25Mbps write? Clearly there is a bottleneck somewhere… let’s look at how the Raspberry Pi is doing

Woah 100% CPU usage, well at least we know our poor Raspberry Pi is trying its best. Clearly we are bounded by the processor, not surprising considering it has the processing power roughly equivalent to a computer in 1998. Let’s look at the breakdown.

Samba (our file share) is only using around 15% not too bad.

The NTFS-3G driver is the culprit here, using 65% of our puny processor. Accessing drives that are formatted as NTFS has always been a bit meh and inefficient on anything other than Windows. Technically I should already be glad that in Linux I can at least read and write to it. I am talking about you Mac OSX (older versions can only read from NTFS).

Seeing how NTFS is the problem, I decided to reformat the drives into something a little more Linux friendly, like ext4.

Result? 8MB/sec read and write or ~64Mbps. We are still processor bound as Samba is now able to “share faster” so its processor usage went up as processor usage for accessing the USB drive filesystem drops.

I could consider overclocking; however, this is a server and it will be running 24/7 so I want to maximize stability and reliability. Therefore overclocking is disregarded.


Didn’t you just say you will disregard that as an option? Yeah, but in the name of science and curiosity let’s briefly this option a little bit 😛

Before someone yells at me for using presets. Yes, I’ve also tried manually tweaking the parameters individually by editing the /boot/config.txt. After all my overclocking experience comes from the PC world 😉 This screenshot is strictly here for your visual pleasure.

900Mhz is as high as I can go without significant issues…

… and by without significant issues I mean:

It boots

The processor is running at 75C (it is rated for 85C so 7x is a “little” uncomfortably high)

The USB/Ethernet chip is now not finger friendly (it is rated for 70C and not finger friendly means 50C+)

Yeah, let’s just put it back into normal mode at 700Mhz

For what it’s worth, this 30% overclock gives us a 20% performance boost all across the board. So if your application requires such performance, I recommend getting some RAM heatsinks for the processor and controller.


For anyone interested in doing the same thing, there’s good news. This is the first generation Raspberry Pi, bought three years ago. The Raspberry Pi has moved on since then and the current one is the Raspberry Pi 3. It is still priced the same, so it’s still “a computer for 35 bucks”. For the processor, mine has a single-core clocked at 700Mhz, the current one is a quad-core clocked at 1.2Ghz. Needless to say, massive performance gains to be had for the same price!

Humming along at 700Mhz, so far it has reliably operated for a month and still ticking (I’ve only shut it down once as I was building a Lego case for it)

Calculating cadence (RPM) with a speedometer

I don’t care about what anything was designed to do, I care about what it can do” – From the movie Apollo 13 (1995)

Last year I bought this speedometer for my bike, quite reliable given that you don’t quick release it all the time (the mount broke eventually). Which is why now I have a Cateye Velo 9, a much sturdier piece of equipment. However, it doesn’t calculate cadence (RPM), which is quite a useful metric. Getting a quality speedometer that does both speed and RPM is expensive so I decided, why not buy another one of these cheap speedometers and turn it into a RPM meter.

The conversion


We no longer mount the sensor to the wheels as we are not measuring speed

Instead we mount the sensor to the pedal so that we can get the RPM of the pedal


These speedometers calculate speed in km/h by: RPM x 60 x Circumference of wheel in mm / 1,000,000

In this equation we are interested in extracting the RPM value and the only variable we can manipulate here is the circumference of wheel.

Therefore, we must manipulate the value for the circumference of wheel to negate the effects of the hard-coded multiplications programmed into speedometer.

Displayed value = RPM x 60 x COW / 1,000,000 where COW = circumference of wheel in mm
Displayed value = RPM x COW x 60 /1,000,000 we re-ordered it a bit
Displayed value = RPM x COW x 0.00006
We want COW x 0.00006 to equal 1 so that we get Displayed value = RPM x 1 which means Displayed value = RPM!
So, for COW x 0.00006 = 1, COW must equal 16,666.667

If we set COW as 16,667 then we will get RPM!

The problem

The maximum wheel circumference I can set is 9,999, way less than the required 16,667

The solution

Divide our COW value by 10 so that it displays RPM /10! Here’s it mathematically

Displayed value = RPM x 60 x COW / 1,000,000 where COW = 16,667/10 = 1,667
Displayed value = RPM x 60 x 1,667 / 1,000,000
Displayed value = RPM x 1/10

The result

When we input 1,667 as the wheel size, if it shows 81 which is how it shows 8.1, we need to remember that number is RPM / 10. So when it displays 8.1, we just x10 to get our RPM value!