Monthly Archives: June 2008

Tabbed Putty : For all those Putty Fan Base

For all those Putty Fans Base :

Putty has been leading simple SSH client people using for some time ( Long time .. ). Many times people Like putty for simple reason .. that is IT is very simple SSH /Remote client.

For the same reason People go away from putty .. and going towards other remote clients .

One of the shortcomings of Putty is . If you want to open ten connections .. Putty will occupy all your task bar area …

Simple solution to the same is ……………………..

Tabbed putty ………… Here is the link — http://puttycm.free.fr/#

I like it very much .. Even you can give a try ..

Features I liked.

1. Renaming tabs.
2. Quick connection bar.
3. Self contained tabs.
4. Database connection – I did not try ..
5. All short cuts ..

Happy Remote working .. 🙂

Python: Dynamic Typing

Python supports Dynamic Typing compared to other programming languages ..

It has its own advantages and disadvantages ..

Lets look at the program .

def diff(x,y):
return x-y

print diff(20, 10)

gives proper output. When you change the input to

print diff(“DATABASE”, “OPERATINGSYSTEMS”)

It will throw exception .. So, You need to be careful when developing your code so that .. You do not end up in exception.

This could be useful feature if you use as below ..

from types import *

def diff(x, y):
if type(x) != type(y):
return “Incompatable Types”
if type(x) == IntType:
return x-y
if type(x) == StringType:
return len(x) – len(y)

print diff(“DATABASE”, 10)
print diff(“DATABASE”,”OPEATION”)
print diff(10, 10)

Output:

Incompatable Types
0
0

If you are not sure of the data types going to be passed then make use of Dynamic Typing feature and develop agile code ..

Happy coding ….

-MD

The cutting sticks problem – Very Good Problem

One of the best Tech Question and Answer I have seen..

I really tried to find equivalent algorithm for the same. I ended up looking at Kanpsack etc..

After some time I felt my thinking is going to be NP-Complete, So, I checked the mail thread itself..

I liked following answer .. Here we go ..

The cutting sticks problem—given a stick of length L and a set of
points where it has to be cut. If the cost of making a cut is equal to
the length of the stick, what is the best algorithm to find the
optimal sequence of cuts(giving minimum cost)

As I understand it, this is equivalent to finding an optimum binary search tree, where the stick length has been normalized to 1. The cut points represent keys, and the segment lengths between cuts represent the probability that a search falls between (or at the ends, below or above) the search keys. The top node of the BST represents the cut on the initial stick, while the child subtrees represent the cuts on the subdivided portions of the stick. The cost of the BST is the sum over the nodes of the probability of each key comparison. This node cost corresponds directly to length of the stick when the cut corresponding to the key is performed.

Willem gave an example which had a stick of length 1, with cuts at 0.45, 0.5, and 0.55. As a BST tree his solution would look like this (use a fixed width font):

+-(0.45,1)–+
v v
[0.45] +-(0.55,0.55) -+
v v
+-(0.5,0.1)-+ [0.45]
v v
[0.05] [0.05]

Each node is represented by (K,P) where K is the key (or cut point position in the original stick) and P is the search probability (or length of the stick at the time the corresponding cut was made). Each leaf is represented by [Q] where Q is the probability the search finds the leaf (or alternately Q is the length of corresponding cut segment).

Knuth’s The Art of Computer Programming (Vol. 3) covers algorithms for optimum BSTs in section 6.2.2. The Hu-Tucker algorithm can be used since the probability that a search will match a key exactly is effectively 0. A suitable implementation will create an optimum BST in time O(N log N). It is more complex than dynamic programming algorithm James Dow Allen gave, so I am not going to try to explain it here. It has some similarities, however, to the algorithm for finding an optimal Huffman coding. There may even be faster algorithms, since this seems to be a well-studied area.

For those without access to Knuth’s books, Google found the thesis at http://www.cs.rit.edu/~std3246/thesis/thesis.html. This has a more detailed description of the Hu-Tucker algorithm.

Jack Rouse

Thanks to Jack Rouce ..

How to ping IP V6 machine

Command to get IP Address:

/sbin/ifconfig

Ping:

 ping6 -I eth1 fa11::32c:e111:aea9:f310

Ping Your self:

Do the following:

ping6 0:0:0:0:0:0:0:1
or
ping6 ::1

Two consecutive "::" stands for any number of ":0" strings required to from a valid 16 byte address
Opps .. I can not point to the source here, From where I read all this.

SSL Client program in java

SSLising a Virtual host in apache took a day out of me..
Oh my god .. Public Key, Private Key, Wallet , CA, Certificate generation , OpenSSL .. huh ..

Having done that I wanted to write Java Program which will connect to that Virtual Host using https: Basically secured way ..

Googled around found following very useful link. What you need is to Point to a proper CA Certificate.

http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Security6.html