[Cool trick] Shortcut to mkdir and cd to it!

Append following code to /$HOME/.bashrc

function mkdir{
  command mkdir $1 && cd $1

Then, execute .bashrc

source ~/.bashrc

Using Git bisect to find out when a bug was introduced!

—-Simplified explanation—-
Here’s how to use git bisect , step-by-step!
Step 1: Find a commit where things were working. …
Step 2: Find a commit where things are not working. …
Step 3 – N: Use git bisect to find the problem commit. …
Step 4: Get back to a working state.
Using Git bisect to figure out when brokenness was introduced

Step by step with code.

git log -4 # find previous working commit
git checkout #hash
git bisect ?

run through previous commits then

git bisect good or bad
git checkout #hash

See link to get more info and better understanding.

How to ignore files only locally in git?

I have automated tests running everyday, and the issue is that those tests make necessary changes to certain files depending on which test is running. This becomes a problem when I have to report the changes in the repo, as this will report untracked changed, which means I have to ignore certain files such that local Git doesn’t report changes in them specifically.

By making sure to run git update-index --assume-unchanged ./matplotlibrc after making the addition to the exclude file this means changes won’t be picked up until then.

git update-index --assume-unchanged index.rst
git update-index --assume-unchanged matplotlibrc




Changes made but untracked, nice!!!

How can I merge two or more Git commits into one[locally and remote]?

You can do this fairly easily without git rebase or git merge --squash. In this example, we’ll squash the last 3 commits.

If you want to write the new commit message from scratch, this suffices:

git reset --soft HEAD~3 &&
git commit

If you want to start editing the new commit message with a concatenation of the existing commit messages (i.e. similar to what a pick/squash/squash/…/squash git rebase -i instruction list would start you with), then you need to extract those messages and pass them to git commit:

git reset --soft HEAD~3 && 
git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"

Both of those methods squash the last three commits into a single new commit in the same way. The soft reset just re-points HEAD to the last commit that you do not want to squash. Neither the index nor the working tree are touched by the soft reset, leaving the index in the desired state for your new commit (i.e. it already has all the changes from the commits that you are about to “throw away”).

Important: If you’ve already pushed commits to GitHub, and then squash them locally, you will have to force the push to your branch.

$ git push origin branch-name --force

Helpful hint: You can always edit your last commit message, before pushing, by using:

$ git commit --amend


Repurpose Old Smartphones for Home Automation by Turning Sensors into Signals [Paper]


This paper proposes an approach to building a low-cost offline home automation or appliance automation by means of re-purposing old and unused smartphones by means of exploiting low-level sensors such as an accelerometer, microphone, GPS, and temperature. It takes information about the surrounding environment through the low-level sensors from a smartphone’s sensor(s) and uploads it directly to the Raspberry Pi for processing before making relevant changes to the home environment, for instance, switching the light on/off by means of shaking your smartphone which utilizes the low-level accelerometer sensor. Experimental results demonstrated that the system can accurately control a home environment and have been offline the user doesn’t risk uploading their personal information to the internet which offers privacy and at this day of age cyber-security is a priority when you work home automation systems as most of them depend on being online as well as uploading important information to the internet which some people might end up using against the home-owner.

Research Interests: 
Paper can be found on:


Diagnosing LAN Speeds

After having network issues/degradation while trying to access a work server, I had to diagnose the network the server is connected to. I had to set myself on a mission – and after realising that the seems to be very limited tools for such things, I stumbled upon ‘iperf‘.

Iperf is a command-line tool used in the diagnostics of network speed issues, it measures the maximum network throughput a server can handle. It is particularly useful when experiencing network speed issues, as you can use Iperf to determine which server is unable to reach maximum throughput.

Iperf installation

Iperf must be installed on both computers you are testing the connection between.

sudo apt-get install -y iperf

TCP Clients & Servers

Iperf requires two systems because one system must act as a server, while the other acts as a client. The client connects to the server you’re testing the speed of.

  1. On the node you wish to test, launch Iperf in server mode:
iperf -s

You should see output similar to:


2. On your second Linode, connect to the first. Replace dbelab04 with the first node’s IP address in my case i’m using the hostname

iperf -c dbelab04

You should see output similar to:

3. You will also see the connection and results on your Iperf server. This will look similar to:


4. To stop the Iperf server process, press CTRL + c.


You can do pretty much the same thing with plain old nc (netcat) if you’re that way inclined. On the server machine:

nc -vvlnp 12345 >/dev/null

You should see something similar to:


And the client can pipe a 10Gb of zeros through dd over the nc tunnel.

dd if=/dev/zero bs=10M count=1K status=progress | nc -vvn 12345

You should see something similar to:


The timing there is given by dd but it should be accurate enough as it can only output as fast the pipe will take it. If you’re unhappy with that you could wrap the whole thing up in a time call.

Remember that the result is in megabytes so multiply it by 8 to get a megabits-per-second speed. The demo above is running at 11.8mbps due to my laptops network limitation and number of hops…

Jenkins – Add Color to Console Output

Jenkins console output is place where you can spend decent amount of time trying to figure out what went wrong (or perhaps right?).

AnsiColor plugins gives you opportunity to color monochromatic Jenkins console output.

1. Install AnsiColor plugin
On Jenkins:
Manage Jenkins > Manage Plugins > Available
> search and install ‘Ansi Color’

2. Configure your build/job
Under Build Environment section check Color ANSI Console Output and select xterm

3. Inside Execute shell step add something like:

set +x
info() {
echo "\033[1;33m[Info]    \033[0m $1"

error() {
echo "\033[1;31m[Error]   \033[0m $1"

success() {
echo "\033[1;32m[Success] \033[0m $1"

info "This is information message"
error "Houston we have a problem"
success "Great!!!"

echo "Foreground colors"
echo "\033[31m Red \033[0m"
echo "\033[32m Green \033[0m"
echo "\033[33m Yellow \033[0m"
echo "\033[34m Blue \033[0m"
echo "\033[35m Magneta \033[0m"
echo "\033[36m Cyan \033[0m"
echo "Background colors"
echo "\033[41m Red \033[0m"
echo "\033[42m Green \033[0m"
echo "\033[43m Yellow \033[0m"
echo "\033[44m Blue \033[0m"
echo "\033[45m Magneta \033[0m"
echo "\033[46m Cyan \033[0m"
echo "Different combinations"
echo "\033[1;31m Red \033[0m"
echo "\033[1;4;37;42m Green \033[0m"
echo "\033[1;43m Yellow \033[0m"
set -x

4. On console output