user is the personal website of Srikanth Eswaran who lives in Bangalore, India.


pdoexception, socket, errors, drupal

Understanding socket connection errors in Drupal and how to solve them

Posted on .

In this post I will briefly record how to resolve the following error

PDOException: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (111) in lock_may_be_available() (line 167 of /var/www/drupal­

This is a frustrating error which has made me go back to my web hosts and understand from them why this error repeated occurs. The biggest drawback of this error is that all drupal installations come to a halt for good and its a big journey from there until you screw up your databases, screw up your content and further are so misled by all explanations on the internet until you feel you are a dumbass for having to use drupal in the first place.

This is the cost of experimental software contributed by a community. Thankfully, Jeffery Yee has provided a solution for this and this is what you need to do to enjoy drupaling all over again.

How to solve this issue? The solution that works best is to create a swap memory for mySQL and allow the applications to take advantage of that. Here’s how to do that:

  • Login into your instance from Terminal or Command Prompt via SSH.
  • Now, switch to Root mode (Sudo su)
  • Run the following command: dd if=/dev/zero of=/swapfile bs=1M count=1024
  • Make a swap file by running: mkswap /swapfile
  • Turn on Swap Files: swapon /swapfile

And that’s it. You’re done. To monitor your Swap file size and free space, just type swapon -s.


treasure hunt

The Moto G anniversary gift treasure hunt

Posted on .

It was my tenth anniversary and the wife being a conservative lady made it difficult for me to choose her a phone of her choice - she wanted a dual sim phone, running android, with what’s app support and small screen size and I wanted it to be a google device and probably with upgrades to kit kat operating system. I bought the Moto G device in Kuala Lumpur for about 765 RM totaling close to about 15+k INR. When my wife went out with the kids, I somehow sneaked it in. This was a device that suited her requirement.

I had exactly one hour and I had to setup the whole thing before my wife was back and make it look like nothing has happened at all. The whole treasure hunt was setup in a flash of an hour’s time and the clues were hidden everywhere possible to make this more interesting. Would you like to know how the game went on ? Look below

The clue strips stuck on a mirror to start the show read thus

Hey We’ve completed 10 years together and you thought I’d let you go without a surprise? Shall we start ?


Rip the sheet and you found the clues :

Clue #1 : A getaway along the salty waters refreshes your mind, body, soul and mouth.


A little bit of thought and she was able to guess this one - a bar of Ghirardelli Sea Salt Escape chocolate kept in the fridge. Down she ran all the way from first floor and found the next clue in the fridge


Clue #2 : The rather long story of squeezing a sugar confectionery better be short

No matter how long she could not guage this one and it stumped her. i had to push her forward with more smaller clues and after a while she realized that it meant - Candy Crush Saga. Off she ran to the first floor again in search of the iPad after holding the record for playing that game the maximum amount of times at home.

There she came across the next clue.


Clue #3 : You’ve always lived life with a simple uncouth unsophisticated RUSTIC guy.

No matter what, she again could not decipher this even though the word RUSTIC was clearly written in capitals. After egging her on a bit more and narrowing down to what I wear she realized the answer. And the next clue was to be found on my T-Shirt


Clue #4 : When thou shalt encounter the Merlion the bell shalt ring

She definitely zeroed in on this one much faster and down she ran again to the ground floor to fetch the bell, a momento from Singapore where the next clue was to be found.



Clue #5 : I hope you don’t feel like the lady who had a tragic affair with Count Vronsky

Pat came the reply again that it meant Anna Karenina the lady whose married life fate was written as a bestseller by Leo Tolstoy. She also knew she was reading that on the Kindle. But then the mind went awry. She started looking for a book on the Kindle for the next clue not being able to find anything anywhere else on it.

It took a while to expose the brilliance of the next secret clue - something written with charcoal pencil right on the body of the Kindle itself


Clue #6 : Life is a book of activities. We finish 10 pages today. The magic square shall spill the secret.

Fairly easy enough to guess after both our kids have tortured us so much with this famous book, she turned to page 10 on the book of 500 activities. The magic square gave the next easy clue.


Clue #7 : Abracadabra ! and the Rabbit’s out of the magician’s hat

Again the clue was an easy one which led her straight to the magician’s hat.


Clue #8 : OOPS !! Its a frog and its LEAPing really high

This one stumped her though she had seen the toy over and over again in the house. Egging her on a bit more and she managed to understand. The next place to go to was to the LEAP FROG educational toy our kids play with.



Clue #9 : A boat, a car, a Bridge and a train, a little more taller and I’ll ride a plane

She got a bit stuck up on this one as well but I managed to push her forward until she found the next clue on a custom made height chart we ordered for our kids.


Clue #10 : An Anniversary is a revisit to those shared special moments its a time to rekindle emotions of fresh romance Every relationship is fragile and so is your GIFT. You need to handle both the same way - with lot of care.

She almost went blank on this one. She thought her gift for her anniversary is ME :-) oh how sweet. She also said maybe she needs to give me a hug. She didn’t get the point. The exact clue, the exact fonts, the exact words everything pointed to one thing and one thing alone - our 5th Anniversary photograph kept high up with a set of portraits.



When she took the photograph out, and held it in her hand, there she found the 10th Anniversary gift, gleaming in the room light.

The MOTO G was her’s to keep along with the sweet smile on her face :-)


What seemed like just yet another anniversary was spruced up so differently in just one hour of time. I hope you enjoyed the treasure hunt dear wifey, as much as i liked creating it for you


software development, 2038, y2k, y3k, computers, programming, time problem, dates, it industry, bangalore, bengaluru, blog, technology, unix, linux, windows, pc

The Year 2038 Time Problem

Posted on .

So we all thought only Y2k and Y3k could cause problems in the world of computing? What about Y2.038k ?? Whats great about this date? Lets have a look. The rest of this article is as quoted by Roger M. Wilcox.

What’s So Special About 2038?

Early UNIX programmers had quite a sense of humor. In their documentation for the tunefs utility, a command-line program that fine-tuned the file system on the machine’s hard disk, a note at the end reads “You can tune a file system, but you can’t tune a fish.” A later generation of UNIX authors, fearful that stuffy, humorless corporate drones would remove this cherished pun, added a programmer’s comment inside the documentation’s source code that read, “Take this out and a UNIX demon will dog your steps until the time_t’s wrap around!”

On January 19, 2038, that is precisely what’s going to happen.

For the uninitiated, time_t is a data type used by C and C++ programs to represent dates and times internally. (You Windows programmers out there might also recognize it as the basis for the CTime and CTimeSpan classes in MFC.) time_t is actually just an integer, a whole number, that counts the number of seconds since January 1, 1970 at 12:00 AM Greenwich Mean Time. A time_t value of 0 would be 12:00:00 AM (exactly midnight) 1-Jan-1970, a time_t value of 1 would be 12:00:01 AM (one second after midnight) 1-Jan-1970, etc.. Since one year lasts for a little over 31 000 000 seconds, the time_t representation of January 1, 1971 is about 31 000 000, the time_t representation for January 1, 1972 is about 62 000 000, et cetera.

If you’re confused, here are some example times and their exact time_t representations:

| Date & time					| time_t representation	|
| :----------------------------	| --------------------: |
| 1-Jan-1970, 12:00:00 AM GMT 	| 0 					|
| 1-Jan-1970, 12:00:01 AM GMT	| 1 					|
| 1-Jan-1970, 12:01:00 AM GMT	| 60 					|
| 1-Jan-1970, 01:00:00 AM GMT	| 3 600 				|
| 2-Jan-1970, 12:00:00 AM GMT	| 86 400 				|
| 3-Jan-1970, 12:00:00 AM GMT	| 172 800 				|
| 1-Feb-1970, 12:00:00 AM GMT	| 2 678 400 			|
| 1-Mar-1970, 12:00:00 AM GMT	| 5 097 600 			|
| 1-Jan-1971, 12:00:00 AM GMT	| 31 536 000 			|
| 1-Jan-1972, 12:00:00 AM GMT	| 63 072 000 			|
| 1-Jan-2003, 12:00:00 AM GMT	| 1 041 379 200 		|
| 1-Jan-2038, 12:00:00 AM GMT	| 2 145 916 800 		|
| 19-Jan-2038, 03:14:07 AM GMT	| 2 147 483 647 		|

By the year 2038, the time_t representation for the current time will be over 2 140 000 000. And that’s the problem. A modern 32-bit computer stores a “signed integer” data type, such as time_t, in 32 bits. The first of these bits is used for the positive/negative sign of the integer, while the remaining 31 bits are used to store the number itself. The highest number these 31 data bits can store works out to exactly 2 147 483 647. A time_t value of this exact number, 2 147 483 647, represents January 19, 2038, at 7 seconds past 3:14 AM Greenwich Mean Time. So, at 3:14:07 AM GMT on that fateful day, every time_t used in a 32-bit C or C++ program will reach its upper limit.

One second later, on 19-January-2038 at 3:14:08 AM GMT, disaster strikes.

To know more about this problem and continue reading further, click here.

Technorati Tags: Software Development, 2038, Y2k, Y3k, Computers, Programming, Time problem, Dates, IT industry, Bangalore, Bengaluru, Blog, Technology, Unix, Linux, Windows, Pc


software development, timers, timeofday, time_t, timeval, strftime, unix, linux, programming, bangalore, bengaluru, technology, blog, tv_usec, tv_sec

Using Current Time Of Day To Timestamp Execution Logs

Posted on .

I keep coming back to timers these days as my work is involving their usage heavily -). The latest was a requirement by me for knowing a current time for timestamping a certain sequence of logs. I found this program at a sourceforge website, which just wonderfully and blissfully did what I wanted …

Here is the small tiny program for reference:

/* C routine: sample gettimeofday with time in milliseconds


#include <sys/time.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>

int mainvoid
  char buffer[30]
  struct timeval tv

  time_t curtime

  gettimeofday&tv, NULL

  strftimebuffer,30,"%m-%d-%Y  %T.",localtime&curtime

  return 0


My execution logs looked something like this:

RESULT : EName:[02-25-2008 15:26:50.MS: 520548] Sub : –[1]– EvID : –[1]– Pub : –[0x9163788]– PName : –[pub1]–
RESULT : EName:[02-25-2008 15:26:50.MS: 520708] Sub : –[1]– EvID : –[1]– Pub : –[0x91638d0]– PName : –[pub2]–
RESULT : EName:[02-25-2008 15:26:50.MS: 520799] Sub : –[1]– EvID : –[1]– Pub : –[0x91639f8]– PName : –[pub3]–

Technorati Tags: Software Development, Timers, Timeofday, Time_t, Timeval, Strftime, Unix, Linux, Programming, Bangalore, Bengaluru, Technology, Blog, Software development, Tv_usec, Tv_sec


Trees They Are The Same In Real Life

Posted on .

layout: post title: “Trees, they are the same in real life” date: 2015-07-10 06:19:49 categories: Software Development, Node, Root, Parent, Chilld, Size, Leaves, Levels, Trees, Lists, Arrays, Linked list, Binary trees, N-ary trees, Leaf, Traversal, Postorder, Preorder, Inorder, Root, Infix, Postfix, Expressions, Arithmetic, Class, C++, C, Recursion, Recursive banner_image: “” featured: false comments: true —

I was researching a bit on trees, and found this useful presentation on Binary Trees. Though it also has a mention of N-Ary trees, the real crux of N-Ary trees can be found in books by O’Rielly. I shall speak about this a bit later, but for now I’ ll leave you with this presentation:

(courtesy and copyrighted by Rick Mercer)

Technorati Tags: Software Development, Node, Root, Parent, Chilld, Size, Leaves, Levels, Trees, Lists, Arrays, Linked list, Binary trees, N-ary trees, Leaf, Traversal, Postorder, Preorder, Inorder, Root, Infix, Postfix, Expressions, Arithmetic, Class, C++, C, Recursion, Recursive