Archive for August, 2009

Setting Up Virtual Hosts in Windows

August 17, 2009
  1. Open up the main Apache main configuration file to enable virtual hosts.
    C:\wamp\bin\apache\Apache2.2.11\conf > open httpd.conf > enable virtual hosts (uncomment Include conf/extra/httpd-vhosts.conf)
  2. open hosts file and edit the text to include the new domain –  e.g.  127.0.0.1 ayanthi.anandagoda.tv
    Go to C:\WINDOWS\system32\drivers\etc
  3. Add a new entry in httpd-vhosts.conf to point to the new document root.
    C:\wamp\bin\apache\Apache2.2.11\conf\extra > open httpd-vhosts.conf

    <VirtualHost *:80>
    DocumentRoot “C:\wamp\www\ayanthi.tv”
    ServerName ayanthi.anandagoda.tv
    </VirtualHost>

Thanks Thilanga for your generous help.

Advertisements

F.R. David – Sahara Night

August 7, 2009

Spirit of the sands
On vast and empty land
Where no one belongs
When the blue gets dark
At the failing light
Between moon and sun
In the desert fields
Fever’s so high
Makes me want to shout
Sahara night
Listen to the wind
Bringing into your ears
Music from afar
You may hear the sounds
Of a tribal dance
Coming from the heights
In the desert fields
Fever’s so high
Makes me wanna shout
Sahara night
And stars screen
The awful mystery of space
With its weight of fear
I now realise
The hold it has on me
I love to watch the sky
Smiling at the stars
Laying on the ground
Gentle is the breeze
Wish it never cease
Soothing my mind
In the desert fields
Fever so high
Makes me wanna shout
Sahara night
Oh, Sahara night
Makes me feel
Makes me feel
So right

I Wish I Knew How It Would Feel to be Free

August 4, 2009

Buddha tried telling us, but we would not believe.
You live to realize.

I wish I knew how it would feel to be free
I wish I could break all the chains holding me
I wish I could say all the things that I should say
Say ’em loud say ’em clear
For the whole wide world to hear

I wish I could share
All the love that’s in my heart
Remove all the bars that keep us apart
And I wish you could know how feels to be me
Then you’d see and agree that every man should be free

I wish I could be like a bird in the sky
How sweet it would be if I found I could fly
Well I’d soar to the sun and look down at the sea
And I’d sing cos I know how it feels to be free

I wish I knew how it would feel to be free
I wish I could break all the chains holding me
And I wish I could say all the things that I wanna say
Say ’em loud say ’em clear
For the whole wide world to hear
Say ’em loud say ’em clear
For the whole wide world to hear
Say ’em loud say ’em clear
For the whole wide world to hear

One love one blood
One life you’ve got to do what you should
One life with each other
Sisters, brothers

One love but we’re not the same
We got to carry each other Carry each other
One One One One One…

I wish I knew how it would feel to be free
I wish I knew how it would feel to be free

PHP/MySQL Basics

August 1, 2009

Basic SQL Commands:

    mysql> show databases;
    mysql> use [db name];
    mysql> show tables;
    mysql> describe [table name];
    mysql> DELETE from [table name] where [field name] = ‘whatever’;
    mysql> create database [databasename];
    mysql> drop database [database name];
    mysql> drop table [table name];
    mysql> SELECT * FROM [table name];
    mysql> show columns from [table name];
    mysql> SELECT * FROM [table name] WHERE [field name] = “whatever”;
    mysql> SELECT COUNT(*) FROM [table name];
    mysql> SELECT SUM(*) FROM [table name];mysql> INSERT INTO user (Host,User,Password) VALUES(‘%’,’username’,PASSWORD(‘password’));
    mysql> flush privileges;

    # mysqladmin -u root password newpassword

* to do: create a function to dump db connectivity details 🙂

<html>
<body>
<Form action=”contact.php” method=”post”>
First Name: <input type=”text” name=”fname” />
Last Name : <input type=”text” name=”lname” />
<input type = “submit” name = “submit” value = “Echo Values” />
<input type = “submit” name = “update_db” value = “Update Database” />
<input type = “submit” name = “display_db” value = “Display Records” />
</form>

<?php
if (isset($_POST[‘submit’]))
{
echo ‘Your First Name Is: ‘.$_POST[‘fname’].'<br />’;
echo ‘Your Last  Name Is: ‘.$_POST[‘lname’].'<br />’;

// mail(‘ayanthianandagoda@hotmail.com’,’PHP mails’,$_POST[‘fname’].$_POST[‘lname’],’ayanthi’);
}

if (isset($_POST[‘update_db’]))
{

$host = “localhost”;
$username = “root”;
$password = “”;
$db_name = “contact”;
$tbl_name = “contact_details”;
$fname = $_POST[‘fname’];
$lname = $_POST[‘lname’];

$con = mysql_connect(“$host”, “$username”, “$password”) or die(“cannot connect”);
if (!$con)
{
die(“could not connect: ” .  mysql_error());
}

mysql_select_db(“$db_name”) or die(“cannot select DB”);

$insert_query = “insert into $tbl_name values(‘$fname’, ‘$lname’)”;
$result = mysql_query($insert_query);

if ($result != 1)
{
echo “insert fail”;
}

}

if (isset($_POST[‘display_db’]))
{

$host = “localhost”;
$username = “root”;
$password = “”;
$db_name = “contact”;
$tbl_name = “contact_details”;
$fname = $_POST[‘fname’];
$lname = $_POST[‘lname’];

$con = mysql_connect(“$host”, “$username”, “$password”) or die(“cannot connect”);
if (!$con)
{
die(“could not connect: ” .  mysql_error());
}

mysql_select_db(“$db_name”) or die(“cannot select DB”);

{
$select_query = “select * from $tbl_name”;
$result = mysql_query($select_query);

while ($newArray = mysql_fetch_array($result))
{
$first_name = $newArray[‘first_name’];
$last_name = $newArray[‘last_name’];
echo $first_name.” “.$last_name.'<br />’;
}
}

}
?>

</body>
</html>

True IT Confessions

August 1, 2009

A colleague from office recently posted a link to an entertaining article. True IT confessions is a post on supergeeks confessing some of the dumbest moves they’ve ever made in their careers – ‘ts hilarious.. Yes, my personal favorite too was #4. Quoting below for your reference:

True IT confession No. 4: What can Brown do for you?

Here’s one of those rare backup mishaps in which data did in fact get backed up. But what it got backed up to is where things goes sour.

Twenty-seven years ago, David Guggenheim had just gotten his first “real job” as biological data manager at an environmental consulting firm in Southern California. At that time, the firm’s hardware consisted of a PDP-11 and a time-share IBM 360 mainframe in Los Angeles, accessed via dial-up.

“It was time to archive an important project from the IBM mainframe, so I cracked my knuckles and began pounding out the JCL [Job Control Language] necessary to write our data to tapes that would then be shipped to our office,” he says. “I submitted the job, satisfied that our data would be safely backed up.”
A few days later a UPS driver poked his head in the door at the firm’s office and shouted, “Is there a David Guggenheim here?”

The UPS truck was filled floor to ceiling with boxes, all of them addressed to Guggenheim. He opened the first one. It was full of punch cards. And so were all the rest of them.
“It was our data from the IBM mainframe,” he says. “To my horror, I realized that instead of specifying output to magnetic tape, I specified output to punch cards. I can’t remember my JCL very well any more, but as I recall, it was the difference between specifying ‘=0’ versus ‘=1.’ I was absolutely humiliated.”

It gets worse. A few days after the entire staff got involved clearing enough floor space for the mountain of boxes, the bill arrived. The cost of a punch-card backup job was nearly $1,000 (and remember, we’re talking about 1982 dollars here).

“I had blown our budget out of the water, killed a forest, and still failed to back up our data onto tape,” says Guggenheim, who’s now Dr. David Guggenheim, Ph.D., president of 1planet 1ocean, and a senior fellow at The Ocean Foundation. “I’ve spent my career since then doing environmental work, so hopefully I paid penance for the dead trees.”

Lessons learned? 1. Little mistakes can cause huge problems, so keep checking until it hurts. 2. Immediately own up to your errors; humility is a great teacher. 3. Take the time to appreciate the humor of a colossal screw-up, says Guggenheim. “It does wonders for the sting.”