My Tech notes: January 2009
Subscribe

Unix Documentation

Free Online Unix Training Materials

Lists many links to free Unix training materials.

Pointers and Arrays Materials

Pointers and Arrays materials Explained for C beginners

C FAQ and General Questions C Interview Questions

Powered By

Free XML Skins for Blogger

Powered by Blogger

Sunday, January 25, 2009

Indian couple invent fuel-less, battery-less auto engine

Kolkata couple invent fuel-less, battery-less auto engine. Interesting that the advances/new technology are able to gain support, instead of being bought out by a petrol car manufacturer and left idle on the bench.
Kolkata couple invent fuel-less, battery-less auto engine
KOLKATA: Kanishk Sinha, 30, and his
wife Lipika, 25, chose to do something different from looking for
jobs—they invented a fuel-less
environment-friendly auto
engine.


"This engine is switched on by a chemical reaction between
zinc and oxygen; hence it is pollution-free. This technology also increases the
durability of the engine," Kanishk Sinha, chairman of the Jasper Motor Vehicle
company, told reporters.

"A water pump can run for five years without any interruption
on this engine and a four-wheeler car can run 450,000 km," said
Sinha.

The young couple established the company registered in the US
five years ago with Rs.1 billion (Rs.100 crore) raised from non-resident
Indians. They got the engine patented with BigPatents India, a body supported by
the Ford Foundation.

The couple has approached Kshiti Goswami, West Bengal's public
works department minister, for land in Bardhaman district.
 blog it

Thursday, January 22, 2009

CVS Short Notes And Useful Commands For Daily Usage

CVS Short Notes And Useful Commands For Daily Usage
Creating a directory tree from a number of files

When you begin using CVS, you will probably already have several projects that can be put under CVS control. In these cases the easiest way is to use the import command.

An example is probably the easiest way to explain how to use it. If the files you want to install in CVS reside in ‘wdir’, and you want them to appear in the repository as ‘$CVSROOT/yoyodyne/rdir’, you can do this:

$ cd wdir
$ cvs import -m "Imported sources" yoyodyne/rdir yoyo start

Unless you supply a log message with the ‘-m’ flag, CVS starts an editor and prompts for
a message. The string ‘yoyo’ is a vendor tag, and ‘start’ is a release tag. They may fill no purpose in this context, but since CVS requires them they must be present


Adding files and folder to CVS individually

To add a folder or file to CVS repository in some existing path, follow these steps.

For example, you want to create a folder “nuport” inside the path “firmware/projects”. First you should have local copy of that “firmware/projects”.

$ cd firmware/projects
$ mkdir nuport
$ cvs add nuport

Suppose you want to add a file to CVS which is inside the “nuport” directory then

$ cvs add filename.c
$ cvs ci –m “comment” filename.c

Remember that for adding files unless you do “cvs ci” the file will not be added completely to CVS.

NOTE: You can use “cvs ci” or “cvs commit”. Both commands are same.


Adding Binary Files

There are two issues with using CVS to store binary files. The first is that CVS by default converts line endings between the canonical form in which they are stored in the repository (linefeed only), and the form appropriate to the operating system in use on the client (for example, carriage return followed by line feed for Windows NT).

The second is that a binary file might happen to contain data which looks like a keyword so keyword expansion must be turned off. The ‘-kb’ option available with some CVS commands insures that neither line ending conversion nor keyword expansion will be done. Here is an example of how you add a binary file “testfile” using the ‘-kb’ flag:
$ cvs add -kb tesfile
$ cvs ci –m "First checkin" testfile


Setting custom versions

If you want to set the numeric revisions, the ‘-r’ option to CVS commit can do that. The ‘-r’ option implies the ‘-f’ option, in the sense that it causes the files to be committed even if they are not modified.

For example, to bring all your files up to revision 3.0 (including those that haven’t changed), you might invoke:

$ cvs commit -r 3.0

Note that the number you specify with ‘-r’ must be larger than any existing revision number. That is, if revision 3.0 exists, you cannot ‘CVS commit -r 1.3’. If you want to maintain several releases in parallel, you need to use a branch.


Check status of a file in working folder

For viewing the status of tags that the file has use :

$ cvs status –v backend.c

The states, as reported by the status command, are:

Up-to-date
The file is identical with the latest revision in the repository for the branch in use.
Locally Modified
You have edited the file, and not yet committed your changes.
Locally Added
You have added the file with add, and not yet committed your changes.
Locally Removed
You have removed the file with remove, and not yet committed your changes.
Needs Checkout
Someone else has committed a newer revision to the repository. The name is slightly misleading; you will ordinarily use update rather than checkout to get that newer revision.
Needs Patch
Like Needs Checkout, but the cvs server will send a patch rather than the entire file. Sending a patch or sending an entire file accomplishes the same thing.
Needs Merge
Someone else has committed a newer revision to the repository, and you have also made modifications to the file.
Unresolved Conflict
A file with the same name as this new file has been added to the repository from a second workspace. This file will need to be moved out of the way to allow an update to complete.
File had conflicts on merge
This is like Locally Modified, except that a previous update command gave a conflict. If you have not already done so, you need to resolve the conflict.
Unknown
CVS doesn’t know anything about this file. For example, you have created a new file and have not run add.


Giving tags

For setting up tags to files use the ‘cvs tag’ command. For example to tag a file called backend.c use the following:

$ cvs tag release-0-4 backend.c

The example in the previous section demonstrates one of the most common ways to choose which revisions to tag. Namely, running the CVS tag command without arguments causes CVS to select the revisions which are checked out in the current working directory.

For example, if the copy of ‘backend.c’ in working directory was checked out from revision 1.4, then CVS will tag revision 1.4. Note that the tag is applied immediately to revision 1.4 in the repository; tagging is not like modifying a file, or other operations in which one first modifies the working directory and then runs CVS commit to transfer that modification to the repository.

One potentially surprising aspect of the fact that CVS tag operates on the repository is that you are tagging the checked-in revisions, which may differ from locally modified files in your working directory. If you want to avoid doing this by mistake, specify the ‘-c’ option to CVS tag. If there are any locally modified files, CVS will abort with an error before it tags any files:

$ cvs tag -c rel-0-4
CVS tag: backend.c is locally modified
CVS [tag aborted]: correct the above errors first!


Use “cvs add” recursively to check-in code instead of “cvs import”

Suppose you want to check-in a large source which is inside a folder name “newfolder”.

To add the folder “newfolder” and it sub-directories into CVS, first do

$ find newfolder –type d –print | xargs cvs add

Then to add the files inside the “newfolder” and its subdirectories

$ find newfolder –name CVS –prune –o –type f –print | xargs cvs add

Then we have to commit these into CVS. The “cvs commit” is recursive, so we can give the following command

$ cvs commit –m “comment” newfolder/.

NOTE Please verify if everything has been checked in with these steps by checking out and compiling. I found some files (only which are last) didn’t get added while doing so, for kernel. This might be due to very large number of files in kernel source.


Important tips:

1) Use “cvs –help-commands” to get a list of supporting commands.
2) Use “cvs H ” to get help on the particular command. For example to get help on the command “commit” give as

$ cvs –H commit

Tuesday, January 20, 2009

Game Theory Explains Why You Can’t Hurry Love

It shows that extended courtship can take place, with a good male being willing to court for longer than a bad male and the female delaying mating. In this way the duration of a male’s courtship effort carries information about his type. By delaying mating, the female is able to make some use of this information to achieve a degree of screening. Because bad males have a greater tendency to quit the courtship game early, as time goes on and the male has not quit it becomes increasingly probable that he is a “good” male.
Scientists have developed a mathematical model of the mating game to help explain why courtship is often protracted.
The study, by researchers at UCL (University College London), University of Warwick and LSE (London School of Economics and Political Science), shows that extended courtship enables a male to signal his suitability to a female and enables the female to screen out the male if he is unsuitable as a mate.
The research uses game theory to analyse how males and females behave strategically towards each other in the mating game.
The mathematical model considers a male and a female in a courtship encounter of unspecified duration, with the game ending when one or other party quits or the female accepts the male as a mate.
The study looks for evolutionarily stable equilibrium behaviours, in which females are doing as well as they can against male behaviour and males are doing as well as they can against female behaviour.
 blog it

Thursday, January 15, 2009

Data Structures Linked List Reverse

simple linked list
Data Structures -- Linked List -- Reverse

/*
* Simple operations on linked list. If any problem
*/

#include

/*
* Data structure used, its simple :)
*/
Typedef struct linked_list_s
{
int value;
struct linked_list_s *next;
}linked_list_t;


/*
* Add a node at the end of the list.
*/

Linked_list_t* add_node(linked_list_t *head, int value)
{
linked_list_t *newNode = NULL;
linked_list_t *node = head;
linked_list_t *prev = head;

newNode = (linked_list_t *)calloc(1, sizeof(linked_list_t));
newNode->value = value;

while(node)
{
prev = node;
node = node->next;
}
if(prev == node)
return newNode;

prev->next = newNode;

return head;
}

/*
* delete a specified node from the list.
*/

Linked_list_t* delete_node(linked_list_t *head, int value)
{
linked_list_t *node = NULL;
linked_list_t *prev = NULL;

for(node = head; node != NULL; prev = node, node = node->next)
{
if(node->value == value)
{
//Check for head node modification
if(prev == NULL)
{
head = head->next;
free(node);
return head;
}

prev->next = node->next;
free(node);
return head;
}
}
return head;
}

/*
* display all the nodes of the list.
*/

Void list_nodes(linked_list_t *head)
{
linked_list_t *node = head;
printf("\nHead");
while(node)
{
printf("->%d ",node->value);
node = node->next;
}
printf("->NULL\and");
}


/*
* Display all the nodes in reverse order withoout modifying list.
*/

Void list_nodes_in_reverse_order(linked_list_t *head)
{
linked_list_t *end = NULL;
linked_list_t *node = NULL;

printf("\nReverse Head");
while(head != end)
{
node = head;
while(node->next != end)
node = node->next;

printf("->%d ",node->value);
end = node;
}
printf("->NULL\and");
}


/*
* Reversing the linked list with recursion; Asked in Qualcomm interview questions..
*/

Linked_list_t* reverse_with_recursion_anotherway(linked_list_t* current, linked_list_t* parent)
{
linked_list_t* revhead = NULL;

if(current == NULL)
revhead = parent;
else
{
revhead = reverse_with_recursion_anotherway(current->next, current);
current->next = parent;
}
return revhead;
}

/*
* Reversing the linked list;
*/

Linked_list_t* reverse_with_recursion(linked_list_t* node)
{
linked_list_t* temp = NULL;

if(node->next == NULL)
return node;

temp = reverse_with_recursion(node->next);
temp->next =node;
return node;
}

/*
* reversing linked list without recursion.
*/

Linked_list_t* reverse_without_recursion(linked_list_t* head)
{
linked_list_t* prevNode = NULL;
linked_list_t* currNode = head;
linked_list_t* nextNode = head->next;

while(currNode)
{
currNode->next = prevNode;
prevNode = currNode;
if(nextNode == NULL)
break;
currNode = nextNode;
nextNode = nextNode->next;
}
return currNode;
}

/*
* main program, which displays menu for maitaining linked list.
*/

Main()
{
int choice = -1;
int value = 0;
linked_list_t *head = NULL;
linked_list_t *node = NULL;

do
{
printf("\and what you wanna do?\and");
printf("1. Add a node \and");
printf("2. Delete a node \and");
printf("3. List all nodes \and");
printf("4. Reverse (without recursion) the list \and");
printf("5. Reverse (recursively) the list \and");
printf("6. Reverse (recursively) another way\and");
printf("7. Just display in reverse order\and");
printf("8. Exit \and");
scanf("%d",&choice);

switch(choice)
{
case 1:
printf("\nEnter value: ");
scanf("%d",&value);
head = add_node(head, value);
break;

case 2:
printf("\nEnter value: ");
scanf("%d",&value);
head = delete_node(head, value);
break;

case 3:
list_nodes(head);
break;

case 4:
node = head;
head = reverse_without_recursion(head);
break;

case 5:
node = head;
while(node->next)
node = node->next;
head = reverse_with_recursion(head);
head->next = NULL;
head = node;
break;

case 6:
head = reverse_with_recursion_anotherway(head, NULL);
break;

case 7:
list_nodes_in_reverse_order(head);
break;

case 8:
exit(0);
break;
}
}while(1);
}

Wednesday, January 14, 2009

How Rich Are You?

$8 could buy you 15 organic apples OR 25 fruit trees for farmers in Honduras to grow and sell fruit at their local market.

$30 could buy you an ER DVD Boxset OR a First Aid kit for a village in Haiti.

$73 could buy you a new mobile phone OR a new mobile health clinic to care for AIDS orphans in Uganda.

$2400 could buy you a second generation High Definition TV OR schooling for an entire generation of school children in an Angolan village.
Global rich list logo
HOW RICH ARE YOU?


Every year we gaze enviously at the lists of the richest people in world.

Wondering what it would be like to have that sort of cash. But where

would you sit on one of those lists? Here's your chance to find out.

Just enter your annual income into the box below and hit 'show me the money'





MY ANNUAL INCOME
     
  







 blog it

Tuesday, January 13, 2009

Hack your brain

DO YOU EVER want to change the way you see the world? Wouldn't it be fun to hallucinate on your lunch break? Although we typically associate such phenomena with powerful drugs like LSD or mescaline, it's easy to fling open the doors of perception without them: All it takes is a basic understanding of how the mind works. Please go to source to read text in the image
clipped from www.boston.com

How to hallucinate with ping-pong balls and a radio

DO YOU EVER want to change the way you see the world? Wouldn't it be fun to hallucinate on
your lunch break? Although we typically associate such phenomena with powerful drugs
like LSD or mescaline, it's easy to fling open the doors of perception without them: All it
takes is a basic understanding of how the mind works.

The first thing to know is that the mind isn't a mirror, or even a passive observer of
reality. Much of what we think of as being out there actually comes from in here, and is a
byproduct of how the brain processes sensation. In recent years scientists have come up
with a number of simple tricks that expose the artifice of our senses, so that we end up perceiving
what we know isn't real - tweaking the cortex to produce something uncannily like
hallucinations. Perhaps we hear the voice of someone who is no longer alive, or feel as if our
nose is suddenly 3 feet long.

 blog it

Monday, January 12, 2009

You Can Look - But Don't Touch

That's what the phenomena of shopping spree based on. When they start to use scientific approach to us, which they calling marketing techniques, we have no chance. Much worst when they doing it secretly and in the final end we are realizing that our money

Researchers from Ohio State University and Illinois State University tested
how touching an item before buying affects how much they are willing to pay for
an item.  A simple experiment with an inexpensive coffee mug revealed that
in many cases, simply touching the coffee mug for a few seconds created an
attachment that led people to pay more for the item. 


The results, which were published recently in the journal Judgment and
Decision Making, found that people become personally attached to the mug within
the first 30 seconds of contact. 

“By simply touching the mug and feeling it in their hands, many people begin to feel like the mug is, in fact, their mug.  Once they begin to feel it is theirs, they are willing to go to greater lengths to keep it.”

 blog it