Friday, June 24, 2016

Apache Rules - I

Apache Trailing Slash Implementation


# first rule removes ending in files (eg : not like /abc.html .. this will now include urls with and without trailing slash)
# second rule removes urls ending in trailing slash
# therefore rewrite rule will match ONLY normal non-file urls not ending in trailing slash

       RewriteCond %{REQUEST_URI} /+[^\.]+$
       RewriteCond %{REQUEST_URI} ^(.*(?!/).)$
       RewriteRule ^(.*)$ $1/ [QSA,R=301,L]

Tuesday, April 10, 2012

dsp:getvalueof


It creates a variable in a given scope or in page scope if none specified.


With  you can create a constantparam or a constant value.
Defining constant value:
The equivalent in JSP:
String age = “25″;
Defining a parameter in request scope:
The equivalent in JSP:
String age = request.getParameter(“customerAge”);
Defining a bean:

The equivalent in JSP:
Employee employee = new Employee();

Saturday, March 10, 2012

Monday, March 5, 2012

The BUG bit me :)))

Adam Huber !! I owe the first 10 minutes of my office time to your creation..  Don't believe me ? Checkout the pic below..

For anyone who doesn't know who "BUG" is, please head over to this site (www.bugcomic.com) or click on the below pic of the lovable cute guy ;))

I guarantee you, you will be hooked !!




Thursday, March 1, 2012

Sorting Shown Visually

I found this site that provides a visual depiction of different sorting algorithms under different conditions.
Please take a look :)

http://www.sorting-algorithms.com/

Wednesday, February 29, 2012

Pill Problem Solution

For those of you who did not get it ;)

Keep aside the 3 pills for later. Take a set of pills from the bottles again (Hopefully be a little less clumsy from now on .. Dude, your life hangs in the balance !! ) .. Continue taking the pills everyday until the day before the end of the prescription month. Now you will be left with one pill in one bottle and none in the other. Mix the one with the 3 pills kept aside.. Now you have 4 pills (2 of one kind and 2 of the other).

Tricky part ;)) .. Divide the 4 pills into halves, eating one half of each as you make them .. Voila ! You just saved your life !! Eat the rest of the halves the next day on your way to the pharmacy ;))

Tuesday, February 28, 2012

Pill Problem

You have a two identical bottles of pills, containing pills that look identical except for their internal chemical composition. Looking/tasting/smelling them ,ie, the physical attributes will not let you know the difference.

The Rules
You HAVE to eat exactly one pill each from each bottle everyday.
If you eat more than one pill of each, you die.
If you eat less than one pill of each, you die.
If you do not eat both pills for a day, you die.
The bottle cannot be refilled until the end of prescription month, which basically means if there are 30 pills in a bottle, then that bottle can be refilled only after 30 days.. NOT before.

The Problem
You start eating the pills religiously following the rules for a couple of days. On the third day, lethargy sets in. when you tip the bottles over to get the pills, out of one bottle, two pills fall out instead of one.
Oboy !! Now you are left with three identical pills on one hand without any way of telling them apart ..

Objective
How do you live to get to the end of the prescription month ?


-- Google Interview