Code Snippets

Over the years as a Web Developer, I've learnt a lot and written many lines of code. Not every line is unique though, thanks to code re-use and the adaptability of websites.

I've accumulated a small pile of code snippets, in the form of text files, bookmarks and scraps of paper. However, finding that method for checking NULL values in C# or the syntax for a cursor in SQL can prove to be time consuming - resorting to a Google Search yet again.

So, I decided to finally put all of the snippets in the one place, for referencing during my day to day work as a Developer. Behold: snippets.slickhouse.com

There's already a few on there in various languages that I've dealt with in the past (and continue to). The site is also powered by SlickCMS - with several adaptions to fit the style, such as simplified Post listings and custom URLs to allow for the same named snippet, but differing Languages.

The style is also inspired by the excellent stackoverflow.com - itself a vital source of information for a Developer. I did plan to make the site open to the public, so that you too could add your own snippets - but I felt that you'd either prefer to roll your own (go ahead and download SlickCMS to get yourself started) - or to use an established service, such as snipplr.

Let me know what you think as always - and feel free to keep checking the snippets site, as I'll be adding many more over the next few days.

comments Posted: Wednesday 6th October 2010, 16:30pm
Categories: SlickCMS
Tags: slickhouse

5th November of Slickhouse

Take a look to the right and you'll see 5 lots of Novembers in the Archive:

Which makes this blog 4 years old! A lot has happened in the past 4 years, including 2 jobs (with a slight career change); visiting Africa twice; becoming a Dad; getting married; becoming a Dad again.

Hopefully I'll be looking back in another 4 years stating that slickhouse.com is 8 years old. Over the coming months into 2010, I plan to make a few strategic changes to the site and increase its popularity. I've learnt a wealth of knowledge working as a Web Developer since May 2007, so I'd like to publish a few articles along those lines too. And my side-project SlickCMS has been rolled out to several sites, so I figure it's now time I bite the bullet and switch from WordPress. There's a bit more functionality still to add, such as RSS feeds and Archives - but once they're done Slickhouse will be powered by SlickCMS.

Don't get me wrong: WordPress is a fantastic piece of Web Publishing Software, it's just that after 4 years I feel it's time to put what I've learnt from using it to good use and develop my own. Besides, I'm an ASP.NET/SQL Developer and my PHP knowledge is dwindling in comparison.

comments Posted: Saturday 14th November 2009, 16:30pm
Categories: SlickCMS, Slickhouse, Web
Tags: slickcms, slickhouse

Speed improvements

Inspired by a few articles I came across recently, namely:

I decided to embark on improving page load times on slickhouse.com - mainly by migrating the content to a separate domain, which would be cookie-less. This provides performance improvements in 2 main ways:
  1. Increasing the number of simultaneous requests
  2. Reducing the size of the requests/responses to and from the server(s)
Slickhouse.co.uk has been registered for a while, but simply used as a pointer to slickhouse.com, so it made sense to use it as the site for serving static content.

1) is achieved by serving the images, css and javascript files from a separate source to the HTML pages. So as you're busy downloading the homepage from slickhouse.com the images are being downloaded from slickhouse.co.uk - bypassing the 2 HTTP requests limit set by the HTML specification.

2) is achieved in the same way, by switching off cookies on slickhouse.co.uk - which in turn, can help reduce the request/response sizes and thus the page load times.

My initial testing has shown a noticeable improvement, though I don't have any metrics to share. I used Microsoft's Fiddler tool to profile the load times and was surprised how much external content the site uses, from 3rd parties. The twitter feed on the right is 2 requests alone and the Google Map that was tucked away in the site's footer added a further 20 or so. This gave a sluggish feel to the site as each page loaded.

So I updated the theme files and removed some of the excess requests, to bring it down to ~14 for the homepage. It's still high and could be improved further using CSS sprites. But I'll save that for the next version.

To summarise, splitting your static content from the dynamic pages helps increase page load times. It also allows for future expandability, as the static content could be hosted on a separate server, or even on a cloud/CDN solution.

comments Posted: Friday 13th November 2009, 16:30pm
Categories: Links, Slickhouse, Web
Tags: cookies, iis, slickhouse

media.slickhouse.com

A few months back my (now) sister-in-law was looking through our DVD collection to find a few to rent, when she suggested I should have a list of them all - as it would be easier to find.

So, I decided to make a simple web application that would store all of the DVDs and games within a database, allowing friends and family to browse the catalogue and to 'rent' any they wished. The application itself was easy to create, the time consuming part was entering all 321 items into the database! It took Anneka and I about 8 hours spread over several evenings. The result is:

media.slickhouse.com

Have a look, filter the collection and view the individual DVDs/games. Let me know if you find any issues too - as it's still in development. I plan to add several more features including:

Let me know if you have any suggestions for additional features or if you're interested in the source code. We were a little surprised with the 321 items in total - I had estimated over 400, but if you split out all the box-sets then it's fairly close to the latter!

comments Posted: Thursday 1st October 2009, 16:30pm
Categories: Games, Slickhouse, Video, Web
Tags: dvd, media, slickhouse, xbox-360

Plenty of downtime!

Apologies if you've tried to visit this site over the past week or two and have encountered an error of sorts. The servers that slickhouse is hosted on have been down several times, due to human errors, for once!

The first time, I had setup a new virtual server (2003), equipped with Active Directory and DNS. After testing AD locally on my workstation, I decided to roll it out by connecting each server in turn to the domain. Unfortunately, I forgot about Windows Update, which proceeded to install updates on each server in turn - which was the first stage of the downtime. Once the main host server had restarted, it then performed a chkdisk that I had scheduled some months ago (to begin on the next restart). This took the whole night!

As the host server is a single core affair, the start-up of each virtual server takes a good 30 minutes, to ensure everything is back up and running as before. So that added more downtime, to the already growing 12+ hours.

The second set of downtime was last night - I had moved the anti virus (Symantec AV) from the host server itself, to one of the virtuals. Bad mistake. When the scheduled scan kicked in at 3am, it brought the whole platform down, 4 virtuals and the host. So that was another 18+ hours!

I've since switched the anti virus back to the host server and have opted for Clamwin, a great Open Source program, that works on Windows workstation and server operating systems. If all goes to plan, it will do its stuff tonight without a blip of performance loss.

So, the moral of the story? There are several in this instance:

  1. Regularly install updates on servers, so that when it comes to a shutdown/restart they won't interfere with things
  2. Plan downtime a good few hours before you go to bed, in case anything goes wrong in the process
  3. Use chkdisk startup scans with caution - and remember when you've scheduled them
  4. Don't break something if it already works, such as moving anti virus duties from a host server to a virtual, when the host was scanning them fine for the past 2 years without a hiccup
  5. Don't port forward RDP to a virtual server, so that when the platform goes down, you cannot connect externally to restart it all
The last point [5] is particularly important - ensure that you can still access the main host server (Server 2003 w/Microsoft Virtual Server in this instance) if all virtual servers are down.

Be patient if you experience downtime in the near future - at least now you know it's most likely due to a human error on my behalf!

comments Posted: Thursday 6th November 2008, 16:30pm
Categories: Computers and Technology, Slickhouse, Web
Tags: slickhouse, virtual-server