Archive October 2007

AJAX Picture Gallery using jQuery View Comments

Oct23

I have been longing for a custom picture gallery for quite some time, to showcase my pictures, but did not want to go for a ready made solution like Coppermine or Gallery. Sure these are great products with endless features, but would not give me that MADE BY MYSELF feeling :-) So I decided to tinker with Prototype and Script.aculo.us , to see if any good carousel is available which I can use as an image slider. I had previously used YUI Carousel by Bill Scott of Yahoo! but did not want to use it because it was way too heavy and hence slow to load initially. So I decided to take a look into jCarousel by Sorgalla which is based on the excellent jQuery Javascript framework. Both jQuery and jCarousel are very lightweight, feature packed, customisable, and contain almost all, if not all, the features of prototype and scriptaculous.

So after a little toying with the carousel and learning a few cool effects of jQuery , I made up http://gallery.naveeng.com . Right now it is very very basic and it’s development is still under progress. I will be adding a lot more features to it, which include:

  • Multiple Albums
  •  Admin Panel
  • User Comments
  • Ratings
  • Last Added Pictures
  • Random Pictures
  • Tags

It may take a lot of time but one day all the above features (plus a lot more!) will be there for sure! The gallery has a lot of jQuery JS code, with the image details stored in XML format on the server. The server side scripting and image manipulation are done in Perl using the fantastic PerlMagick API of ImageMagick .

Durga Puja Pandals and Idols in Kolkata- Day 3 View Comments

Oct20

KOLKATA DURGA PUJA IMAGES – DAY 1

KOLKATA DURGA PUJA IMAGES – DAY 2

CLICK ON THE IMAGES TO SEE FULL SIZE

A SMALL BUT BEAUTIFUL PUJA ON C.I.T. ROAD

A traditional Santhal dance being performed in front of pandal

Decorative lanterns on trees

A 12 storey Vodafone banner at Ekdalia!

DESHAPRIYA PARK (Google Maps)

A replica of he famous TIRUPATHI Temple in Andhra Pradesh, India

The idol at Deshapriya Park

PARK CIRCUS

Replica of the famous Golden Temple, Amritsar, India

The Goddess at Park Circus

Durga Puja Pandals and Idols in Kolkata- Day 2 View Comments

Oct19

CLICK HERE TO SEE MORE IMAGES OF DURGA PUJA IN KOLKATA

As I had promised, I’m back with more pictures of the breathtaking Durga Puja scene in Kolkata right now. The fervour is electrifying and the craftsmanship simply scintillating. It seems as if the whole of Kolkata is out on the streets (it actually is!) during Pujas, and the sights throughout the night remain the same, forcing you to believe that the clock has stopped! Anyways, I’ll cut the crap and below are the snaps of Golpark, Ekdalia Evergreen in Gariahat, Singhi Park opposite the former :-)

CLICK ON THE IMAGES TO SEE FULL SIZE

GOLPARK (Google Maps)

THE EKDALIA ENTRANCE -GARIAHAT (Google Maps)

Awesome illumination work

The huge pandal from a distance

Must have been thousands out there!

The traditional Durga idol at Ekdalia

Chandelier!!

RELATIVELY SMALL PUJA OF PHALGUNI SANGHA, BESIDE EKDALIA

SINGHI PARK, BANG OPPOSITE EKDALIA

Its Halloween time!!

Is it Durga Puja or Vodafone Puja!!

The magnificent Singhi Park deity

Intricate artistry inside the pandal

HINDUSTAN CLUB PUJA, BEHIND SINGHI PARK

Durga Puja Pandals and Idols – Day 1 View Comments

Oct18

CLICK HERE TO SEE LATEST PICTURES OF  DURGA PUJA IN KOLKATA

It was Mahasasthi, 1st day of the famous Durga Puja and I ventured out in the evening for some pandal hopping. Didn’t cover much, but saw 3 famous Pujas of South Kolkata. Below are some of the pictures I took with my cellphone. Will be posting more and soon, better quality pictures taken from digicam.

CLICK ON THE IMAGES TO SEE FULL SIZE

PANDAL IN ANANDA PALIT (in my locality – Google Maps)

 

IDOL AND PANDAL NEAR LAKE TEMPLE ROAD, SOUTHERN AVENUE (Google Maps)

SHIV MANDIR PUJA COMMITTE – LAKE TEMPLE ROAD (Google Maps)

Brilliant Lighting arrangements!

The Puja theme is awesome – intricate artistry

It is Rotating!

The Main Pandal

On the walls

The Idol

LAKE YOUTH CORNER – BESIDE SHIV MANDIR

The pandal has been designed like a Banyan Tree!

And its all earth! Clay cups used for construction!

The Best Idol I saw yet

MUDIALI (Google Maps)

A PUJA IN A LAKE GARDENS PARK

LAKE SOUTH CLUB – LAKE GARDENS

THE FAMOUS JODHPUR PARK PUJA (Google Maps)

MY LOCALITY PUJA :-) C.I.T ROAD (Google Maps)

Perl one-liner to sort a hash and return the top most key/value View Comments

Oct17

A while ago Deepz asked me whether we can sort a hash and print the top most key or value or both in a single line, in PERL. After a little permutation & combination, I wrote the following piece. I’m sure there must be a more elegant and efficient way of doing it, but this will also serve the purpose on most occasions and with a little tweaking can be applied to almost all hashes.

  • The code needs to be modified if the hash keys contain any digits
  • The sort algorithm can be changed as per the requirement, by default I’m sorting by hash values which are digits

print grep {s/\d//g} grep {/1/} map { $i+=1 , $_.=$i , “\n”} sort {$hash{$a} <=> $hash{$b}} keys %hash;

Vanilla Ice Cream that puzzled General Motors View Comments

Oct17

Many of you, unlike me, might have come across this long ago, as it is in circulation for years now. But I just received it today and was spellbound by the incident. For those who are not aware of it, it goes like this -
Never underestimate your Clients’ Complaint, no matter how funny it might seem!

This is a real story that happened between the customer of General Motors and its Customer-Care Executive. Please read on…..

A complaint was received by the Pontiac Division of General Motors:

‘This is the second time I have written to you, and I don’t blame you for not answering me, because I sounded crazy, but it is a fact that we have a tradition in our family of Ice-Cream for dessert after dinner each night, but the kind of ice cream varies so, every night, after we’ve eaten, the whole family votes on which kind of ice cream we should have and I drive down to the store to get it. It’s also a fact that I recently purchased a new Pontiac and since then my trips to the store have created a  problem….

You see, every time I buy a vanilla ice-cream, when I start back from the store my car won’t start. If I get any other kind of ice cream, the car starts just fine. I want you to know I’m serious about this question, no matter how silly it sounds “What is there about a Pontiac that makes it not start when I get vanilla ice cream, and easy to start whenever I get any other kind?” The Pontiac President was understandably skeptical about the letter, but sent an Engineer to check it out anyway.

The latter was surprised to be greeted by a successful, obviously well educated man in a fine neighborhood. He had arranged to meet the man just after dinner time, so the two hopped into the car and drove to the ice cream store. It was vanilla ice cream that night and, sure enough, after they came back to the car, it wouldn’t start.

The Engineer returned for three more nights. The first night, they got chocolate. The car started. The second night, he got strawberry. The car started. The third night he ordered vanilla. The car failed to start.

Now the engineer, being a logical man, refused to believe that this man’s car was allergic to vanilla ice cream. He arranged, therefore, to continue his visits for as long as it took to solve the problem. And toward this end he began to take notes: He jotted down all sorts of data: time of day, type of gas uses, time to drive back and forth etc.

In a short time, he had a clue: the man took less time to buy vanilla than any other flavor. Why? The answer was in the layout of the store. Vanilla, being the most popular flavor, was in a separate case at the front of the store for quick pickup. All the other flavors were kept in the back of the store at a different counter where it took considerably longer to check out the flavor.

Now, the question for the Engineer was why the car wouldn’t start when it took less time. Eureka – Time was now the problem – not the vanilla ice cream!!!! The engineer quickly came up with the answer: “vapor lock”.

It was happening every night; but the extra time taken to get the other flavors allowed the engine to cool down sufficiently to start. When the man got vanilla, the engine was still too hot for the vapor lock to dissipate.

Even crazy looking problems are sometimes real and all problems seem to be simple only when we find the solution, with cool thinking.

————————————————————-

Huh!!

The Stranger – Amazing Short Story View Comments

Oct17

I just received an email having a scanned document as an attachment. It seems to be some kind of a literature examination paper of some Soham Bandhopadhyay, and is a short story named THE STRANGER. It has been evaluated as excellent by the examiner and given the 1st place, deservingly so. A brilliant piece of writing which compels you to keep thinking about the story till long after you’ve read it. I am reproducing the story here below, and also link to the original PDF document. Download and go through the document to see the examiner’s evaluation.

THE STRANGER

She was getting engaged.

And all I could do was stand by and appluad along with all.
I didn’t dare open my mouth for fear of saying somethign stupid, something like “I LOVE YOU”.

I remembered the other day when she had come to me with red eyes. Her “BEST FRIEND” was going away. It had never mattered to me that her best friend was a guy. I thought I was above such things. But her tears awoke the sin of jealousy in my heart. Fighting it I had consoled her and given her chocolates to eat. She proceeded to rest her head in the crook of my arm. And promptly fell asleep. I chuckled at her baby-like innocence.
But now, as I applauded, I felt something stabbing at my heart.

She was getting married.
I saw her come down the stairs decked out in her bridal finery. Never had I seen her looking this pretty. I saw her taking the seven rounds around the sacred fire with the man I had come to hate, holding his hands. I saw exchanging garlands with him.

She was a total stranger to me now.

I was standing near the car when they both came over to me. I wondered what they wanted. I wondered how to say Farewell to the Departed.

Nevertheless, as my Daughter and Son-in-law touched my feet, I blessed them. She was openly crying. I told them not to worry. That I’ll always be here.

She responded by hugging me.

And I could not stop the tears anymore.

CREDITS: SOHAM BANDHOPADHYAY

                   EMP NO. – 51067

                   DEPTT – PED

Download PDF: The Stranger By Soham Bandhopadhyay

Install Perl Modules without root View Comments

Oct16

How many times Perl developers have to scratch their heads when they find that there is a module dependency which is breaking their code. Worse, they do not have sufficient privileges to install the required modules on the system. And the worst – there is no immediate way to get the module installed and the application needs to be tested/deployed ASAP! Well, I faced a similar situation during my experience in deploying a website on a shared hosting account, where I was on the mercy of the Hosting Service Provider to decide which modules I’m going to use and which not. But this is hardly the way a programmer works, and more so for a Perl programmer! I came across a few wonderful workarounds (hacks!) to overcome the above.

Download the module from CPAN or elsewhere. Place it in any directory, where you have permissions. Preferably, create a directory called

lib

in the application directory and place your module there. Untar it, you will see a few files and folders – Makefile.pl (to install the module, we don’t need this) , Readme.txt (this either), Examples (not required), lib directory – this is the only thing we are concerned with. It contains the main module files. Go inside the lib directory, and copy all the folders (if any) and all .pm files and place them directly inside the lib directory you just created. Remove all other files and folders.

The next thing which you need to do is go to the Perl code where you want to use that module and write the following:

BEGIN { unshift @INC, "./lib"; }
use Module::Name;

And voila!! Your code works like a charm with all the functionalities of the module included.

How it works? - When you use a module in a program, like

use CGI::Ajax;

perl searches for it in a predefined library search path on the system. You can determine which directories are in the path by executing

perl -e 'print for @INC;'

Any module in order to be usable in the program needs to be in any of the directories above, which is where the modules get installed if installed via

cpan or ppm

command or using Makefile.pl.

But in the situation discussed, it is not the case, as we cannot install a module as it should be. Instead what we do is place the modules in a directory of our choice (lib) and then insert the path of that directory in the

@INC

so that later when the perl interpreter tries to do

use Module::Name;

it finds its path in

@INC

Why BEGIN { } ? -

use Module::Name

happens at compile time, when the interpreter reads the program while

unshift @INC, "./lib"

happens at run-time, after the compilation, i.e, attempt to load the module, even if the latter is placed above the former in the program. So in order to force the program to modify

@INC

before trying to use the module, we use

BEGIN { }

block. Any code which is written within

BEGIN { }

block is executed at compile-time as opposed to other code which is executed at run-time.

Note: Remember that many modules have further dependencies, i.e. modules which are required for the former to work. And if these dependencies are not on the system, the code won’t work. You need to perform the above operations for each of those dependencies as well. For example, if CGI::Ajax requires Class::Accessor to work, you need to

a) create the directory CGI and place Ajax.pm within it

b) create the directory Class and place Accessor.pm and the directory Accessor within it and

c) unshift/push the path of the directory which contains these 2 directories CGI and Class, into @INC.

I have used this method to use more than 30 odd modules and have faced no difficulty whatsoever. However it will not work if the module’s Makefile.pl does more than just copying the .pm files in the right place and do some other work such as using external C libraries etc.

Another method of extending

@INC

is setting the

PERL5LIB

environment variable on your system to include the path of the manually placed modules.

In Bourne Shell do something like-

PERL5LIB=/path/to/module/directory; export PERL5LIB

It is useful when you do no want to write the BEGIN blocks in all the files where you use the module. But only users who are setting the

PERL5LIB

environment variable can only use it and other users can’t.

Golden Temple comes to Park Circus for Durga Puja View Comments

Oct16

I couldn’t resist clicking this morning, as I was about to take cab for office from Park Circus. As always, the Durga Puja pandal at PC is turning out to be magnificent and this year’s theme is Golden Temple, Amritsar. Although not yet completed, with ornamentation and much of the frills yet to be done, it is strikingly similar to the original masterpiece. It is one of the biggest Pujas in Kolkata with millions thronging the Puja fair, which lasts well over a month after the Pujas are over. Below are 2 snaps from my cell, will keep on posting more :-)

Park Circus Pandal - Golden Temple, Amritsar

Park Circus Pandal - Golden Temple, Amritsar

My First JAPH! View Comments

Oct15

Finally after procrastinating for long, I decided to tread the path traversed only by the GODs of PERL – writing JAPHs!! And my brain storming for about 6 hours finally ended with a JAPH, not too bad for a debut, albeit a little amateur. For those of who are still wondering what the heck is a JAPH – it refers to a PERL program which prints the phrase JUST ANOTHER PERL HACKER. It is an art initiated by Randal Schwartz and further mastered by the likes of Abigail. My piece of code is as follows:

#!/usr/bin/perl

@b=map +{keys %$_} , map +{chr}, grep {!/6[68]|7[0137]|81/} (65..85);

%hs1=(74,1,85,2,83,3,84,4);
%hs2=(65,1,78,2,79,3,84,4,72,5,69,6,82,7);
%hs3=(80,1,69,2,82,3,76,4);
%hs4=(72,1,65,2,67,3,75,4,69,5,82,6);

for $i(1..4) { $n=”h2″.$i;for (0..13) {@abc=keys %{$b[$_]};$k=pop @abc;map { ${$n}{$_}++ } keys %{$b[$_]} if ((($i==1) && ($k=~m![tsuj]!i)) || (($i==2) && ($k=~m![rehtona]!i)) || (($i==3) && ($k=~m![lrep]!i)) || (($i==4) && ($k=~m![rekcah]!i))); }}

for (1..4){$m=”h2″.$_;$ms=”hs”.$_; print sort {${$ms}{ord $a} <=> ${$ms}{ord $b}} keys %{$m}, ” “;}

I particularly don’t like two parts of the above code -

1) The 4 hashes at the top – they are used to sort the letters in the words (It took most of my time)

2) The big if ( ) { } block – it kinda gives the code a very amateurish look.

So while I work on improving myself, do give in some suggestions if you may please :-)

And if you think that was smart, then have a look at http://www.cpan.org/misc/japh or http://en.wikipedia.org/wiki/JAPH for some of the most astonishing piece of coding across any language on this planet.

Naveen's Journal is powered by WordPress and FREEmium Theme.
developed by Dariusz Siedlecki and brought to you by FreebiesDock.com