Final blog @ blog.com
Hi,
This is my final blog at Blog.com. I will continue to blog at http://www.maxinbjohn.info/
Hi,
This is my final blog at Blog.com. I will continue to blog at http://www.maxinbjohn.info/
|
Security Alert ICICI Bank has been receiving complaints from our customers of unauthorized access of the NetBanking accounts. As a result we have started reviewing our To update your records click the following link(s) and fill in the necessary requirements : Personal Account Holders - https://infinity.icicibank.co.in/BANKAWAY?Action.RetUser.Init.001=Y&AppSignonBankId=ICI&AppType=retail&abrdPrf=N Please sign in to Online Banking after you have verified your account to ensure your account security. It is all about your security. Sincerely, Benoy Dasgupta |
Hmm… A really good looking work of fraud…… phishing at it’s best.
But I decided to give it a try at Firefox and Internet Explor(d)er. IE acted as though nothing happenned. But the Firefox actually advised me that this is an unsafe website and it is potentially dangerous for me to browse that site !! Watch it…!!

I will call it people friendly technology. Long live Free Software….. and of course Firefox. I feel it is lot more safer for me and people that I know to use Firefox as their default browser.
“A mind map is a diagram used to represent words, ideas, tasks, or other items linked to and arranged radially around a central key word or idea. It is used to generate, visualize, structure, and classify ideas, and as an aid in study, organization, problem solving, decision making, and writing.” — Says wikipedia.
Recent days, I have been using Freemind extensively, for the presentations ( yes, I did one “Introduction to programming in Python” presentation in Freemind for HP zone members of Ushustech). I was really able to convey the “Flow of my thought” using mindmaps in Freemind and I really enjoyed that presentation ( I hope those guys too ).
We can use freemind for designs of applications too. I have decided to do one small Java ME application to find the Body Mass Index (BMI) . First thing I created is the mindmap of that application and then code it. That way, I can think over the application’s features and drawbacks visually. My BMI mindmap goes like this..

Next time , when you are going to present something, do it in Freemind . It will be a refreshingly new experience.
Just download the software from http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-1.3-linux-x86.tgz. As it is a java based Software, make sure that you have openjdk installed in your machine. In the latest Ubuntu Hardy Heron release, the execution of Sweet Home 3D was flawless.
Have a look at my experiements with SweetHome 3D

It’s really cool.. You can make wonders with some sense of beauty and a mind willing to spend hours with this software.
After some comparison by visiting multiple stores, we have decided to buy the Acer Aspire PC, which costs about 23000 (nowadays, I feel laptops are better than Desktops when we think about our wallet). It had a 1.6 Ghz, 1 MB L2 cache, 800 MHz FSB , Intel pentium dual core processor , 1 gb ram, Intel 945 GC motherboard, DVD writer….
Well, the dealers has installed some games on the PC and just after booting the PC in Windows XP , Unnikkuttan started playing the games, mostly nothing to with education and more to do with the violence. Jose Uncle wasn’t that happy with what unnikkuttan doing with the PC.
Next week, I have visited Unnikkuttan’s home , this time with 3DVDs of Debian Etch Gnu/Linux. I have installed the Debian on the 40 GB partition of that massive 160 GB HDD. Installed the Debian Gnu/Linux. Both Unnikkuttan and Ponnu were amused by the installation steps of Debian. The whole installation took around 30 minutes (thanks to that high speed processor with 1 GB ram ).
After that it was the time for Education softwares. I have installed GCompris and Kdeedu and asked Unni and Ponnu to use it. They really liked those programs, I could guess it from their fight for playing the games. Again not willing to hurt Unnikkuttan’s desire for Racing, I have installed the Torcs race game for him. He got thrilled by that game anyway..
The PC boots directly into Debian and I have configured the Debian to have a “passwordless” entry to the Desktop to reduce the “password” problem for children. I know they are smart enough to remember the passwords. But unfortunately I dont’ remember my passwords these days. So I have decided to not to take a chance for myself
Nowadays Unnikkuttan and ponnu are proud owners of a Debian Linux ( I have removed the GNU to for ease of the kids) machine. They are the future, let them play with the Gnu/Linux
( I wonder why people are saying Linux is hard to use while children like Unnikkuttan and ponnu , with ages 4 and 6 respectively are using it without any problem)
To start with Cheetah, we can download the latest release of cheetah from http://sourceforge.net/project/showfiles.php?group_id=28961.
Installation is done by the usual
python setup.py install
After this we are going to test the prime functionality of Cheetah, the Web Development scenario.
The simplest template (Greeting.tmpl)
###################################
Hello, $firstName.
Your order (#$order) has shipped:
###################################
Compile it using Cheetah
cheetah compile Greeting.tmpl
Compiling Greeting.tmpl -> Greeting.py
Now we got a Greeting.py. So let’s test that in python
>>> from Greeting import *
>>> t = Greeting()
>>> t.firstName= ‘Maxin’
>>> t.order = 23342
>>> print t
Hello, Maxin.
Your order (#23342) has shipped:
Hmm.. It works..
Best reference for cheetah is available at http://www.cheetahtemplate.org/docs/users_guide_html
But, again it is fun to create a simple gui which demonstrates how to create an active System tray application using pygtk. My simple app goes like this.
#######################################################################################
#!/usr/bin/env python
import gtk
class StatusIcc:
# activate callback
def activate( self, widget, data=None):
dialog = gtk.MessageDialog(
parent = None,
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
type = gtk.MESSAGE_INFO,
buttons = gtk.BUTTONS_YES_NO,
message_format = “Did you like this Activation example \n by Maxin B. John <maxinbjohn@gmail.com>?”)
dialog.set_title(’Popup example’)
dialog.connect(’response’, self.show_hide)
dialog.show()
# Show_Hide callback
def show_hide(self, widget,response_id, data= None):
if response_id == gtk.RESPONSE_YES:
widget.hide()
else:
widget.hide()
# destroyer callback
def destroyer(self, widget,response_id, data= None):
if response_id == gtk.RESPONSE_OK:
gtk.main_quit()
else:
widget.hide()
# popup callback
def popup(self, button, widget, data=None):
dialog = gtk.MessageDialog(
parent = None,
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
type = gtk.MESSAGE_INFO,
buttons = gtk.BUTTONS_OK_CANCEL,
message_format = “Do you want to close this Status Icon program?”)
dialog.set_title(’Popup Window’)
dialog.connect(’response’, self.destroyer)
dialog.show()
def __init__(self):
# create a new Status Icon
self.staticon = gtk.StatusIcon()
self.staticon.set_from_stock(gtk.STOCK_ABOUT)
self.staticon.set_blinking(True)
self.staticon.connect(“activate”, self.activate)
self.staticon.connect(“popup_menu”, self.popup)
self.staticon.set_visible(True)
# invoking the main()
gtk.main()
if __name__ == “__main__”:
statusicon = StatusIcc()
####################################################################################
Hmm , The code is pretty simple . It is using gtk.StatusIcon() for the System Tray app. The most important signal for the StatusIcon are “activate” and “poup_menu”. The callbacks for those singals are also self explanatory. So not much comments on the code. Now lets see my
app in action.

The Information (i) symbol in the system tray area is the running application. Right click and Left clicks will generate the “poup_menu” and “activate” signals respectively.
Try the tray app for you next programming adventure
Now let’s have a look at python and integrate the Twitter with Python. Python-twitter module is a python wrapper around Twitter API which is available at http://code.google.com/p/python-twitter/. The twitter module depends on simplejson module which is available from http://pypi.python.org/packages/source/s/simplejson/simplejson-1.9.1.tar.gz. As it is a pure python implementation, installation is very easy and traditional.
Then download the python-twitter module from http://python-twitter.googlecode.com/files/python-twitter-0.5.tar.gz .
tar zxvf python-twitter-0.5.tar.gz
cd python-twitter
python setup.py build
python setup.py install
and we are done
Now let’s write the simplest python script to post a message in twitter.
###############################################################
# The simplest python program to play with twitter using python-twitter
# Google Code: http://code.google.com/p/python-twitter/
# Google Groups: http://groups.google.com/group/python-twitter
# Python twitter API can be used to send and receive twitter messages
#
# Thanks to DeWitt Clinton <dewitt@google.com> for this wonderful module
#
import twitter
api = twitter.Api(username=”my_twitter_username”, password=”my_secret_password”, input_encoding=None)
status = api.PostUpdate(“example of the simplest twitter message program “)
print status.text
###########################################################
It is very simple. Now let’s run the code as
python simple_twitter.py
example of the simplest twitter message program
Now when I visit my twitter home (http://twitter.com/maxinbjohn), I can see that message and I think it is cool
Hmm.. it saved a considerable amount of time for me.
uname -a
Linux maxin-desktop 2.6.24-16-generic #1 SMP Thu Apr 10 13:23:42 UTC 2008 i686 GNU/Linux
At first I have tested it in the Ekiga Phone Software. Later decided to do something interesting with that. So I have installed ‘motion’ in Ubuntu Linux
sudo apt-get install motion
About Motion: ” motion uses a video4linux device for detecting movement. It makes snapshots of the movement which can be converted to MPEG movies in realtime (or later for low cpu usage), making it usable as an observation or security system”
Output of motion in Ubuntu Linux using my Logitech Quickcam Go webcam

It runs a webserver on port 8081 in my machine. I will be able to monitor whether somebody is present in front of my pc (or if the ‘motion’ is installed in my home pc, I can check whether somebody is intruding my home or not) using an ordinary web browser.
In the hooks directory of a repository we can find these template files:
post-commit.tmpl pre-unlock.tmpl
post-lock.tmpl pre-commit.tmpl
start-commit.tmpl post-revprop-change.tmpl
pre-lock.tmpl post-unlock.tmpl pre-revprop-change.tmpl
start-commit Before the commit transaction starts
pre-commit After the commit transaction starts but before the transaction is commited
post-commit After the commit transaction completes
pre-revprop-change Before a revision property is changed Repository Path,
post-revprop-change: After a revision property is changed Repository Path
pre-lock: Before the lock being acquired
post-lock: After the lock being acquired
To test how a hook works, let’s create a repository in our Gnu/Linux Box.
svnadmin create hello
Now we have a repository called hello and it will contain files like
conf dav db format hooks joke.py locks pre-commit README.txt
Modify the conf/svnserve.conf to include passwd file and add users to the passwd file along with their passwords.
Then run the server as svnserve -d -r hello
To checkout :
svn co svn://127.0.0.1
Then lets move to the real work. We need to stop anybody who is trying to commit to our repository just because we are doing some important work on the server or we just dont want anybody to help us
To do that, let’s create a file called pre-commit in hooks folder in the repository (hello). The content of the pre-commit should be :
#!/usr/bin/env python
# ====================================================================
# The simplest pre-commit hook which prevents all the commits to the repository
# This can be useful(?) when you are doing the backup of your subversion repo.
# This small script will prevent the commit and will give a simple message
# to the person who is commiting the changes.
#
# USAGE:
# copy this script as pre-commit in the hooks directory of the svn server
#
# ====================================================================
import sys
MESSAGE=”"”
Dear Sir,
As we are doing some important work in the server,all those who are submitting
the changes will have to wait for some time.
Sorry for the inconvenience caused.
Regards,
Administrator.
“”"
# Messages written to the stderr will be shown to the person who is commiting.
sys.stderr.write(MESSAGE)
# Need to exit with anything other than 0 to fail the commit
sys.exit(2)
Let’s change the mode of the pre-commit to executable (chmod +x pre-commit)
To test this setup, lets create a sandbox and then try to commit our changes to the server.
svn co svn://127.0.0.1
cd 127.0.0.1
mkdir test
svn add test
svn commit -m “adding the test directory”
Now we will see the pre-commit hook in action:
Adding test
svn: Commit failed (details follow):
svn: ‘pre-commit’ hook failed with error output:
Dear Sir,
As we are doing some important work in the server,all those who are submitting
the changes will have to wait for some time.
Sorry for the inconvenience caused.
Regards,
Administrator.
This is the most simplest hook that can be implemented in Python. More complex hooks can be implemented in python using the svn module. More useful hooks examples are available from http://subversion.tigris.org/tools_contrib.html#hook_scripts