Wednesday, September 29, 2010

Getting Twitter’s @Anywhere hovercards to work based on URLs

Twitter has a cool script you can add to your site to turn any references to a twitter account into a helpful hovercard that shows the twitter user, some stats, and a Follow button.  It’s subtle and useful, but it could be a little easier to add for developers.

I won’t repeat what is already available on the docs at Twitter, but the gist is if I put @kpespisa in a post, the @anywhere script will find that and turn it into a hyperlink that shows a hovercard when you put your mouse over the link. 

Sadly I noticed there was no simple way to get a hovercard to appear based on the URL of a hyperlink.  If I added a link that says “Follow me on twitter”, it would be nice to have the hovercard appear when I hover over that hyperlink as well. 

Adding a little jQuery gets the job done.  Using this code, you can just set the URL to and it will create a hovercard for you using the twitter account that is in the URL.

   1: <script src=""></script>
   2: <script src=";v=1"></script>
   3: <script type="text/javascript">
   4:     $(document).ready(function() {
   5:         $("a[href^='']").add("a[href^='']").attr("title", function() {
   6:             return '@' + this.href.substr(this.href.lastIndexOf('/') + 1);
   7:         });
   8:     });
  10:     twttr.anywhere(function(T) { 
  11:         T.hovercards(); 
  13:         T("a[title^='@']").hovercards({
  14:             username: function(node) {
  15:                 return node.title;
  16:             }
  17:         });
  18:     });
  19: </script>

For example:  Follow me on Twitter!

Thursday, May 06, 2010

DotNetRocks in Boston

This past Monday I went to see the Boston stop of the DotNetRocks road trip, hosted by Carl Franklin and Richard Campbell. The duo put on a good event, bringing in guest Chris Sells for their podcast, as well as a panel of guests to discuss F#.

The portion of the evening I found most interesting was the F# discussion. I didn't expect to get much out of it. I had heard enough of F# to that point to make up my mind that it wasn't for me. I reasoned that if it isn't a language I can completely switch to, I'm better off focusing on VB or C#.

So I was surprised when I heard the F# experts suggest that we use the language to complement our projects rather than use it as an all-purpose language. They encouraged us to use the language for its strengths, such as asynchronous processing and parallelism. One could create an assembly written in F# and include that in a VB project, for example, to handle some heavy computations. We already use a handful of non-core languages in our projects such as HTML, Javascript, LINQ or SQL, so the idea of blending yet another language into our projects is not a foreign concept.

The panel suggested we add F# to our repertoire and understand its strengths, and use it where it's beneficial. I'm going to take that advice. Bottom line is if I can replace 50 lines of confusing C# code with 10 lines of elegant F#, I've done myself a service.

A big thank you to Carl and Richard for their hard work in putting this event together, and for entertaining me with their podcasts during my commutes, jogs, walks, and housework.

Tuesday, May 04, 2010

Setting up a Mercurial server on Win2k3 / IIS 6.0

There are several tutorials right now explaining how to setup a Mercurial server in Windows, but most are outdated just enough to make the whole process fail due to recent changes to Mercurial.  I tried a few, but the best one available as of Mercurial 1.5.2 is from Matt Hawley from  His post explains how to set up the server using IIS 7.0, and the process is slightly different in IIS 6.0, as I’ll explain.

First, read his blog post to get a sense of the procedure.  The post is broken into two major sections, Packages Installation, and Configuration.  I followed the Packages Installation section exactly as written, with the exception of downloading the latest source for Mercurial, which is 1.5.2. 

Once you’ve completed the Packages Installation, follow these steps instead to configure IIS 6.0.  Many of these steps are the same as Matt describes, but for convenience I’ve duplicated them here.  All credit for this goes to Matt for getting us 99% of the way there. 

These steps assume you have IIS installed already.

  1. Create a folder to host your Mercurial site.  As Matt suggests, you can use c:\inetpub\hg
  2. Copy the file from c:\(mercurial source code location)\contrib\win32 to c:\inetpub\hg
  3. Edit in a text editor and change the two lines as follows:

    hgweb_config = r’c:\inetpub\hg\hgweb.config’
    path_prefix = 0
  4. Open a command prompt and go to the c:\inetpub\hg folder
  5. Run python  If python isn’t installed on the system path, you may need to include the path to it and use c:\python26\python
  6. Create a new text file named hgweb.config in the c:\inetpub\hg folder and add the following.  Here c:\repos is the folder where you will store your repositories.

    / = c:\repos\*

    At this point, your folder should look like this:
  7. In IIS Manager, create a new application pool with the name Mercurial.
  8. Create a new website called Mercurial, and set the TCP port to 81 (or any unused port).  Leave the Host header field blank.
  9. Set the path to c:\inetpub\hg and finish the wizard.
  10. Right-click the Mercurial website and choose properties.
  11. On the Home Directory tab, click Configuration, and then click Insert… in the Wildcard application maps section.  Enter the path to the isapi dll (c:\inetpub\hg\_hgwebdir_wsgi.dll) and uncheck verify file exists.
  12. On the ISAPI filters tab, click Add… and enter Mercurial-ISAPI as the filter name and c:\inetpub\hg\_hgwebdir_wsgi.dll as the executable.
  13. Finally, go to the Web Service Extensions in IIS Manager and Add a new Web service extension.  Give it the name Mercurial-ISAPI, and add the required file c:\inetpub\hg\_hgwebdir_wsgi.dll, and check the “Set extension status to Allowed” option.
  14. Finally, browse to http://localhost:81 (or substitute 81 for the port you chose in step 8).  You should now see the Mercurial Repositories page!


Wednesday, February 17, 2010

iPhone Game Rebates

Jon Lam, CEO of the game development company Ph03nix New Media, has started a new program to push iPhone games to the top of the App Store charts. The site,, will highlight a selected app for two weeks, offering a full rebate (up to $1) if you purchase that app and forward your iTunes receipt.
For a limited time, to build up a following, they are offering this program on any app in the App Store. The site is legitimate and I have already received my rebate, which was sent directly to my PayPal account.
How does this work? Essentially the app developers cover the cost of the rebate (meaning they lose the 30% commission taken by Apple), and in return their apps are pushed up the charts. By climbing the charts, the app is more exposed and more people are likely to buy it, thus covering the loss taken during the rebate period.
I'm definitely going to be a fan of this site, and can't wait to see what apps they give away starting next month!