Del.icio.us – FavPal.NET is dead?

This sounds pretty unlikely, but I’m a new (and very enthusiastic) del.icio.us user (and have to think hard about where to put the dots every time I type it).  I guess you can’t jump on ‘every’ bandwagon.  I tend to discover stuff that I ‘need’ these days rather than get too ‘wowed’ by yet another networking site.


I developed a tool called FavPal.NET (don’t worry – I’m sure you haven’t heard of it!), a few years back as I saw there was nothing that allowed you to search through browser bookmarks with any degree of speed or accuracy.  It was a tray app that kept a ‘cache’ pool of IE instances (as load time was pretty bad back then), and allowed you to search through your favourites, then load up URL’s into a cached instance in double-quick time.  This served two purposes



  1. Search Favourites
  2. Load IE quickly

Del.icio.us obviously more than scores with requirement 1 as it allows you to keep your bookmarks centrally (BTW – I also use the IGoogle bookmarks gadget for ‘home page’ access to my most frequently used stuff).  One thing was still lacking – an ‘integrated’ search within the browser (or rather a search without having to point your browser to del.icio.us), but now there’s an IE extension (for IE6/7) that sits as a sidebar (nice).


I noticed there’s a Delicious.NET framework, and I’m still not terribly satisfied with the initial application load speed of any browser (even Firefox and Safari), so maybe FavPal’s not quite dead.  The search functionality could now simply hook into del.icio.us and still use the cache.  With tabbed browsing on IE7 now though the object model may well have changed.  If anyone wants to have a crack at it you’re more than welcome, and I’ll send you the code, as it got removed from the late lamented gotdotnet workspaces.


Of course the load speed will ineviatably go up with the more plugins like del.icio.us you bloat the browser with – d’oh!

Giving Guidance Explorer another go

I downloaded the Patterns and Practices ‘Guidance Explorer’ a year or more ago, and quite liked the idea.  I think the problem with any tool that tried to be a flexible storage and delivery method for ‘organic’ content (I’m interested in using it for development processes/standards etc) is viewed and searched by different people in completely different ways. 


Some like to dip into ‘reference’ material, some always ‘search’, and some people like to print everything and read cover to cover.  I know there’ve been some updates to the tool, and although the download count is still pretty low (3000 ish) I’ll give it another go and see if it works for me.


Other people just throw this stuff into docs and put it on SharePoint.  Others use something like WikidPad – which again I liked but ultimately got out of the habit of using – meaning it obviously didn’t work for me. 


Update


I just noticed that there’s no possible way of printing from Guidance Explorer, and so while I can understand the reasons why it isn’t implemented (to try and encourage people to write screen-consumable, concise content), it simply won’t work for the users I’m looking to target.  Shame 🙁

Using RSS.NET to re-write an existing feed XML file

Don’t know what happened to RSS.NET.  Looks like it’s trying to go commercial, but still very quiet.  Code examples are few and far between (with some simple ones on the site).  Also on InformIT.


I’m writing a quick RSS console app (as I lost the last one I wrote!) that I can use to write an RSS feed from a SubVersion hook.  Most people use a pre-existing tool for Python (can’t remember the name), but I thought I’d give RSS.NET another go just for kicks.


The example above works fine assuming you’re maintaining state somewhere other than the feed xml file itself.  The example also assumes you’re serving this up to the web.  You can override the RssFeed.Write() method to take a filename.


If run the same code again (assuming you’ve written to a file) it will simply overwrite it with one item (not add to it).  This isn’t what I wanted so…


You need to



  1. Read the file back in if it’s there – otherwise create
  2. Add your item to the existing channel if it’s there – otherwise create
  3. Fix the date behaviour as RSS.NET always assumes UTC dates and appends ‘GMT’.  The problem here is that if you’re in Australia (like me) reading and rewriting the same items will effectively add several hours on to existing items every time, because you write the date you read back in for existing items (read and parse into region-specific date, then write back as is).  There’s two ways to fix this:

    1. Before you add your new item – loop through all items and change the item.PubDate to item.PubDate.ToUniversalTime().  This effectively sets it back to the ‘correct’ date.
    2. Change the RSSWriter class in RSS.NET to convert ToUniversalTime for the Item.PubDate, Channel.PubDate etc.  This seems like a better option, but it has potentially more knock on effects in RSS.NET.  I’m here to achieve a result, not change the behaviour (possibly adversely) of RSS.NET so I chose option 1

So here’s the code.  Not finished yet and rough around the edges, but works as I need.  The intention is to avoid the need for config files and configuring up of feeds specifically.  I just want a library function that’s called by a console app.  The web serving will simply be based on the location of the file and pointing to some folder in IIS.


        private static void WriteFeed(string feedFileName, string feedName, string feedDescription, 
        string feedURL, string itemTitle, string itemDescription, 
        DateTime itemPublishDate, 
string itemURL)
        {
            
bool newFeed = false;
            
//Try and first open the feed (to see if it’s existing)
            
RssFeed feed = null;
            try
            
{
                feed 
RssFeed.Read(feedFileName);
            
}
            
catch (FileNotFoundException ex)
            {
                feed 
= new RssFeed();
                
newFeed = true;
            
}
            
catch (Exception ex)
            {
                WriteError(ex)
;
                return;
            
}

            RssChannel channel 
= null;

            
//Loop through all channels and if we’ve got the same title reuse
            
for (int 0i < feed.Channels.Counti++)
            {
                
if (feed.Channels[i].Title == feedName)
                {
                    channel 
feed.Channels[i];
                    break;
                
}
            }

            
if (channel == null)
            {
                channel 
= new RssChannel();
                
feed.Channels.Add(channel)//might blow up if already there?
            
}

            RssItem item 
= new RssItem();

            
item.Title itemTitle;
            
item.Description itemDescription;
            
item.PubDate itemPublishDate.ToUniversalTime();
            
item.Link = new Uri(itemURL);

            
//To ensure we don’t screw up existing dates – convert to UTC
            
foreach (RssItem existingItem in channel.Items)
            {
                existingItem.PubDate 
existingItem.PubDate.ToUniversalTime();
            
}

            
//Now add our new item
            
channel.Items.Add(item);

            
channel.Title feedName;
            
channel.Description feedDescription;
            
//channel.LastBuildDate = channel.Items.LatestPubDate();
            
channel.PubDate DateTime.UtcNow;
            
channel.Link = new Uri(feedURL);

            
feed.Write(feedFileName);
        
}



Colorized by: CarlosAg.CodeColorizer

 


 

Getting the most out of ASP.NET Web Deployment Projects

In my ongoing love (but mostly) hate relationship with ASP.NET Web ‘Site’s’ I’ve been using Web Deployment projects to make things more bearable. 


I currently swap in connection strings from 3 files – one for each build configuration (debug, test, release – connectionstrings.debug.config etc ).  This works fine as per the doco on WDP.  I use CruiseControl.NET and NAnt to automate builds, and a few nagging ‘automated’ pieces were missing from the puzzle. 



  1. Encryption of connectionStrings (or other web.config sections that you want to protect) – without affecting the ‘source’ file.  I’ve assumed here that ‘internal’ people are trusted. 
  2. Changing of other config stuff (like debug=false) in the test and release builds.  (My attempts to get this to work had previously failed as you don’t seem to be able to specify system.web as a replaceable section.
  3. Encrypting Forms authentication passwords, using MD5 hash.  This isn’t difficult, I just didn’t have a tool to generate the hash value.

Encryption of config sections


OK – after re-reading Scott Gu’s post on Web Deployment Projects, and K. Scott Allen’s post on how to simply encrypt sections of config files, I realised that I could just add a post-build event (manually) in the wdproj file (right-click in solution explorer –> open project file). 


The build events are already in but commented at the bottom of the file.  I ended up with

<Target Name=”AfterBuild”>
<Exec WorkingDirectory=”$(OutputPath)” 
Command=”C:\windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pef connectionStrings .”
/>
<!– Also remove our ‘source’ config files using the del command rather than the delete task as you
have to jump through hoops to specify wildcards –>
<Exec WorkingDirectory=”$(OutputPath)” Command=”del compilation*.config” />
<Exec WorkingDirectory=”$(OutputPath)” Command=”del connectionstrings*.config” />

</Target>


If I put this anywhere other than ‘AfterBuild’ it didn’t seem to do anything.  I certainly learnt a bit more about aspnet_regiis, as I’d only used it previously to ‘install’ ASP.NET.  I also had to specify the path to aspnet_regiis, but you could obviously use a property for this (I’m new to MSBuild – only dipping in when I have to, so the framework path may already be a standard property?).


Replacement of system.web sections


The key thing here (which I don’t believe was documented very well anywhere) is how to replace system.web elements.  Other typical replacements – e.g. appSettings or connectionStrings are children of the root config element.  You’d therefore assume that you need to replace the whole of system.web (which is a little inconvenient – but still worth it).  This doesn’t work and you’ll get a ‘nice’ WDP00002 error saying it can’t find the system.web element (a bit like saying ‘can’t find printer’ when it’s right next to the computer!). 


You just have to go one level down as follows (in the Deployment –> Web.config file section replacements property page):


system.web/compilation=compilation.release.config


compilation.release.config may be as simple as…

<compilation debug=”false”></compilation>

You might have a warning saying ‘compilation’ isn’t a valid element, but this is just the intellisense barking as it validates against the config schema.


Encrypting Forms Authentication Passwords


This is pretty simple and there’s lots of docs to support this, but I wanted a simple tool to generate the hash for a given string, and a quick google yielded a nice little command-line tool


This way you can plug it into your build if you need to, but also replace for different environments using the techniques above.


Programmatically add Meta Tags to ASP.NET Master Pages using a SiteMap

I hadn’t really used SiteMaps before, but it’s a useful feature of ASP.NET 2.0 (most people using them to drive BreadCrumb controls and site navigation).


After realising there was no support for design of the sitemap (apart from the default text editor) I found a simple (and functional) SiteMap editor here.


I then realised that I needed to add meta tags for each page in the site (NOTE: this is a simple ‘content’ site, so don’t come running to me if you have the need to generate specific tags based on what colour trousers the user is wearing!).


You can add new attributes very easily to the sitemap, and access them programmatically.  The editor has a nice little grid to make this extra easy for you.  In my example here we’ve added a ‘keywords’ attribute. 


Assuming you’re using a treeview (or something similar) for navigation on your site and you’re binding to the SiteMap data source, then you’ll get the context of the current site map node in your page (or master page).


You can then use it to set your meta tags as follows:



You can also set Page.Title from currNode.Title etc.


This is actually quite a neat way to drive things like other standard properties of your master page – e.g. subheadings. 

Free Visual Studio 2005 Addins

I’m currently without ReSharper (eek), so am trying to make the best of it.  Looking around for VS 2005 addins (that I haven’t already got), I stumbled across a few resources….


Carl J has a list of Free Addins, and, wait – there’s another list


Not forgetting Hanselman’s (old) list


I’m sure there’s more, but I don’t want to overcapitalise and slow my machine down more than Resharper did (maybe I should look at CodeRush?)

Google Gadget for Connex Melbourne Service Status

I was playing around today and knocked up a quick Google Gadget (for use with iGoogle) for people in Melbourne to monitor the status of the train services delivered by Connex.  This is available on the Connex site, but conveniently sits in its own frame and so was easy to port to a ‘gadget’.


No real rocket science (and the gadget editor’s a bit buggy) – but I love the concept…



Click Add to Google to add it to your iGoogle Page


I’ve posted it to the ‘directory’ so it will hopefully be accessible from the main ‘gadget search’ soon…

Windows Powershell – Batch files with knobs on

Just downloading a few .NET 3.0 bits and pieces from MS and happened across some ‘you might like to download this’ links.  Once of which was Windows PowerShell.  Haven’t tried it yet, but will certainly give it a go in my next ‘scripting’ escapade.

Microsoft have obviously developed this quite a lot based on the amount of documentation I’ve not had chance to look at yet!

Update in 2018 – things have obviously moved on for PowerShell – so much so you may need a cheat sheet to find your way around.