Wednesday 28 April, 2010

editcap

vim, less and any other file manipulation commands take lot of time to load or search in very big files and so we use split such big files into small to analyze them.
Similarly, we used to face problems in analyzing network packets captured files. To cut the files or to filter some packets from the network traces captured files, you can use editcap. Its command line oriented provided along with ethereal/wireshark.
Also, there are few perl scripts available in Internet which are based on libpcap. I yet to install and try that. Looks like that give us more control in filtering the packets.
If some one know or have idea about using libpcap, share it with us.

IndianRail - Frustration

I booked a tatkal rail ticket from the counter thinking that
- there will be more quota at the counter
- if the ticket is in waiting list, this ticket will be given preference compared to eticket.
I'm sure about second point, but not sure about first point.
But, now, I lost the ticket. I have the PNR number, Xerox copy, photo ID card and so approached counter to take the duplicate ticket.
Here, to provide a duplicate ticket, they are charging half the ticket fare. Its too huge penalty just to print a ticket. They are sucking the blood.
This was for my wife - so I just paid the money and took the ticket in order not for any problem for her during travel. If it was for my travel, I should have just took the xerox copy and the photo ID card.
So, if any one face this problem and ready to fight with TC, take these and say you lost the ticket while climbing the train.
Can any one help me in complaining about the huge penalty for duplicate ticket?

Tuesday 27 April, 2010

Issue with union

Recently, found the union in the 'C' code with 33 bits as a structure and an unsigned long as members.
There will be no problem in the memory allocation. But, what might be the problem with this type of data structure?
Issue we had was the union variable initialization. Usually, the unsigned long variable in union will be initialized to intialize the bits in structure. But, being 33 bits, one bit won't be initialized. A learning we had!!

Monday 26 April, 2010

Couple of Blogspot features

- Came across this "Follow" feature combining Google Reader and Blogger. Previously, I used to subscribe to blogs using feeds in Google Reader. Now, this helps better. Also, it helps you to find out who are following you.
- Integration with openId. Blogger provides you an openId url which can be used for authentication against any openId enabled web sites.
Aren't they cool?

RaahuKaalam calculation

Recently found an interesting article how to calculate Raahukaalam. It depends on the Sunrise and sunset in that area on that day. (Sunset-sunrise) is the day and it is divided into 8 parts. Each part is called period and Raahukaalam comes in one of the periods in a day. There is no Rahu Kalam during the first period of any weekday. On Monday it falls on the 2nd period, Saturday 3rd period, Friday 4th period, Wednesday 5th period, Thursday 6th period, Tuesday 7th period & Sunday 8th period.
Courtesy: http://www.astrojyoti.com/rahukalam.htm
But, I don't have idea why they say so.

Scheduling work in multithreaded environment

Its always better to schedule any work at the end of the thread execution as the scheduled work can delete the object all together.
Consider a scenario like
fn Query::readData()
{
getData();
if(m_readDataSize > 0)
...
}
Query object needs some data to evaluate and thus called getData(). But, this getData() can do scheduling to read more data or may place the already read data size in m_readDataSize or it can schedule work to delete the object because of any error case like improper query.
And, if so, there is chance of code getting crashed while accessing m_readDataSize as object might got deleted if the work got scheduled and executed before returning from this function call. So, better is to mark the work to be scheduled and schedule it at the end of the thread execution, say, something like thread->postWork().
With this in view, I always like the OSs which are single threaded like Netware. It gives the better performance, flexibility in using CPU, ease in programming (Ofcourse, it have its own challenges like yielding.)

Wednesday 21 April, 2010

ssh auto login script

Finding the script for ssh auto login is not at all difficult. Thinking that, I hadn't stored the link that I found as useful. Later when I tried to get that link, it took me some 10 mins to get the same link, and so, thought of blogging it.
Copied the below script from http://programminglinuxblog.blogspot.com/2008/02/automatic-ssh-login-script-all.html

Below script takes care of copying your certificate content into the remote box, which is not the case with other scripts found at different locations. Also, you can learn shell script with this script.

#!/bin/bash

if [ ! $1 ]; then
echo "usage: pushssh.sh user@remoteserver "
exit
fi

PORT=22

if [ $2 ]; then
PORT=$2
fi

# Uploads your id_rsa.pub to the specified host, wrapped for readability

if [ ! -r ${HOME}/.ssh/id_rsa.pub ]; then
ssh-keygen -b 2048 -t rsa
fi

# Make sure auth file exists and chmod to 600

ssh $1 -p $PORT 0> echo "mkdir ~/.ssh; touch ~/.ssh/authorized_keys;
chmod u+rw .ssh/authorized_keys"

# Append to the copy on the remote server

cat ~/.ssh/id_rsa.pub | ssh $1 -p $PORT "cat - >> .ssh/authorized_keys"

if [ $? -eq 0 ]; then
echo "Success"
fi

Once you are done, you just need to create another script say "execRemoteCmd" to execute the command you want as follows:
ssh root@164.99.184.111 $@
ssh root@164.99.184.111 $@
and use it as execRemoteCmd ls -ltr /chroot/lag/core.*

Monday 19 April, 2010

How to reach google.com?

Whenever I type google.com, it always used to make me land in google.co.in. How to reach google.com then?
Reach www.google.com/ncr. It won't redirect you to google.co.in.

Monday 5 April, 2010

FYI regarding platelets

Drinking juice made of papaya tree leaves makes blood platelets count shootup much much faster. My friend was suffering from dengue fever and his blood platelets count had dropped close to critical. He was administered platelets(which is an expensive process too) but it was not working much. His family members searched on internet and found that papaya leaves juice will help a lotttttt. He was given that and even doctors in Apollo were surprised to see the result. The taste of the juice will be highly bitter so just mix lemon juice with it to have a better taste. Doctors were taking his blood samples every 4hrs to see the effect and after taking 5teaspoon full of the juice, it was doing wonders.
Information source: My friend Krishna Mohan