Saturday, May 29, 2010

nohup - Keeping Background Processes Around

I know this is a very basic Unix command, but ironically I've gotten to use it very recently only.

You can prevent a background process from terminating, which is the default action, when you sign off or are disconnected. The nohup command prevents your process from getting the HUP (Hang UP) signal and enables it to continue processing.

The nohup command is simple to use--just add it before the command you actually want to run. Because nohup is designed to run when there is no terminal attached, it wants you to redirect output to a file. If you do not, nohup redirects it automatically to a file known as nohup.out.

Running a process in the background with nohup looks like the following:

$ nohup ls &
[1] 6695
$ Sending output to nohup.out

Because I do not redirect the output from nohup, it does it for me. If I redirect the output ( nohup ls > results &), I do not see the second message.

Forward Proxy Vs Reverse Proxy

A forward proxy is usually for Out-bound traffic. It's analogous to an ISP using a proxy to forward all HTTP traffic from its clients to external web servers on the Internet.

However, a reverse proxy is usually for In-bound traffic. It's analogous to having a proxy receiving all user requests and redirecting, internally, from one server to a set of servers(Server Farm) for processing, akin to load-balancing.

Just making the concepts clear

Friday, January 01, 2010

Avatar

Firstly, I wish everybody, a very Happy and Prosperous new year!

Today I took the 7 hour sojourn to (and back from) IMAX, Wadala, Mumbai, theatre to watch James Cameron’s “Avatar” in all of it’s 3D glory. I must say, I am not disappointed. The movie, to say the least, was spectacular and very entertaining.

Of course, you would have to turn off your brain, regarding, some elements. For eg, Where did those Nav’i (the indigenous humanoid population of the the film’s fictional planet, Pandora) folks learn to speak such good English, noting that that they have their own language ? Apparently, Grace(Scientist played by Sigourney waever) had setup a school to teach the Nav'i some english . The depths to which Cameron went to define, describe the alien world is astonishing. The magnificent animals, bioluminescent plants and the Nav’i people, themselves, are very well made.

Definitely a 4 star (say, out of 5) for this one. And mind you the IMAX experience is worth all the effort I’ve put in to watching this movie (Good 3 Hrs in travelling alone). But, here, the tickets are a tad expensive. Rs.500, Phew!!. But since I’ve never watched a proper movie in IMAX, i thought I’ll spend it anyway.

The movie is already making loads of money at the box office and i bet it would end up with a bunch of Oscars too (I expect, at least 2). So, go head and the enjoy the experience called ‘Avatar’ yourself (If possible in an IMAX theatre).

Adios’

Friday, November 13, 2009

Lazy Initialization Holder Class Idiom

Often when dealing with Singleton pattern, if the object in question is a costly one to make, developers try to use lazy creation. For example


class MySingleton {

private static MySingleton instance;

private MySingleton() { }

public static MySingleton getInstance() {
if(instance == null) {
instance = new MySingleton();
}
return instance;
}
}

The above implementation works fine for single-threaded systems, but for concurrent ones, if two callers invoke MySingleton.getInstance() at the same time, the system might end up with 2 different instances of MySingleton, which is undesirable.

Well, there are ways to deal with it. A popular way, is to use Double-Checking synchronization mechanism. However even that's not guaranteed to work flawlessly across all JVM implementations.

I've come across one another approach to this, i.e, to use Holder Class to perform lazy initialization. The above example may be refactored to follow this idiom as,


class MySingleton {

private MySingleton() { }

private static class MySingletonHolder {

private static final MySingleton instance = new MySingleton();
}

public static MySingleton getInstance() {
return MySingletonHolder.instance;
}
}

When the class MySingleton is loaded by the JVM, the class goes through initialization. Since the class does not have any static variables to initialize, the initialization completes trivially. The static class definition MySingletonHolder within it is not initialized until the JVM determines that MySingletonHolder must be executed.

The static class MySingletonHolder is only executed when the static method getInstance is invoked on the class MySingleton, and the first time this happens the JVM will load and initialize the MySingletonHolder class. The initialization of the MySingletonHolder class results in static variable instance being initialized by executing the (private) constructor for the outer class MySingleton. Since the class initialization phase is guaranteed by the JLS to be serial, i.e., non-concurrent, no further synchronization is required in the static getInstance method during loading and initialization. And since the initialization phase writes the static variable instance in a serial operation, all subsequent concurrent invocations of the getInstance will return the same correctly initialized instance without incurring any additional synchronization overhead.

Thursday, August 13, 2009

Definitely, Maybe

When you propose to someone and this is what you hear in reply, doesn't it confuse you ?(not to mention that it pisses you off). Anyway, this movie I've just completed watching, is titled as above. I liked it very much, though some people mightn't because of it's slower narration.

All the actors were convincing and did their part well. The girl, who plays the male lead's daughter was fantastic. Except, to hear words like penis, thrust, vagina from her sounded a bit gross, especially, considering her age. However it's a soft and refreshing movie. The one you would typically want to watch on a lazy Sunday afternoon (Though it's nearly mid-night now).

Romantic movies are evergreen, Way to go.

Monday, August 03, 2009

Movie Mania

Off late, I've been to loads of movies. Thought i'll offload my ratings on them here,

  • Terminator Salvation - 3 star
  • Ice Age - Dawn of Dinosaurs - 3.5 star
  • HP & Half blood prince - 3 star
  • The Hangover - 4 star
  • Magadheera - 2.5 stars

In the pipeline, Transformers - Revenge of the fallen, Love Aaj kal, Kaminey....

Monday, July 06, 2009

The Holiday

I've just finished watching "The Holiday" . It's romance all the way, spilled with bits of humor here and there.

Well, the main theme being how each of the characters end up finding true love, after being snubbed by the false ones. There are moments with butt-cracking comedy, as well as, heart-wrenching emotion. And i think all the actors, especially the main ones - Diaz & Winslet, did a wonderful job. I didn't have a single boring moment.

I'd definitely recommend this to anyone, well, anyone who enjoy romantic comedy's actually.

Wednesday, February 25, 2009

Underdog wins the Oscar

Stayed up until 1 am yesterday, to watch the re-telecast of the oscar awards prensentation ceremony. This is the first time ever i have seen oscar presentations. As has been widely predicted, 'Slumdog millionaire' has won 8 awards of the 10 nominations it received, including the one for best picture. What's more thrilling is that 3 of them were won by indians (AR Rahman 2 & Resul Pookutty 1).

Steve Martin/Tina Fey episode was very funny, so was the overall presentation by Hugh Jackman.

The most touching moments for me were the ones regarding 'Best Supporting Actor' and 'Best Lead Actress'. Heath Ledger won the former( posthumous ) and Kate Winslet the later. Heath has delivered a breath-taking performance as the 'Joker' in 'The Dark Knight'. I didn't quite like the movie when i saw it first, but when i saw it for the second & third times, it became evident that heath's exhilarating performance has overtaken all other characters in that movie. He was simply superb, the movie was worth watching for heath's performance alone and he deservedly won an Oscar. The moment when his family came onstage to accept the award on his behalf, it was heart touching. I really wished the real heath was here today to receive it himself.

Another touching moment involved 'Kate Winslet', she has previously got 5 nominations only to be snubbed at the last moment. She finally won the oscar for her scintillating performance in 'The Reader'. I haven't seen the movie myself, but heard it's a world war II based drama. will try to see it in near future.


Lots of exciting movies are lined up for 2009,
1) Angels & Demons
2) Terminator Salvation
3) Kungfu Panda 2
4) Harry Potter & The HBP ......

can't wait to catch them........

Thursday, October 09, 2008

Keep your fingers crossed!!

9th October, 2008......ban on short-selling lifted......12:52 AM (US 3:22PM).....Stock's 20.65% down....holding my breath

Friday, October 03, 2008

Secure Your Wireless Network

Recent bomb-blasts in New Delhi have sent tremors across the nation. The national capital hasn't yet recovered fully from the terrible blasts that occurred earlier in the month that these fresh blasts created chaos. Fortunately (though not much), there wasn't too much loss of life this time. Nevertheless the security of common man is becoming more of an illusion day-by-day.

One interesting aspect that has come out of this, is that, the terror emails that were sent just after/before the blasts goading the government to try stop the blasts have come from IP addresses that belong to innocent citizens like you and me. The mistake of these people is that they left their wireless networks unsecured. And this allowed those anti-social elements to hack in to these networks and send those emails. My wireless network too was unsecured until last week. But after hearing this news, I fully understood the hazards of leaving your wireless network unsecured.

Here am outlining the measures one need to take in order to secure one's wireless network,

1) Firstly change the default 'admin' password for your wireless router.

2) Assign a private 'SSID' for your router and disable SSID broadcast feature, which helps other wireless devices to detect your network

3) Then enable MAC filtering and explicitly list the MAC addresses of the computers that you intend to connect to your wireless network via your router, in it's allowed MAC addresses list

4) Enable wireless security like WEP or WPA and specify a secret key of sufficient complexity and reveal it only to people you really trust.

One more precaution could be to position your router in such a way that it's not near the edges of the house(balcony etc) thus reducing it's range outside the house.

Taking these measure would ensure that no stranger can hack in to your wireless network and do any malicious things.