September 11, 2008

Thanks, but I don’t want to try out Google Chrome (yet)

Filed under: Blog — krkhan @ 4:36 am

Alright, Google finally releases the Chrome browser, along with a certain comic detailing features of their product. I check out the comic and the feature-list, I decide that there isn’t any compelling reason for me to switch to Windows and run the beta. I also decide never to blog about it unless I deem it important enough for a try out. So far, so good.

But hey, I have violated the unimpeachable moral obligation of going along with the current buzzword by declining to be a part of the Chromosphere. In the past week, at least seven different people have tried to persuade me to believe Chrome is going to take over the world. In fact, that is the inherent problem with Google and Apple fanboys. They equate anything remotely new from their favorite corporation with the second coming of Christ, and then try to convince other people over it. I do happen to be a fan of both as well, but I still don’t see why products like 3G iPhone or Google Chrome deserve the applauds lauded by these people. Here’s a list of arguments Chrome fans presented to me:

  • Chrome is Google’s attempt to blur the line between desktop and web, and it is the future Operating System
    Bullocks. The line between desktop and web shall never be blurred. Are you trying to tell me that you’ll be installing your printer or screen drivers to web one day? Will a browser ever be capable of doing even half of the stuff that operating systems do, e.g., implement the POSIX specification or host other processes?
    No? I didn’t think so either. Yes? You do not have any idea what an operating system is.
  • Chrome isn’t a memory hog like Firefox
    Firefox’s memory-usage has steadily improved over the released and I have yet to encounter someone who had any serious memory troubles with the former that were solved by the latter.
  • Chrome’s Javascript runs faster
    The only worthwhile feature of Chrome is its Javascript engine. Nevertheless, milliseconds of speed improvement won’t even be noticeable by me. The AJAXed Facebook or Gmail run on my Firefox extremely well and I don’t think my productivity with either would increase by switching to Chrome.
  • Chrome’s rendering engine (WebKit) is new whereas Firefox’s rendering engine (Gecko) is outdated
    Wrong. Totally wrong. Gecko might be bloated, but Mozilla does a more than reasonable job of making it perform well. Gecko is huge — WebKit comparatively isn’t — but it is still frequently updated and properly maintained. The huge codebase is an issue for the developers rather than the users and as long as developers are delivering stable final products using that codebase, it’s certainly not an issue for me. WebKit is great for new applications like Chrome, but Mozilla has already settled with Gecko so it isn’t a bother for them.
  • Chrome uses separate processes for each tab
    And this was the only “visible” feature Google was able to highlight in their comics. This is nifty behavior, but with frequency of my browser crashes reduced to almost once a month, this isn’t enough to convert me over.

On the other hand, consider the mammoth developer base Mozilla already has for its Firefox extensions. Google isn’t going to replicate that as well as bundle Chrome with killer feature(s) anytime soon, if ever. What Google perhaps aimed to do was to get other browsers to adopt Javascript enhancements that they’re going to introduce with Chrome. More than that, I don’t think Chrome shall ever compete in user share against Safari, let alone against the big guns.

Tags: , , , , , , , , ,

September 7, 2008

Flash-back

Filed under: Blog — krkhan @ 1:04 am

Once upon a time (or, “in before times, long long ago” according to South Park speak), I used to be a Flash developer. I even developed a half-useful extension called “External Text MX” circa 2003, which got a little bit popular too. I loved Flash and even found ActionScript to be an intriguing language for a learning programmer.

And then, slowly and gradually, I realized that Flash isn’t worth 10% of the hype it usually gets. I’m in no way trying to debunk the wonderful art produced by Flash developers. It’s wonderful. My realization was a direct consequence of the troubles I had with Flash as a user rather than as a developer. Flash, for all the great things it embodies on a particular version on a particular platform, is still a proprietary technology steered by an enterprise giant. I started using different architectures and operating systems than simply 32-bit Windozes and most of the time I felt like the efforts needed to get Flash running aren’t worth all the animations and sounds. The mere idea of something as vendor-specific as Flash “driving” the “next-generation” of something as general as Web was enough to make me scowl.

Flash fans usually try to argue that it did become a driving force behind Web 2.0 afterall, and come up with YouTube as the example supporting their claim. Actually though, I had been using major Web 2.0 sites (YouTube, Facebook, Slashdot) for about 2 years now without any Flash support. YouTube videos can easily be viewed without Flash plugin and other websites are careful enough not to rely on Flash for their business. During this period, I treated Flash plugin with contempt simply because Adobe have been epically unsuccessful for providing a working version for 64-bit Linux. I was aware of a method which allowed usage of the 32-bit plugin to work with the 64-bit platforms, but it turned out to be highly unstable and resource intensive with my initial efforts. This method involved installing a “wrapper” plugin named NSpluginwrapper in Firefox. My verdict: “totally not worth it”; up until just a few weeks ago, when I retried the NSpluginwrapper with Firefox 3 and the official Adobe Flash Player 9.0 r124 plugin. The result? Finally the PITA vs. worth ratio has been reduced significantly enough to guarantee its continued existence on my laptop. YouTube works wonders and even the sound gets played through PulseAudio like a charm. Too many animations do tend to crash my X.org server every once a while but I’m willing to spare this much for now.

Not to mention, I still immediately close any website which starts with a Flash-y intro ;-) .

Tags: , , , , , , , , , , , ,

August 1, 2008

Ample reinforcements

Filed under: Blog — krkhan @ 7:46 am

“For the wise man looks into space and he knows there is no limited dimensions.” — Lao Tzu

Western Digital Passport Essential

I’ve always suspected that pornography has a history with mankind but I never guessed that the founder of Taoism had already been downloading enough to foresee virtually limitless data capacity needs. History repeated itself as I logged in yesterday just to notice that the free space on my hard disk was about 400 MB. Panic time, and the only efficient solution I could work out was to buy a Western Digital 320 GB portable hard drive.

Now, these days, buying any digital storage medium which has its capacity advertised in GBs is subject to the 7.2% deficit rule (I just conjured this name so I can’t be held responsible if it doesn’t occupy an entry in Wikipedia yet). The rule is simple: For every digital storage that you buy, you won’t ever see 7.2% of the GBs quoted on the product. Which means, if you buy a 250 GB hard drive, you’ll only be able to use 232 GB. For my 320 GB buy, I lose 320 x 7.2% = 23.04 and end up with 296.96 GB. Unless you’re prepared to tackle the difference between powers of 2 and 10, don’t even bother questioning the origins of this rule.

So, the passport drive came bundled with some software for synchronization and encryption. Did I bother? No. I reformatted it straight away as an Ext3 partition. After that, TrueCrypt and rsync were more than enough to cater for all my needs without any hassle. For the curious, here’s the command that I used to synchronize my home directory:

rsync -r -t -p -o -g -v --progress --delete --exclude=".*" /home/krkhan/ /media/Inspirated/Home/

This would exclude all hidden directories, and synchonize the /media/Inspirated/Home to mirror the exact state of /home/krkhan. The fun part, for those unfamiliar with rsync, is that if I synchronize, let’s say, fortnightly; only the data newer since last backup is copied.

I hope it would be least a couple of years before I get to quote Lao Tzu again.

Tags: , , , , , , , , , , ,

July 27, 2008

At least I wasn’t even close

Filed under: Blog — krkhan @ 4:35 pm

“I think I have a problem with that silver medal.
I think, if I was an Olympic athlete, I would rather come in last then win the silver.
If you think about it… if you win the gold, you feel good.
If you win in the bronze, you think: “Well, at least I got something.”
But if you win that silver, it’s like:
“Congratulations! You… almost won.”
“Of all the losers, you came in first of that group.”
“You’re the number one… loser.”
“No one lost… ahead of you.”" — Jerry Seinfeld

I had two chances for progressing in Code Jam by qualifying in one of the two sub-rounds assigned to me. Both sub-rounds had three problems A, B & C ordered in increasing difficulty level. Here’s a quick summary of both:

  • For the first sub-round (1A), I did solve problem A and got 15 points. However, I didn’t solve it quick enough. Problem B was left untouched by me. Problem C’s small input contained only 29 cases and could have very well been solved using only a scientific calculator. However, that just didn’t seem the right way of progressing (30 points would have been enough to qualify, but I’d definitely have failed at the subsequent rounds).
  • For the second sub-round (1C), apart from connectivity issues, I couldn’t provide correct output for any of the problems. I did solve problem B but as my solution was recursive, it was taking too much time for calculating the output. I’m not that good with refactoring recursive solutions for yielding iterative ones, so my chances got blown right away.

Overall, Code Jam was pretty fun and having fun was the sole aim of participating this year. Now I’ve got to start reading the Introduction to Algorithms book and get myself formally acquainted with algorithmic problem solving. Good luck to all the gurus who did progress (seeing some of them solve all 3 problems within half the time was amazing). They thoroughly deserve it and I’ll keep monitoring later rounds as a spectator — just reading through their ingenuous solutions is nothing short of a delightful experience.

Tags: , , , , , ,

July 18, 2008

Jam and Geometry

Filed under: Blog — krkhan @ 5:24 am

The scores for Google Code Jam qualification round are out. It lasted 24-hours, and the participants were allowed to enter any time and try to solve any of the three given problems. Each problem had one small and one large input set. Participants were able to check during the qualification whether their programs produced correct results on the small input sets but had to wait for the round to finish to know whether correct outputs were produced on large ones.

Correct solutions for small and large input sets were worth 5 and 20 points respectively. To progress to Online Round 1, each participant needed to score at least 25 points. Participants based on the times of their correct submissions and their wrong submissions. And, what I actually did not know was that the timer started ticking with the qualification kick-off. Which means that if someone slept through the earlier hours (or watched the final scenes of One Flew Over the Cuckoo’s Nest again, like me), he’d be ranked lower even though he may solve the problem within half an hour of viewing it.

Anyways, since points were what mattered the most and not the rankings, I actually started off with the problem set 2-3 hours after the qualification had started. Participants were provided with the following three problems:

  1. Saving the Universe

    The urban legend goes that if you go to the Google homepage and search for “Google”, the universe will implode. We have a secret to share… It is true! Please don’t try it, or tell anyone. All right, maybe not. We are just kidding.

    The same is not true for a universe far far away. In that universe, if you search on any search engine for that search engine’s name, the universe does implode!

    To combat this, people came up with an interesting solution. All queries are pooled together. They are passed to a central system that decides which query goes to which search engine. The central system sends a series of queries to one search engine, and can switch to another at any time. Queries must be processed in the order they’re received. The central system must never send a query to a search engine whose name matches the query. In order to reduce costs, the number of switches should be minimized.

    Your task is to tell us how many times the central system will have to switch between search engines, assuming that we program it optimally.

    I solved the problem using a vector of strings in STL. It took me around 35-40 minutes. My entry for the small input set was judged to be correct on my first attempt.

  2. Train Timetable

    A train line has two stations on it, A and B. Trains can take trips from A to B or from B to A multiple times during a day. When a train arrives at B from A (or arrives at A from B), it needs a certain amount of time before it is ready to take the return journey - this is the turnaround time. For example, if a train arrives at 12:00 and the turnaround time is 0 minutes, it can leave immediately, at 12:00.

    A train timetable specifies departure and arrival time of all trips between A and B. The train company needs to know how many trains have to start the day at A and B in order to make the timetable work: whenever a train is supposed to leave A or B, there must actually be one there ready to go. There are passing sections on the track, so trains don’t necessarily arrive in the same order that they leave. Trains may not travel on trips that do not appear on the schedule.

    This was actually easier than problem A. As I only had to use a simple multimap and a vector to hold the departure/arrival times in minutes and then loop throughout the day and manage the trains. I had 2 wrong attempts on the smaller input set though, which were caused by the fact that I started solving the problem initially with a map instead of multimap; which was imposing the limit of only one train’s departure from a station at a given instant.

  3. Fly Swatter

    What are your chances of hitting a fly with a tennis racquet?

    To start with, ignore the racquet’s handle. Assume the racquet is a perfect ring, of outer radius R and thickness t (so the inner radius of the ring is R−t).

    The ring is covered with horizontal and vertical strings. Each string is a cylinder of radius r. Each string is a chord of the ring (a straight line connecting two points of the circle). There is a gap of length g between neighbouring strings. The strings are symmetric with respect to the center of the racquet i.e. there is a pair of strings whose centers meet at the center of the ring.

    The fly is a sphere of radius f. Assume that the racquet is moving in a straight line perpendicular to the plane of the ring. Assume also that the fly’s center is inside the outer radius of the racquet and is equally likely to be anywhere within that radius. Any overlap between the fly and the racquet (the ring or a string) counts as a hit.

    This is where I got stuck, and stuck bad. This problem had more to do with Euclidean Geometry than with data structures, STL or structured programming, and I know this much about Euclidean Geometry: chapter 6 from my higher-secondary school Mathematics book was titled “Conic Sections”. Naturally, my first resort was to try and find some library which would issue my particular problems (using free library code is allowed in Code Jam). More specifically, I wanted a library that would allow me to calculate the area of intersection between a circle and a rectangle (so that I’d gradually subtract out the racket strings’ area in calculations). The result wasn’t much different from my Euclidean Geometry knowledge, as now I know this too: there’s a GPL library called GLAC which does geometry stuff. To summarize, I was unsuccessful in solving this problem. Maybe I’ll need to familiarize myself with GLAC before next round to have a good shot at progressing.

One of the advantages of using STL is that if your program is correct on small inputs, i.e., the logic is applied correctly, there’s little chance that things shall take the unfortunate route for the large ones as larger data structures are accommodated dynamically. Consequently, my solutions for A and B were later on judged as correct for the large input sets too. This gave me 50 points, and 1319th rank among the 7154 participants (I wish I had known that wasting time earlier on means a drop in my ranks, but all’s well that ends well).

The Online Round 1 takes place in another week or so. I started solving algorithmic problems only a fortnight ago so I think I’ll need some more practice to be able to compete properly. To be fair though, I didn’t have high hopes for even the qualification round, as I had entered just for fun and some experience so that I’d be able to contend properly next year — after I’ve had some proper and extensive practice with this kind of problem-solving.

Tags: , , , , , , , , , , , , , , ,

July 11, 2008

Programming Challenges: Australian Voting

Filed under: Blog — krkhan @ 10:44 am

PC/UVa IDs: 110108/10142, Popularity: B, Success rate: low, Level: 1

I had 28 (that’s twenty-eight) “Time Limit Exceeded” tries on this problem. I was looking everywhere for a loop that would drag, for every possible input that would cause breakdown and I couldn’t find any such thing. So much so, that I considered labeling this post as Australian Nightmare. The issue, once I found it, had nothing to do with Australia and all to do with the string and istringstream objects being significantly heavy to be constructed/destructed on each iteration of the loop on lines #138-153.

The book recommends further reading on voting systems and has linked to some mathematical theorem that proves that no voting system can ever be perfect. Considering the democratic results around the world in recent elections, yeah, what an absolute shocker.
(more…)

Tags: , , , , , , , , , , ,

July 3, 2008

Foxy records

Filed under: Blog — krkhan @ 9:14 am

“Adversity causes some men software to break; others to break records.” — William Arthur Ward

It’s official. Firefox 3 has created a world record for being the most downloaded software in a 24-hour time-period (approximately 8 million times actually, and that too with a server outage). I did download the source-code on the release day but I didn’t compile it until only yesterday. The compilation went smoothly, mainly because I had already solved out incompatibility issues while messing with the betas.

The grandmother’s theorem just got another postulate to build open ;-) .

Tags: , , , , , ,

July 2, 2008

Programming Challenges: Check the Check

Filed under: Blog — krkhan @ 7:55 pm

PC/UVa IDs: 110107/10196, Popularity: B, Success rate: average, Level: 1

I had two approaches in mind for checking the check before solving this problem:

  • return a flag value from the move-generation functions as soon as opponent’s king is encountered in a reachable square.
  • Generate all reachable squares for a side first, and then check whether opponent’s king is positioned on one.

I opted for the latter because even though it was more performance-intensive, it made my move-generation functions more generic and appropriate for extensibility.
(more…)

Tags: , , , , , , , , , , , , , , , , ,

July 1, 2008

Programming Challenges: Interpreter

Filed under: Blog — krkhan @ 8:38 am

PC/UVa IDs: 110106/10033, Popularity: B, Success rate: low, Level: 2

Nothing extraordinarily interesting here — typical straight-outta-the-book exercise.
(more…)

Tags: , , , , , , , , ,

Programming Challenges: Graphical Editor

Filed under: Blog — krkhan @ 1:31 am

PC/UVa IDs: 110105/10267, Popularity: B, Success rate: low, Level: 1

Few notes:

  • In the problem input, pixels are specified as [column# row#], whereas two-dimensional vectors (or arrays) are referenced using [row# column#] format.
  • The program would be doomed to infinite recursion if the condition on line #51 is omitted.

(more…)

Tags: , , , , , , , , , ,
Next Page »