Switched to Hugo from Wordpress

It’s been a relief to move away from the bloat of WordPress. I decided to use Hugo and host all of the content in Github. I am even able to use Github Actions to manage the continuous integration/delivery of the source to Github Pages all entirely for free. While Github Pages, and Hugo both generate static html pages, I was able to enable comments, via utteranc.es which stores the comments in Github as issues.

5 things you probably didn't know about .NET WebSockets

As most of you probably already know WebSocket provides full-duplex communication over a single TCP connection. .NET 4.5 added support for WebSockets as part of the BCL. In this article I am going to talk about few of the subtleties that you need to think about. Connection upgrade is somewhat expensive WebSocket connections are initiated as traditional HTTP connections. The client then usually requests an “upgrade” to a WebSocket session, this upgrade process is relatively expensive.

Building a service execution pipeline

Most software built today have a notion of a client and a service. This is even more true with mobile/web applications because you want your client apps to do as little as possible, and your service to do most of the heavy lifting. This allows you to improve your service without requiring constant client updates. Also since you have a single service that serves potentially various native clients (iOS, Android, or Windows Phone), being able to update it independently of your users gives you a clear competitive edge.


Sebastian Junger (pronounced Younger) was on Bill Maher last night. Junger is an award winning Afghanistan war correspondent, and director, and his latest documentary Which way is the front line from here? has been proclaimed a success at the Sundance Film Festival this year. During the interview Bill asked why war felt like an addiction to some soldiers. In particular, what psychology drove this behavior? To that Sebastian responded: “The consequences in war are huge.

Introduction to Machine Learning

In most computer science programs, machine learning is usually a graduate level course. It’s a specialization within the field of artificial intelligence, which is often thought of as a theoretical study than practical applications. But yet, machine learning today is used heavily to solve problems. Our team for instance, uses it to build acoustic models for speech recognition. It’s no longer a theory, it’s applied science. But if you wanted to start in this field, which I suspect is going to play a major role in software in the future, where do you start?

.NET and Node.JS - Performance Comparison (Updated)

Update (3/31/2013 - 11:41 PM PST): This article has been updated! As most readers have commented the node.js async package is not asynchronous, which is what the original article was based on. I made an assumption I should not have. I have since rerun the tests taking this into account, as well as some of the changes recommended by Guillaume Lecomte. I have decided to update this existing post so that there’s no confusion in the future with the data.

Improving Wordpress site speed on IIS

One of the first things I did when I started this blog was to change the way static files are cached by IIS to improve site speed. Static files are things that aren’t going to change, things like CSS, JavaScript, images, documents, and so on. With IIS this is actually quite easy to achieve, you can start by making the following change to your web.config: <system.webServer> <staticContent> <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" /> </staticContent> </system.


Came across this wonderful quote from Jeff Hammerbacher: “The best minds of my generation are thinking about how to make people click ads”. I won’t get into the details of what the implications of this are - but I think you can figure it out.

Composition over Inheritance

There are several ways to extend the behavior of a class. One of my preferred approach to extending behaviors is composition, and that is what we are going to talk about today. Let’s start with a simple example of inheritance: public class Search : ISearch { IEnumerable<SearchResults> Search(Query q); } public class Related : Search { IEnumerable<RelatedEntities> Related(Query q); } So in this simple example, we extend Search and create Related - which provides some additional functionality.

Azure service monitoring

Monitoring your Azure services couldn’t get easier. Windows Azure recently released a capability to test connectivity of your service (REST or website) from over three continents. It’s super simple to setup. Login to your azure management console, add your website URL to monitor and select up to three locations to monitor from: With that you can start getting response time, and uptime reports (my uptime was 100% so I didn’t show it here): In this case, Violet is Chicago, Blue is Hong Kong, and Green is Amsterdam.

C-Sharp as a scripting language

Here’s a cool technology you might not have heard of: scriptcs. Gives you the ability to use C# as a scripting language. It does this using the Rosyln compiler. So here’s an example below, taken directly from the scriptcs website: using System; using System.IO; using System.Web.Http; using System.Web.Http.SelfHost; var address = "http://localhost:8080"; var conf = new HttpSelfHostConfiguration(new Uri(address)); conf.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); var server = new HttpSelfHostServer(conf); server.

Using the MVVM pattern on web applications – Part III

We are at the finale of this three part series. In part I we discussed the MVVM design pattern, in part II we looked at the overall architecture and how the server side fits into the picture. In this article we are going to look at the client side of this and close with some final thoughts. The best place to start with the client is the HTML - so here’s the part of the HTML that’s interesting:

IE Compatibility and W3C Validation

I’ve always been a junkie when it comes to markup validation. It’s important to me that my sites are 100% XHTML/strict compatible. But recently I came across a situation that I thought I simply couldn’t get around. In this article I am going to show you how you can add the X-UA-Compatible attribute and at the same time validate your pages through W3C validation. My website had the following tag:

Using the MVVM pattern on web applications – Part II

Last time we looked at what the MVVM pattern was, and how it is used today in XAML-based applications. Today we are going to take a step further and build a mechanism to use the MVVM pattern on traditional web applications. Imagine how powerful it would be if your UI could evolve independently. We are going to build a simple web application that will display top 5 “memory intensive” processes on the server side, and here’s our basic architecture: Recall, with MVVM we need the ability for our ViewModels to somehow send messages to the UI.

Microsoft on{x} - Automate your life

Microsoft on{x} is a set of services built by the team I work for. On{x} allows you to configure arbitrary actions during specific circumstances. For instance, on{x} provides an API called modeOfTransport. This API gives the developer the current mode of transportation - whether you are walking, running or driving. You can subscribe to a change in this event and build cool scenarios like when someone is going from driving to walking (imagine parking a car), your phone can automatically remember your parking location.

How do you test your software?

There seems to be two types of developers out there. One that believes in integration tests, and the other that believes in both unit and integration tests. Integration tests are tests that execute everything as if they were real “transactions” only to verify the expected results. For instance, if you were building a web application that managed a list of employees and their supervisors. Your integration test would probably add an employee to the database (actually add it), and then read it back from that database, and so on (from a test database of course).

Using the MVVM pattern on web applications – Part I

In this series I will be discussing how the MVVM pattern can be used for almost any type of web application. MVVM (a variant on the MVP pattern) - is a really powerful pattern that can be used in UI applications. Traditionally these UI applications has been WPF and Silverlight. In this article I will show you how you can use the same principles to build web applications. With MVVM you have the following three ideas:

Learning to program

If you or your kids want to learn how to program - you can start here: http://www.code.org/. For instance, just see this example. You have a great editor, where you can type and see results immediately on the right. On top of that, you have a video, with someone talking you through basic ideas like functions, and parameters. The site has support from top names like Bill Gates and Mark Zuckerberg.

Asynchronous Anonymous Methods

So a cool new feature in .NET 4.5 is the ability to create anonymous methods that are asynchronous (async). Task.Run(async () => await Task.Yield()); That’s just a cool way of saying do nothing!

Task Timeouts

When dealing with .NET tasks – we often want to timeout the operation if it does not complete within a certain period of time. For instance, if you make an asynchronous WebRequest call – you may want to timeout this asynchronous operation within 3 seconds if you don’t get a response back. In the past, we had to create Timers to monitor the Task (or the Thread) for completion in the callback of the timer, and then do other crazy gymnastics to make it all play well together.

Brief introduction to PRISM

Before I go into the technical details of this article. I want to provide some context for this discussion. So we are using PRISM to develop a user-interface (UI) platform in the context of a Silverlight (but they apply to WPF also). The idea behind the UI platform is we will provide the basic functional look and feel and various plumbing (such as security, service encapsulation, messaging and exception handling, among others) and allow others to develop modules/components on top.

How to check if Integrated Windows Authentication is available?

If you’ve ever worked on an intranet site, you often want to know, programmatically, if a client that’s accessing your website has the ability to automatically login to your site (Integrated Windows Authentication). With Integration Windows Authentication, Windows can basically send (as a HTTP header) the currently “logged on” username. So your application can access this LOGON_USER HTTP header and go from there. I won’t get into the details of how to setup integrated windows authentication, but basically the idea is you go into IIS and for a given resource (a folder or a file) on your site you change the directory security to Integrated Windows Authentication.

Better Presentations

You can drastically improve your PowerPoint presentations by simply leveraging pptPlex! It’s a add-on for PowerPoint to build dynamic, contextual presentations. Contextual presentations allows your viewers to see the global context of your discussion, which in turn helps them to follow your line of thought. Watch some of the videos on the pptPlex website to see what’s possible.

Rendering Step 1 of … (ASP.NET)

The MultiView control, Wizard control or even a custom panel-based control is very useful to collect large sets of data in wizard form; and it’s often useful to give visual ques to the user as to which step he/she is in. Something similar to: The following ASP.NET code/C# allows us to build a dynamic step control which grows or shrinks automatically given the number of views you have in a MultiView control, or the number of steps in a wizard control.

Presentation on jQuery

I presented a topic on jQuery at our campus web publishers meeting. Here are the sample pages and the PowerPoint presentation. I will talk more discussions on jQuery and how it has helped us to build a powerful web-application next week.

Automatic Documentation

Generally all programmers are lazy–and specially when it comes to documentation because it takes so much time and doesn’t necessarily produce any material benefit. GhostDoc1, designed by Roland Weigelt, is a plugin for Visual Studio 2005 that automates the generation of XML comments. For example if you have the following C#1 function: public User GetByUserName(string userName); GhostDoc will automatically generate: /// <summary> /// Gets the name of the by user. /// </summary> /// <param name="userName">Name of the user.

Using SSIS to Access Network Resources

SSIS (SQL Server Integration Services) is the replacement for DTS in SQL 2005. One of the more deceitful concepts in SSIS is it’s security context. When you run a SSIS package form your Visual Studio Environment, it obviously runs under a different security context (most possibly as you–the developer) than it would run if it was run as a scheduled service on the SQL server itself. So let’s say you’ve developed a SSIS package that uses resources within your domain, such as accessing a network drive.

Script Task reading/returning data

When you are using the Script Task in SSIS it’s often useful to have the script task return data, and also at times useful to have access to external data. Once you drop a Script Task onto the designer and go to it’s editor, under the script tab you’ll find two attributes: ReadOnlyVariables, ReadWriteVariables. The first allows the script to access external user variables for reading, while the latter allows write access.

Reverse a linked list recursively

A question came up the other day while I was helping a friend of mine about recursively reversing a singly linked list. The moment I heard about it I came up with a solution, but turns out the solution requires the function to accept the following signature: List* reverseList(List *l); This actually poses a problem because there’s no way to keep track of the head, or maintain any back pointers which could’ve been done if the function accepted a second parameter.

Legacy code

I manage a good portion of legacy code, written by so called consultants, and I can’t believe how many places I have seen code like this: bool flag; if(x==y) { flag=true; } else { flag=false; } Or a variation of this bool flag=false; if(x==y) { flag=true; } Although the latter is better, you can write an equivalent statement as follows: bool flag = (x==y); How much easier is that to read?

Using Control Adapters

ASP.NET 2.0 introduced a new way of modifying how ASP.NET renders a control. For example, when you say: <asp:textbox id="FirstName" runat="server" /> You have very limited control over how the control actually renders. You can specify a cssclass to modify the look and feel, but the actual HTML rendering is limited to what’s available from the ASP.NET server attributes. For example you cannot add client-side onfocus or onblur statements. This is where Control Adapters comes in.

Automatic Printing

Summary: Learn about automatic printing in a Windows platform using WScript. Automatic printing is a subject you will find a lot of content about on the internet – but most of it is useless. It’s a massive collection of try-this-try-that. I was searching for some descent content on how to do scheduled automatic printing but spent far more time that I would like to. Finally I arrive at this code:

Four Part Naming Convention in SQL Server

In SQL server if you want to reference a table using four-part naming convention and you receive the error message: Server ‘xxxx’ is not configured for DATA ACCESS. Then you need to execute this statement against the target server: EXEC sp_serveroption 'xxxx','DATA ACCESS',TRUE … that should fix the problem. An obvious point here is to replace xxxx with the target server.


In Windows XP pressing CTRL+ALT+DEL twice in the login screen will take you to the classic login screen where you can manually type in the username and password to authenticate yourself. According to a Microsoft employee this feature maybe removed in future releases of Windows or worst yet it might be removed in future service packs. This would have caused serious problems for me because non-of the users I have on the intial list are administrators to the system.

Using ASP.NET to authenticate against AD

The company I work for reliies heavily on active-directory to organize, authenticate and integrate. In order to login to the intranet from our site, we currently request the integrated windows authentication box and ask the user to login. For some people this was a little flattering because it didn’t really say why the login was taking place – where are they loging into and so on. So to remedy this issue, I am working on a ASP.

Finding Content in your files

If you want to search text files in your computer for a specific string you can do this easily using the following code: for /f "tokens=*" %i IN ('dir /s /b *.asp') DO find /I "depthomepages" %i >> output.txt You can replace dir /s /b *.asp to something more appropriate. You can alternatively search only specific folders also, by simply modifying the dir arguments.

Recursion in SQL

Oracle database supports a very strange construct called: start with, and connect by. For instance if you have a table which has two columns one that defines the parent of the other column such as: Parent Child 0 1 1 9 9 7 7 2 The parent of 2 is 7 and 7’s parent is nine and 9’s parent is one and so on until finally 1 who parent is 0 signifying no parent.

Typed ToArray() from ArrayList

To get a typed Array of type int [] from an ArrayList you can do the following: (int [])TestArray.ToArray(typeof(int)); First the ToArray() function accepts a System.Type argument which is what it uses to convert the Array to type int. However, the return type of ToArray() is still object so we will need to cast that as well which can be done using the (int []).

FTP & Microsoft ISA Server 2004

Microsoft ISA (Internet Security and Acceleration Server) 2004 is a tool to secure and accelerate (as the name suggests) networks running on Windows platforms. It’s a very powerful tool and is one of the most flexible firewalls I have seen in the market. Where I work, Microsoft ISA actually replaced several CISCO firewalls. Not only were we able to migrate all the access lists rules we were able to do far more than that.

Recursive Fun (C#)

Recursive functions can be a lot of fun! I was playing around with a collegue of mine at work about solving recursive problems. And we both worked on a problem of deciding weather a number is the median in a list of numbers. Here’s my solution: using System; public class MedianRecursive { private delegate bool Function(int A, int B); private static bool GreaterThan(int A, int B) { return A>B; } private static bool LessThan(int A, int B) { return A<b; } private static string Partition(int[] List, int M, int Position, Function Compare) { if(Position>=List.

Partial Classes

Out of several enchancements available in .NET 2.0 partial classes is one of them. Partial classes simply means that you can break your class and write them separately (as if they were separate entities). This becomes a useful feature when you have a large class that does more than one thing. If you open a software engineering book, you are likely to find statements like: “…your function/classes should do one thing and do it well”.


XMLHttp is the future of web application development. It allows threaded communication between the client and the server without ever leaving the page. If more advanced JavaScript features are standardized this might mean that a web application will act and feel very much like a regular windows application. Up until now, one of the major differences between a windows application and a web application was statelessness. However, with XMLHttp this is reduced much further because a state will no longer be round-trip from the server, it will be when the user enters a page does several thousand things and leaves the page (when they leave the page the state is lost) however during those thousand events all the state will be maintainted – this can be done using XMLHttp.

The trailing slash

Sometimes a simple change as adding a slash may improve the performance of your web-applications. Consider this: the link www.salmanq.com is slower than www.salmanq.com/ (the only difference being the trailing slash). They will both work but the latter is faster. When this link: www.onupol.com is followed the web-server returns a 301 (Moved Permanently) pointing to www.salmanq.com/ that’s one extra round trip to and from the server per link. If you have a site that’s running without the trailing slash and you have 10K+ visitors you will certainly start to feel the consequence.

Old bugs are harder to catch

About three years ago I worked on an application that in-part had to blend in with several other applications. Among many features one of them was to automatically generate something known as deadlines. The actual details are far to complicated to explain in details here, so I will use a simpler example. Assume that you have four types of documents each have their own specific way of computing deadline. One of them follows a rule like:

MySQL version information

You can use this simple command to find the MySQL version you are running: select Version() as Version; Hope that helps.

ValueType Boxing

In .NET an interesting phehomenon occurs known as “boxing”. Let me illustrate the problem and then we will look at the possible solutions: using System; using System.Collections; class Test { struct BankAccount { /* A simple BankAccount structure */ public float Balance; /* Balance in the account */ public BankAccount(float _Balance) { /* overloaded-contructor */ Balance = _Balance; } /* A method to charge the account */ public void ChargeAccount(float Fee) { Balance-=Fee; } } public static void Main() { ArrayList Accounts = new ArrayList(); /* An array */ Accounts.

Uncertaintly Principal and Software Engineering

Uncertainty Principal is a principle of quantum mechanics postulated by Nobel laureate Werner Heisenberg in the 1920s which states that it is not possible to determine both the position and the momentum of a particle at the same instant. The reason he argued, was that the act of “observing” the particle changes its behavior with respect to what is being measured. He was one of the first scientists to bring in probability into the predictable science of physics.

Form posts and CacheControl

Let’s say you have an HTML form which posts to another page, and that page in turn posts to other page(s) (maybe even to itself). Consider what happens in a very common scenario such as this: User visits page 1 Types in username and password Posts to page 2 (valid user) User sorts a column in page 2 which posts the column name and the order to page 2. Page 2 reloads.

Option Groups

Not many people know about this. In a HTML dropdown (select) there is a option group tag that groups your options together. For instance: <select name="cars"> <optgroup label="Honda"> <option>Honda Accord DX</option> <option>Honda Accord LX</option> <option>Honda Accord EX</option> </optgroup> <optgroup label="BMW"> <option>BMW 530iL</option> <option>BMW 640iL</option> <option>BMW 740i</option> </optgroup> </select> If you run the code above you will notice users can’t even select the option group (which is perfectly valid). And the automatic indendation within the sub-groups is very useful also.

Why run as doesn’t work on explorer.exe?

You will notice in windows no matter how you want to “Run as” explorer.exe it will not work. Almost all programs you can right-click or hold CTRL and right click to get the run as option but with explorer this doesn’t seem work. You cannot even use the command line tool runas /u:administrator to run explorer. Explorer.exe is a special task. It actually runs all the time and is responsible for the taskbar and other features on the Windows desktop, press CTRL+ALT+DEL right now and you will see explorer.

Can UIs produce bugs?

All developers are aware how programming errors such as logic error, exception error or incorrect input data can produce bugs. But can UIs produce bugs or at least attract the user towards a bug? The answer yes! And these bugs tend to be quite difficult to catch because each user react to the UI in a different way. And the fact that programmers are so used to the behaviors of the default controls in a GUI environment it’s hard for them to test the application for UI confusions.

Optimizing Regular Expressions

Optimizing regular expressions is an exceptionally complex field. A vast majority of the problems within this field is NP or NP-COMPLETE. Meaning that their solutions cannot be bound (time/space) under any definite polynomial. All APIs (such as: .NET, PHP, ASP (classic VB really), JavaScript) that support regular expressions performs some form of equivalence reduction meaning it tries to reduce the given regular expression into a reduced YET equivalent regular expression. Of course there is no full-proof way of doing this for couple of reasons: (1) There is no way to guarantee that a reduced regular expression is the most efficient regular expression possible.

Faster table rendering

Unlike FireFox, Internet Explorer does not display a table until the complete table data has arrived. This can be looked at both positvely and negatively. The positives are, once the table is rendered it is not modified (width, height, positioning) because all the data has already arrived and IE can properly compute the width and height of the cells and rendered it top-down, right-to-left without making any other adjustments to the cells already displayed.

Re-Useable Images

I was working on a project last week and part of the work was to create sort of like a template / menu / footer with an opening image. Initally I was positioning the title of the page as a regular h3 but then I thought of something great (I find it to be). Take a look at this page – if you notice carefully you will see “Salman’s Blog” is just a text.

Logos in Photoshop

Inspired by Macintosh Panther logo, I designed this logo. I started with the letter X of course, then I manually marked the black marks. The second step was to add lighting. I used dodge and burning to do the lighting (while being careful about the nature of light). Then I marked the X layer to Bevel-and-Emboss blending. To give the letter a texture I added a little bit of monochrome gaussian noise.

Roomba: Maintaining Direction Part III

So far I have discussed the following topics: Introduction to our intelligent Roomba Vacuum cleaner. How a torus (smart array) is used to maintain the state of the cleaning surface. Today I will discuss how we managed to maintain the direction we are traveling in. What we did was to connect two light sensors on both sides of the robot. Then we attached a pinwheel (printed on a paper; see diagram below) attached to the motor using gears, right in front of the sensor.

Outlook’s vCalender using ASP

As part of a continuing effort to build more functional and user-friendly products I am working on an ASP-based vCalendar concept. Originally I was working on a training enrollment system where users could enroll/drop for a class, standby in a waiting list and things of that nature. My department has been using this product for sometime now and my boss is starting to realize that more people signup than actually showing up.

Macintosh Like Light (CSS)

I was working on a new design for something at work and I came up with this header layout. The background is separated into three images and the center image resizes to fit the content of the header information. Except the images the entire thing is done using CSS.

Torus: Smart Array - Part II

As I was discussing I am working on an intelligent vacuum cleaner. In this article I will discuss how we did our state management for the surface the robot is vacuuming. In order to maintain the state information for the surface, one of things we had for our intelligent Roomba was a char array (VACUUMED, UNKNOWN, BLOCKED are the possible values for each cell). However a simple array wouldn’t work because the robot could be physically placed anywhere on the floor, yet our starting position would always be (0,0).

Vacuum Cleaner

For the past few weeks me and a team of three extremely bright computer science graduate students have been working on a vacuum cleaner. The idea is to design a robot that can clean a room efficiently; the key term here being efficiently. There is an existing product called: Roomba which sells for about $300.00 dollars and does the same thing we are trying to do – but it does it zero intelligence.

Object Databases (ORDBMS)

ORDBMS - Object Relational, Database Management system. Is an object oriented database management system. The concept at first is a bit suprising since relational database sort of by definition negates the concept of objects. In theory a relational database is a set of relation R; each table, formally known as relations, can be joined (cartesian product) to produce a new relation (which is an improper subset of R1xR2). There are many problems with this scenario.

JavaScript Performance - Part II

As I discussed last week setInterval in general gives better performance compared to setTimeout. Today I will discuss how in order to improve performance, one thread can be used to run multiple animations. Multiple animations come up in several scenarios. For instance, if you have a menu that does some animation onmouseover then although not clear at first this menu system could be running multiple animations at the same time. For example, let’s say the animation takes 2 secs to run.

JavaScript Performance - Part I

This is the first in a series of articles I plan to write on improving performance in JavaScript heavy web-applications. More specifically I will discuss some of the ways you can improve on JavaScript based animations, reducing object chains, cross-browser DOM, clever ways of writing/designing objects and so on. Improving on Animations No matter what type of animation it is if it’s written using JavaScript it’s most likely going to make use of setTimeout or setInterval.

Using XSLT to view graphical poll results

How I came to this is not relevant I think, so I will jump straight to the examples. The idea was to convert this XML document to produce this output. So I set out to do it – and it was finally done using this XSLT stylesheet. The idea is quite basic. Count the number of ‘I agree’ responses and store it in a variable. Count the number of ‘I disagree’ responses and store it into another variable, and so on… Once that’s done, the count values are multiplied with the expansion factor (variable: efactor) and this number is set to the height of a div element.

Solution to Line Tracker

In my previous post I discussed an algorithm that it is much better than the general line following algorithm that one might think of at first. Last night I implemented the algorithm with NQC with descent results. Here’s the solution: /*********************************************** * Salman Quazi * CS-595EA * Date: September 19, 2004 ***********************************************/ /* Constant Definitions */ #define SENSOR SENSOR_1 #define LEFT_MOTOR OUT_C #define RIGHT_MOTOR OUT_A /* Speed settings */ #define NORMAL_SPEED 7 #define TURN_SPEED 2 #define DELAY 20 /* This setting depends on several conditions like: lighting, contrast between the tape and the floor .

Line Tracker

I have a project due in few weeks. The idea of the project is that the LEGO mindstorm has to follow a black line on the floor. So I started thinking about this problem and my initial approach was the following: I assume my robot starts ON the black line. So it starts traveling forward and continues until it finds white (which is the floor). At this point it has to turn but which way?

Dynamic contents

Generating dynamic contents can be a great way to allow your users to find information quickly. In this example the page headlines menu option was created dynamically (using JavaScript). In this case the contents was generated dynamically using H3 tags it can be very easily modified to read H1,H2, IMG, IFRAME, SPAN, DIV or any other tag that comes to mind (except perhaps BR :-))

Date Format (using XSLT)

It was sort of surprising to find out that XSLT does not have any predefined date formatting function. So after spending sometime on my own I came up with this solution: <xsl:template name="format-date"> <xsl:param name="date" /> <xsl:variable name="monthName" select="substring-before($date, '/')" /> <xsl:variable name="day" select="substring-before(substring-after($date, '/'), '/')" /> <xsl:variable name="year" select="substring-after(substring-after($date, '/'), '/')" /> <xsl:variable name="month" select="substring(substring-after('01Jan02Feb03Mar04Apr05May06Jun07Jul08Aug09Sep10Oct11Nov12Dec', $monthName), 1, 3)" /> <xsl:value-of select="concat($month, ', ', $year)" /> </xsl:template> You can call this function like this:

Search for PGP key given a keyserver

In Linux just do this: gpg --keyserver "ldap://certserver.pgp.com" --search-keys "<e-mail address>" Note the option: –keyserver can be other Keyservers like the MIT Key Server (pgp.mit.edu).

JavaScript Buffering - Offscreen

Just before I go to bed I thought I make an interesting post. The other day I worked on a site for a client; like most of my sites it was very heavy on style sheet (meaning most of the alignments and things were done with style sheet rather than tables, etc.) So what would happen is the page would load without style sheet for a sec. and then the style sheet would be applied.

Sequential Preloading..

How do you make certain JavaScript sequentially preloads your images? For instance if you have 10 images and the size of image 9 is the smallest then it’s most likely JavaScript (internet explorer rather) will load image 9 first. Then the second smallest or perhaps in no true order. However there are times when you need to make certain the images are loaded in sequence…. The following accomplishes this – figured it out after a lot of problems:

Speaking about events technically

The other day I was working on something in JavaScript and I thought I would share that with you. Before I can begin though I have to describe the scenario. I have an image in an HTML page (lets call it: MyImage). I dynamically attach an event to the Image’s onload method. Due to other events on the page MyImage’s SRC attribute gets changed to something else. Now logically the onload event should execute again once the new SRC element gets loaded.

Embedded Software

Interesting semester coming up for me. As some of you may know I am starting (at least partially) my masters in Computer Science. After much thought. I have decided to focus on the field of: Embedded Software Development. Embedded applications are everywhere. When you use your microwave, drive your car, program your tv, program you DVD player and on and on. Almost all household devices have some software embedded into it.

Alpha Beta Searching

I have a test tonight. I am fairly certain I will get an A; however, there is only one thing that I am unsure about: AlphaBeta searching. So I went online and read couple of books. Here’s my understanding (in brief of course): AlphaBeta searching is an optimized searching model based on MinMax searching (or MiniMax search). So to understand AlphaBeta searching we must first understand MinMax searching. MinMax searching can be applied on game trees (if you are not familiar with game trees then please go here).

Unique Elements (in XSLT)

At work I have this XML document that lists all the employees along with their responsiblities. The general format looks something like this (staff.xml): <ga-staff> <department title="Administration"> <employee> <responsibility>Director, Corporate Accounting</responsibility> <name>...</name> <phone>...</phone> <email>...</email> </employee> <employee> <responsibility>Manager</responsibility> <name>...</name> <phone>...</phone> <email>...</email> </employee> </department> <department title=""> ... </department> </ga-staff> I was asked to generate a flat (meaning only their name, phone and e-mail) output (sorted by name) of all the staffs in our department.

Kolmogorov Complexity

A computer science/mathematics student learns various ways of measuring complexity of a problem. I feel this is an extremely important field because it allows us to measure the difficulty-level (or complexity of a problem). Without it, it would be like trying to lift a box without knowing how much it weighs. For instance, how complex is it to sort N numbers? Using standard notation it turns out the best possible solution can be: O(n*lg(n)) (we can prove that this is the best possible solution).

CSS: word-wrap

You will notice this blog site will not overflow in the x-direction no matter what resolution you view this site in (I tried upto 640x480). When you have a div area and you are using PRE or XMP to view formatted contents (like I do in this page to view code) within that div – this would be almost impossible to do. Here’s the reason: unless otherwise stated a PRE or an XMP is displayed as is.

Power of PROLOG

Here’s yet another example of the power available to you in PROLOG. Let’s consider this simultaneous equation: 3x + 4y = 17 4x + 3y = 18 In PROLOG I can find the values of X and Y just like this: compute(X,Y):- fd_domain([X,Y],0,1000), 3*X + 4*Y #= 17, 4*X + 3*Y #= 18. That almost seems like I am joking – but I am really not. That 3 lines of code will find all solutions to X and Y.

Constraint Logic Programming

PROLOG can is one of many languages that can be used to perform Constraint Logic Programming (CLP). Just like C++ and Visual Basic can be used to program Object Oriented Programs (OOP). Same idea. The idea behind CLP is the following: give contraints to a problem and request all solutions. For instance, if I had: X+Y=100 Suppose I wanted to find all the integer solutions to this problem it would be very difficult to code in a regular language (not so much in this specific case because it’s too simple, but in general).

Hiding Elements During Printing

I work in an environment where my collegues surrounding me strongly believe there is no difference between “Microsoft Excel” and the web. One of the arguments I almost always hear: “…why can’t you do it? it can be done in excel – see!”. So that’s how it all started; Excel apparently has a feature that allows a user to hide certain elements from the spreadsheet during print-out; I am not sure how exactly it’s done, I am not an Excel expert.

Volume Backup

I am trying to work on a system/method to perform incremental backup over the network (using SAMBA). Here are some of the steps I have taken… First I decided on the set of data that needs to be backed up. Since the very beginning all my data files (such as documents, programs, musics and so on) are kept in a completely separate drive. This drive (although large in size) is used only for my personal stuff and I never install anything or create any dependencies on this drive.

Random Numbers

There are tons of masters, PhD thesis written on generating uniform (as in uniform distribution) random numbers using a computer. The problem with generating random numbers is finding a true source of entropy. The usual rand() or RND function found in most languages use the system clock as the source of entropy. This is perhaps the worst method of generating a random number; the reason being the change of entropy is predictable (because the change of time is predictable – the millisecond counter changes 1/1000 sec).


In PROLOG there is an idea called: unification. It’s similar to setting a variable to something but there are certainly several difference (otherwise it would be called assignment). One major difference in unification is pattern matching. For instance if I had the following code segment in PROLOG X / Y = 10 / a Then the variable X will be assigned 10 and the variable Y will be assigned a. This is very powerful tool.


Almost all HTML/XHTML tags have an attribute called: accesskey. What this does is allows the programmer to assign key-codes to elements in the page. For instance, if I did this: Search: <input type="text" name="Search" value="" access="S" /> Then the user could enter: ALT+S to jump to this field no matter where they are on the page. This feature can make a web-site very user friendly. For instance to jump to search field on this page enter: ALT+4.


Structure and Interpretaition of Computer Program is often considered one of the greatest books written on LISP or generally program structure (as the name suggests). Strangely enough the book is now available freely (through MIT) at: http://mitpress.mit.edu/sicp/full-text/book/book.html One of my favorite quotes happens to be written in the Preface section of the first edition of this book: “Programs must be written for people to read, and only incidentally for machines to execute.

Thinking in C++

I found this great book only it’s called: Thinking in C++. It’s a complete 1200+ pages book for FREE. Download it!

Bit Operations

A friend of mine once asked me what the following code does. register int a; a ^= a; After a bit of thought I realized that “a” gets initialized to zero. But why do it that way when you can do it like this: int a; a = 0; The answer lies in the machine translation for each of these segments. Let’s look at it one piece at a time. The first code segment requests “a” to be part of one of the several general paramenter registers in the CPU.


This semester I am taking a course in PROLOG. It has been almost 5 weeks now since I have been taking this course; and I strongly believe that every programmer should take at least one course in a logic programming class. I feel a course of this type will open the mind so greatly that it will not only help one program in other languages but help in several other aspects of one’s life.

Verifying your site is running?

This question often comes up-how do you make sure that your site is running? One solution is to run tools like WhatsUp Gold that monitors your IIS service status, SQL service status etc. As long as these services respond as saying they are running, WhatsUp gold is happy. But unfortunately, the fact that these services are running does not mean that your website is functioning to the public. For example if you have a page that depends on an external web service, and for some reason the external web service is down, then your page will not respond and will eventually time out.