Wednesday, December 26, 2007

cool n770 hack

If you are a nokia tablet user like me (n770/n800/n810), you must have wished for this feature I am going to describe.

When I am browsing the net on my desktop I come across a webpage that I would like to open on my n770 right away - mostly it's some maemo package that I would like to download and install. The problem is rewriting the cryptic URLs in n770's address bar is time-consuming and error-prone. Going to the same URL through google search takes couple of page loads, which takes sizeable time.

One way to ease this process is to use some clipboard sharing software (synergy, vnc viewer), I am not sure if that works, but I bet someone has tried it. Besides, it will be too heavy as compared to the following method I suggest here.

If you have ssh enabled on your tablet then you can run this simple script on your desktop and command the tablet to open any URL in its browser.

It is only this single command:

ssh root@<ip of tablet> "dbus-send --system --type=method_call --dest=\"com.nokia.osso_browser\" --print-reply /com/nokia/osso_browser/request com.nokia.osso_browser.load_url string:\"$1\""


Save this in a script nokia-browser.sh and the next time you want to open a URL, just execute:

nokia-browser.sh <URL>

You will be prompted for password (unless you have setup the keys)

Check your tablet, it must be loading the URL by now. If a browser is not already open it will be opened automatically because by d-bus magic.

I learnt about this command from this mailing list post. I am just trying to use it remotely.

Saturday, December 15, 2007

Picasso

I have no authority in art. But once in a while I try to understand the greatness of some masterpieces.

I have been watching this painting of Pablo Picasso while passing through one corridor in my office. It's titled "Bullfight - Horse air".

I liked it, in a sense that it is simple. You can see a man riding a horse hunting a bull. If one has gift of control over one's hand then one sure can paint this. I didn't exactly understand why Picasso would be a great artist for doing such work.

Every time before when I used to see this picture I used to see the three figures. But yesterday when I looked at it I only saw a handful strokes of brushes and that amazed me. In other words, what I saw was how the artist would have drawn it. It sure is trivial to duplicate something in real life on to paper (it's not trivial to me, but for gifted hands it is). But what is not trivial is, extracting the abstractions out of the real things and expressing them with minimal use of paint. I guess that qualifies the greatness of an artist.

Thursday, November 29, 2007

Colbie Caillat

Last month or so I heard "Bubbly" and just loved it. For past week I have been listening to "Realize" and I just adored the way Colbie Caillat can play her voice.

She has great talent and genuine voice. Halfway through "Realize" she just takes her time to play her vocal chords to create magic out of the words "didn't I tell you...".

It's not usual to find someone's live performance as good as their post processed published albums. If you see this live performance by Colbie, you will find an exception to that rule.

Tuesday, November 20, 2007

Firefox 3 is brilliant!!!

If you read this on slashdot this morning you must already know. I just tried it on my Mac OSx and the review is completely true.

Starting firefox 2 on my freshly booted MacBook was taking very very long time. It was unusually slow even after compared to sluggishness of firefox on Linux. Don't know why. So when I tried firefox 3 beta 1 on it I could clearly tell the difference. The fire in firefox is back.

[The only reason you might want to hold from upgrading just as yet is lack of availability of compatible plugins. As the official release nears, this problem will go away]

XML RPC server inside apache mod_python

Writing XML RPC server and client in python is extremely easy. There are many examples. xmlrpclib is part of python, so writing client doesn't need anything extra. There are many examples of XMLRPC server as well. I used Julien Oster's.

The problem comes when you want to use XML RPC server in a production environment alongside your apache web server. If you are not a big shop then you very likely want to host both of them on same machine. Then two different servers can't listen for HTTP on same port. You might use an alternate port (second in popularity to port 80), but the users behind corporate firewall will suffer. If you understand the protocol stack, you would know it shouldn't be difficult to run the XMLRPC server inside an apache server. I realized that last weekend, and in couple of hours I hosted Julien Oster's XML RPC server inside my apache mod_python framework.

Download the XML RPC server. You will find a single file xmlrpcserver.py.

You will find a class XmlRpcServer in it. That's all you need. Add following method to it:
    def handle(self,req):
length = int(req.headers_in["Content-length"])

request_string = req.read(length)
request = StringIO(request_string)

request.seek(0)
response = StringIO()

try:
self.execute(request, response, None)
except Exception, e:

return apache.HTTP_INTERNAL_SERVER_ERROR
finally:
response.seek(0)

rstr = response.read()
req.headers_out['Content-type'] = 'text/xml'

req.headers_out['Content-length'] = "%d"%len(rstr)

req.write(rstr)
return apache.OK

Now host the following code in your index.py file (or any python file you have configured as PythonHandler in your apache settings)

from mod_python import apache

from xmlrpcserver import XmlRpcServer

def handler(req):

try:
xmlserver = XmlRpcServer()
app = Application()

xmlserver.register_class('app',app)

result = xmlserver.handle(req)

return result
except Exception, e:
return apache.HTTP_INTERNAL_SERVER_ERROR

# The following class is where you can put your application logic
class Application:
def __init__(self):
pass

def getName(self):
return 'example'

Once you save the above index.py to your webserver, you can use a python client to invoke XMLRPC calls to your apache server.

Assuming you saved above file to $(DOCROOT)/xmlrpc/index.py, your client code would look like this:
import xmlrpclib

remote = xmlrpclib.Server('http://yourserver.com/xmlrpc/')
name = remote.app.getName()


And you are all set!

syntax highlighted by Code2HTML

Thursday, October 25, 2007

best effort technologies

It occurred to me today, that this principle when applied to software design is quite effective. Then I thought about all the softwares we use today and tried to find instances of this principle applied in practice. And I came up with this post.

The 'best effort' approach comes into picture when you are trying to solve a problem that is very difficult to solve. The solution for the problem is not defined, to the extent that it might seem infeasible.

Here are some examples we see in today's digital life that obey this principle. Although they are specific instances I think they are representative of many others like them.

Tivo
I had read about how Tivo started and evolved. Initially they had to figure out how to collect the show times of variety of shows on different channels, so that their users can program their boxes to record their favorite programs. Their initial solution was as rudimentary as employing manual labor to go through the show times published in newspapers and formatting and feeding them to their boxes over network. They surely didn't have any solid scheme to collect the meta data of the shows. Being a startup, they couldn't expect all channels providing such information for a technology that was so unusual and unproven. But Tivo applied a best effort strategy. And we all know how well it paid.

Amarok
I haven't seen this in other players, it might be there, I am just not aware. But only today I found out how Amarok's context tab fetches the lyrics of a song I am playing on the fly using the best-effort strategy. I don't know if they scan ID3 tags or just file name or what else, but their strategy just worked for a song I randomly received from a friend. I have been using iTunes for more than a year, I know they provide lyrics in some cases (I got continuum's lyrics in a pdf when i bought the album). But iTunes controls the music they deliver. The problem to solve here is: "Given an audio song, show its lyrics in real time". In an ideal world you could do speech processing. But in a more practical world, meta-data is the only solution. For iTunes it's fairly easy to acquire the meta-data, because they control the data itself. Softwares like Amarok, won't have the luxury of well defined meta data. So they do the best they can. They might be subscribing to some well defined repositories of lyrics and just doing best effort match against ID3 tags or filenames. If they find exact match, they show it; if not, they give suggestions. It works like a charm though.

Thunderbird
Have you used MS Outlook in your office and tried to search through the mail by typing in that box on upper right. If yes then by now your mind must have fixed this action to a non-responsive interface hung for at least 5 seconds. I experienced this in my last job and have heard same comments from colleagues. Fortunately I switched to Thunderbird in my current job. Although Thunderbird isn't a perfect mail client, just see how slick it makes searching through your email. The reason it gives results so fast, is because by default it searches only through the subject line and To, Cc list of the emails in the folder. This is their best effort for speed. And it yields desired results almost always, because it is based on a right assumption - a subject line is the summary of the email. Surely this search might not be sufficient ~5% of times when you don't know what you are looking for and remeber only vague keywords. But that is covered by giving you an alternative to include entire mail body for search. (Why MS misses this is topic of another discussion)

Google search
I am no expert in search technologies. But just by observing the output of the software I can tell, that Google search (or any search for that matter) wasn't full proof in the beginning. In the beginning of search era, one could get unexpected search results than what they originally intended to find. But Google did the best they could do to try to understand what user was looking for. They didn't waste their time implementing a classic solution for Natural Language Processing, they just tried their best to figure out the user's intent. No need to mention how successful the strategy has been.

Google desktop
I remember Microsoft planning a filesystem (for longhorn/vista) designed on top of a database, so that it will make searching through your desktop files as efficient as SQL query processing. Everyone knows what happened to it. Compare this to Google's best effort approach to solve this problem. They didn't need to redesign the whole file system. They instead made a daemon which runs non-intrusively in background indexing your files. Initial indexing will take time, so if you install Google desktop and immediately fire a search it won't give you proper results. But that's only for first few hours. Once indexing is done Google desktop will give you what you're looking for. It must be doing some incremental indexing for the new files/emails that keep coming in. But that works so well. I remember using it as an alternative to MS outlook's search box at my last job. It would show up fairly recent mails in the search results.

.... I think we can find more of such examples easily.

I don't think this is a radically new concept/term I am talking about. I think this approach - "best effort strategy" - to software design is just one of the shades of extreme programming. It is just one of the lessons that can be learnt from the software startups in recent past. But it works so well, doesn't it?

Friday, October 05, 2007

formula of a horror movie

Imagine you are working all day at your office. You interact with so many people. Many people come to your office or desk uninvited. They just show up standing besides you, you at first fail to notice them, then suddenly you become aware of their presence. You travel on a subway or in a bus or shop in a department store, but when a totally stranger face or body shows up in your eyesight, you just take it granted - let alone stun or scare.

Now you come back from your office or bus or mall to your two bedroom apartment where you live alone. You go into the kitchen, start cooking... after few minutes you realize that a total stranger is standing 4 feet from you looking at what you are cooking.... you will be just short of a heart attack. However benign and harmless that strange face is, you will skip few heart beats before coming to senses. It is a regular stranger whose presence you wouldn't even acknowledge, had it been a grocery store and not your kitchen.

Then why is it so scary?

The answer is simple. We feel anxiety if something unexpected happens. And non-expectancy of someone other than you being in your apartment is extremely high "in your mind". Naturally your anxiety in response is also very high, almost a shock or horror.

This is what I think about the concept.

Imagine of a finitely practical situation in which one person's non-expectancy of an event is entirely commonplace occurrence for other person. And the situation should be practical in the sense that the audience should identify with both persons' points of view.

Imagine such a situation and you can have an intelligent horror movie.

I guess this is a general equation for horror movies, everyone just finds a different solution that satisfies all sides of it.

Thursday, August 30, 2007

next desktop jump

Now Fedora 7 is out for couple of months, Fiesty Fawn was out even before that. So it was obvious that I would find something wrong with my Fedora 6 installations and convince myself to get bored of it.

I am the Redhat guy, and never could make myself like package management of other distros. But Ubuntu making so much noise and after reading Mark Shuttleworth's blog for a while, I couldn't avoid getting excited about Feisty Fawn. I gave it a first shot within 2-3 days of its release. But I found myself afraid of diving into the LVM configuration that Kubuntu-alternative installation CD offers. I didn't want to blow my existing LVs. I did some experiments in a virtual machine. Finally I braved myself into swallowing the pill. Seconds later I felt like choking when the system went into freeze at a screen after I chose to configure LVM. Thanks to the shell, I realized it wasn't frozen but was blocking. When I tailed the system logs, I found it was waiting for each volume to get discover and was waiting 30 seconds on each of them. With 7 volumes I could manage to steal a nap. Once it was done, it listed all LVs and rest of the things went smoothly. After entire installation the system booted just fine, without any video driver problems etc. Usual setup tasks (firefox, thunderbird,....) went fine. Liked the GUI on top of apt-get system. But wondered why it was giving some red colored "Bad install" errors during installation of some packages. It's dependencies might be failing, but couldn't find any straightforward error saying so. My biggest motivation for desktop switch was Beryl. But after spending an hour or so and following all instructions on forums, I still couldn't get beryl-manager and emerald-theme-manager to install. The repo that provided them didn't provide many dependencies that were needed. Big bummer! Never could find any repos that could satisfy those dependencies (and there were lot). I left it aside for a while and started installing gaim. Realized pidgin is the new name. The same story repeats. I couldn't install pidgin after spending some 10 minutes...... Thankfully I had my FC6 installation on one of the volumes, so I switched back.......


....enter Fedora 7. Installed it first day (or second?!). Everything went fine. But it wouldn't boot alright - giving me tons of Red "[Failed]" results for various services. I always have these problems office machines where NIS, NFS all doesn't work unless you do everything right. I was lucky with FC6 last time. But F7 got screwed. so back to FC6 for few days....

Since I can't reboot my office machine quite often (with so many things open all the time), it took till this week to me try again. My FC6 was very sluggish. The reason I found out was: my home directory was on the network drive. And our file server is overloaded nowadays. So I had decided to create local account and home directories next time. On Monday, I reinstalled F7 and didn't configure NIS at the installation time. Everything worked like a charm. No... Beryl won't work out of the box. But I knew what to do. It seems the stock NVidia driver that comes with F7 (nv) isn't sufficient (at least for the graphics card I have). But the additional steps I had to do were straightforward:
Goto Livna and install their RPM which automatically adds its repo address to your yum configuration.
Install kmod-nvidia using yum install. [Note: Do NOT install this RPM using rpm commandline, USE yum. More likely this driver is compiled with a newer linux kernel that the stock F7. So "yum install" will automatically do this upgrade, you might miss that out with manual rpm installation. I read some posts which messed up because of this]
Reboot (Now you should see nVidia logo before X starts)
Run Beryl-manager it should work.


........... So Fedora 7 gets my vote again this time.

I think Ubuntu is a nice system. Might be very user friendly, once it's installed. But it is still not good for power users (or at least not enough to lure RedHat power users to its camp). I wish just like kubuntu, xubuntu, they come up with "Pubuntu - Ubuntu for power users" - which has support for LVM management at installation time, etc.

P.S. Pidgin was a great find. It has awesome GUI compared to gaim.

Tuesday, July 17, 2007

The "Screen"

Thanks to a friend who introduced me to the screen utility about a year ago. It is a very fine utility for unix programmers/users who spend most of the time using CLIs. I would say it is a desktop virtualization solution applied to command line terminal. It is to the command prompt, what VNC is to the graphical desktop. To learn more follow the above link or google. It is installed on almost all linux distributions by default, so you can just start using it right away.

I was however slow in adopting it. Mainly because switching between the screens wasn't so quick. The screen command line utility gives an option of creating tabs in one screen and switching between them, but that meant mastering several key sequences. So I wrote my own wrapper script to do the job. Following is the code. Save it in a file and name it suitably (use a short name that's handy - I call it 'sc') and just execute it.

The code is available here

Here is a sample run:

jayesh@bluebox [~] sc --help
Usage: sc
Generates list of screens if available and gives a prompt
Valid commands to enter at prompt -->
new-<NEW_SCREEN> - creates a new screen with name NEW_SCREEN
and connects to it
[number] - number is the index of the screen you want
to connect to
q - quit

jayesh@bluebox [~] sc
Create new screen. Use the command 'new-'
>>new-root
[Now you can login as root on this user to do all administrative tasks]

.....
[create bunch of other screens for others tasks you do -
compiler,editor, etc.]

jayesh@bluebox [~] sc
0] compiler
1] root
2] editor
>> 1

[Now you connect to screen 1, where you are logged in as user.
You don't have to enter root password again-n-again]


Suggestions are always welcome!

Thursday, June 28, 2007

Nice review article on virtualization technologies

This one is pretty thorough analysis of status quo on Virtualization.

I liked this quote best...

"Between Microsoft, Novell, Red Hat, XenSource, VMware and the scarcity of good benchmark data, it's going to be tricky for users to figure out which operating systems will deliver the best virtualization performance on whose version of which hypervisor."

Monday, June 04, 2007

Once again... a quote from 'Troy'

Everytime I watch Troy, I find some dialog worth blogging....

This one is from Achilles mother Thetis to him when he is deciding to leave for Troy...

"If you stay in Larisa......you will find peace.

You will find a wonderful woman.

You will have sons and daughters,and they will have children. And they will love you.
When you are gone,they will remember you.

But when your children are dead and their children after them...
...your name will be lost.



If you go to Troy......glory will be yours.

They will write stories about your
victories for thousands of years.

The world will remember your name.

But if you go to Troy......you will never come home.

For your glory walks hand in hand with your doom.

And I shall never see you again."

Sunday, May 13, 2007

quotes from George Carlin

Here is the original post.

And here are the ones I liked very much:

* Think of how stupid the average person is, and realize half of them are stupider than that.

* I put a dollar in a change machine. Nothing changed.

* No one knows what’s next, but everybody does it.

* I’ve never seen a homeless guy with a bottle of Gatorade.

* So far, this is the oldest I’ve been.

Saturday, April 07, 2007

"from time import sleep"

Now you wonder what's about the title! What does it mean?

It's a line I am quoting out of context. Any guesses, what context I read it in?!

... a python script. :) .... (and no it wasn't part of a comment, it's a valid python statement)

Thursday, March 22, 2007

Sea surfing under the Golden Gate

Here is one video from my trip to San Francisco.

Monday, March 12, 2007

Trip videos

When I was browsing through my camera's memory yesterday, I revisited the videos I had taken during my road trip from MN to CA. Two of them I found worth uploading.

The first one I shot in the evening of second day of my drive. I tried to describe it with words in my last post. Here is how it looked like. But it is still far from the actual experience.



This one was just something cool to capture in camera.



Enjoy!