Weekly Tweet Update 14-03-2013

Posted in General | Tagged , | Leave a comment

IEnumberable.Max and Nullable types

Came across an interesting little snippet of code today.

var max = list.Max(i => i.Value)

This simply returns the maximum value of the "Value" property in the list. However there is a possible problem with this code, depending on the type of Value and the number of elements in the list.

If there are NO elements in the list and Value is NOT nullable (e.g. it is a Integer) then the above will throw an exception.

If there are NO elements in the list and Value IS nullable then it will return NULL.

var max = list.Max(i => i.Value ?? 0)

If the list is empty and Value IS nullable then the above will also throw an exception.

var max = list.Max(i => i.Value) ?? 0

If the list is empty and Value IS nullable then the above will return 0.

Posted in Code | Tagged , , | Leave a comment

Image widths in emails

While hacking around trying to include some images in an email I was trying to set the height and width of the IMG tag. This wasn't working at all (which I had read about) but then I put the images in a table with a cellpadding and all of a sudden the images are being resized.

Not sure why that is but thought it might help anyone trying to do the same thing.

<table cellpadding="1">
<tr><td><img width="100" height="50" src="https://www.google.co.uk/images/srpr/logo3w.png" /></td></tr>
</table>

Note: Only really tested in Outlook 2010, so might not work in other email clients.

Posted in Code | Tagged , , , | Leave a comment

Weekly Tweet Update 03-01-2013

Posted in General | Tagged , | Leave a comment

Weekly Tweet Update 11-10-2012

Posted in General | Tagged , | Leave a comment

Weekly Tweet Update 27-09-2012

Posted in General | Tagged , | Leave a comment

Weekly Tweet Update 13-09-2012

Posted in General | Tagged , | Leave a comment

Weekly Tweet Update 16-08-2012

Posted in General | Tagged , | Leave a comment

FlickrNet 3.5 Release

Just a quick post to say I've release version 3.5 of the FlickrNet API library.

A couple of things regarding this version and the FlickrNet library roadmap:

  • This will be the last version to support the old Authentication model. Going forward only oauth will be supported.
  • This will also be the last version to support .Net Compact Framework.

Going forward I also hope the next version will support Windows Runtime as well, at least for .Net applications (not sure about JavaScript/C++ support yet).

Download it fromĀ http://flickrnet.codeplex.com/Ā or get it via NuGet.

Posted in Code | Tagged , , | Leave a comment

Weekly Tweet Update 09-08-2012

  • Microsoft Attack Surface Analyzer 1.0 Released - Another tool to look at adding into my development pipeline. http://t.co/JMnPu9v9 ->
  • Exiting a batch file without exiting the command shell -and- batch file subroutines - Batch file subroutines?… http://t.co/Ll4wdC6J ->
  • NCrunch for Visual Studio - Loving this wonderful tool for unit testing http://t.co/tTPcCdCM ->
  • Productivity vs. Guilt and Self-Loathing - Scott Hanselman - Something I agree wholeheartedly with. http://t.co/ma443pAe ->
Posted in General | Tagged , | Leave a comment