Archive for October, 2008
Phoonk
Monday, October 6th, 2008Horror movies seldom frighten me and I did not watch Phoonk hoping that it would. I was hoping, though, that it wouldn’t move me to fits of laughter (which it unfortunately did).
There’s no doubt that Ram Gopal Varma’s genre of horror is way better than the traditional Ramsay Brothers’ formula. Even so, low expectations is no excuse for making a mediocre film. Phoonk is a mixture of ideas taken from The Omen, The Exorcist and others, with an occasional attempt at cuteness. The underlying theme is the usual one: a man who doesn’t believe in the supernatural and his gradual transformation into a believer. Perhaps this movie was aimed at an audience unfamiliar with those classic themes, but a little originality would have been more than welcome.
I am also disappointed with the background score of the film. This is one of the most important elements of any movie, and is especially important for one that claims to scare its audience. Consider any well-received movie and you will find a fantastic score played at the right time and place, subtle yet effective. In the case of Phoonk and such other films, there’s nothing but a supposedly scary piece of music played loudly at random intervals, making it quite hard to listen to the dialogue.
Cinema is a composition of light and sound that requires careful timing, a plot built up at the right pace and a series of climaxes that enthralls the audience in one way or the other. Phoonk tries to be a ‘scary movie’ from the beginning to the end, and not surprisingly, it fails at this task.
Flashback
Sunday, October 5th, 2008Is there meaning attached to a picture taken years ago? Is it alchemy that transforms the ordinary into sweet paradise, years after we move on? Is it mere human weakness that we crave the moments that we can no longer have? This must be one of life’s great mysteries.…
Scripting Magic
Sunday, October 5th, 2008It’s amazing how much can be achieved with the help of a few scripts. If you come to think of it, scripts are the original mashups that Web 2.0 has venerated in recent times.
Today, I decided that I would have a “Now Listening” box shown on my blog — I’m not sure if it is visible at this moment — which would display the name of the artist of the currently playing track on my computer. So here’s what I came up with -
- A Bash script that would use DCOP to query Amarok, determine the currently playing song, and update a temporary file accordingly.
- A small PHP script that would read the file and display this information, but only if it is available.
- A set of CSS rules to format the generated XHTML.
- A cron job to execute the script every minute.
Voila! It’s done…almost like magic.
A Fun Way To Spend A Saturday
Saturday, October 4th, 2008Don’t try this at home, kids.
- Open a console window on your trusty old Linux box.
- Find a WordPress plugin you don’t need.
- Start typing
rm -fr /path/to/wordpress/plugin-name. - Instead, type
rm -fr /path/to/wordpressand press enter. - Oops.
- Spend a few hours setting up your blog all over again.
- Sleep.
Step #5 is the part I love the most.
Roller Skating Crash Course
Saturday, October 4th, 2008Disclaimer: I skated for the first time in my life this week, for not more than an hour. Everything I say in this post is based on personal experience, so use your own judgment before doing something silly and injuring yourself. The responsibility is all yours.
The ‘quad’ roller skates are simply shoes with four wheels underneath. You wear the shoes and, instead of walking, you skate (or fall).
They say practice makes perfect, which is certainly true to some extent. However, like any other sport, there is a technique to doing it right that is far more important. Here’s a breakdown of what I discovered this week:
Bend your knees
This is true for almost any sport. Bending your knees automatically forces you into a crouching position, moving your weight ahead of your feet. This ensures that you don’t fall backward, which is painful and dangerous. The instinctive reaction to falling forward is to put one foot ahead and stop the fall, which is exactly what you need to do to start skating.
Gather momentum
The simplest and probably the only way to gather momentum is to put one foot ahead and put your weight on that single foot. You have your knees bent, right? The trick here is to apply pressure on the foot not directly straight ahead but towards the side. That is, you push your right foot forward and towards the right, and then your left foot forward and towards the left alternately. This provides some control over your motion.
Don’t straighten up
…unless you know what you are doing. If you are moving slowly, it is alright to straighten up temporarily, but you need to bend your knees again before stepping again.
Don’t put you weight on both feet
Consider your normal walk: your front foot presses against the ground, while your back foot provides support. It’s the same principle at work here. Naturally, you can’t put pressure on both feet, otherwise your feet will drift wider and wider apart until you do the splits.
A possible misunderstanding by the novice is to imagine that the wheels would magically carry him ahead. In reality, the best analogy to roller skating is walking, except that the ground is rolling away behind you. Ergo, you need to lift up one foot at a time and place it ahead.
P.S. — How often do you get to use the word “ergo” in your posts?
Idempotence In System Architecture
Friday, October 3rd, 2008A useful paradigm that should be considered when a stateful software system is to be designed is idempotence. Leaving aside its exact definition in mathematics and computer science, idempotence can be roughly described as a system characteristic whereby, calling an operation multiple times is equivalent to doing it exactly once.
For instance, setting the value of a variable X is an idempotent operation, because setting its value to be Y several times has the same effect as setting it just once. On the other hand, incrementing its value is not an idempotent method because the result depends on the number of times the operation is called.
Implementation
Before delving into why you might want to have idempotence, let’s have a look at how it can be implemented. One way of doing it is like this:
Design a state machine
A state machine identifies every unique state that the system can exist in, with a clear indication of which states the system can transition to from any given state, and under what conditions.
Design a minimal API
An application programming interface is the gateway for external systems to interact with the service. We start by designing a minimal API, identifying all the methods that could change the state of the system. It is best not to clutter the API with non-critical methods at this stage.
Expressed differently, an API method represents a single transition in the state diagram. For example, a system could have states such as ReadyToPurchase and TaxAdded. The addTax() method, if successful, provides the transition from the first state to the second. This method can never be applied a second time, because by then the system has already moved on to the next state.
An important restriction on the API is that if the state has some attributes, they must be maintained meticulously and checked against incoming requests. Suppose the addTax() method takes a parameter called amount. If the method is called again with the same amount, then the expected response is success, since the system is indeed in a state that the function call was supposed to move it to. However, if amount is different, then the response should be a failure, or at least some kind of partial failure — otherwise, the client will assume that the new tax amount had been added. A state should never change its internal attributes once they have been set.
Transitions should be atomic
It goes without saying that transitions need to be atomic, so that multiple requests do not corrupt the state while the system is transitioning. This can be achieved easily by acquiring a lock on a mutex at the start of a transition, and releasing it on completion.
Why Idempotence?
Naturally, it is a good idea to ask why we are putting in so much effort. While this may seem inordinately complex at first, you will soon discover that such a design actually simplifies the system tremendously when there is a great deal of concurrency. When there are a large number of processes or threads communicating with each other and the number of messages exchanged is huge, idempotence provides a guarantee of sorts about what the system can or cannot do. The state machine approach allows you to simply worry about the system in its current state, rather than the system as a whole. As a debugging technique, the developer simply needs to say, “This was the previous state A, and now it has moved into this new state B — what combination of parameters caused such a transition?” Idempotence makes this approach even more robust, ensuring that the system works in the face of message duplication and errors.
This robustness also allows the design to sacrifice a reliable communication layer in exchange for speed. For example, TCP (which has a larger overhead) can be replaced with UDP, since the application is resilient to message loss and duplication.
Zeitgeist
Wednesday, October 1st, 2008Call it curiosity if you will. That little dropdown list that pops up every time I start typing into Google’s search box makes me wonder what people are searching for, and more importantly, why. Here’s a list of terms beginning with how to that a lot of people are interested in:
- how to tie a tie
- how to kiss
- how to lose weight
- how to draw
- how to make money
- how to write a resume
- how to play guitar
- how to make a website
- how to get pregnant
- how to play poker
Interestingly, how to make a website has the largest number of results, whereas how to write a resume has the least, amongst these search phrases. I am not sure if these are ordered by popularity, but if they are, then I guess these days the average Internet surfer is more interested in knotting a tie than learning to kiss — especially when you consider last year’s statistics.
And while you’re there, does it seem strange to you that who is god is the most popular query of that type? Are we getting more pious these days? Don’t worry, who is satan is not too far behind — it holds the tenth spot.
A Quick GIMP Beveled Logo Guide
Wednesday, October 1st, 2008
This is the no-nonsense guide to creating your very own awesome beveled logo using GIMP, something that looks like the image shown here. There are detailed guides floating around in the series of tubes known as the Internet, but this is for those who are put off by tedious explanations and figures. Naturally, you need to be know the basics of GIMP if you want to understand this guide.
So here goes:
- Create a new image slightly larger than the desired image size with a transparent background.
- Make a rectangular selection the size of the actual logo, convert it to a round-edged rectangle and fill the selection with the highlight color (for example, the red on the edge of the logo).
- Duplicate the layer twice.
- Fill the lowermost layer with black, and blur it in order to create a shadow effect. It needs to spill out from behind the main logo slightly. Scale up the layer a few pixels if requried.
- Scale down the top most layer by around 10 – 15 pixels, and apply a slightly darker shade gradient to it. (for example, a darker shade of red). The gradient should be subtle and slightly asymmetrical. Blur this layer just a little, so that it merges with the middle layer which is just below it.
- Create a new text or image layer to add your logo to the image foreground.
- Save your file.
That’s it — you’re done!







