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/-.)