Tim

Footprints in the snow of a warped mind

Development

Where to find me

Flickr Icon  Twitter Icon  Linked In Icon  FaceBook Icon  Windows Live Alerts Butterfly  RSS 2.0 

Tag Cloud

AJAX (4) ASP (6) ASP.Net (52) Error Reporting (4) Web Service (2) WSDL (1) Atlas (2) Business (76) Business Start-up Advice (25) Client (14) Expanding Your Business (17) C# (17) Canoeing (4) Canoe Racing (5) Cheshire Ring Race (5) Racing (2) Training (4) CIMA (1) Cisco (1) 7970G (1) CSS (3) dasBlog (4) DDD (1) Design (9) Icons (1) Development (13) eCommerce (1) General (39) Christmas (6) Fun and Games (11) Internet (22) Random (46) RX-8 (8) Home Cinema (2) Hosting (2) IIS (10) iPhone (1) JavaScript (4) jQuery (1) Marketing (5) Email (1) Multipack (1) Networking (2) Nintendo (1) OS Commerce (1) Photography (1) PHP (1) PowerShell (2) Press Release (1) Productivity (2) Security (2) SEO (5) Server Maintenance (4) Server Management (9) Social Media (1) Social Networking (2) Experiment (1) Software (9) Office (5) Visual Studio (12) Windows (4) Vista (1) SQL (1) SQL Server (13) Stored Procedure (1) Testing (1) The Site Doctor (106) Turnover Challenge (1) Twitter (2) uCommerce (1) Umbraco (18) 2009 (1) Web Development (57) WebDD (33) Wii (1)

Blog Archive

Search

<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

Recent Comments

Blog Archive

Various Links

Blogs I Read

[Feed] Google Blog
Official Google Webmaster Central Blog
[Feed] Matt Cutts
Gadgets, Google, and SEO
[Feed] Ol' Deano's Blog
My mate Dean's blog on my space, equally as random as mine but not off on as much of a tangent!
[Feed] Sam's Blog
Sam is one of my younger brothers studying Product Design and Manufacture at Loughborough, this is his blog :) Enjoy!

Recent Tracks

last.fm - The Social Music Revolution

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

newtelligence dasBlog 2.2.8279.16125

Send mail to the author(s) Email Me (Tim Gaunt)

© 2010 Tim Gaunt.

Sign In

    # Wednesday, August 18, 2010

    Developer Pitfall: When to call it quits on a problem

    Wednesday, August 18, 2010 4:50:07 PM (GMT Daylight Time, UTC+01:00)

    frustration[1]We’ve all done it, you’ve run into a problem while developing which you bash at for a few hours and before you know it, you’ve lost the day, not got anywhere and feel completely frustrated. What’s more, is it’s usually something so screamingly obvious and/or simple that you just know you’ll find the answer on Google.

    Rather than pulling your hair out for hours on end, there’s a rather simple rule-of-thumb that you should follow:

    If you’re able to bash at it for 30 minutes without feeling you’re getting any closer, you’re probably looking at it from the wrong direction and having someone else’s perspective on the problem will probably answer it within seconds. By walking away from the problem you’re also taking away the pressure and you’ll often find the solution comes to you.

    Another advantage of putting a time limit on the issue is it avoids you losing the day and should also mean you’ve explored Google and the lists so when you ask your “friend”, it should stop you getting that annoying lmgtfy response when asking for help (it’s a similar concept to the “wait 1 minute before sending” facility within Outlook).

    So the next time you realise something’s taking longer than you think it should, start the timer!

    # Wednesday, April 21, 2010

    Stop jQuery.hide() showing the elements on page load

    Wednesday, April 21, 2010 10:30:25 PM (GMT Daylight Time, UTC+01:00)

    This is a great little tip that Andy Higgs shared with me a couple of months ago while we were developing Crisis Cover. If you write jQuery that hides the div when the user has JavaScript enabled, you can avoid the divs all being shown while the page loads by simply adding a class to the body of the page using jQuery and hide it using CSS like so:

    <html>
    <head></head>
    <!-- Reference to jQuery here -->
    <body>
    <!-- This should be the first bit of code and don't wait until the page has loaded -->
    <script type="text/javascript">$('body').addClass('js');</script>
    <!-- The rest of your code here -->
    <div class="jsHide">
    	<p>This paragraph is hidden if the user has JavaScript enabled.</p>
    </div>
    </body>
    </html>

     

    Then you just need to add the css:

    .js .jsHide

    Your divs will now be hidden until you show them with JavaScript. Nice, simple solution to an ever annoying problem.

    Note: For my demo to work you'll need to include jQuery

    Update: As pointed out by Petr below and Andy Higgs/Trevor Morris, it would be better to target using JavaScript without jQuery and target the body for maximum flexibility (note the space at the front in case there is already a class):

    <script type="text/javascript">document.getElementsByTagName('html')[0].className+=' js'</script>
    # Saturday, February 27, 2010

    Collapse all Solution Explorer items in Visual Studio 2010

    Saturday, February 27, 2010 12:22:48 PM (GMT Standard Time, UTC+00:00)

    Ever wanted to be able to collapse all items within Visual Studio's solution window? This is a nifty little Visual Studio macro that I came across a few years ago and have been using successfully in Visual Studio 2005, Visual Studio 2008 and now in the Visual Studio 2010 RC.

    I'll overview how to install it below in case you're unsure how to do it but I have this bound to the key combination Ctrl+Shift+` as ReSharper now uses my previous key combination of Ctrl+` for it's new bookmark explorer.

    Anyway, here's the Visual Studio Solution Explorer item Collapse All macro:

    Imports System
    Imports EnvDTE
    Imports EnvDTE80
    Imports EnvDTE90
    Imports System.Diagnostics
    '-----------------------------------------------------------
    ' CollapseAll Module
    '-----------------------------------------------------------
    ' Simple macro that fully collapses all items in the 
    ' Solution Explorer rather than just the top level node
    '
    ' To make live easier, bind it to a keyboard setting such
    ' as Ctrl+Shift+` which by default has no bindings (Ctrl+` is
    ' now used by Resharper
    '
    ' Tested and works with:
    ' Visual Studio 2005
    ' Visual Studio 2008
    ' Visual Studio 2010
    '
    ' Originally from: http://bit.ly/bmRu3W
    '-----------------------------------------------------------
    Public Module CollapseAll
    
        Sub CollapseTree()
            ' Get the the Solution Explorer tree
            Dim solutionExplorer As UIHierarchy
            solutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object()
    
            ' Check if there is any open solution
            If (solutionExplorer.UIHierarchyItems.Count = 0) Then
                Return
            End If
    
            ' Get the top node (the name of the solution)
            Dim rootNode As UIHierarchyItem = solutionExplorer.UIHierarchyItems.Item(1)
            rootNode.DTE.SuppressUI = True
    
            ' Collapse each project node
            Collapse(rootNode, solutionExplorer)
    
            ' Select the solution node, or else when you click 
            ' on the solution window
            ' scrollbar, it will synchronize the open document 
            ' with the tree and pop
            ' out the corresponding node which is probably not what you want.
            rootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)
            rootNode.DTE.SuppressUI = False
        End Sub
    
        Private Sub Collapse(ByVal item As UIHierarchyItem, ByRef solutionExplorer As UIHierarchy)
            For Each innerItem As UIHierarchyItem In item.UIHierarchyItems
                If innerItem.UIHierarchyItems.Count > 0 Then
                    ' Re-cursive call
                    Collapse(innerItem, solutionExplorer)
                    ' Collapse
                    If innerItem.UIHierarchyItems.Expanded Then
                        innerItem.UIHierarchyItems.Expanded = False
                        If innerItem.UIHierarchyItems.Expanded = True Then
                            ' Bug in VS 2005
                            innerItem.Select(vsUISelectionType.vsUISelectionTypeSelect)
                            solutionExplorer.DoDefaultAction()
                        End If
                    End If
    
                End If
            Next
        End Sub
    End Module

     

    In case you've never installed a Visual Studio macro before, here's a couple of instructions:

    1. In Visual Studio, press Alt+F11 to load up the Visual Studio Macro editor (or View > Other Windows > Macro Explorer > Double Click on "Module1" in "My Macros")
    2. Either create a new module of it it's not in use, you can edit Module1 and past in the code above
    3. Save and close the Visual Studio Macro editor
    4. You should be back in Visual Studio so click "Tools > Options > Environment > Keyboard"
    5. In the "Show commands containing" text box, enter "CollapseTree" and the macro you just created should be shown.
    6. Make sure "Global" is selected in the "Use new shortcut in:" drop down list
    7. Press Ctrl+Shift+` in the "Press shortcut keys:" text box
    8. Click Assign
    9. Click OK

    You're done :)

    # Tuesday, May 12, 2009

    C# FileInfo.MoveTo Cannot create a file when that file already exists exception

    Tuesday, May 12, 2009 8:39:35 PM (GMT Daylight Time, UTC+01:00)

    This was one of those irritating errors that you get when you're trying to do something quickly before you go home and you can't for the life of you fathom the issue.

    I had the following code (simple enough):

    FileInfo f = new FileInfo("## File's Path ");
    try
    {
        f.MoveTo("## DROP OFF DIRECTORY ##"));
    }
    catch (Exception e)
    {
        //Log the exception here
    }

    The fix was simple, you just have to remember to specify the new filename too. (DOH!). Here's the "correct" code.

    FileInfo f = new FileInfo("## File's Path ");
    try
    {
        f.MoveTo(Path.Combine("## DROP OFF DIRECTORY ##", f.Name));
    }
    catch (Exception e)
    {
        //Log the exception here
    }

    Hope that helps you out ;)

    # Friday, April 17, 2009

    Quick ASP.Net tip: Half your page size in ASP.Net instantly

    Friday, April 17, 2009 3:53:05 PM (GMT Daylight Time, UTC+01:00)

    Ok it might be a little less than half side but it's near enough. I've been sitting on this for a while and needed to reference it for someone so I thought I'd post quickly about it. One of the most common complaints about .Net is that you have a lot of hidden "content" by the way of hidden inputs and the likes throughout your site. This can easily get corrupt on postback/slowdown the page load times etc.

    Really you should be optimising each control on the page (enabling/disabling where relevant) but if you want to cheat (lets face it, we all do):

    1. Download the files: PageStateAdapterv1.0.zip (3KB)
    2. Put PageStateAdapter.browser into your /App_Browsers/ folder (or create one and add it)
    3. Put TSDPageStateAdapter.dll into your website's /bin/ folder
    4. Load up your website and checkout your ViewState :)

    Incase you're interested in the source for it:

    PageStateAdapter.browser

    <browsers>
        <browser refID="Default">
            <controlAdapters>
                <adapter controlType="System.Web.UI.Page" adapterType="TheSiteDoctor.PageStateAdapter.PageStateAdapter" />
            </controlAdapters>
            <capabilities>
                <capability name="requiresControlStateInSession" value="true" />
            </capabilities>
        </browser>
    </browsers>

    PageStateAdapter.cs

    using System.Web.UI;

    namespace TheSiteDoctor.PageStateAdapter
    {
        public class PageStateAdapter : System.Web.UI.Adapters.PageAdapter
        {
            public override PageStatePersister GetStatePersister()
            {
                return new SessionPageStatePersister(this.Page);
            }
        }
    }

    The best example of how much this reduces ViewState by is when you add a large DataGrid to your site.

    Post files: PageStateAdapterv1.0.zip (3KB)

    Update: Apologies to those of you who downloaded and found it wouldn't compile, the .browser file was a little off (missing the second "PageStateAdapter"). I've updated it and changed the zip file download. Enjoy!

    # Wednesday, November 26, 2008

    IE classes DDD feedback site as a phishing site…

    Wednesday, November 26, 2008 1:00:05 PM (GMT Standard Time, UTC+00:00)

    This one made me laugh today, Chris Anderson alerted me to it but you would have thought the MS guys would have picked up on it...

    2008-11-26_1151.png

    Incidentally, it's the first time I've seen this message on any site...

    2008-11-26_1152.png

    # Wednesday, September 03, 2008

    Clean out unused media items from Umbraco media folder

    Wednesday, September 03, 2008 5:15:14 PM (GMT Daylight Time, UTC+01:00)

    When uploading some new media items for a client today we noticed that if you selected "Remove" before saving, it doesn't actually remove the file from the FileSystem. Having a quick look around the forums I saw there are a few posts already pointing this out so I thought I'd fix it.

    This is a little application that simply checks the media items in the database and then compares it against a folder you select on your machine. If the file is in use according to the database then it's ignored otherwise it will remove it.

    To use:

    1. Enter your server's login details
    2. Click "Test Connection"
    3. Select the relevant database from the drop down
    4. Check the "Media Folder Name" matches your Umbraco's installation
    5. Locate your Media Folder on your computer
    6. Click "Check Media Folder" -this will then list all the orphan files
    7. If it looks right, click "Delete" -with caution
    8. Job done

    There are a few checks in place to avoid mishap but it's not 100% foolproof as I needed something rough and ready to sort a couple of installations out. If this is something that's seen as useful I'll extend it a touch, some ideas I've got already:

    • Check that the selected media folder matches that of the database
    • Check that the media id's are the same (to avoid wiping another installation)
    • Save config settings for easy re-use
    • Use webservices rather than a direct connection to the database
    • Enable FTP useage

    Please note: I accept no responsibility if anything was to go horribly wrong with this. I would backup your folder first just in case!

    You can download the MediaFolderCleaner application here

    # Tuesday, July 15, 2008

    How to: Convert Hexadecimal Strings

    Tuesday, July 15, 2008 10:25:56 AM (GMT Daylight Time, UTC+01:00)

    As it's my Birthday today I thought I'd post a silly ditty. I'm currently altering Protx's old ASP.Net library to accommodate their changes in regards 3D Secure and while reflecting some of the code came across an enum with their number representations as Hexadecimal strings. I needed to convert these to decimals so thought I'd share a quick and easy way to do it.

    Open up Window's Calculator (Windows Key + R then type in calc) under the View menu select "Scientific". Press the F5 key to switch over to Hex entry. Type in the value after the 0x and hit F6

    Simple, easy and will help you convert all those Hexadecimal strings (ones that look like this: 0x01 or 0x1a).

    Right, time for a coffee :)

    How to: Convert Hexadecimal Strings
    Useful Links:  #  digg it!  del.icio.us  Technorati  email it!  Post CommentsComments [2]  Trackback LinkTrackback
    CategoriesTags: C# | Development
    # Saturday, June 21, 2008

    UK Umbraco meet up

    Saturday, June 21, 2008 12:17:58 AM (GMT Daylight Time, UTC+01:00)

    In a previous post about CodeGarden 08, I asked people to get in touch if they'd be interested in a UK Umbraco meet up. I've had a fair few people get in touch so I think it's something worthwhile pursuing further. The nest stage from my POV is working out the location and potential content of the meet so I thought I'd open it up to the floor.

    With the forthcoming DDD7, I thought it might be a ready-built platform that we could use but I agree with Phil that DDD7 may not be a suitable platform for a multitude of reasons.

    As I've had people from the South West and Scotland voice an interest, I don't think it'll suit the majority of people to have it based in London so suggest it is based in the Midlands -probably Birmingham as it's easy to get to (M6 from the North, M4 from London, M5 from the South -or train!) and there are plenty of places to have the meet.

    In regards the format/content of the meet, does anyone have any suggestions? We could follow Niels' and Per's open format or we can have a more structured theme? I've not had too much of a think as to subject matter but some I have come up with so far:

    • An introduction to Umbraco and what it is (many of the people I've spoken to have only just started using Umbraco)
    • Examples of Umbraco how Umbraco can be used
    • More advanced Umbraco functionality (membership etc)
    • Getting to grips with XSLT
    • How to sell Umbraco to your clients

    So that's where I've got to so far, does anyone have anything to add?

    BTW the logo is just a working logo atm, need to have Niels approve it ;)

    Update: I have posted a post on the Umbraco forums about a UK Umbraco meet here

    UK Umbraco meet up
    Useful Links:  #  digg it!  del.icio.us  Technorati  email it!  Post CommentsComments [4]  Trackback LinkTrackback
    CategoriesTags: Development | The Site Doctor | Umbraco | Web Development
    # Wednesday, June 18, 2008

    Talk about a confusing error message

    Wednesday, June 18, 2008 11:37:58 PM (GMT Daylight Time, UTC+01:00)

    I don't mind when I get told I've made a mistake -or there's a problem with the system but this error message kinda takes the P! Quite what the developers were thinking when they wrote this one I'm not sure!

    What do I do? celebrate that it went through ok or commiserate because it failed?

    The "Ok." relates to the transaction completing without an issue, the "Stop" actually says that it failed so it's not even "Part A was ok, but Part B failed". Really odd, someone needs to look into testing their system.

    Looks pretty though!

    Talk about a confusing error message
    Useful Links:  #  digg it!  del.icio.us  Technorati  email it!  Post CommentsComments [2]  Trackback LinkTrackback
    CategoriesTags: Design | Development | Random | Testing
    # Tuesday, June 10, 2008

    CodeGarden 08 -been there, done that, got the t-shirt!

    Tuesday, June 10, 2008 7:18:53 PM (GMT Daylight Time, UTC+01:00)

    So things have been manic here the past week, for those of you who didn't know, I popped over to Denmark at the last minute to attend Umbraco's CodeGarden 08. It was great fun and I have to thank Niels Hartvig and Per Ploug Hansen for putting on a great couple of days.

    You can check out my photos from the event on Flickr (bear with me, I'm just getting started with Flickr).

    I'm sure a fair few people have blogged about the highlights (if you're interested check www.umbraco.org) but the biggy was announcing the release of Umbraco v3.14.0 which is pretty exciting news as it has a ton of feature enhancements and UI improvements. Also, you'll be pleased to hear that they're making 2008 the year of Umbraco documentation!

    Another interesting points from the conference was the pending release of Umbraco.TV which will feature tutorial videos and insights from the core team on how to use Umbraco and the Umbraco store which allows you to easily distribute the packages you make :) All in all some interesting developments.

    There were also a fair few English developers at the conference so discussion inevitably turned to a UK meet (I know there are a fair few designers and developers here that couldn't justify the expense) so that's something that I'm going to look into setting up. If this is something you'd be interested in, leave a comment or drop me an email and we'll see how much interest there is.

    To all the rest of you -it was great to meet you, you're all a lovely bunch and I look forward to meeting you again at CodeGarden 09!

    The other thing I've finally clarified (this is for you Simon!) is the Umbraco licensing rules so if you're unsure on those, check out my post on when you need to purchase an Umbraco license (the answer is always -or never, it's up to you!).

    # Monday, June 09, 2008

    When do I need to buy an Umbraco license?

    Monday, June 09, 2008 6:16:00 PM (GMT Daylight Time, UTC+01:00)

    This may seem a slightly obvious/silly post but the answer is simple -it's just not *that* well documented/explained.

    In a nutshell there are three scenarios you need to worry about:

    • Using Umbraco in a non-commercial environment with the branding (logos etc) intact -no fee
    • Using Umbraco in a commercial environment with the branding (logos etc) intact -no fee
    • Using Umbraco in a commercial environment without the branding (logos etc) -fee

    So there you have it. But to be fair, you should always pay for it if you're using it in a commercial environment just because it's a great product (and it's good for your karma!)

    # Thursday, May 29, 2008

    A seriously elegant SQL Injection -how it was sorted

    Thursday, May 29, 2008 3:32:33 PM (GMT Daylight Time, UTC+01:00)

    Doug Setzer posted this comment in response to my recent "A seriously elegant SQL Injection" post and I thought it may be of interest to others so have promoted it to a post...


    Well, I'll step up and say that I am the "mate" who had this done.  Tim's right - *always* sanitize your inputs.  In my defence, this was a site that I inherited from a previous contractor.  I'm not entirely absent of blame, I still should have done a security sweep through the code.

    I'd like to document the steps that I went through once this was identified to try and avoid this kind of thing in the future.

    1. Edit every web page that executes a query to sanitize any parameters that are passed in.  Since the site was classic ASP, I used my "SQLStringFieldValue" function:
      www.27seconds.com/kb/article_view.aspx?id=50
    2. Modify the DB user account that is used to have *read only* access to the database
    3. Modify the pages that DO write to the database to have *read/write* access to the specific tables that are being changed.  This limits the number of places that SQL Injection can occur to a smaller set than was previously possible.  I still sanitize all of my input, but I'm extra spastic in these database calls.
    4. Add database auditing (triggers writing to mirror tables with audit event indicator & date/time) to see when data changes occur.  This is still problematic with the pages that have "write" permissions to the tables, but again- that footprint is much smaller.
      My future plans are to move to a view/stored procedure based architecture.  I can then limit write permissions to just the stored procedures and read permissions to just the views.  My grand gusto plans are to move to using command objects & parameters, but I'd sooner re-write the entire site.

    Although Doug's attack wasn't the same nihaorr1.com attack that's going around atm it was similar so I would imagine other's will find this useful.

    It still amazes me how many developers still fail to sanitise strings, only last week I came across another site (in PHP) that was allowing simple SQL injections to be used to log into their administration system. It was down to a problem with the sanitization string, but why not at least check your site before it goes live? It takes 2 minutes and even less to fix...

    For those of you who need a few pointers, there's a good discussion or two about sanitising strings on the 4 Guys From Rolla site.