Archive for October, 2008

Congenital Defects

Tuesday, October 28th, 2008

We live in a violent society. History books speak of wars and battles, but there is violence right here amongst us today, and it is sad to see that the billions of people who are against it in principle can do nothing to stop it.

People killing other people…mobs burning buses…terrorists detonating bombs in crowded places. Is it something that we were born with, a drive to destroy? Perhaps all this can be simpli­fied to a single question — when a man sees a work of art or engineering, what goes through his head: an urge to destroy it, or curiosity as to how it can be improved? Maybe there is a middle path of complete indif­fer­ence, where one follows the crowd in their merry acts of vandalism.

I, for one, fail to under­stand how so many of our species can engage in such acts without remorse. One might say that the fear of conse­quences is what keeps such acts in check, but to me, that is super­fluous, a moat beyond the walls. Is there no passion for progress? The world is a giant machine after all; isn’t every step towards making it run smoother an achieve­ment and a reward in itself?

Isn’t there a switch in the brain or the genes where the madness can be turned off?

Back To Normal

Sunday, October 26th, 2008

At the risk of having spoken too soon, I would like to say that my Internet connec­tion now seems to be back to normal. As the ancient Chinese adage goes, “a stable Internet connec­tion after two weeks is like fresh air to a drowning man.”

Outages

Thursday, October 23rd, 2008

Internet connec­tivity to my server seems to be inter­mit­tent and somewhat erratic. When will Comcast fix my connec­tion? When will modems start behaving themselves? Who is John Galt?

Baby’s Day Out

Saturday, October 18th, 2008

XFCE Desktop

Saturday, October 18th, 2008

To cut a long story short, I’ve switched from KDE to XFCE, which is univer­sally acknowl­edged as a ‘light­weight’ and easily customiz­able desktop environ­ment. When I earlier switched to KDE 4.1, there were several bugs that were a constant source of irrita­tion. Add to that the fact that appli­ca­tions like Amarok (which were the reason why I loved KDE) did not have the same level of features as their 3.5 version avatars, and I realized there was nothing that I really needed from KDE 4.1 anymore. I could have switched back to 3.5 of course, but I gener­ally don’t like to rollback to an earlier version after having tasted the newer one. That’s how I ended up with XFCE.

XFCE has a nice clean look, and it is much faster too. Person­ally, I would happily sacri­fice desktop effects for perfor­mace, so this switch worked out pretty well for me. Of course, there was ‘The Terminal UTF-8 Problem’ which I will describe in detail in another post.…

KDE 4.1: Now In Portage

Saturday, October 11th, 2008

The wait is finally over. KDE 4.1 is now in the official portage repos­i­tory, which means that Gentoo users can upgrade to it without having to unmask any packages or setting up an overlay.

I upgraded to the new and shiny KDE 4.1 today for the first time. I could have easily gotten it from an overlay a long time ago, but then I figured it was best to wait for it to mature. Like its prede­cessor (KDE 3.5), this version of KDE looks quite unpol­ished until you spend some time customizing it. For instance, I cannot fathom the reasons behind not enabling font anti-aliasing by default. Without this tweak, all fonts look jagged and ugly. KDE also seems to have taken the path of Microsoft’s Windows Vista in terms of its color scheme: gray and black seem to be the norm.

Overall, I am not too disap­pointed with the upgrade, but I realize now that I’m going to have to wait for future releases for many pieces of function­ality that I used to love in KDE. This is one of the downsides of having software redesigned from scratch. For instance, Amarok 2 (still in beta) included in this version of KDE, is missing several key features, such as track-queuing and equal­izer support. I just wish the KDE devel­opers had focused on having a 4.1 release that was on par with 3.5.10 in terms of features, rather than worry about the details.

Time To Buy Stock

Thursday, October 9th, 2008

The stock markets plunged even further today. See the blue line in the chart down there?

Pretty Picture

I think now would be a good time to buy stock. After all, you have all these people selling like crazy, and as long as there are goods of value being produced and consumed, the market will bounce back up eventually.

The problem with the finan­cial system today is that everyone has these little bits of paper and no one is quite sure how much each piece is worth. If the paper is stock, we end up with a volatile market. If it is currency, we end up with infla­tion. Either way, we might be better off with some kind of barter system in which what you see is exactly what you get. Of course, when it comes to the stock market, we have people trying to guess how much the stock will be worth, which makes life even more difficult.

The big question that needs to be answered is: how much is this economy really worth? I wish someone would come up with nice round figure and announce it to the world. If people believe it, then the market won’t slide too much below that point. All we need to do is keep up the pretense that every­thing is hunky-dory. This game is based on hope and wishful thinking.

Lesson in English

Wednesday, October 8th, 2008

frus·tra·tion
noun. Staring hungrily at a bowl of spaghetti but being unable to eat it, because it keeps sliding off the spoon, and there is no fork to spare.

Minimizing Downtime

Wednesday, October 8th, 2008

Now that this site is hosted on my own server, I wanted ensure that the server is up and running most of the time. Although five 9’s is not my avail­ability target, I needed some mecha­nism by which changes and updates that I made to the site were not reflected in the produc­tion website (can I call it that?) until the right time.

The solution is a simple one: run a devel­op­ment website in parallel, so that all changes can be tested on that first. Updating the primary website would be like flipping a switch. Here’s how I managed this:

  1. Set up a new virtual host for the devel­op­ment site.
  2. Set up a new database for the devel­op­ment site and populate it with existing records.
  3. Update the WordPress config­u­ra­tion file to select a different database based on the current working directory.
  4. Set up server authen­ti­ca­tion for the devel­op­ment website.
  5. Write an init script to copy (rsync) all the files from the devel­op­ment site to the primary one. Exclude the authen­ti­ca­tion files like htpasswd, of course.
  6. Set up a depen­dency on the new script in Apache, so that restarting the service also restarts Apache (this is useful at times).

It’s as simple as that!

Regular Expressions

Tuesday, October 7th, 2008

Regular expres­sions (regexes) are one of those concepts that sound innocuous, turn out to be fright­en­ingly complex when you approach them, but aren’t that big a deal when you actually get to know them.

The idea behind a regex is quite simple: it is a single concise series of symbols that can be used to repre­sent a class of expres­sions exactly. For example, a regex could be used to repre­sent “a sequence of charac­ters that begins with the letter C” or “a sequence begin­ning with b, ending with d and any number of x’s in between.” Regexes are extremely expres­sive, and can come in handy at odd times.

Regular expres­sions are built on simple rules. The following is not a compre­hen­sive list, but should provide an idea of what regular expres­sions look like -

  1. Alpha­bets and numbers repre­sent themselves. So do a large number of punctu­a­tion charac­ters. These are case-sensitive.
  2. A dot “.” repre­sents a single instance of any character.
  3. An asterisk “*” indicates that the preceding character may be repeated zero or more times.
  4. An plus “+” indicates that the preceding character may be repeated one or more times.
  5. A carot “^” is an anchor for the start of the line.
  6. A dollar “$” is an anchor for the end of the line.
  7. The “<” and “>” symbols are anchors for start and end of a word respectively.
  8. Et cetera.

For example, ^Cof*e+$ would match Coffee, Coeeeeee or Coffffffe but not Coffff, coffee or Cofeen. Regexes can be much more compli­cated in practice, but the basics are suffi­cient for many common cases.

The most impor­tant advan­tage of under­standing regexes is that it opens up the doors to a huge collec­tion of Unix tools, such as grep, sed and awk. Most Unix text editors also support regexes to some degree.

While grep is the most well-known amongst these tools — it is used to find lines that match a given expres­sion — sed aka ‘the stream editor’ is perhaps the most useful, because it can actually manip­u­late text. For instance, when I migrated more than a hundred old posts into this blog a couple of weeks ago, I needed to replace a whole bunch of <div> tags with <p> tags. That’s when sed came in useful: it took just ten minutes and a single command to get the job done.