Thursday, September 10, 2015

OpenFrameworks: Another cool Multi-platform Framework for Graphics

Steps to download and build OpenFrameWorks:
  • git clone
  • goto the OF root.  This is usually the folder openFrameworks.  Change directory to ./scripts/linux/ubuntu (e.g: cd openFrameworks/scripts/linux/ubuntu)
  • Execute the scripts in the folder as root:
sudo ./
sudo ./

Go to ./scripts/linux and execute:


To generate projects (Makefile etc.)  for all the examples, goto OF root, then type:

projectGenerator -v -r examples/

wxWidgets 3.0

To add the repository, first import the key:
sudo apt-key adv --fetch-keys
Then add the source:

sudo tee /etc/apt/sources.list.d/wxwidgets.list
deb  $(lsb_release -sc) universe
sudo apt-get update

Install wxWidgets modules:

sudo apt-get install libwxbase3.0-0-unofficial libwxbase3.0-dbg libwxbase3.0-dev libwxgtk3.0-0-unofficial libwxgtk3.0-dbg wx3.0-doc wx3.0-examples 

Create soft-link:
sudo ln -s /usr/include/wx-3.0-unofficial/wx /usr/include/wx 
To compile a single file, create a script named wxcompile and edit it with the content as below (assume with have subdirectory obj/Debug and bin/Debug:


if [ -z "${1}" ]
    echo "$0 "
    exit 1

FILE=`basename $1`
OBJF=`basename -s .cpp $CPPF`
g++ -g -c -Wall -DWX_PRECOMP -Winvalid-pch `wx-config --cppflags` -o obj/Debug/${OBJF} ${CPPF}

To link, create a script file name 'wxlink' and its content as below:


if [ -z "${1}" ]
    echo "$0 "
    exit 1


g++ -v obj/Debug/*.o `wx-config --libs` -o obj/Debug/$FOUT

For a bigger project which requires more complicated and conditional compilation, use Makefile.

Friday, July 3, 2015

Watching Nabawi-TV via VLC on Raspberry Pi

A new Indonesian da'wah TV has provided a streaming.

To watch, install vlc.  Once installed, open the VLC, click "Media", and then "Open Network Stream".  Enter:


Friday, April 3, 2015

Script to simulate multiple DHCP clients

#simulate 255 IPhones requesting DHCP
# Apple OUI = D8:96:95
if [ -e $FROM ]; then FROM=1; fi
if [ -e $TO ]; then TO=1; fi
for i in `seq $FROM $TO`
    LSB=`echo "obase=16; $i" | bc`
    HNAME="`uname -n`-fakehost-$i"
    #CMD="$HOME/bin/dhtest -m $MAC -V -i eth1 -h '$HNAME'"
    CMD="$HOME/bin/dhtest -m $MAC -i eth1 -h '$HNAME'"
    echo $CMD
    sleep 1

Another way, the program dhtest (source code) can be download from  

For example:
git clone
cd dhtest

Daily backup of local git changes

While working on a ticket and not ready to commit, it's a good idea to backup all of our changes to an archive file.

The following script does all that and executed daily by cronjob automatically.
  1. create a file, say "backup" in /etc/cron.daily
  2. Type the following (change '<yourhome directory>' to your own login name and <git location> to the git directory where source codes are located):
backing up changed files to tarball
pushd <your source-code location>
LIST=`git status --porcelain | sed -n -e '/^ [D|M]/p' | sed -e 's/^ [D|M] //'`
backupname=`git branch | sed -n -e "/^* /p" | sed  -e 's/** //'`
backupname=$backupname-`date "+%s"`.backup.tar.bz2
dest='<your home directory>'
if [ ! -d "$dest" ]
    mkdir -p $dest
tar jcvf $dest/$backupname $LIST > /dev/null

Make the file executable:
chmod +x /etc/cron.daily/backup

Sunday, March 22, 2015

Block Access during certain period using EBTABLES

Say, we want to block any packets coming from a device with mac address 00:01:02:03:04:05 (in other words, our router/switch should just silently drop any packets coming from this MAC address) during period of time 00:00 (00:00 AM) to 6:00 AM, do:

#ebtables -A INPUT -s 00:01:02:03:04:05  --timestart 0:0 --timestop 06:00 -j DROP

If we just want to drop IPv4 packets for the above:

#ebtables -A INPUT -p IPv4 -s 00:01:02:03:04:05  --timestart 0:0 --timestop 06:00 -j DROP

So, parameters for ebtables are actually similar (yet subset) of iptables (netfilter).