How to Create a PFX Certificate

If you are working with Azure cloud or any other services that require a PFX certificate, here is an easy way to create a certificate.

Step 01
Create vs.bat as below

Be sure to replace that with a path valid for your system, of course. Alternatively, skip this step and instead open up a visual studio command prompt.

Step 02
Create pfx.bat as below

Step 03

  • Open a command prompt (Run > cmd) and cd to the folder where above batch files were created
  • Run vs.bat with no parameters
  • Run pfx.bat <pfx-file-name> <cert-name> <pfx-password>
    • pfx-file-name: Name of the certificate file (say, mypfx). Any valid file name, without spaces.
    • cert-name: Name of the certificate (say, MyApplicationCertificate), without spaces
    • pfx-password: Password for the PFX. This is different from the PVK password that you will be prompted for.

Note that the “without spaces” restriction is due to limitations of the batch file that I’ve done in a hurry. If you wish to have spaces, either use the commands directly or improve the batch file.

Adding TweetBacks to Thesis

Was trying to add the tweetback plugin to my thesis themed blog recently and found out that the tweets doesn’t appear automatically as comments if you just enable the plugin. Some searching around didn’t help much either. Here is a step by step account on what worked for me.

Download and Install TweetBacks Plugin
You can just search for the term “tweetback” on your WordPress plugin installer or go to Yoast

Activate and Configure TweetBacks
Activate the plugin and do the basic configuration available, including update frequency, list of exclusions, etc.

Edit comments.php
Go to Appearance > Editor in your admin area and edt comments.php.

Find the line of code below

And replace it with the below code

You’re all set! The tweets will now appear as trackbacks.

Anchor Click Not Working in FireFox / Opera / Chrome

One issue that web developers trying to port a “designed for IE” application (to support more browsers) is the use of certain IE-specific method calls. One such is the use of .click on anchor tags. This method call will generate an error in browsers other than IE as it is not defined.

Here is one way to solve this issue, without changing the existing code. What we have to do is see if .click is defined and if not, define it with an alternative that works in our target browser.

By putting the above code in the head section of your page, we can ensure that .click is defined. You may need to change the this[“onclick”]() part based on your target browser.

Here is a sample piece of html for testing the above script. Clicking on the second link should navigate to target URL of the first link.

Install SharePoint 2010 Beta on Win7 – How To

Everyone says SP2010 can be installed on Win7 and when you actually try to do it – BAM!
It says setup is unable to proceed as the product requires Windows Server 2008 (x64).

Error Saying Win 7 is not Supported
Error Saying Win 7 is not Supported

Here is what came to my rescue:

The above issue can be solved easily by adding one extra line to your setup configuration file, usually found at C:\Program Files (x86)\MSECache\oserver2010\Files\Setup\config.xml

Edit the file and add the below line just before </config>

Now you can go ahead and run C:\Program Files (x86)\MSECache\oserver2010\splash.hta

Call Twitter APIs from C# .Net

Twitter has an API implementation that is very simple to understand and use. Here is how it works, if you want to get the friends timeline of a user.

Here there are 3 keywords.
What are you working on? statuses
What do you need from the above object? friends_timeline
In what format do you need it? RSS

Formats supported are: xml, json, rss, atom
Methods supported: See Twitter API
There are many objects supported, but the above format applies for only a few like Statuses, User, Direct Messages. The rest are also similar.

Now, let us look at a GET to bring in Friend Status.

First off, we would need the URL above

The public method GetFriendsStatus calls a generic method InvokeAPI to (surprise!) invoke the API. This function in turn relies on GetUrl to build the URL for this request. AskTwitter is a helper method that does a GET request and returns the result.

As you can see, AskTwitter takes in 2 parameters. First one is the URL we built earlier. The second parameter is user credential, for requests that require credentials. This can be built easily as below.

Hope that helped get you started. Am working on a complete set of wrappers that will make using these APIs much more easier. Please leave a comment and let me know if you would be interested in any specific features.

PowerShell Script to Search Files Recursively

We had a requirement to find all images within our solution folder and check which all of them are being referenced. This was mainly to identify the unused images and cleanup the deployment.

Looked like a good place to use Windows PowerShell and this is what I came up with. From the current folder, it looks all subfolders and builds a list of files. Then, a list of images is made similarly. Then a loop runs to find if any of these images are present in file content.

There are couple of known limitations to this script
1. The script doesn’t look at the actual path of the referenced file, just looks for file name
2. There is no filter for file-type when we get list of files (deliberately left out, please add)

MINIF and MAXIF in Excel 2003 or 2007

Like COUNTIF and SUMIF, it is helpful to have a conditional MAX or MIN. Excel doesn’t have it for now (yeah, “for now”, ‘coz MS has steadily been adding such useful functions with every new release).

Well, the good news is that there is a work-around.

The approach is to have an array formula on the IF column returning a bool, and multiplying it with the column from which MAX is to be found.

Say, we need to find the MAX in column F based on a condition on Column A and K5 having the compare value. We can do this as below.

Since it is an array formula, do a Ctrl+Shift+Enter and it’ll become {=MAX((A2:A30=K5)*(F2:F30))}. Do NOT manually add the braces.

This is very similar to what we did in the above activity. Just replace MAX with MIN.


Again, this is an array formula and need to do Ctrl+Shift+Enter.

Note that empty cells in column F might break this formula.

COUNTIFS and SUMIFS in Excel 2003

COUNTIFS is a new function available in Excel 2007. This has proved to be very helpful and it is always a problem if you switch back and forth between the two versions. Well, here is an equivalent for COUNTIFS that you can use until your company decides to spend those extra bucks and get everyone on to version 2007 :)

Let’s assume the data is as below.

These will be the equivalents in 2003, using SUMPRODUCT.


Where E5 has the counter and F5 has the sales-person. The same can be extended for a SUMIFS as below.



Next post, we’ll talk about two functions that are not in any version of Excel yet – MAXIF and MINIF.

First and Last day of a Month in C# and VB .NET

In date manipulation, one common task is to arrive at first and last day of a month. Here are two methods to achieve the same in VB and C#.

This is my favorite method for creating date out of numbers. The beauty is that the function accepts numbers beyond the usual range. i.e. Month = 14 would mean 2nd month of next year. Negative numbers too are accepted.

AddMonths and AddDays
In the C# world, it is not as straight-forward to use the above function. The below work-around helps.

As usual, no rocket-science being discussed here. Just small snippets to make your search life easier :)