Archive for June, 2008

Adding || subtracting dates in java

June 24, 2008

I see so many posts around so many forums where people want help on adding or subtracting days from a specific date. So I thought Id leave on the wild world of the net some help which might come handy to someone, someday. Here it is.. you can either follow the logic and add some jazz to it and become the hero of your project or do what most of us happily do, copy paste !

import java.util.Calendar;
import java.util.Date;
public class DateAdder {
public Date addOrSubstractDaysFromDate(Date aDate,int noOfDays) {
Calendar calendar = Calendar.getInstance(); //get teh calendar instance
calendar.setTime(aDate);//set it to today
calendar.add(Calendar.DATE, noOfDays);// this is where the adding || subtracting happens
return calendar.getTime();
}

public static void main(String[] args){
Date today = new Date();
DateAdder dateAdd = new DateAdder();
System.out.println(“Date today : “+today);
System.out.println(“Date after 10 days : “+ dateAdd.addOrSubstractDaysFromDate(today, 10));
System.out.println(“Date before 10 days : “+dateAdd.addOrSubstractDaysFromDate(today, -10));
}
}

enjoy madi

P.S: the formatting is as usual screwy, or may be I dont know how to do it. This is the best I can do to help. If you need further assistance leave a message and Ill see what I can do for ya !!

Advertisements

Ideal Futuristic City’s Architecture

June 10, 2008

This is my idea of what an ideal city would be, in a few years.
What you have to basically understand, is, what a city is made up of.
this is an abstract list of the things and behaviours a typical city would have.
1) Houses (residential places)
2) Offices (Workplaces)
3) Recreation (Parks, Gymnasiums, Zoo,Restaurents, pubs and Theaters)
4) Shopping malls
5) Health (hospitals and healing centers)
6) Religion ( religious places)
7) Outer city limits ( boundary of the city)
8 ) Education (educational institutes)

now picture this.

You are looking at clusters. 7 of them. The 8th one is really a virtual boundary of the city that I will be making.
When I say clusters, you can imagine huge(I mean really huge) circular(or may be square) buildings.
All of these clusters will be built so they are earthquake,lightning (and all other possible calamaties) proof and probably be painted with a paint which already comes with a fire repellant.We are talking about gigantic structures so it is implied they will have express lifts too.
Every structure will have its own emergency units trained for multiple emergencies and ofcourse exceptionally networked with each other.
Each of these clusters would be connected with a Multi Modal transport system which would run at altering speeds depending on its usage. For example the frequency of the trains would be more at rush hours and relatively lesser at other time periods. There would be one dedicated train available all the time at all the clusters for emergencies.
Without snatching the innocent joy of playing in the gardens and getting drenched in rain and going out for a walk with the elders in the house… all the clusters would be surrounded with beautiful parks with huge trees everywhere. All the parks would be outside and surrounding the clusters to have the natural feel. There will be one petrol pump too. I dont want to rob the joy that humans get when they drive their automobiles. I would always love to take my de-modified bullet out for a drive once a week. All the clusters will be connected alternately with roads and walk paths. The usage of roads for automobiles will be very limited, where you will be allowed to take your automobile out on the roads once a week. Exceptions will be made for the driving schools.

Now, you can imagine the life of people living in my city. Everything moving in order and at peace with every other thing in the city.
Everyday morning you wake up, you are in the residential cluster. You take a lift to the station and there you have a train waiting to transport you to work. Your children will follow the same suit.Your parents can take a train to the parks and have a walk around there. So many things are sorted. You can imagine till your mind drops. You dont see a person dying because he didnt get medical attention, because he was stuck in a traffic jam. No Consumption of petrol. The Cellular companies save by installing lesser but more technically advanced equipment. You live better.

Although just an idea, I think one day, all the cities of the world will be modelled this way. There is no other way out. You GOTTO have better infrastructure and you have a right to live life the best possible way, its after all, one life.

Petrol Prices Hiked

June 5, 2008

When is this going to end ?

Eventually, now, they say the increase in spending power is causing the rise in the inflation.
Petrol prices hiked by Rs. 5. Dont think this is too much of a hike for a busy house hold where the man and the woman of the house are both earning, well, doing code. Think about the other people. Round about 80% of a typical city’s population is non IT. This is going to have a tremendous impact on their existence. Its a chain affect. Now everythings price would increase. The fares of the public transport, the price of vegetables, Carbide rippened fruits..etc.Its progressive, you see.
Now, the governments of different states are reducing sales tax on petrol. Do you think the minister making this decision would be a fool to cause loses to the state ex-chequer ? Aww.. cmmon they ARE going to increase prices of other essential commodities like cigarettes and alcohol. A rise in cigarette prices is coming.
I end up paying so much of tax and am sure are so many other boys and girls. There really is no clue as to where the money is going.No improvement in power supply systems, no improvement in the transport and commutation systems.The life of a human continues to get cheaper by the day. Heck, one goes and a million are supplied, they say ! …and No one knows what the Right to Information means !
I heard from somewhere that all these oil companies post humongous profit margins in their annual reports. Why doesnt the government urge these companies to go on a cost cutting spree ? When is it going to end. Now, the boys are gonna make some hullabaloo about the price rise.. one week and everything is going to get back to normal.
I think all of this will have to eventually end when the people of India awaken from their slumber of electing wrong people to lead them, who time and again have made wrong decisions. This is a wake up call for more and more younger and dynamic people to get into the politics of India and improve things. Else, we are looking at a very bleak future.
I think this is the most catalystic time for people investing their time in coming out with alternate sources of energy that petrol can produce. You can have peace, for it is proven, time and again, anything that starts getting extinct will be replaced by a newer and a better thing (read Science of Growing Rich ?).

^ M Command Not found, shell script execution

June 2, 2008

^M Command Not found, shell script execution

if you get an error, in unix duh-uh, which says “^M Command not found”, that means, you just got a freaking extra useless “space” somewhere in your script (while running the script generally the exception comes immediately after execution/interpretation of the line, where you left the space in the file).
you can also run unix2dos which will help you in this.

Disclaimer

June 2, 2008

This is applicable to all that I write here. It is my personal opinion.
You may not hold anything written here as evidence in any court of law.
I may be come across as an opinionated guy. But thats just me. If you incur loses or damages due to this, I am not responsible. Infact, I am not responsible for anything that might arise out of you reading my posts.
These are my thoughts and opinions. Opinions, are like assholes, everyone has one.

Baby in a pram – rant

June 2, 2008

I really feel for the young babies being wheeled around in prams.
Picture this, a deserted evening. The sun just about setting so its making the blue skies dipped in orange color and somewhere an aged gardener sprinkling water on plants and trees along the road, giving rise to that irresistable smell that comes when earth is watered. I am sitting on a bench watching them. A young couple walking on a road where vehicles ply, albeit, rarely, with their baby in a pram who is so small that its hands fully spread wouldnt even cover 1/8th of your palm. True torque style, a motorcycle zaps by the pram throwing its exhaust fumes …and the baby doesnt even have enough air in its lungs to cough ! Blinking eyes rapidly, It just keeps moving its hands across her face, as if trying to clear away the smoke.

Now this is a rant against young couples who have just become parents and think moving their babes around their apartments and localities in a pram, is very “in”. If you have pictured the above scenario properly, you can imagine anything happening to that young child. An autorickshaw passing by and a careless smoker throws a cigarette ? A dog near by comes all of a sudden and puts his head in the pram ? Just a few of the hazards you can think of. There can be so many more imaginations. I can only imagine how hard this can be for the baby. Poor child.

Ever thought how a baby will stop crying just when it is given back to its mother. They say a baby stops crying as soon as it is given back to its mother is because it can synchronise with the harmony of its mothers heart beats. Its been listening to it for 9 months ! It has a profound effect on babys, what they hear when they are still in the womb.In a recent experiment pregnant ladies were repeatedly made to listen a specific rhyme. After the baby was born and a couple of months old, when the same rhyme was played, the baby responded to the same music. You gotta keep that child closer to your heart man. I can only see the future of our country going down the drain with broken families and depressed youngsters.

Its a gift to be a parent. Scriptural studies suggest that if you are to receive the highest blessings from the cosmos, it will be channeled through your parents. Thats the law. A wo/man who unfortunately get cursed by parents have no salvation, they say. You have to feel and realise this power in you…And THIS is the treatment you give to your child. I am sure hes gonna grow up and kick your butt when your old. Or atleast kick the wheel chair you might be in.
Can you imagine the plight of a couple who cant concieve? I have seen them so closely, you cannot imagine the mental agaony you go through ALL the time.

If you think you cant carry the weight of a baby, you dont deserve being a mother.Thankfully, its not too prevelant that a mother doesnt hire a financially unfortunate mother to provide mothers-milk to the baby. Again, if you think about it, this will be the future.

I still remember the days when my mother used to hold me in her arms and go about doing her daily chores.In the nights my dad used to sing lullabies, lying me on his chest. wow..those were the days. I still cherish those memories. Alas the new generation kids wont even have memories to remember !

Take clue from the women who work in the field. They tie their child to their backs and do their job. They will not even put the child under the shade of a tree and go about doing their job. Get a baby holder. Keep your child closer to your heart, cos thats where they belong, atleast momentarily.