Hey I'm Lee. My blog was put up to house my strange thoughts, ramblings, nuggets of information I can refer back to and document my learning curves on new dev stuff and fitness regimes.

All thoughts and comments on here are my own, and in no way reflect my employer - I also take no responsibility for spelling, grammar, terminology, accuracy of facts etc... So read at your own risk!

Nofollow All External Links In Html Page Using HtmlAgilityPack

A little method to find auto find and mark external links in a block of HTML as nofollow and add a custom class to them. public static string NofollowExternalLinks(string html, string externalClassName = "external") { var doc = new HtmlDocument(); doc.LoadHtml(html); foreach (var link in doc.DocumentNode.SelectNodes(@"//a[@href]")) { var att = link.Attributes["href"]; if (att == null) continue; ...

Read More
Posted by
Lee

Export All nopCommerce Blogs Or Products Into Xml (In Fact Any Db Table)

There is a really cool feature that not many people know about in SQL Management Studio. Exporting to XML. All you need to do is use the following line after your query FOR XML AUTO So for example we could get all nopCommerce blog posts like so (The reason we use 'As BlogItem' is so we get a known xml element) SELECT BlogPostTitle ,BlogPostBody ,CreatedOn FROM Nop_BlogPost As BlogItem FOR XML AUTO This would give us...

Read More
Posted by
Lee

How To Use The nForum Source To Debug Your Forum

I get a lot of questions on our.umbraco about problems using nForum in existing websites. 99% of the time it's impossible to diagnose, as I have no idea how the package has been moved around or changed. First thing to do if you are having problems is check the installation. Checking Installation This post below, was written for v1.X+ to v1.6 and covers all the basic things to check. For v1.7+ everything applies to check, EXCEPT ...

Read More
Posted by
Lee

New Training Routine

I've been doing pretty much the same training regime for a while. I had little variations, where I'd try a kettle bell session of some other session that was on at the gym. I was doing some reading at the weekend and I found Arnie's basic mass routine, which looks like it might be doable within my time constraints. I also found his advanced routine… But you'd need 4+ hours a day to do that lol!! So we'll leave that for the moment. ...

Read More
Posted by
Lee

Getting IPublishedContent In A Custom Action / Class

If you want to make use of the cool new Querying/Api that came with Umbraco MVC. Then its as simple as getting an instance of the UmbracoHelper like so. var uHelper = new UmbracoHelper(UmbracoContext.Current); Then just use it like you normally do within a View and get your IPublishedContent back and use it however you need. uHelper.TypedContent(); uHelper.TypedMedia(); etc.. etc…

Read More
Posted by
Lee

Which w3wp.exe Belongs To Which Application Pool In IIS7

If you have a few sites running on your server, and want to know which worker process/application pool is taking up the most memory. There is a very simple script you can run. 1.) Make sure you have the PID column showing in your processes tab. 2.) Open the cmd window and type the following to get you into the 'inetsrv' folder cd C:\Windows\System32\inetsrv and then type the following appcmd list wp This will give y...

Read More
Posted by
Lee

Unable To Create Database Diagram - No Valid Owner

When restoring databases locally from other servers, you often can't get the database diagram to load and get the following error. Database diagram support objects cannot be installed because this database does not have a valid owner. A simple fix for this is to use the following SQL Query. ALTER AUTHORIZATION ON DATABASE::YourDbNameHere TO sa GO

Read More
Posted by
Lee

Useful Script To Clear/Drop All Tables In A Database

Thought I had dumped this up here before, but seemingly not! Very useful (And dangerous) little script to quickly clear out a Db of tables. If you get constraint errors, just keep running it and it will clear dependencies and then the children. EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"

Read More
Posted by
Lee

Using Linq Select To Cast/Map Objects

I'm always looking for cool snippets of code using Lambdas to reduce my code, I have opted for using Linq Select() extension method to cast objects to a different type or Map one object to another one.  These are really simple examples of how to do this but pretty useful. Casting An example of take a string CSV and casting to a List<int> using the Linq Select() extension method. var intList = csvString.Split(',').S...

Read More
Posted by
Lee

Dealing With 1000’s Of Members In Umbraco Without The API Or Examine

I had a situation recently with a client site that has literally 1000's of members, and was getting about 20 new members sign up per day. I initially started off with the built in API, but each 'group' has around 20+ custom properties and even with a cache it started to creek when searching and mass downloading members into CSV files (Watching with SqlProfiler made your eyes wince). So I opted for Examine next. I wrote a really nice ...

Read More
Posted by
Lee
Back to top