December 31, 2008

Happy New Year 2009!

As we close in on 2008, here's wishing all of you and myself a very Happy New Year!

This will be my last post this year, so signing off in style:


This was a great year. God was simple awesome.

Thanks to all of you and wish you all the very best in what ever you do. Do no Evil :-)

Enjoy! See you next year :-)

Independent Research is not so easy after all

December 30, 2008

Book Review: The Theory of Everything: The Origin and Fate of the Universe

I finished reading The Theory of Everything: The Origin and Fate of the Universe by Stephen Hawking, which is one of the newest additions to my library.

It is a collection of essays by Stephen Hawking as he shares his views on the origin of the universe with the reader. Rightly composed as a collection of essays, there possibly cannot be a unified treatment of the various theories that exist or existed or will exist on the subject. The essays talk about Black Holes, Bing Bang model, the theories that about of the current state and fate of the universe.

I particularly liked the essay on the arrows of time (Wikipedia article) . Starting from the earliest theories of about the Universe, this book proved to be a good refresher of the earliest science classes I took back in my pre-university classes.

I must confess that I did not get the hang of many a thing of what he has written about, but then I am no science geek.

December 29, 2008

Year Update: The good, better and the best, switch to KDE

Couple of days to go in 2008. It's not my style to write year end reviews in public. However I am going to do it this time. This year has all been about the good, better and the best in my life. I don't write diaries, so I would better log it somewhere where I can find it tomorrow, day after and years after...

First up, major highlights:

  • Graduation: I completed my under-graduate studies (from Haldia Institute of Technology) with major in Computer Science and Engineering. I did perform well too, finishing with a overall 8.58/10 score. Thanks to all my teachers/professors who allowed me to bunk classes (I had barely 30 % attendance, but I still managed to pass :-) ).
  • Sun Microsystems: I joined Sun Microsystems, India immediately after my studies. Boy! That is wha you call- Dream Come True
  • Moved to Bangalore from West Bengal
  • Featured on Sun Developer Network, South Asia: I was featured on the SDN South Asia page in November, 2007
  • First Foreign Trip: Yippie! I went to Riga in Latvia (Western Europe) during September, 2008
  • Go Karting: The most non-geeky fun thing I did this year
Miscellaneous stuffs worth mentioning:
  • I took over BOJUG, a enthusiastic community of Java developers in Bangalore. This is a great experience to run a community
  • I am a NetBeans comitter now
  • I started learning Lisp
  • I am coding more in Python and helping the Python support in NetBeans project
  • I blogged a LOT at this blog and http://blogs.sun.com/amitsaha
  • I have credit cards now :-)
  • I have been reading pretty well this year
  • I ate at a LOT of different places in Bangalore. I know more about cuisines than I knew 6 months back. I haven't repeated ANY restaurant, so far, courtesy Sayantini (No. She doesn't have a blog yet)
Turning point:

The year also proved to be a turning point in a small way (might turn out to be bigger). I was all set to pursue a research career in Parallel Computing/Artificial Intelligence having worked under Prof. Kumar Sankar Ray, Indian Statistical Institute, Kolkata. An offer from Sun Microsystems and other compulsions left me with no choices, however. Its good so far. But my heart still yearns for the scientific community and folks like the Late Randy Pausch makes it all the more attractive.

I am not expecting anything more dramatic to happen this year to merit a update to this post.

(This isn't dramatic, but a very significant happening)

UPDATE: Couple of things I forgot to mention:
  • I have switched from GNOME to KDE full-time. Its a switch for the better. I found KDE too much "cluttered", so I was happily a GNOME user. Thanks to the constant GNOME bashing of my colleague, Kunal I made a switch to KDE, gave it sometime and I think GNOME is for nannies and the newbies to Linux. GNOME is simple, but underpowered
  • I also made the switch to OpenSUSE from Ubuntu, full time after 4 years, mainly because KDE doesn't rock on Ubuntu and I wanted to try KDE.
How did your year go? Do I have any reader? :-)

December 28, 2008

Book Review: Practical Common Lisp

Practical Common Lisp is a freely available book on Common Lisp which gives the impression that it can be appealing to the ignorant but enthusiastic newbie to Lisp. Lisp and other languages of this niche category are often thought to be of any use, only in academic circles. This book attempts to dispel that myth by having a ToC which mixes theory and practical applications, both.

I have a working knowledge in C/C++, Python and Java and am knowledgeable of the Functional Programming paradigm. However, I have zero experience with any dialect of lisp.

In this post I shall try to put down my own reviews. chapter wise, as I read and work them.

Chapter 1: Introduction: Why Lisp?
From the book chapter: "If you think the greatest pleasure in programming comes from getting a lot done with code that simply and clearly expresses your intention, then programming in Common Lisp is likely to be about the most fun you can have with a computer. You'll get more done, faster, using it than you would using pretty much any other language."

This chapter puts the whole book into perspective and answers the first question that comes to the reader's mind. A bit of history about Lisp is discussed, along with the author's personal experiences with Lisp about getting the job done in much fewer lines of code.

Personally, I love picking up a new language from time to time. Lisp has been beckoning me for some time now. Hence, I picked up the book at the first instance.

A good first chapter. Me, the newbie likes it.

Chapter 2: Lather, Rinse, Repeat: A Tour of the REPL

The first taste of Lisp programming is felt in this chapter.

Lisp in a Box packages a Common Lisp implementation- Allegro with the Emacs editor and
SLIME- Superior Lisp Interaction Mode for Emacs. Once you extract the
tarball downloaded, you will find that there is Allegro CL
implementation, Slime and Emacs binaries.

On executing the 'lispbox.sh' script, you will finally get Lisp prompt:CL-USER>

You
can also modify the 'lispbox.sh' script to use your existing Emacs
binaries, instead of the one bundled. Modify the last line, starting
with exec emacs to point to your own Emacs installation. For eg.
exec /usr/bin/emacs --no-init-file --no-site-file --eval='(progn (load "lispbox") (slime))'<br />
The List processing is well introduced with examples such as (+ 2 3), (format t "hello world") . The concept of the return values and side-effects of functions is well demonstrated.

The rest of the chapter takes the reader in a REPL loop, moving from a "Hello, World" value Lisp code to a "Hello, World" program to the concepts of functions in Lisp. The reader also learns to save his Lisp programs and load use them in later sessions. The Lisp debugger is also mentioned.

Readers
new to Emacs are made familiar some rudimentary Emacs commands to move
around, save files, compile and re-compile Lisp sources.

Along with being a introductory chapter on Lisp programming, the reader almost has a feeling that he is learning Emacs as well, which is double whammy :-)

UPDATE: More than being a double whammy, I think its more of a hindrance to try and learn Emacs along with Lisp, even though the two do go hand-in-hand. You are better off just using the Allegro CL Environment for the code editing and execution.

All set for the next chapter.

Chapter 3: Practical: A Simple Database

This chapter is the book's first Practical chapter in which you write some CL code to design a useful working application for you. Here, the reader code a MP3 database for a personal music collection.

This is the first post Hello World program and language features such as the fundamental list, Lisp operators- functions, macros, Property lists- simplified, but useful stripped down hash table-like data structure, Simple interactions with the user, loading and saving files on disk.

Lambdas, or anonymous functions are introduced and used widely in the code.

I come from a background in C/C++, Python, Java where one of the things I essentially do is call a function and use its return values in variables or placeholders. What I learnt in this chapter, is to design a program around functions and lambdas (anonymous functions). Yes, Python has lambdas, but I haven't learnt to design my program around it, till now.

Another concept that I really found new is the concept of macros in Lisp:

"Common Lisp macro shares
essentially nothing but the name with the text-based macros found in
C and C++. Where the C pre-processor operates by textual substitution
and understands almost nothing of the structure of C and C++, a Lisp
macro is essentially a code generator that gets run for you
automatically by the compiler. When
a Lisp expression contains a call to a macro, instead of evaluating
the arguments and passing them to the function, the Lisp compiler
passes the arguments, unevaluated, to the macro code, which returns a
new Lisp expression that is then evaluated in place of the original
macro call."

Pure enlightenment.

Somwhere in my mind, now I have started thinking about a program as independent blocks of symbols and operators with the order of evaluation being determined by the parenthesis. I think I will be able to write this in a more sensible way as I learn more of this.

As a side note, I would highly recommend you to read this article: The Nature of Lisp

Chapter 4: Syntax and Symantics

This chapter helps you to sink in all that has been introduced in the previous chapter. It introduces the basic paradigms and concepts behind a Lisp program with just the right amount of detail.

The burning question: What's with All the Parentheses? is addressed in this chapter. Why does such a syntax make sense? This is explained by talking about how the execution of a Lisp program differs from the stages of execution of a program coded in other languages in Breaking Open the Black Box.

S-expressions
and symbols- functions, macros and special symbols are all explained in detail. The usage of macros in the previous chapter is explained in greater detail here.

The reader also gets to know about how all (almost) Lisp operations are evaluated as functions and all expressions are Lists in Lisp. Thus, appreciating all the parenthesis that surrounds the code.

The chapter concludes by looking at Truth, Falsehood, and Equality
in Lisp.

Chapter 5:
Functions

Functions, which is one of the three basic components of Lisp programs (others being, macros and variables) are given detailed treatment in this chapter. After using them in chapters 2 and 3, this chapter looks at the various components of a function in great detail.

Different kinds of parameters that a function can take is discussed here.

Returning from functions, Higher Order functions, Lambdas (Anonymous functions) are the other things discussed.


Chapter 6: Variables

This chapter takes a look at another basic building block of Common Lisp- variables.
Lexical and Dynamic variables and their features are discussed in detail. Closures are discussed for the first time in this chapter.

Basic operations on variables are demonstrated.


Chapter 7 and 8: Macros: Standard Control Constructs, Defining your own

In these two chapters, the author writes about Macros in Common Lisp. In chapter 7, the author looks at the standard control construct macros defined by Common Lisp. This chapter helps the reader to understand a lot about how macros are used, almost everywhere in the language itself in Common Lisp.

The next chapter builds upon the former to help the reader to write a trivial, but useful macro on his own, introducing concepts along the way to write code that writes code.


Chapter 9: Practical: Building a Unit Testing Framework

In the second Practical
chapter, the author helps the reader code a simple Unit Testing
Framework, mostly making use of some of the concepts introduced in the
last couple of chapters on Macros.

Chapter 10: Numbers, Characters and Strings

As the name of the chapter suggests, this will be one of those reference chapters you will coming back to, as you use more of numbers, characters and strings in the Common Lisp language.

From here onwards, you will notice that, reviews for later chapters appear earlier and vice versa.

This indicates a couple of things:

  1. That I am reading the chapters, which I find interesting first and then coming back to some earlier chapter which might have been referred to in there
  2. More importantly: Most of the basics have been covered till Chapter 10

Chapter 21: Programming in the Large:Packages and Symbols

As is apparent, this chapter is a first step in the world of writing and using medium to large scale Common Lisp codes. As you start coding you may want to help the world by creating and distributing your own packages or use a lot of third party packages which provide Common Lisp features which may not be available in a standard implementation. This chapter takes on a tour of packages and a detailed look into how the REPL resolves symbols.

A must read before moving on to the later chapters.

Chapter 14 and 15:

Files and File I/O and the next Practical chapter, as their names suggest looks at working with files- text and binary using Common Lisp.

These chapters introduce important concepts such as Pathnames which help abstract Operating System level differences in the way files are referred to. The practical chapter builds upon Pathnames to code up a truly portable pathname library using *FEATURES* to work across several Common Lisp implementations. This pathname package will be used in later chapters to code up other practically useful tools.


Post last updated on March 10, 2009

December 27, 2008

Randy Pausch: The Last Lecture

Being true to my, better-late-than-never way of life and the way I seem to miss out on time, I just watched Randy Pausch's Last Lecture- a good 1 year after he delivered it.

But boy, this was the first ever streaming video of this length that I watched at one go- without checking my mails in between, alternating between the N windows open and blah, blah. I am not saying all this because that will make you watch it. I hardly add any kind of value to your opinions, anyways.

I just want all of you to watch it. It will be worth it. Your link:
http://www.cmu.edu/uls/journeys/randy-pausch/index.html

December 24, 2008

Walking up/down directory trees in Python

You can use the os.walk in Python to traverse a directory tree:

os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]])

For example:


#!/usr/bin/python

import tarfile
import os

for dirpath, dirnames, filenames in os.walk("/tmp"):
print dirnames

gives:
/tmp
/tmp/.vbox-amit-ipc
/tmp/ssh-zYrvo4322
/tmp/.ICE-unix
/tmp/kde-amit
/tmp/plugtmp-1
/tmp/acroread_1000_100

The output can be best understood when co-related with the o/p of tree.

Usage: A simple Python script to create a tar archive out of a directory is here

Book Chapter Review: (Python) Package Management

Chapter 9 of the book Python for Unix and Linux System Administration, 1st Edition discusses package management in the Python programming language.

When you read the chapter, you get a feeling that you are reading about package management on your favorite Linux distro, which IMO is a good thing. I, personally love to co-relate the new things I learn with things I already know.

It starts off with Python's own apt-get (or zypper or yum): easy_install. Then it moves on to Python eggs, and how simple it is to create them.

You have written a Python package and you want to upload it to the Python package index. The book shows you how.

The chapter also looks at Buildout, and virtualenv (which helps set up more than one 'virtual' Python environments on your system, like chroot does)

Update: The book also talks about ESP Package Manager (EPM)

December 23, 2008

Automating your FTP session using expect

Shamelessly derived from a code on the Wikipedia entry for Expect, here is how you would automate a FTP session:


# Open an ftp session to a remote server, logs in using your credentials and retrieves the current
# directory listing from there

# Amit k. Saha

# This is how you set variables in 'expect'

set remote_server your-ftp-server
set my_user_id your-user-ide
set my_password your-pass

spawn ftp $remote_server
expect "username:"

# Send the username, and then wait for a password prompt.
send "$my_user_id\r"
expect "password:"
# Send the password, and then wait for an ftp prompt.
send "$my_password\r"

expect "ftp>"

# list all the files
send "ls \r"

expect "ftp>"

# Exit the ftp session, and wait for a special end-of-file character.
send "bye\r"
expect eof

December 22, 2008

CSV to HTML Table in Python

I recently wrote a quick script to convert CSV files of the form:

foo, bar
blah, blah

into nice HTML displays.

Pseudo code:

  1. Open the CSV file for reading
  2. Parse each line of the CSV file
  3. Each line of the CSV file => 1 row in the HTML file table
  4. repeat 2 and 3
The code is here

Hope it is useful! Suggestions to improve it welcome.

PS: Useful tips for handling CSV files in Python is here

BOJUG Meet in Pics

Tirthankar has got the pics (almost all of them) of our last BOJUG meet on his blog.

Here is one, he did not post:



Me, Abhishek, Tirthankar

It was a great meet. Thanks to Vaibhav, Subroto, Tirthankar, Abhishek and Vasudha.

December 18, 2008

BOJUG Meet: JavaFX in all the screens of your life!

Hi Folks,

To celebrate the launch of JavaFX (http://www.javafx.com), we are having a JavaFX special *BOJUG* (http://groups.google.com/group/bojug) meet this *Saturday*.

Please find the details of the meet as follows:

Date & Venue:

*Saturday, 20th December 2008*

Starting time: *03.00 PM*

Sun Microsystems India Pvt. Ltd.
Himalaya Conference Room,
Ground Floor, DivyaSree Chambers,

*Sessions:*

JavaFX in all the Screens Of Your Life! , By: Vaibhav Chaudhary
(http://blogs.sun.com/vaibhav/), and Subrata Nath, Sun Microsystems, India


Highlight: *JavaFX* and **Pizzas*** !

If you are planning to attend, please put up your name on the wiki
page at http://bojug.wikispaces.com. Putting up your name will
*ensure* that you get a Pizza and also help in smooth conduction of
the meet :-)

For any queries, please contact me : amitsaha.in@gmail.com

See you!

December 17, 2008

Fast Forward













Mailing list archives for The Tutor Archives

December 16, 2008

Pygments: Python syntax highlighter engine









http://pygments.org/

Sample Python Projects in NetBeans IDE

I have pushed some basic sample projects in Python/Jython to help you in Python development with NetBeans.



















For details, please see the page at http://wiki.netbeans.org/Nbpysamples

December 12, 2008

Vote for NetBeans

We need your vote for NetBeans as the BEST IDE in the SOA Readers' Choice Awards

Bitbucket: Free Mercurial (Hg) code repositories

http://www.bitbucket.org is a Hg code repository hosting service which allows you to host upto 150 MB of your codes for FREE.

I like the private repository feature.

December 11, 2008

Update to the OpenSolaris 2008.11 final release

If you have been running any of the pre-release versions (RC1 or earlier) of OpenSolaris 2008.11, updating yourself to the final release is easy: (Please refer this link for more information)

$pfexec pkg image-update
I was running RC1 and so it d/led around 225 MBs of stuff and a new boot environment was created for me. You will get a new GRUB entry called opensolaris-1, which you can boot into on restart.

The desktop looks awesomely attractive:

OpenSolaris 2008.11 on VirtualBox

With the official release of OpenSolaris 2008.11, this post may be useful: http://blogs.sun.com/amitsaha/entry/open_solaris_2008_11_on

December 9, 2008

Six Degrees of Separation

Just the other day, I was casually giving a somewhat silly, but true example of how the Six degrees of separation can be found true in the real world.

The Social Life of Routers is a story on how researchers are applying the same principles for routing Internet packets.

Python modules in the NetBeans 6.5 UC


You can now install the Python support for NetBeans from the NetBeans 6.5 Update Center provided you have the Beta UC added (which should exist by default)

Mercurial 1.1 on OpenSuse 11.1

To build Mercurial 1.1 on Unix, follow the instructions at http://www.selenic.com/mercurial/wiki/index.cgi/UnixInstall

You might get a not found error regarding 'Python.h'. So you will have to install the 'python-devel' package. On OpenSuse 11.1, you would do:


sudo zypper install python-devel

December 5, 2008

JavaFX Launched: Start Doing More

All your cross-platform RIA needs are met here : http://www.javafx.com
JavaFX Launch: http://channelsun.sun.com/video/software/javafx/1915439297

December 2, 2008

OpenSolaris 2008.11 release is out!

Grab the bits from http://www.genunix2.org/