Lee Kelleher

Archive for posts tagged with 'Code'

  1. Elegant Objects by Yegor Bugayenko

    Posted on

    At last month's Code Cabin, I was chatting with Steve Temple about Ditto and best coding practices, he suggested that I read Elegant Objects by Yegor Bugayenko, as it made him think totally differently about object-oriented programming. Looking around Yegor's blog, I liked his ideas, so I ordered the book ... I even noticed a small CSS bug on his blog and submitted a fix for it. I do love open-source! A day or so…

    Tags: ,

  2. Code Syntax Highlighting in Wyam

    Posted on

    I'd been going back and forth on how I should handle the syntax highlighting of my blog's code snippets. A popular choice would be to use a JavaScript library, (such as Prettify or Prism). I have nothing against those libraries, but in the pursuit of making my website fast and lightweight, I wanted a non-JavaScript option. My idea was to use a .NET library to convert my source-code snippets into colourised markup. The only library…

    Tags: ,

  3. Bulk Photo Resizing with ImageProcessor

    Posted on

    I'm currently on a month long holiday in Sri Lanka, taking a nice overdue break from work, (much respect to Rich for holding the Umbrella fort!). During my travels, I've been keeping a family blog - journal updates, add a few photos, etc. However the WiFi upload speeds at the various hotels we've been staying at have been painful slow; uploading a single photo (around 3Mb) to our blog or even Facebook is taking an…

    Tags: , ,

  4. How to use umbraco.library GetMedia in XSLT for Umbraco v4.5

    Posted on

    This is a quick follow-up on my previous blog post: “How to use umbraco.library GetMedia in XSLT“.  At the request of fellow Umbraco South-West UK developer, Dan, that I should update the code snippets for the new XML schema in Umbraco v4.5+ First a quick notice; if you are using v4.5.0, then please upgrade to v4.5.1, as there was a tiny bug in GetMedia that caused great confusion and headaches – you have been advised!…

    Tags: , , , ,

  5. How to use umbraco.library GetMedia in XSLT

    Posted on

    From time to time I notice a reoccurring post over at the Our Umbraco forum; how to display an image (from the Media section) in XSLT? A quick answer can be found on the Our Umbraco wiki for the umbraco.library GetMedia method. For most uses, the last example in the wiki works great.  But I want to show you a “super safe” way of dealing with GetMedia in XSLT. Where I find a lot of…

    Tags: , , , ,

  6. How to convert NameValueCollection to a (Query) String [Revised]

    Posted on

    Following on from a comment on my previous post about converting a NameValueCollection to a (query) string – I have finally got around to revising my code snippet.  Now the method will handle same key multiple values, (it no longer comma-separates them). I have also added extra parameters so that you can define your own delimiter (since the HTTP specification says that you can use both ampersands & and semicolons ;) and there is an…

    Tags: , , , , ,

  7. MySql data-source support for ELMAH

    Posted on

    Following on from my last post (a couple of months ago) about Integrating ELMAH with Umbraco, I received a comment if it was possible for ELMAH to use MySQL as a back-end data-source. After a few emails back and forth between myself and Rajiv, (as well as Rajiv’s requests over at the ELMAH support group), the advice was to simpily develop some code that implemented the ErrorLog class, (making use of the 3 core methods:…

    Tags: , , , , , ,

  8. Using jQuery to swap form fields

    Posted on

    Due to an technical decision early on in my project, the date-of-birth field on a profile edit page in a single text-input element.  My client would now like the date-of-birth to be 3 dropdown lists, (day, month and year).  The amount of work involved making changes to both the back and front ends would take at least a day. (It sounds a lot, but you know it would). Here’s where a front-end developer’s best friend…

    Tags: , , ,

  9. Populating multiple DropDownList controls with generic ListItem array

    Posted on

    I’ve just had some fun spending the last half-an-hour trying to figure out why when I used the SelectedValue property of a DropDownList, it also set the value of another DropDownList control. Here’s some background to the problem.  On my web-form, I have 2 fieldsets, one for a "Start Date", the other for an "End Date".  For each fieldset there are 3 DropDownList; Day, Month and Year. Now rather than populating the values declaratively, using…

    Tags: , , , , , , , ,

  10. How to best embed a WMV video clip?

    Posted on

    I hate to admit it, but I’m stuck… I’m trying to figure out how to best embed a WMV video clip in a web-page, so that it works cross-browser (and cross-platform). Even after all my years of web-development, I’m still confused to which browser supports which tag … nested <embed> tags in <object> tags … it gets messy! I’m as equally confused with the Class ID attribute: “CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6” – surely that can’t be the same…

    Tags: , , , , , ,

  11. How to convert NameValueCollection to a (Query) String

    Posted on

    Most ASP.NET developers know that you can get a key/value pair string from the Request.QueryString object (via the .ToString() method). However that functionality isn't the same for a generic NameValueCollection object (of which Request.QueryString is derived from). So how do you take a NameValueCollection object and get a nicely formatted key/value pair string? (i.e. "key1=value1&key2=value2") ... Here's a method I wrote a while ago: /// &lt;summary&gt; /// Constructs a QueryString (string). /// Consider this method…

    Tags: , , , ,

  12. Making Request.QueryString writable (by clone/copy)

    Posted on

    Every now and then I completely forget that the Request.QueryString (and Request.Form) object is read-only. Today I had a bit of functionality where I needed to remove a key/value from the collection - but the Remove() method (of the NameValueCollection object) throws an exception. Unfortunately, the Request.QueryString's CopyTo method assigns the values to an ARRAY, not a NameValueCollection - losing functionality and flexibility. You need to copy the Request.QueryString object to a new NameValueCollection instance,…

    Tags: , , , ,

  13. Upgrade WordPress Shell Script

    Posted on

    Now that I’ve found my new best friend (the sourcecode short-code), I want to put it to good use now. Here’s a quick Unix shell script that I use to upgrade my WordPress installations: #!/bin/sh # WordPress Update Script # Written by: Lee Kelleher # Released: 2008-04-23 # Email: lee # at # vertino # dot # net # Released under GPL echo "Downloading current version of WordPress..." wget http://wordpress.org/latest.tar.gz echo "Uncompressing WordPress archive..." tar…

    Tags: , , , , , ,

  14. Posting source code on WordPress.com

    Posted on

    I feel like a complete n00b … I’ve only just found out how to mark-up source-code snippets on WordPress.com It’s in their FAQs: How do I post source code? Essentially you use the short-code: [sourcecode language='css']...[/sourcecode] Here’s an example: // A "Hello World!" program in C# class Hello { static void Main() { System.Console.WriteLine("Hello World!"); } } I knew about WP.org plugins that did this, but I’ve been scratching my head on how do this…

    Tags: , , , ,