Thursday, December 15, 2011

Create 3d Array in Javascript from a Java Map of Map and populate result in dropdown

Map<String, Map<String,ArrayList<String>>> is to be broken down into 3 arrays (1d, 2d, 3d) and populate them in dropdown menus.
1d Array --> Movie Main Category (English, French, Bengali etc)
2d Array --> Movie Subcategory (Director Name(Bergman, Kurosawa), Actor Name ) depends on 1st choice
3d Array --> Movie List (Depends upon 1st 2 choices)

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>



<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.Set"%>
<%@page import="java.util.Iterator"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
var array1d = new Array();
var array2d = new Array();
var array3d = new Array();
<%

Map<String, Map<String,ArrayList<String>>> map = (Map<String, Map<String,ArrayList<String>>>)request.getAttribute("MainCategory");
Map<String,ArrayList<String>> innerMap = null;

ArrayList<Integer> sizeOfSubCategories = new ArrayList<Integer>(map.size());
ArrayList<String> movieNameList = null;
int index =0;
for(Map.Entry<String, Map<String,ArrayList<String>>> entry : map.entrySet()){
%>
array1d.push('<%=entry.getKey()%>');
array2d[<%=index%>] = new Array();
array3d[<%=index%>] = new Array();
<%
int innerIndex = 0;
for(Map.Entry<String,ArrayList<String>> innerEntry : entry.getValue().entrySet()){
%>
array2d[<%=index%>].push('<%=innerEntry.getKey().replaceAll(" ","_")%>');
array3d[<%=index%>][<%=innerIndex%>] = new Array();
<%
movieNameList = innerEntry.getValue();
for(String myMovieName : movieNameList){
%>
array3d[<%=index%>][<%=innerIndex%>].push("<%=myMovieName%>");
<%
}innerIndex++;
}index++;
}
%>
function populateDropDown(){

var mainCategoryOption = document.getElementById('mainCategoryDropDown').options;
for(var i =0; i < array1d.length; i++)
mainCategoryOption[i] = new Option(array1d[i],i,false,false);
}

function populateSubCategory(mainCategory){
var mainCategoryIndex = mainCategory.selectedIndex;

var subCategoryOption = document.getElementById('subCategoryDropDown').options;
//alert(array2d[mainCategoryIndex]);
subCategoryOption.length = 0;
for(var i =0; i < array2d[mainCategoryIndex].length; i++)
subCategoryOption[i] = new Option(array2d[mainCategoryIndex][i],i,false,false);
populateMovieList(document.getElementById('subCategoryDropDown'));
}

function populateMovieList(subCategory){

var subCategoryIndex = subCategory.selectedIndex;
var mainCategoryIndex = document.getElementById('mainCategoryDropDown').selectedIndex;
var movieListOption = document.getElementById('movieNameDropDown').options;
//alert(array2d[mainCategoryIndex]);
movieListOption.length = 0;
for(var i =0; i < array3d[mainCategoryIndex][subCategoryIndex].length; i++)
movieListOption[i] = new Option(array3d[mainCategoryIndex][subCategoryIndex][i],i,false,false);
}
window.onload = populateDropDown
</script>
</head>
<body>

<select id = "mainCategoryDropDown" onchange="populateSubCategory(this)">
</select>

<select id = 'subCategoryDropDown' onchange="populateMovieList(this)">
<option value="null">Selection</option>
</select>

<select id = 'movieNameDropDown'>
<option value="null">Selection</option>
</select>



</body>
</html>

Saturday, September 26, 2009

Prajna Paramita Heart Sutra and its Translation




(Perfect wisdom heart sutra)

aryavalokitesvaro bodhisattvo
(Avalokateshvara bodhisattva)
gambhiram prajnaparamita caryam caramano vyavalokayati
(deep perfect wisdom action perform luminously)
sma panca skandhas tams ca sva bhava sunyam
(saw five bundles them own nature empty)
pasyati sma iha sariputra
(? saw oh Sariputra)

rupam sunyata va rupam rupan na prithak
(form emptiness evidently form form not different)
sunyata sunyataya na prithag rupam
(emptiness emptiness not different form)
yad rupam sa sunyata ya sunyata sa rupam
(this form that emptiness this emptiness that form)
evam eva vedana samjna samskara vijnanam
(like this feeling thought choice consiousness)

iha sariputra sarva dharma sunyata
(oh Sariputra all dharmas emptiness)
laksana anutpanna anruddha avmala anuna aparpurna
(mark not born not pure not increase not decrease ?)
ta sariputra sunyatayam
(therefore Sariputra in the middle of emptiness)

na vidya na vidya na vidya ksayo va vidya ksayo
(no clarity no clarity no clarity exhaustion no clarity exhaustion)
ya van jaramaranam na jaramarana ksayo
(up to old age no old age exhaustion)
na duhkha samudaya nirdoha margajna
(no suffering end of suffering path)
na jnanam na prapti na bhismaya tasmai na prapti
(no knowledge no ownership no witnessing no thing to own)

tvad bodhisattva prajnaparamita asritya
(therefore bodhisattva perfect wisdom dwells)
viha ratya citta varano vidya ksayo na vidya ksayo
(in dwell thought no obstacle clarity exhaustion not clairty exhaustion)
ya van jaramaranam na jaramarana ksayo
(up to old age no old age exhaustion)
na duhkha samudaya nirodha margajna
(no suffering end of suffering path)
na jnanam na prapti na bhismaya tasmai na prapti
(no knowledge no property no witnessing no thing to own)

tvad bodhisattvanam prajnaparamita asritya
(therefore bodhisattva perfect wisdom dwells)
viha ratya citta varano citta varano
(in dwell thought no obstacle thought no obstacle)
na siddhitvad atrasto vipa ryasa ti kranto
(no existence fear fright inverse reverse ? separate)
ni stha nirvana tya dha vyava sthitah
(perfectly stands nirvana three worlds thing experiences)

sarva buddhah prajnaparamitam asritya
(all buddhas perfect wisdom dwell)
(a?)nuttaram samyaksambodhim abdhisambuddhah
(unexcelled ultimate perfect insight together ? buddhas)
ta smai jnata vyam
(therefore should know ?)
prajnaparamitamahamantram mahavidyamantram
(perfect wisdom great charm great clear charm)

anuttaramantram asamasama mantram
(unexcelled charm unequalled equal charm)
sarva duhkha prasa manam sa tyam ami thyatvat
(all suffering stop terminate genuine real not vain)
prajnaparamitayam ukto mantrah tadyatha
(perfect wisdom declaired charm saying)

GATE GATE PARAGATE PARASAMGATE BODHI SVAHA
(gone gone totally gone totally completely gone enlightened so be it)

Tuesday, February 5, 2008

Red Alert


Red Alert
Knowing that his friend was out to kill herself, Lo Ren-hung typed a message on an internet bulletin board

John Dyson

*This article was published in Readers Digest September 2007

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

At 2 am one night last July, Lo Ren-hung was thinking about going home from his job as a computer technician in Taipei. Surfing the internet, he clicked on a bulletin board that usually had messages seeking advice about purchases and wanting to chat.

The newest post got his attention. Signed by a user called Cutecat0604, it said simply: ''I need to talk.''

Intrigued, Ren-hung sent Cutecat his phone number. Moments later, his mobile phone rang. A young woman was on the line. ''I can't sleep at night,'' she said, her voice soft and weary. ''I am a bit upset. I don't like to be so alone.''

''Hey, Little Princess,'' Ren-hung said cheerfully. ''Don't be like that!''

By the time they got off the phone two hours later, a friendship was born.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Ren-hung spent long, lonely nights at the China Post newspaper, standing by to help fix computer problems. In his fourth-floor office, cluttered with discarded screens, keyboards, printers, disk drives and wires, he often passed the time on the PTT, the ''professional technology temple'' bulletin board. With about one million users and 10,000 discussion groups, PTT is the biggest of its kind in the Chinese world.

Refined and good looking with oblong glasses, Ren-hung would chuckle as he scrolled through the messages posted on a group called Hate – a hot-bed of gossip, news, jokes and outrage for PTT users.

Ren-hung's name meant ''Great Benevolence'' and he liked to reach out and help people. He quickly learned that Cutecat's real name was Yang Yu-ting and that she was a 22-year-old studying English at a college in Kaohsiung City, a large industrial centre, some 300 kilometres from Taipei.

Every night they talked, sometimes for hours.

''If I was sitting beside you right now, would you give me a hug?'' Yu-ting asked one night.

''Of course – the biggest hug in the world,'' Ren-hung promised.

When Yu-ting said she wrote a blog, Ren-hung looked it up. In her picture, she looked petite and as fragile as a big-eyed doll with a pert smile. But Yu-ting was clearly troubled. She admitted to Ren-hung that she had taken pills to kill herself several times, but was always found in time. ''I have a huge hole in my heart and it will never mend,'' she told him.

Little by little, Ren-hung uncovered the reasons behind her depression. When she was 15, her father had an affair with a colleague. She had two serious boyfriends, but drove each one away because she was ''so afraid of being alone.''

In 2004 she had a heart with wings tattooed on her abdomen. ''One day I will fly away,'' she vowed.

Ren-hung's cheerful voice on the phone did more for Yu-ting's depression than the medication from her doctors.

But on December 20, everything changed.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Yu-ting parked her scooter outside a hotel. The bright lobby was decorated with artificial roses spangled with glitter. ''Do you have a room?'' Yu-ting asked manager Huang Tsu-peng, who was working reception.

''How many of you?'' he asked. He took little notice of the girl.

''One.''

She paid $18 and took the key to room 808. Sitting on the bed, Yu-ting pulled out the prescription sleeping pills and, one by one, swallowed about 20.

Next, she unwrapped a barbecue set she had smuggled into the hotel. The starters caught at once, heating the charcoal briquettes and quickly filling the room with deadly fumes.

Yu-ting sat on the bed and wrote in a notebook: ''I'm sorry. I'm just too tired and my future has no answer. Dear Daddy, dear Mummy, and my baby sister, I love you.''

Then she dialled Lo Ren-hung.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

8:55pm
Sitting at his office computer, Ren-hung smiled when his phone rang. He knew it must be Yu-ting but her voice was different – lethargic, spaced-out.

''Do you know what I'm doing?'' she asked dreamily.

''What are you doing?''

''I'm burning charcoal.''

Ren-hung sat up sharply, his heart racing. Burning charcoal emitted deadly carbon monoxide fumes. It was one of the most common methods of suicide in Taiwan.

''Where are you?'' he demanded.

''I'm in a hotel so you won't find me.'' As she slurred her words, Ren-hung realised she'd taken pills as well.

''What's the hotel's name?''

''No way. You'll never know where I am. I'm flying away.''

''OK, what's your room number?''

''I won't tell you.''

''What floor are you on?''

''Oh, what does it matter?'' Yu-ting sighed. ''I'm on the eighth floor.''

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

9:07pm
Fingers flying over his keyboard, Ren-hung called up PTT's Hate board, opened a new post and typed:

''A girl in Kaohsiung City right now is trying to commit suicide, but I am in Taipei. The reasons are relationship problems and melancholia. Her name is Yang Yu-ting. She has just checked into a room on the eighth floor of a hotel and is burning charcoal to gas herself. Netizens in Kaohsiung please help to find her. If we can find her in less than an hour, we might save her.''

He wrote ''RED ALERT'' in the subject line and sent the message.

It went first to a moderator who checked messages as they came in. He fired a message back to Ren-hung: ''Is this real or a practical joke?''

''Of course it's real,'' Ren-hung replied. The moderator attached a yellow star to the post to show that it was important and cross-referenced it to other boards. Almost immediately, responses flashed in.

''Quickly,'' posted YivanL. ''Netizens go to her rescue.''

''A number of hotels in Kaohsiung are more than eight storeys,'' wrote another. ''Can the scope be narrowed?''

''Please help make a list,'' said gogomisa. ''Call the hotels and check whether there is a guest by this name.''

The dramatic speed of the posts gave Ren-hung hope. He called the fire and ambulance services and explained what was happening; they promised to alert emergency services in Kaohsiung.

He dialled Yu-ting's number. No answer. Ren-hung imagined the deadly fumes – tasteless and colourless – steadily filling the hotel room. But there was nothing more he could do.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

9:45pm
Chen Wei-chuan* logged on to PTT. Strongly built and 1.88 metres tall, the shy 28-year-old university student lived with his parents in Kaohsiung. Tonight, on a whim, he did something unusual – he clicked on Hate.

Instantly Lo Ren-hung's message jumped onto his screen. It already had 40 responses and more were coming in every minute. ''Does anyone know her?'' asked sh54inq. ''Let's call her folks, her boyfriend or her classmates.''

Then somebody recognised Yu-ting's name and gave the name of her college. ''Classmates of hers, please call and soothe her!'' said yanki826.

VGA reported that Yu-ting was in her class at secondary school but they had lost touch.

"What can I do to help?" Wei-chuan wondered. Reading the messages again, he jotted down the most important points.

The college was in San-min district. That's not too far from here.

The hotel has at least eight floors. That's something to go on.

The girl is a student. The hotel will be a cheap one.

He decided to start with the Yi-da Hotel – it had ten floors, it was near his home, it was cheap.

He dialled and a man answered. Wei-chuan knew that hotels were usually reluctant to give information about guests, so he made a reservation. ''Could you give me a room on Sunday?''

''Yes, we can,'' the manager told him, and started to take his details.

''By the way,'' Wei-chuan went on. ''I've got a friend called Yang Yu-ting. She might have checked in already. Is she there?''

''Oh yes, she's here.''

Wei-chuan could hardly believe what he heard. ''Listen,'' he said urgently. ''This girl wants to commit suicide. Go and knock on her door – hurry!''

Huang Tsu-peng, the hotel manager, called emergency services then dashed upstairs. He banged on the door. No answer. His skeleton key opened the lock, but the door was chained. With two sharp blows he smashed it open.

The room was thick with smoke, but the girl was breathing. He flung open a window and, slapping Yu-ting's cheeks to keep her awake, laid her on a luggage trolley and got her out of the room.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

10:23pm
A message from Wei-chuan flashed up on every screen: ''Just called and found this person in Yi-da Hotel.''

Now the messages sang a new song. ''I want to cry,'' wrote malakaki. ''Is she all right?''

''Hope it's not too late,'' said sorryboy.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

11:30pm
In Taipei, Ren-hung was relieved and thrilled. Smiling broadly, he posted a last message: ''Miss Yang is in hospital and her family has asked me to say thank you. She might be angry with me, but at least we have to let her know that people won't give up on her – so I hope she won't give up on herself.''

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

A month later, Yu-ting travelled to Taipei to meet Ren-hung. They talked about what happened. ''You owe me one thing, remember,'' Yu-ting said.

''Yes, I know,'' Ren-hung said. He leaned over and hugged her tightly.

''Thank you for everything you did,'' she told him.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

//image source wackylodeon

Tuesday, January 8, 2008

Breaking the Sound Barrier and Sonic Boom

In aerodynamics, the sound barrier usually refers to flight at transonic speeds, between subsonic and supersonic speeds. The term came into use during World War II when a number of aircraft started to encounter the effects of compressibility, a grab-bag of unrelated aerodynamic effects. The term fell out of use in the 1950s when aircraft started to routinely "break" the sound barrier.


U.S. Navy F/A-18 at transonic speed. The origin of the cloud is debated; the leading theory claims: "a drop in air pressure at the plane described by the Prandtl-Glauert Singularity occurs so that moist air condenses there to form water droplets."

  • What causes a sonic boom?

You can learn a lot about sonic booms by looking at the wakes boats leave in the water.

If you toss a pebble in a pond, little waves will form in concentric circles and propagate away from the point of impact. If a boat travels through the pond at 3 to 5 miles per hour, little waves will propagate in the same way both ahead of and behind the boat, and the boat will travel through them.

If a boat travels faster than the waves can propagate through water, then the waves "can't get out of the way" of the boat fast enough, and they form a wake. A wake is a larger single wave. It is formed out of all the little waves that would have propagated ahead of the boat but could not.


When an airplane travels through the air, it produces sound waves. If the plane is traveling slower than the speed of sound (the speed of sound varies, but 700 mph is typical through air), then sound waves can propagate ahead of the plane. If the plane breaks the sound barrier and flies faster than the speed of sound, it produces a sonic boom when it flies past. The boom is the "wake" of the plane's sound waves. All of the sound waves that would have normally propagated ahead of the plane are combined together so at first you hear nothing, and then you hear the boom they create.

It is just like being on the shore of a smooth lake when a boat speeds past. There is no disturbance in the water as the boat comes by, but eventually a large wave from the wake rolls onto shore. When a plane flies past at supersonic speeds the exact same thing happens, but instead of the large wake wave, you get a sonic boom.

  • Jet-F-18 Breaking Sound Barrier

  • Sonic Booms

  • Breaking The Sound Barrier

Sunday, December 30, 2007

Pigpen


The pigpen cipher (sometimes called the masonic cipher or Freemason's cipher) is a simple substitution cipher exchanging letters for symbols based on a grid.
This cipher goes back to the time of the Crusades (1095-1272) but it wasn’t until the time of the American Civil War in the 1860s that the pigpen cipher became popular for sending secret messages. This cipher is known as the pigpen cipher because the letters of the alphabet – the “pigs” are trapped within the lines – the “pens.” The shapes made by these “pens” either with or without a dot, represent the letters inside.
Other Diagram Ciphers
Tic-Tac-Toe Cipher

Take a look at the tic-tac-toe symbol below and you’ll see that the entire alphabet is contained in its nine different spaces or “rooms” with a question mark added after the letter Z.We

can represent each letter by drawing a picture of the room it is in and by indicating with a dot whether the letter is at the top, middle or bottom of its room.



Triple Square Cipher

This cipher uses a combination of triangle and dots. Although the key is drawn large so all the letters can fit, when you send a secret message you can draw all the triangles the same size.

The orientation of the triangle and the placement of the dot inside will tell your friend what letter is needed to decipher your secret message.





Quarter Circle Cipher

The quarter circle cipher uses little pie shapes and dots as a substitution for letters. A quarter circle and a dot in one of seven possible positions, three around the outside and four inside, represent each letter of the alphabet.


Thursday, December 27, 2007


MOTHER

1. When you were 1 year old, she fed you and bathed you.
You thanked her by crying all the night.

2. When you were 2 years old, she taught you to walk.
You thanked her by running away when she called.

3. When you were 3 years old, she made all your meals
with love. You thanked her by tossing your plate on
the floor.

4. When you were 4 years old, she gave you some
crayons. You thanked her by coloring the dinning room
table.

5. When you were 5 years old, she dressed you for the
holidays. You thanked her by looping into the nearest
pile of mud.

6. When you were 6 years old, she walked you into
school. You thanked her by screaming, "I'M NOT GOING".


7. When you were 7 years old, she bought you a
baseball. You thanked her by throwing it through the
next-door-neighbor window.

8. When you were 8 years old, she handed you an ice
cream. You thanked her by dripping it all over you
lap.

9. When you were 9 years old, she paid for piano
lessons. You thanked her by never even bothering to
practice it.

10. When you were 10 years old, she drove you all day,
from soccer to gymnastic to one birthday party after
another. You thanked her by jumping out of the car and
never looking back.


11. When you were 11 years old, she took you and your
friends to the movies. You thanked her by asking to
sit in the different row.

12. When you were 12 years old, she warned you not to
watch certain TV shows. You thanked her by waiting
until she left the house.

13. When you were 13, she suggested a haircut that was
becoming. You thanked her by telling her she had no
taste.

14. When you were 14, she paid for a month away at
summer camp. You thanked her by forgetting to write a
single letter.

15. When you were 15, she came home from work, looking
for a hug. You thanked her by having your bedroom door
locked.

16. When you were 16, she taught you how to drive her
car. You thanked her by taking it every chance you
could.

17. When you were 17, she was expecting an important
call. You thanked her by being on the phone all night.


18. When you were 18, she cried at your school
graduation. You thanked her by staying out partying
until dawn.


19. When you were 19, she paid for your college
tuition, drove you to campus, carried your bags. You
thanked her by saying good-bye outside the dorm so you
wouldn't be embarrassed in front of you friends.

20. When you were 20, she asked whether you were
seeing anyone. You thanked her by saying "It's none of
you business".

21. When you were 21, she suggested certain careers
for your future. You thanked her by saying "I don't
want to be like you".

22. When you were 22, she hugged you at your college
graduation. You thanked her by asking whether she
could pay for a trip to
Europe .

23. When you were 23, she gave you furniture for your
first apartment. You thanked her by telling your
friend it was ugly.

24. When you were 24, she met your fiancé and asked
about your plans for the future. You thanked her by
glaring and growling, "Muuhh-ther, please!"

25. When you were 25, she helped to pay for your
wedding, and she cried and told how deeply she loved
you. You thanked her by moving halfway across the
country.

26. When you were 30, she called with some advice on
the baby. You thanked by telling her, "Things are
different now."

27. When you were 40, she called to remind you of a
relative's birthday. You thanked her by saying you
were "really busy right now."

28. When you were 50, she fell ill and needed you to
take care of her. You thanked her by reading about the
burden parents become to their children.

29. and then, one day, she quietly died. And
everything you never did came crashing down like
thunder on your heart.

IF SHE' S STILL AROUND, NEVER FORGET TO LOVE HER MORE THAN EVER. AND IF SHE' S NOT, REMEMBER HER UNCONDITIONAL LOVE.


***Credit goes to MHO