Adrian Chen

Raspberry Pi Torrent Box

gear, hardware, mini-project, pi, raspberry

With the new release of the Raspberry Pi 2, it reminded me of the old Raspberry Pi model B I have that’s covered in dust doing nothing. Feeling a bit sad for my Raspberry Pi I decided to turn it into something useful, a 24/7 bit torrent client. For downloading erm… all the public domain legal earth watching that I do.

The Pi’s power consumption is so low, it almost cost nothing on your electricity bill, and it’s passive cooling which means it noiseless.

I mostly followed this guide here on setting up Deluge the bit torrent client & samba share on the Raspberry Pi.

When I first tried out the guide, I had an self powered external hard drive that I plugged straight into the Pi, however when ever we try to access the files more than a minute, I would get an I/O error writing to ... then I would have to remount the drive on the pi. After trying out different combination of the format and partition of the hard disk… it turned out there was a power surge on the hard disk USB plug, when it connects to the Pi it would disrupt it’s operation.

This is my working solution:

"Setup of the Raspberry Pi torrent box using the powered usb hub and external hard drive"

I Added a powered usb hub between the Raspberry Pi and the external hard disk to make sure the hard disk is not drawing power from the Pi, and also changed the external hard disk to be one of the simple plug and play WD My Passport without any power source, this have been running smoothly without an issue so far for the past 2 months, quietly sitting on my shelf next the my router~ Hope this will help some of us who had the similar problem on external hard drive with the raspberry pi.

Quick PHP Server

gulp, impactjs, nodejs, php, workflow

I’ve been playing with ImpactJS for a while, I’ve found myself needing to run a php server to use it’s level editor Weltmister.

I didn’t want to install a full server stack solution like mamp, xampp, etc… As I already use gulp for the streaming build system. The simplest solution I’ve found is to run php and nodejs side by side. You can fire up a quick php server using it’s built-in web server:

$ cd ~/impactJs
$ php -S localhost:9090

How to Settimeout in Jasmine 2

jasmine, tdd, test, timeout

The waitsFor funciton for asynchronous specs have been removed in Jasmine 2, instead we have a done callback argument that when present, will make Jasmine consider its coresponding block as asynchronous, and waits for it to be invoked before timing out or finishing the spec, very similar to how Mocha does it’s async tests.

describe "When fetched", ->
  beforeEach: (done)->
          success: ->

  it "should update its stock price", ->

This is all well and good, until I ran into a problem when doing intergration test with my app that includes thrid party library that I can’t really dig into, in mycase it was the Google Maps API. To use the done syntax, you require to have an entry point of knowing when your ajax call finishes to raise the done event.

To get round this you need to use the good old setTimeout method like so:

describe "on running a search", ->
    it "returns places", (done) ->
        places = null
        $(searchBox).on "placesChanged", (e, data) ->
          places = data
          expect(places.length).toBeGreaterThan 0
        setInputVal = ->
          input.focus().simulate("keydown", { keyCode: 13 })
        # No way for us to know exactly when the Google SearchBox is ready for input ...
        setTimeout(setInputVal, 1000)

In my opinion the waitsFor function still has a place in Jasmine, the done callback syntax doesn’t completely replaces waitsFor.

Should You Buy a Cheap Apple Keyboard Knockoff

apple, gear, keyboards

Should You Buy a Cheap Apple Keyboard Knockoff?

I recently stumbled on an apple ‘like’ wireless keyboard called iWantIt it looks like the apple wireless keyboard but it’s 100% cheap plastic.

It was on offer for £ 8.99 in Currys (a British electrical retailer). It so happens I was looking at an official apple wireless keyboard the day before, which is selling for £53.99 at Amazon.

Cheap apple keyboard

At a first glance the layout is very similar to the apple keyboard, and with a price of £8.99. I thought this may work, and bought it…

TLDR: Should You Buy a Cheap Apple Keyboard knockoff? No, save up if your broke. So many flaws makes this un-usable.

When I rest my hand on top of the keyboard, first thing i noticed was the angle of this is steeper than the apple keyboard, you need to raise curl your fingers a bit more to type.


Whenever I press a key, the rest of the keyboard sort of cave in and bend into the pressure point of I’m typing, this may or may not be a problem for you, depending how hard you press down when typing.

There’s also a bit of a ‘recoil’ like shooting a gun in CoD. Soon as you gain some speed when typing, it would nudge and move a little on the table, and wouldn’t stay put.


This key on the top left… (You mean the esc key?) WRONG!!! It’s an home button… A freaking home button… To use it as an esc key, you have to hold down the fn key. I don’t know about you guys, but I tend press the esc key quite a lot, and so far this is driving me nuts.

esc key

I tried coming up with at least 1 good point about this keyboard, but I just can’t think of any.

So yeah kids… Don’t buy cheap apple keyboards knockoff…

Beginner’s Mac OS X Terminal Tips

CLI, Terminal, bash, commands

Just started using the terminal, want to know the basics? Here are some tips I wish someone had told me at the start. This guide is mainly aimed at Mac OS users, ( you’ve probably know that from the title. )

The terminal app you get from Mac OS is pretty basic. It comes with some preset themes, you have your Grass, Homebrew, Ocean, Red Sand, etc…


The standard Mac Terminal app is okay to begin with, I recommend taking a look at iTerm2, it has a lot more features and customisation, plus it’s free. I’ve also got a post on tips and tricks for iTerm2.

Open prompt / terminal’s location with Finder

Use the command open . will bring up Finder with the currently location of the prompt. No more opening up finder from the dock and re-navigating folders, great time saver!

How to Show Hidden Files and Folders on Mac Finder

Show hidden files and folders:

defaults write AppleShowAllFiles YES && killall Finder

Hide hidden files and folders:

defaults write AppleShowAllFiles NO && killall Finder

Disable Mac’s Dashboard

I personally never found Dashboard useful, and i only ever opened it by accident, heres how you can disable it:

defaults write mcx-disabled YES && killall Dock

To re-enable the Dashboard:

defaults write mcx-disabled NO && killall Dock

Previous Commands You’ve Used

I use to do something like this to get a previous command I’ve entered:

history | grep ssh

This would come back with a list of commands you have used containing ssh. You can replace that with whatever you’re looking for.

There’s a faster way to search history, simply press Ctrl + R key combo, and keep typing till you find what you’re looking for.

You have any tips you would like to share? leave a comment below :)

iTerm2 Tips & Tricks

iterm, terminal, tools, workflow


iTerm2 is an free terminal emulator for Mac OS X.

Here are some useful & interesting iTerm hotkeys i’ve discoverd along the way;

Command Keys
iTerm2 Exposé Cmd + Alt + E
Paste history Cmd + Shift + H
All panes Input Cmd + Alt + I
split pane (h) Cmd + D
split pane (v) Cmd + Shift + D
next pane Cmd + ]
previous pane Cmd + [
increase fontsize Cmd + +
decrease fontsize Cmd + -
default fontsize Cmd + 0
rainbow cursor Cmd + /

Custom Hotkeys

I have also set up some custom hotkeys for myself:

Keys Action Value Purpose
⌘ ← “HEX CODE” 0x01 Jump to beginning of the line
⌘ ➝ “HEX CODE” 0x05 Jump to end of the line
⌘ Backspace “HEX CODE” 0x15 Delete current line
⌥ ← “ESCAPE SEQ” b Jumo to beginning of the word
⌥ ➝ “ESCAPE SEQ” f Jumo to end of the word
⌥ Backspace “HEX CODE” 0x17 Delete word

iTerm2 Visor

You can set up iterm to act like a “visor”, similar to how the Quake’s terminal / Guake works. This has an advantage of getting to your termals quickly among other things you’ve had opened on your screen.

First you will need to set up a hotkey, I’ve got mine to use F9.

Preferences >> Keys >> Hotkey

Set up iterm act like a visor

Then inside your terminal’s profile, set the style to something other than the default normal option.

Preferences >> Profiles >> Window >> Style

Set up iterm act like a visor

Quit iTerm2?

I’ve also unchecked the default option for Confirm “Quit iTerm2” window.

Preferences >> General >> Closing

I find this gets in the way everytime I shutdown my Mac, it pops up & I need to click it again to not let it stop the the shutdown process. iTerm2 has stoped the shutdown

If you often find yourself spliting panes in your terminal window, I highly recommend setting up a Window Arrangement profile to save you time.

On my 15” macbook pro i set my a workspace which consist of 3 panes (shown below), Once your happy with your setup, you can save it by Cmd + Shift + S. iTerm2 has stoped the shutdown I also set up a hotkey for mine to quickly bring up a new terminal window with the predefined panes.

You got any awsome tips I’ve not mentioned? Let us know from leaving a comment :)