Linuxgazette app for Android Platform
Today, I have created Android and Windows Mobile apps for www.linuxgazette.net
Thanks to www.appmakr.com for a “code-less” app generation for Android and Windows mobile platforms !!
Thanks to Vishnu, Arun and Jithendra for installing and using the Linuxgazette.net application on Nexus, Wildfire and Xperia handsets.
A quick fascination with QR (Quick Response) codes
The QR codes makes our life real easy. If you have the right QR Code reader application in your mobile, you just need to show your mobile to the QR code and bingo you got the text/content/app in your mobile… You don’t need to type anything. I almost got addicted to this technology when I started using the Android Mobiles.. Just click and there you go…
More information is available from Wikipedia:
http://en.wikipedia.org/wiki/QR_code
To make our own QR codes in Ubuntu, we need to follow these steps:
First, install the Library for QR encoding: “libqrencode” :
# wget http://fukuchi.org/works/qrencode/qrencode-3.1.1.tar.bz2
# tar jxvf qrencode-3.1.1.tar.bz2
# cd qrencode-3.1.1/
# ./configure –prefix=/usr
# make
# sudo make install
This will install the “qrencode library” as well as the “qrencode” application to create the QR codes.
Eg. The following command will create the QR codes for you:
# qrencode http://www.maxinbjohn.info -o maxinbjohn.png -s 10
If you are not satisfied with this application and do some programming in Python, then go on and follow these steps:
# git clone https://github.com/bitly/pyqrencode.git
# cd pyqrencode/
# sudo python setup.py install
This will install the “qrencode” module for Python. A simple python program to create a very personal QR code:
$ cat hello.py
from qrencode import Encoder
enc = Encoder()
image = enc.encode(‘http://www.maxinbjohn.info’)
image.save(‘maxin.png’)
The output of this program :

GNOME3 .. the awesomest gnome ever…
Python Script to automate the Assembly Language Debugger
The Assembly Language Debugger is a tool for debugging Linux elf files (executable programs) at the assembly level.
ALD is available here: http://ald.sourceforge.net/
This script makes it easy to collect the complete disassembled output from ald : disas.py
eg:
# python disas.py ./a.out
This script uses “expect” to collect the complete disassembled output of the executable file. Without this script, the user will have to keep on pressing “enter” to collect the complete output from ald.
# This post will be moved to the random scripts page shortly
The Man with the GPLv3 Watch
I received my Ez430 Chronos Wireless watch development kit yesterday. A watch with temperature sensor, Pressure sensor, 3 axis accelerometer and a CC430-based development system for just $49. TI just priced it right…

There were some programs to use the watch as Mouse , Controlling the PPTs and so on. Still, I wasn’t so happy, because I didn’t get to see what’s “inside” the watch — “The Internals of the firmware”
Time for building the “OpenChronos” firmware for the watch. It is licensed under GPL v3 and we will get to see the code from here:
https://github.com/poelzi/OpenChronos/
Make sure you are connected to INTERNET.
Prepare the development environment in your PC or Laptop. Lets start with the MSPGCC tool chain.
# sudo su
# apt-get install makeinfo
# git clone git://mspgcc4.git.sourceforge.net/gitroot/mspgcc4/mspgcc4
# cd mspgcc4 && perl buildgcc.pl
select the default choices for the toolchain build options.
# make
The MSP430-GCC toolchain will get installed in the default path: /opt/msp430-gcc-4.4.5
Get the OpenChronos source:
# git clone https://github.com/poelzi/OpenChronos.git
If you havent read the GPLv3 License till now, please do so from the OpenChronos directory
# vim gpl-3.txt
Export the msp430 toolchain PATH
# export PATH=$PATH:/opt/msp430-gcc-4.4.5/bin/
Go to Openchronos directory, choose the modules for the firmware and build it.
This is similar to the ‘make menuconfig’ of the Linux kernel build procedure:
# make config
# make
If everything goes well, you will get these two files in “build” directory.
eZChronos.elf
eZChronos.txt
choose the ezChronos.txt (TI specific format for the CC430)
Go to the (default) path of eZ430 Control Center.
# cd /usr/local/eZ430-Chronos Setup/Control Center/Chronos Control Center
# ./eZ430-Chronos_CC_1_1.tcl
In the Control Center’s Flash tab, Select the “eZChronos.txt”. Set the Watch into “RFBSL” mode and start flashing.
You can see the percentage of flashing process in the LCD of the watch. Within a minute, the OpenChronos firmware will kick into action.
Switch the watch to “SYNC” mode and update the date and time from your Linux PC. Now wear it.. You are the “Man with the GPLv3 Watch”
With default TI firmware:

With OpenChronos firmware:

FAQ:
1. Why are you calling this post as “Man with the GPLv3 Watch”
I am a huge fan of James Bond Movies. This name is inspired by “The Man with the Golden Gun” (Roger Moore, Christopher Lee)
2. How do you understand that your watch uses the “original” TI firmware or OpenChronos firmware ?
1. Original firmware dont show the “day of the week”
2. OpenChronos firmware doesnt support the “BlueRobin” (Just press the * key to check it)
3. Most visible change is in the ‘ACC’ mode. It is shown as “ACC” in orignal firmware, where as it is “Acc” in OpenChronos firmware
Official list is as below:
* More Features that can be configured with make config
* Day of week
* Disable 12h support (saves space)
* Sleep Phase Clock – primary designed for http://github.com/poelzi/uberclock
* The wireless flashing starts differently:
Select RFBSL, Press DOWN to unlock, Press # long to start
* No BlueRobin support. BlueRobin is a closed source binary blob.
We don’t have a compatible object file for that
* Pressing STAR and UP long sets silent mode (no beep)
3. What is the use of using the GPLv3 Licensed firmware on your watch?
Technically, it gives me the freedom to read, study and modify the firmware of this watch.
Well, I just want to use Free Softwares in all the equipments that I use. This just makes me happy ![]()
4. Where can I get more information ?
* http://processors.wiki.ti.com/index.php/EZ430-Chronos
* http://mspgcc4.sourceforge.net/
The Linux Foundation Credit Cards !
Personally, I never liked the Financial fundamentals behind the Credit Cards. However, due to some personal requirements, I have decided to go for a credit card. I got my credit card from Nordea Bank, last month.
I would have applied for the Credit cards much earlier, if these Credit cards were present in India..
Yes. You can go for these cards if you are in US. It is provided by UMB Financial Corporation.
You can apply for The Linux Foundation Visa® Platinum Rewards Card here: http://www.cardpartner.com/app/the-linux-foundation
Happy Hacking and Shopping
A simple C program to calculate Levenshtein distance
Levenshtein distance is a metric for measuring the amount of difference between two sequence. The sequences will be strings in most of the real life cases.
More information is available at Wikipedia: http://en.wikipedia.org/wiki/Levenshtein_distance
Its a simple program to implement it.
/******************************************************
* A simple program to calculate Levenshtein distance *
* *
* http://en.wikipedia.org/wiki/Levenshtein_distance *
* *
******************************************************/
#include<stdio.h>
#include<string.h>
int levenshtein_compare(const char *s1, const char *s2)
{
int l1 = strlen(s1);
int l2 = strlen(s2);
return l1 != l2 ? l1 - l2 : strcmp(s1, s2);
}
int main()
{
const char *str1 = "strong";
const char *str2 = "string";
printf("Levenshtein Distance is %d \n", levenshtein_compare(str1, str2));
return 0;
}
If you want to think of it in Python, here it goes:
# Python program for simple lavenshtein distance calculation
def levenshtein_compare(s1, s2):
len1 = len(s1)
len2 = len(s2)
if (len1 != len2):
ret_val = len1 – len2
else:
ret_val = cmp(s2,s1) #(s1 > s2) – (s1 < s2)
return ret_val
if __name__ == “__main__”:
print “Distance is:”, levenshtein_compare(“paintt”, “past”)
Let others to locate you in the world using Android, Python, PHP and Google Maps
“Locate mii” – a DIY solution to publish your location to the web so that other people can locate “where in the world you are !!”
To locate me now, go to this URL:
http://goo.gl/QThKv
Requirements:
1 .An Android Phone with Android scripting environment (for Python support).
2. A GPRS connection to push your latitude and longitude values to the web server
3. A website where you can run PHP scripts (Otherwise, you can use the Local wireless setup with Internet connection)
Design:
1. A Python script reads the latitude and longitude values from the Android’s GPS and pushes it to the web server using GPRS
2. A PHP script in the web server to parse and write the submitted values to corresponding files in the server
3. Another PHP files to read those latitude and longitude values from server and pass it to the Google Maps api to help others locate you in this world
Code :
1. livegps.py ( To fetch and submit latitude and longitude to the web from an android phone)
Available at : http://pastebin.com/HusGn77z
==========================================================
”’
Started on 10, Dec 2010 by Maxin B. John <maxinbjohn@gmail.com>
This file is licensed under the GPLv3
”’
import android
import urllib2
import time
import string
droid = android.Android()
def get_update_gps_status():
”’ GET and Update the GPS status in Server”’
# PHP script expects the longitude and latitude in the URL as given below
GPS_URL=’http://www.maxinbjohn.info/locate-mii/test.php?lat=%s&long=%s’
# begins the gps location process in Phone
droid.startLocating()
# giving some time for the phone to think ![]()
time.sleep(10)
try:
# read the latitude and longitude from the phone
loc= droid.readLocation()[1]
# check for Null in pythonic way
if loc:
longitude = loc['network']['longitude']
latitude = loc['network']['latitude']
# prepares the URL as expected by the PHP script
url = GPS_URL % (latitude, longitude)
print url
try:
# submits the latitude and longitude values to the web page
handler = urllib2.urlopen(url)
# to ensure the data submission
data = handler.read()
except URLError:
print “Error in Connection!”
finally:
handler.close()
except:
print “Error in getting the lattitde and longitude values!”
if __name__ == ‘__main__’:
”’ Updating the GPS status in Server ”’
while True:
get_update_gps_status()
=======================================================
2. test.php (sorry for the horrible naming.. It’s a simple PHP script to write down the latitude and longitude values)
Available at: http://pastebin.com/A71D2ka9
=========================================
<html>
<?
$latitude = $_GET['lat'];
$longitude = $_GET['long'];
$latf = “mylattitude.txt”;
$longf = “mylongitude.txt”;
$latfh = fopen($latf, ‘w’) or die(“can’t open file”);
fwrite($latfh, $latitude);
fclose($latfh);
$longfh = fopen($longf, ‘w’) or die(“can’t open file”);
fwrite($longfh, $longitude);
fclose($longfh);
echo “var mylocation = new google.maps.LatLng($latitude, $longitude);”;
?>
</html>
=========================================
3. locate-mii.php
Available here: http://pastebin.com/89kpCGtp
============================================
<!DOCTYPE html>
<html>
<head>
<meta name=”viewport” content=”initial-scale=1.0, user-scalable=no” />
<meta http-equiv=”content-type” content=”text/html; charset=UTF-8″/>
<title>Locate Mii</title>
<link href=”http://code.google.com/apis/maps/documentation/javascript/examples/default.css” rel=”stylesheet” type=”text/css” />
<script type=”text/javascript” src=”http://maps.google.com/maps/api/js?sensor=true”></script>
<script type=”text/javascript”>
var initialLocation;
<?
$filename1 = “./mylattitude.txt”;
$handle1 = fopen($filename1, “r”) or die(“can’t open file”);
$lattitude = fread($handle1, filesize($filename1));
fclose($handle1);
$filename2 = “./mylongitude.txt”;
$handle2 = fopen($filename2, “r”) or die(“can’t open file”);
$longitude = fread($handle2, filesize($filename2));
fclose($handle2);
?>
var mylocation = new google.maps.LatLng(<? echo $lattitude ; ?>,<? echo $longitude; ?>);
var browserSupportFlag = new Boolean();
var map;
var infowindow = new google.maps.InfoWindow();
function initialize() {
var myOptions = {
zoom: 18,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById(“map_canvas”), myOptions);
browserSupportFlag = false;
handleNoGeolocation(browserSupportFlag);
}
function handleNoGeolocation(errorFlag) {
initialLocation = mylocation;
contentString = “I am here!”;
map.setCenter(initialLocation);
infowindow.setContent(contentString);
infowindow.setPosition(initialLocation);
infowindow.open(map);
}
</script>
</head>
<body onload=”initialize()”>
<div id=”map_canvas”></div>
</body>
</html>
==========================================
Todo:
1. Code cleanup
2 . Auto refreshing of google maps page
Warning:
It’s a DIY thing. I haven’t incorporated any security measures to the code. Code is really ugly and logic is pretty simple.
Finally don’t blame me if your boss locates you in a Cinema hall while you are in “Sick leave”
Comments are welcome !!



