Tuesday, September 22, 2015

Venice the sinking city

Wednesday, September 16, 2015

My first day to work at XYZ


It was my first day to work. This is going to be my second job since I have given away my first one with all the good things heard about the new company.

According to the contract given, my work should start by 8 am, so I decided to be before time. Our HR already taken my vehicle number and assign me a parking slot. She already mailed me the details so there is no hassle for me to find a park on first day in unknown territory.

I came to office by 7.50. Amazingly our HR and System Administrator waiting for me at front door. HR gave me my company ID first place since she has taken my photograph earlier. She show me my seat and there is a nice welcome pack waiting at my desk for me including company hand book, company pen, note book, cap and a T shirt. How she came to know my T size?

Then it came the sys admin to me with a booklet with all the details that I should know. It got my machine username/password and cooperate username/password and steps to change them if I want. They got single sign-in for all the systems with intranet to manage all the domain links. What a relief for me as I had to remember more than five username/passwords in my previous place.

I logged in to my machine and open the new email. Amazing..., our HR has already send me a welcome mail with all my details and some of my new colleagues already greeted me through mail. I was amazed to see that even my new PM has send me a greeting mail with description of my new assignment. He has stated the steps to download even code and all the access were already available. How much they have believe on me....

Few minutes later my buddy came to me. Wow, I got a buddy too and I heard that he is going to give me a company sponsored lunch at the end of my probation period. He introduce all the people to me, show me the lunch area and wash rooms too. He teach me all the rules and regulations of the company including procedures of laving last to order a cab to use of company booked swimming pool.

Ohh, they have prepare a surprise treat for me too at 10 am. What a warm welcome and what a first day...

Vidula Hasaranga
http://vidula-sinhala.blogspot.com
http://vidulahasaranga.blogspot.com

Monday, September 07, 2015

Resolving ORA-01882: timezone region not found



Recently I have changed my oracle jar version in Tomcat lib to ojdbc6-11.2.0.4.jar and started to see following error while starting tomcat.

java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region  not found

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:389)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:382)
at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:675)
at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:448)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:383)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:776)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:432)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:254)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528)

I have got same issue sometime back with my sqldeveloper, and fixed by adding some java options to its property file, so this time I tried the same in catalina.sh:

export JAVA_OPTS="$JAVA_OPTS -Duser.timezone=+05:30 "

Restart tomcat and the error log is no more.

Monday, June 11, 2012

How to reverse a String using Stack / Queue

Reversing a string / word / name is very common interview question to see how the candidate studied his data structures. This involves the knowledge of Stacks and Queues.

How to reverse using a Stack.


This is straight forward if you know how a stack is working. Stack is working as a First In Last Out (FILO) data structure. So what you have to do is put letters from beginning to end in to the stack and pop one by one and write in popping order. Lets see an example for word HELP.

Pushing to the stack:

HELP

+---+---+---+---+---+
|   |   |   |   |   |
+---+---+---+---+---+

ELP

+---+---+---+---+---+
| H |   |   |   |   |
+---+---+---+---+---+

LP

+---+---+---+---+---+
| E | H |   |   |   |
+---+---+---+---+---+

P

+---+---+---+---+---+
| L | E | H |   |   |
+---+---+---+---+---+


+---+---+---+---+---+
| P | L | E | H |   |
+---+---+---+---+---+

Popping from stack:

P

+---+---+---+---+---+
| L | E | H |   |   |
+---+---+---+---+---+

PL

+---+---+---+---+---+
| E | H |   |   |   |
+---+---+---+---+---+

PLE

+---+---+---+---+---+
| H |   |   |   |   |
+---+---+---+---+---+

PLEH

+---+---+---+---+---+
|   |   |   |   |   |
+---+---+---+---+---+

Here we go: HELP --> PLEH

How to reverse using a Queue.
This is not that straight forward as we did using a Stack. But if you know how to do it using a stack, and how to implement a stack using queues you are done with this.

Implementation of a stack can be done using 2 queues. Lets see the above example using 2 queues.


HELP

+---+---+---+---+---+
|   |   |   |   |   |
+---+---+---+---+---+

+---+---+---+---+---+   +---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+   +---+---+---+---+---+

ELP

+---+---+---+---+---+
| H |   |   |   |   |
+---+---+---+---+---+
Put H to first queue.
+---+---+---+---+---+   +---+---+---+---+---+
| H |   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+   +---+---+---+---+---+

LP

+---+---+---+---+---+
| E | H |   |   |   |
+---+---+---+---+---+
Dequeue values from first queue and put them to second queue. Put E to the same.
+---+---+---+---+---+   +---+---+---+---+---+
|   |   |   |   |   |   | E | H |   |   |   |
+---+---+---+---+---+   +---+---+---+---+---+

P

+---+---+---+---+---+
| L | E | H |   |   |
+---+---+---+---+---+

Dequeue values from second queue and put them to first. Put L to the same.
+---+---+---+---+---+   +---+---+---+---+---+
| L | E | H |   |   |   |   |   |   |   |   |
+---+---+---+---+---+   +---+---+---+---+---+


+---+---+---+---+---+
| P | L | E | H |   |
+---+---+---+---+---+

+---+---+---+---+---+   +---+---+---+---+---+
|   |   |   |   |   |   | P | L | E | H |   |
+---+---+---+---+---+   +---+---+---+---+---+
Same way you can dequeue by swapping the queues to implement pop method of the stack.


Vidula Hasaranga
http://vidula-sinhala.blogspot.com
http://vidulahasaranga.blogspot.com