package com.ravis;

public class Stack {
int pointer = -1;
int stackMaxLength = 10;
int container[] = new int[stackMaxLength];

public Stack(){

for (int i = 0; i < container.length; i++) {
try {
} catch (Exception e) {

for (int i = 0; i < container.length; i++) {
try {
} catch (Exception e) {

} public static void main(String[] args) {
new Stack();
void push(final int newValue) throws Exception{
if(pointer == stackMaxLength){
System.out.println(“Stack is full”); return;
container[++pointer] = newValue;
int pop() throws Exception{
if(pointer == -1){
System.out.println(“Stack is empty”);
new Exception();
System.out.println(“Pop the value –> “+container[pointer]);
return pointer;


Issue connecting to database

Issue connecting to database:

[root@ravikumar]# psql -U postgres -d EMSDB
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432”?


1. Try to stop the database

bash-4.2$ ./pg_ctl -D /data/ems/db/ -o -p5342 stop -m fast
pg_ctl: directory “/data/ems/db/” is not a database cluster directory

2. If it gives above error,
i) remove postgres pid or lock files under /tmp
ii) check pg_hba.conf file has correct values

3. Excute the command under postgres_home/bin ./pg_ctl -D /data/aniems/db/ -o -p5342 start

4. If the above step does not work, restart the system

Converting long value in string to timestamp

\d student
Column        |         Type                        | Modifiers
id                      | numeric(20,0)             |
name               | character varying(50) |
joiningtime    | character varying(30) |

select id,name,joiningtime,to_timestamp(CAST(coalesce(joiningtime, ‘0’) AS numeric)/1000) from student

id        | name      |  joiningtime     |         to_timestamp
168364 | Ravi        | 1484833632817 | 2017-01-19 19:17:12.817+05:30
168351  | Kumar   | 1484833632296 | 2017-01-19 19:17:12.296+05:30


Auto vacuum and analyse larger tables

Postgresql database operations becomes slower if table gets larger. In order to improve the performance, we can configure to auto-vacuum the table for every x inserts/updates/deletes.

Using below settings, a table would be auto vacuumed and analysed every 5,000 inserts, updates, or deletes.

ALTER TABLE mytable SET (autovacuum_vacuum_scale_factor = 0.0);

ALTER TABLE mytable SET (autovacuum_analyze_scale_factor = 0.0);

ALTER TABLE mytable SET (autovacuum_vacuum_threshold = 10000);



Elon Musk

I came to know about Elon Mush from my manager some time back and starting reading about him . Elon Mush is known for his new inventions, Tesla, contribution towards renewable energy, sustainable energy, solarcity, Zip2, OpenAI, etc…. the list is going on and on….

He is an inspiration to everyone.

Happy and Healthy Marriage Life

Marriage is an Social, Cultural, Emotional, Economical, Physical, Psychological bonding (SCEEPP) between an men and women. It is highly impossible to get a spouse who matches 100%. But it is important that everyone should know the limitation of
the spouse. Otherwise either one or both need to suffer. In most of the cases, the dominant person would suppress the feelings of his/her spouse which lead the spouse to suffer. Married couple can lead an happy life as long as there is no damage done in SCEEPP. We often see couples look very happy for few years and they started complaining about each other. In any relationships, we would look the positive on other person and life would go happily. Based on one’s skill and capability, it will take days to year to evaluate other person. As soon as we see any negativity on other person, the bubble will burst one by one.


How to maintain healthy relationships?

1. Trust

Trusting spouse would give happiness which also make his/her spouse more responsible

2. Tolerance

Zero tolerance may be successful in work life, but definitely not in family life. It needs certain level tolerance to understand spouse’s situation (like work life tension, financial issue). Based on the spouse’s situation one can act or help.

3. Provide personal space

Marriage does not mean that men and women needs to forget the personal goals and dreams. Everyone has personal space and it is important to spend time to grow personally and professionally. But it is important to make the spouse to understand the personal and professional goals and justify it in advance.

4. Good communication and Help each other

In a ever changing world, we may miss the commitment like accompanying spouse to dinner or present jewels for birthday, etc.. Due to some unavoidable circumstances
one may not able to achieve the promises. It is important to communicate and help each other especially in difficult times as soon as possible to avoid the conflict and mistrust.

5. Mutual respect

Married Couples needs to respect each other especially in-front of children and others. One would ready to face the consequences immediately or later if he/she disrespect spouse
in-front of others. So try to give respect each other.

6. Say Sorry

Nothing wrong to say sorry to his/her spouse for an mistake. Mistake will be forgotten immediately as a relief and good suggestion/advice may be given as a bonus from spouse.

7. No ego

Ego is a slow poison. It won’t takes us anywhere. Leaving ego make life happy

There is a famous quote “Men from mars and women from venus”. So even though men and women are human, it is not necessary that they would think and act similarly. Every married couples lead life happily if we understand the above quote.

Love and Live happily 🙂