Saturday, August 09, 2008

Orkut community Thread re-title (Greasemonkey)

This script allows you to change the titles of Orkut community threads while viewing them locally.
Tested with:
Ubuntu Hardy Heron 8.04
Firefox/3.0.1 (Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.1) Gecko/2008072820)
Greasemonkey 0.8.20080609.0

Of course, it's local - it doesn't actually affect the data on Orkut's servers and you don't need any special privileges in the community to use this.

Name changes are persistent (will remain even after the browser is restarted - I think the info is lost if you Ctrl+Shift+Del your cache).

Refer elsewhere for how to install a Greasemonkey user-script.
Test with: http://www.orkut.co.in/CommTopics.aspx?cmm=22317

This does have some minor bugs which I'll fix if someone is interested in using this.

// ==UserScript==
// @name Orkut Community Re-title 1.0
// @namespace tag:abhijitppai@gmail.com,2008-08-07:Algoretitle
// @description script to re-title Orkut community threads
// @include http://www.orkut.co.in/CommTopics.aspx*
// ==/UserScript==
function myclick() {
if(this.checked==true)
{
c = document.createElement('input');
c.type="text";
c.name="apt"+this.name;
c.value=GM_getValue(String(this.name),"");
this.parentNode.insertBefore(c, this.nextSibling);
}
else
{
c=document.getElementsByName("apt"+this.name)[0];
GM_setValue(String(this.name),c.value);
var link = this.parentNode.childNodes[1];

if(c.value!="")
{
//don't have old value saved yet
if(""==GM_getValue("orig"+this.name,""))
{
//save it
GM_setValue("orig"+this.name,link.innerHTML);
}
link.innerHTML = c.value;
link.style.color="red";
}
else
{
link.innerHTML = GM_getValue("orig"+this.name,"blank");
this.parentNode.childNodes[1].style.color="grey";
}
this.parentNode.removeChild(this.parentNode.childNodes[3]);
}
}

var allLinks, thisLink;
allLinks = document.evaluate(
'//a[@href]',
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);

for (var i = 0; i < allLinks.snapshotLength; i++) {
thisLink = allLinks.snapshotItem(i);
var k = thisLink.href.search("&tid=");
if(k>0)
{
k=k+5;
b = document.createElement('input');
b.type="checkbox";
b.name=String(thisLink.href.substr(k));
vlue = GM_getValue(b.name,"");
if(vlue!="")
{
thisLink.innerHTML = vlue;
thisLink.style.color="red";
}
b.addEventListener("click", myclick, true);
//insert after
thisLink.parentNode.insertBefore(b, thisLink.nextSibling);
}
}

LAPP on Ubuntu 8.04 (Hardy Heron)

To install LAPP (Apache, PostgreSQL, Perl on Linux)

At the prompt:

1) sudo apt-get install perl postgresql apache2
Say Y to download dependencies.
2) sudo su postgres
3) psql
> create table a(b integer);
> insert into a values(2);
> \password

Enter a new postgres database user password twice, say "qwe" (without quotes).
> quit
4) logout (of the postgres user only)
5) sudo vi /etc/postgresql/8.3/main/pg_hba.conf

Change all the "ident sameuser" in the last column of all (non-commented) lines to "md5".

6) sudo vi /etc/postgresql/8.3/main/postgresql.conf

Find the line:
#listen_address

Remove the hash from the start (de-comment it).
Change the address from 'localhost' to '*' (including quotes).

7) cd /usr/lib/cgi-bin
8) sudo vi c.cgi

#!/usr/bin/perl

use DBI;

print "Content-type: text\html\n\n";

my $dbh = DBI->connect('DBI:Pg:dbname=postgres;host=localhost','postgres','qwe')
or die "Couldn't connect to database: " . DBI->errstr;
my $sth = $dbh->prepare('SELECT * FROM a')
or die "Couldn't prepare statement: " . $dbh->errstr;
$sth->execute()
or die "Couldn't execute statement: " . $sth->errstr;

while (@data = $sth->fetchrow_array()) {
print "$data[0]\n";
}
$dbh->disconnect();



9) sudo chmod +x c.cgi
10) Open firefox.
Try:
http://localhost/cgi-bin/c.cgi
You should see 2 on the screen.

This means LAPP (where the last P is Perl) is successfully installed.

Monday, August 04, 2008

External Hard disk bought

I bought a Seagate FreeAgent 500 GB external USB hard disk from A. S. Computers on S. P. Road yesterday for Rs. 5174/- (all inclusive).
Also purchased: Transcend 4 GB pen drive for 624/- (all inclusive) (- the 8 GB Transcend was appx. 1150/-.)

Thursday, April 17, 2008

Karnataka Medical Research Foundation

From an e-mail:

I AM EXTREMELY happy to inform you about the launch of my own Medical Research Organization, named KARNATAKA MEDICAL RESEARCH FOUNDATION. It was officially launched on 4th Feb 2008, and brought to public notice through a press conference on 1st April 2008. We have now begun full scale operations.

The Foundation is established with the vision to carry out indigenously relevant medical research and establish a network to conduct transitional medical research. This foundation will also provide quality guidance and motivation for aspiring researchers particularly for medical students and basic life science students. Our foundation will focus on research required to evolve Health science pertinent to India. It is responsibility of every Indian to solve problems in our country and take it forward. Western countries, which we are dependent on will not help us solve our health problems unless it is of a gain to them.

I have established this foundation on ideology of true SOCIALISM and will follow the principles of HIND SWARAJ of Mahatma Gandhi.

I Invite you to visit our website http://kmrf.in and provide your valuable feedback.

If u r interested, read on,

THE STORY BEHIND

I conceived the idea of this foundation 1.5 years ago.Since then I have been establishing a base to begin this venture. With just 5 years of medical research experience on hand, i have taken a bold step to establish such a foundation at this young age. With a clear progressive vision and attitude I trust I would be successful in this venture. Set backs in medical research career, personal life and UG life pushed me to establish something new and different. Infact this had to be a reality 6-8 months back, but due to set back in personal life, the launch had been delayed. The anger against ruthless and inhuman globalisation policy of India (manmohan singh) and support to it by majority of educated India has partly fueled the ideology and mission behind this foundation.

I have a unique structure in place with very little democracy in the foundation.

Though launched to the scientific community in FEB i am bringing this to public notice including my family members now. Thus far, response from the scientific arena, government and peers have been positive. I have already secured valuable collaborations, internationally. I hope in years to come, we would be able to make significant contribution to health science and MOTHER INDIA.

Many thanks for all your support and encouragement thus far.

JAI HIND

Dr.Himanshu M.
Chairman
Karnataka Medical Research Foundation
www.kmrf.in

ಹಚ್ಕೇವು ಕನ್ನಡದ ದೀಪ.
ಸಿರಿಗನ್ನಡಂ ಗೆಲ್ಗೆ

Resident Doctor - Obstetrics And Gynecology
M.S.Ramaiah Memorial Hospital
Bangalore

Wednesday, April 16, 2008

Perl script to change CVS Root in a directory tree

We moved our CVS to a different machine and our CVS Root thus changed. On Windows, if you use TortoiseCVS (at least), then it creates a CVS folder inside each folder of your repository and each of this CVS folders has a file called Root which has the CVS Root string. Now, I had to update each of these few hundred files with the new CVSROOT string. Perl (v5.8.4 built for MSWin32-x86-multi-thread on my system) to the rescue:

use File::Find;
find(\&wanted, "$ARGV[0]");
sub wanted
{
if($_ eq 'Root')
{
open(fp,">" . $File::Find::dir . "/" . $_);
print ">" . $File::Find::dir . "/" . $_ . "\n";
print fp "$ARGV[1]";
close(fp);
}
}


Pass the base folder name as the first argument and the new CVSROOT as the second argument.

Monday, March 03, 2008

NFS mount problem and solution

At our lab, we have a Compaq ES45 server on the harddisk of which our home folders reside, and we mount these on our local machines using NFS.

We added configuration for some machines (running Ubuntu 7.10 32-bit and RHEL4 64-bit) so that we could use these mounts, but the following problem arose.
Consider folder, a directory in my home directory:

cd folder gave:
-bash: cd: folder: Not a directory

vi folder gave:
"folder" is a directory

ls -ld folder gave:
drwxr-xr-x 4 abhi users 8192 2008-02-12 16:32 folder

Sometimes, files in my home directory were accessible, directories and files within weren't. And sometimes, I could not even access my home folder.

After persistent internet lookup, a labmate found that the problem was due to incompatible NFS versions. These Ubuntu/RHEL machines tried using NFS version 3 which apparently is not backward compatible with NFS version 2 which is the version on the Compaq server.

The 4th and 5th columns of the /etc/fstab entry were made to read:
nfs defaults,vers=2
and now everything works fine.