The Frog in the Well
2
Once there was an old frog who lived inside a deep well. Frog was so happy with his home that he always told his friends who also lived in his well how wonderful the well was.
One day, Frog was sitting on a ledge near the wall of his well appreciating the sky when he saw an unexpected visitor at the corner of the big round sky. It was a big turtle from the Eastern Ocean that Frog had never seen before.
“Hi there!” Frog croaked. “I don’t believe we’ve met before! Please friend, please come into my well and pay me a visit. My well is the best place in the world, and I’m sure you’ll be very comfortable here.”
Turtle looked down inside the small well, straining his eyes. “Alright,” said Turtle. But the closer he got to the well, the smaller the opening looked to him. “I’m sorry Frog, I don’t think I can make it down there – I think I’d get stuck!”
“But of course you can fit in my well!” said Frog, “It’s very spacious! And you don’t look too big to me.”
“That’s because the opening to your well is so small, you can only see my face. You still can’t see the rest of me! But you’re right, in comparison with my friends from the Eastern Ocean, I’m not very big.”
Frog’s eyes bulged. “You mean there are creatures outside of my well there that are bigger than you?”
“Much bigger!” Turtle said. “Here you have tadpoles, but in the Eastern Ocean we have whales! Here you have goldfish, but in the Eastern Ocean we have Sting rays, sharks, and schools of small fish that are so big that they look like clouds. The Eastern Ocean is so big that it can hold all of those things and we never feel cramped. We can’t see the end of the Eastern Ocean like you can in your well.”
The Frog fell off his lily pad in shock. Then he climbed back up, a little unsteadily. He stared at Turtle for a moment in disbelief, and then said, “I’m not sure I believe you. I don’t think there could be anything that big, and certainly not as nice as my well.”
Turtle smiled, “Then I’ll take you to see it.”
It took all of his strength but by hopping off of the walls, Frog was finally able to jump out of his well and land on the dewy grass beside it. But once outside, Frog couldn’t sop sneezing and squinting.
Turtle asked, “Do you feel alright, little friend?”
The sun was so hot on his back, but eventually Frog nodded. “I always thought that the sky was round and that it was the size of my well’s opening. I never knew that it was so huge – I can’t even see its edge! And the sun! It blinds my eyes! I never knew it was so powerful!”
“Now do you understand why I said the well is small?” Turtle said gently. “Certainly your well is a great place to live, but there are many great places on the earth – some much greater than your well.”
Frog just hung his head in embarrassment. He knew he would still enjoy his life in the well, but now he realized that he and his well were a small part of a very big world.
Next time,
1. A newbie linux user tells me that linux is secure than windows because it is virus free,
2. A moron tries to convince me that opensource is the way to succeed in business
3. Even my manager tells me that gvim is better than emacs,
this is the link I’m going to forward to them. It is like fighting with a dirty pig when you try to argue with these people. You are gonna waste your time and energy at the end.
Just want to vent out my frustration. People are ever ready to start a flame war, but never ever think about learning something new. Biased Morons.
Delete a remote branch in git
2
We use Git here at interviewstreet. Using Git, branching, testing and reverting is so easy.
Almost all commands are simple and easy to remember in Git, except for deleting a remote branch.
The command to delete a remote branch “feature1″ is
git push origin :feature1
Just wanted to note this down.
Advanced Bash Scripting – Part 2
3
The problem statement is as follows :
The Playfair Cipher encrypts text by substitution of digrams (2-letter groupings). It is traditional to use a 5 x 5 letter scrambled-alphabet key square for the encryption and decryption.
Each letter of the alphabet appears once, except “I” also represents “J”. The arbitrarily chosen key word, “CODES” comes first, then all the rest of the alphabet, in order from left to right, skipping letters already used.
To encrypt, separate the plaintext message into digrams (2-letter groups). If a group has two identical letters, delete the second, and form a new group. If there is a single letter left over at the end, insert a “null” character, typically an “X.”
To read more about the question, check http://tldp.org/LDP/abs/html/writingscripts.html
The solution for this question is pretty long (over 100 lines in shell script). You can check the final solution at http://sp2hari.com/bash/playfair-cipher.html
Explanation of function/code used in the solution.
locateInKeySquare: Searches for the character passed as the parameter in the keySquare and returns the position of the character.
addToKeySquare: Adds a character c passed as the parameter to the keySquare. This checks if the character is already present, if it is J and changes it to uppercase (if needed)
printKeySquare: Prints the keySquare from 1D to 2D format.
The rest of the code adds the keyWord to keySquare. The the remaining words are added to the keySquare. After that, we extract the dialects from the plaintext and based on the 3 rules, we encrypt the text.
Hope this is helpful..
Query String in URL using Codeigniter
0CodeIgniter by default won’t allow you to use query strings in the URL.
This is how you enable query string in url in codeigniter.
1. Set $config['uri_protocol'] = “PATH_INFO” in config.php
2. Set $config['enable_query_strings'] = TRUE in config.php
3. Make you sure you have QSA in your .htaccess. For example,
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|includes)
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]
Note: If you make these changes, the pagination module is affected. So, if you had implemented any pagination before changing these settings, you might want to check them again.
My first 30 day challenge.
6I’m a big fan of Matt Cutts (who isn’t) and especially like his 30 day challenges.

So, I decided probably I can give it a shot for a couple of months.
So, some of the stuff I had in my list are.
1. Learn Hadoop.
2. Read a book every 2 days.
3. Learn a new programming language
4. Go to beach everyday and spend at least 30 mins there..
So, this is what I’m going to try for this month. Sleep properly for a month. I’ve neglected my bad sleeping habits for a very long time and it’s time I try to do something about it.
So, planning to go to bed by 1 AM and not wake up before 6AM.
Let us see how long I can manage this one…
Importing Contacts from Google Mail using OAuth
3This is my second post in the fetch contacts from email account series. In this post, we are going to fetch contacts from a Google account. This isn’t a detailed tutorial, but a quick 2 minute how-to.
$this->config->item(‘google_return_url’) is the url of the page to which user is returned after a login attempt.
1. Add the following code where the user has to select Google Mail to import contacts.
<a href="https://www.google.com/accounts/AuthSubRequest?next=<?php echo $this->config->item('google_return_url').'?data=abc'; ?>&scope=http://www.google.com/m8/feeds/contacts/default/thin&secure=0&session=1">Fetch Google Contacts</a>
2. Include these 2 functions in your PHP code.
function make_api_call($url, $token)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curlheader[0] = sprintf("Authorization: AuthSub token=\"%s\"/n", $token);
curl_setopt($ch, CURLOPT_HTTPHEADER, $curlheader);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
function get_session_token($onetimetoken)
{
$output = make_api_call("https://www.google.com/accounts/AuthSubSessionToken", $onetimetoken);
if (preg_match("/Token=(.*)/", $output, $matches))
{
$sessiontoken = $matches[1];
} else {
echo "Error authenticating with Google.";
exit;
}
return $sessiontoken;
}
3. Add the following code to the return url file.
$sessiontoken = get_session_token($_GET['token']);
$contacts = make_api_call("http://www.google.com/m8/feeds/contacts/default/thin?alt=json&max-results=1000", $sessiontoken);
$contacts = json_decode($contacts, TRUE);
foreach ($contacts['feed']['entry'] as $contact)
{
$emails[] = $contact['gd$email'][0]['address'];
}
//$emails array has the email addresses of all the contacts.
4. That’s it folks. It is that simple.
Further reading :
1. http://code.google.com/apis/contacts/
2. http://code.google.com/apis/contacts/docs/3.0/reference.html












