Memoization - Optimize your function calls

Memoization is an optimization technique where the idea is to create functions that cache computed values for various input sets so that subsequent invocations can return the value from the cache instead of re-computing the results. It is a simple space for time trade-off where processing time is reduced at…

Read this article

Random Lisp thoughts

I have covered about 4 chapters from the book Practical Common Lisp and what I have learnt so far is quite fascinating to say the least. Here're some random observations that I happened to make about Commmon Lisp. Please note that whenever I use the term Lisp below I refer…

Read this article

Learning Common Lisp

As is frequently the case with such things (at least with me) I have decided, for no compelling reason whatsoever, that I will learn to program in the Common Lisp programming language. It might perhaps have something to do with the fact that I stumbled upon the following impassioned pleas…

Read this article

JavaScript closures act like implicit function state?

Consider this JavaScript code: function acc( n ) { return function( i ) { return n += i; }; } var fn = acc( 5 ); var n1 = fn( 1 ); var n2 = fn( 2 ); The question, of course, is what the values of n1 and n2 will be. It is perhaps evident that n1 must now equal to 6…

Read this article

Calling a JavaScript function with variable arguments

I am working on this little Windows Scripting Host script using JavaScript where I basically need to load up a Word document and do a bunch of text transformation tasks on each line and dump the output to the console (which I plan to redirect to a file). I decided…

Read this article

Centering elements on a canvas in WPF

While I was fiddling around with WPF in general I noticed that when I dropped inane little circles and boxes onto a canvas I'd never be able to center it inside the containing canvas just right. If you try the following XAML in the excellent Kaxaml tool for instance: <…

Read this article

Custom windows with WPF

I am working on a little WPF app to build a UI for the Freebase web database and decided that the entry point to the app will be a simple textbox where the user can type in the search text. Here's what it looks like: While this was the look…

Read this article

What's a good error message?

In general, when writing code for handling the case for when something goes wrong, the programmer's natural instinct seems to be to just get over with it as soon as is possible and move on to other more exciting things. I speak, of course, from first hand experience. Now, there…

Read this article

How to create a simple Workflow Foundation (WF) activity

Quite suddenly, with no prior warning whatsoever, I resolved with firm determination that I will without further delay inflict upon unsuspecting world, my first screen recorded, poorly narrated technical tutorial. After many failed attempts with many miserable little screen capture programs, I finally managed to put something together using a…

Read this article

Gmail - Can't take security for granted!

A couple of disturbing stories about how your email account can be compromised! Google's GMail security failure leaves my business sabotaged A Question of Programming Ethics …

Read this article

Silverlight Tic-Tac-Toe

I got it into my head one fine day that I will try to find out what this Silverlight thingy is all about. I read the quickstart tutorials a bit, read some arbit blogs and finally decided to write up a tic-tac-toe implementation using the alpha version of Silverlight 1…

Read this article

Switching threads - my second article for Code Project!

After much grievous toil my second Code Project article has finally been posted (phew)! It talks about a thread switching technique that lets you switch the thread on which a routine is running by messing around with stack pointers, CPU registers and window messages. You'll find the article here: http…

Read this article

Concurrency with an STA?

I was recently experimenting with the Windows Running Object Table (ROT) when I ran into a peculiar problem. Here's the scenario: I had a simple in-process COM component configured to run in a single threaded apartment (STA). The STA apartment configuration, if you didn't know, is an indication to the…

Read this article

PathIsDirectory woes!

Here's what MSDN has to say about PathIsDirectory's return value: Returns TRUE if the path is a valid directory, or FALSE otherwise. One of the architectural goals for the product that I am working on is the enabling of cross platform source code portability with minimal development effort. To this…

Read this article

On (Im)Possibilities

There I was, boarding a train on the day lovers consider special filled with the blooming hope that large scale celebration of love in global proportions will somehow cause the very atmosphere to be so infused with the romantic spirit that it would prove to be all but impossible that…

Read this article

On Bugs and Destiny

A recent experience at work has left me convinced that sometimes a bug is quite simply just meant to be. I do not refer mind you to bugs that choose to make an appearance only after the user has performed a jiggle in front of the monitor having muttered strange…

Read this article

Pay attention to that demo

It seems implicitly apparent to me that when someone bothers to create and distribute a demo version of their software product, it must be because they want people to have a go at it and hopefully so impress them that they will want to fork up money and actually buy…

Read this article

Shaw on shame

The character Tanner's retort to Ramsden's contention that Tanner is an impudent man. Excerpt from George Bernard Shaw's play - Man and Superman. "We live in an atmosphere of shame. We are ashamed of everything that is real about us; ashamed of ourselves, of our relatives, of our incomes…

Read this article

On appreciating music

There is a certain superior kind of person who is frequently fond of making scandalous remarks in order to appear unconventional and witty with the equally frequent consequence of appearing merely impertinently conspicuous. He insists upon being decidedly disagreeable - solely counting upon the possibility that the contrary opinion will…

Read this article

System API call hooking

I have for sometime been meaning to investigate into how exactly one set about hooking system API calls, i.e., be able to intercept/instrument calls to Win32 APIs made by any given process on the system. Surprisingly, there are quite a few good, informed articles on the subject. Here're…

Read this article