Connect multiple Carambola2 devices together using Openwrt

I found a fun little network enabled device that runs Openwrt called Carambola2. The developer kit version has two ethernet ports and I wanted to try connecting them all on the same subnet by daisy chaining via the eth0 and eth1 across multiple devices. The requirement is to connect them in a way that any device can connect to any other device on the network but do not use a centralized switch to do so. The following configuration on the lan part of the network configuration shows how I connected eth0 and eth1. The configuration uses staticIP but I have not figured out if dhcp works via the main router yet.

config interface 'lan'
option type 'bridge'
option proto 'static'
option netmask ''
option ipaddr ''
option _orig_ifname 'eth0'
option _orig_bridge 'true'
option ifname 'eth0 eth1'
option gateway ''
option dns ''
option broadcast ''

In this case, the device node is set to Make sure each device has a unique IP within the subnet range.

Setup your own deb repository

It is difficult to setup a Debian repository that is signed and can handle multiple versions of any single package. I went through many different packages and tutorials in how to setup my own Debian repository and it was a pain to find a method that works. My two requirements might be specific to my needs but they give the user the ability to do these two things.

The signed part allows automated scripts to upgrade a package as it allows the following.

sudo apt-get -y install <package>

The ability to handle multiple versions of the same package would allow the user to install which ever version of the package with the following command example

sudo apt-get -y install <package>=<version>

Generate a gpg key

We need a gpg key to sign our packages and repository. So let’s generate one before setting up freight.

gpg –gen-key

Select option 4 RSA (sign only)

Fill out all the information that it asks.

Note: Be sure to add an email. It will be needed to configure freight.

One thing that will happen most likely is that there is not enough entropy to generate the key and it waits for entropy. I found a good way to generate some entropy is to run stress. Open another terminal to install and run stress while leaving the gen key running.

sudo apt-get install stress

stress –hdd 8 –io 8

If you want to watch the available entropy get generated, open another terminal and watch with this command

watch cat /proc/sys/kernel/random/entropy_avail

Installing Freight

The package that I found to handle both my requirements was freight. The instructions are there, but I will document what I did just to be complete.

I installed via apt-get and so I needed to add the third party source list before installing

echo “deb $(lsb_release -sc) main” | sudo tee /etc/apt/sources.list.d/rcrowley.list

sudo wget -O /etc/apt/trusted.gpg.d/rcrowley.gpg

sudo apt-get update

sudo apt-get -y install freight

Configuring Freight

Copy the example conf

sudo cp /etc/freight.conf.example /etc/freight.conf

Edit the freight.conf and add


Add deb packages

Take a deb file you already created and added to the repository. The apt/squeeze, etc arguments are the different distros where the deb should be published.

freight add foobar_1.2.3-1_all.deb apt/squeeze apt/lucid apt/natty

Build the cache

freight cache

Setting up Nginx

Now we need to serve out the repository over http. You can use any web server to do this. I chose Nginx and here is the setup procedure.

sudo apt-get install nginx

Setup hosting file

cd /etc/nginx/sites-available

sudo vi

Put something like this into the site configuration file

server {
listen 80;
access_log /var/log/nginx/;
error_log /var/log/nginx/;

location / {
alias /var/cache/freight/;

Enable the new site

cd /etc/nginx/sites-enabled

sudo ln -s /etc/nginx/sites-available/

Restart Nginx

sudo service nginx restart

Consume packages

Now to install the packages from your new repository on a Debian machine, add the source list and the key

echo “deb $(lsb_release -sc) main” | sudo tee /etc/apt/sources.list.d/mydomain.list

sudo wget -O /etc/apt/trusted.gpg.d/mydomain.gpg

Now you can do the normal apt-get procedure to install a package

sudo apt-get update
sudo apt-get -y install foobar

AngularJS interval example

One useful technique to keep content synced between client and server is doing continuous polling. Of course websockets are even better, but for this post, I’m going to just talk about the polling technique using AngularJS. AngularJS has an $interval service that can do this well. However, they do warn that you have to handle manually killing the interval service when you don’t want it to persist anymore like when you destroy a controller. This can be done with the following example code snippet.

var startedInterval;
$scope.startPing = function(num) {
    if (angular.isDefined(startedInterval)) {

    startedInterval = $interval(function() {
        console.log("Ping " + num);
    }, 1000);

$scope.stopPing = function() {
    if (angular.isDefined(startedInterval)){
        startedInterval = undefined;

$scope.$on('$destroy', function() {

var num = Math.random();

This is just a quick demonstration of this technique.

Getting Ionic framework running on Ubuntu

Very frustrating when it appears that Ionic setup is as simple as to get a helloworld running. But I received all kinds of errors when following those simple instructions. Primarily, there were Cordova dependencies that were missing and are not installed if you only follow Ionic instructions.

So here they are. After installing cordova and ionic

sudo npm install -g cordova

sudo npm install -g ionic

Install ADT

Unzip to somewhere that makes sense for you on your home dir

Add paths

edit your .bashrc and add this to the bottom

export PATH=$PATH:/[path to adt]/adt-bundle/sdk/platform-tools:/[path to adt]/adt-bundle/sdk/tools

Save your .bashrc then run

source ~/.bashrc

Then install ant

sudo apt-get install ant

Then create a AVD

android create avd -n <name> -t <targetID>

you can list targets to see what you have available

android list targets

Now that everything else is installed and an AVD is created, you can continue with the Ionic instructions.

$ cd myApp
$ ionic platform android
$ ionic emulate android
$ ionic run android <-- still getting an error on this one



Google Chrome Voice Search Extension Memory Leak

Screenshot from 2013-12-11 16:57:26This was observed on Ubuntu 12.04 where just opening Chrome without going to any pages would see memory start to get eaten up. The cpu usage would go way up as well. The culprit was the Google Voice Search Hotword Extension. If you go to upper right three horizontal bars -> Tools -> Extensions and disable that extension, everything is solved.

Get Electricity Usage Analytics Like The Utility Companies

Ever wanted to track how much electricity a device at home is using over time? Here is a nice DIY for doing just that. It does require a bit of soldering but not much.

Bitbucket brightens my day from the github pricing gloom

I’ve been using github for a while now and honestly, it rocks. It really beats the heck out of the dinosaur, svn. However, the pricing for private repos on github is just something I had a hard time justifying. I have been running my own svn server for quite a while and it does not create additional cost to me. Plus, I can have unlimited number of private repos and of course because I can, I do. So in order to switch to github and shutdown my svn server, I would have to pay $50/month since I have more than 20 projects.

Alas, I have found what I’m looking for. Bitbucket. It is also git, although you can use mercurial too, but I just prefer git. It has all the niceties of github like integrated issue tracking, ease of collaboration, and of course all the good stuff of git. But the pricing is very different. They take the route that if you don’t have many contributors to a project, then it is too small charge. So they allow you to have private repos for free up to 5 users. After that, you need to start paying. That makes a lot more sense to me since after that, you are definitely running a legitimate business and should pull your weight. Before that, they are considered play projects or incubator projects. Oh, and you can have unlimited number of free private projects.

Time to say goodbye to my svn server.