SQL: How to get depth from a recursive cte

If you need to know what level deep you are when recursing through a series of parent child relationships, there is a pretty easy way.

WITH cteFolder( FolderID,Depth )
SELECT @topFolderID,Depth = 0
SELECT f.ID, Depth +1
FROM Folder f
JOIN cteFolder cte
ON f.ParentID = cte.FolderID


Happy Coding!

SQL: How to include an incrementing column in your query without a cursor or loop

I had the need to do a recursive call that included depth and sort orders. I wanted to reformat the sort orders in a single query without using a cursor or loop.

Turns out there is an easy way with SQL 2005 or higher.

@Folders is a table var from my CTE with Depth and SortOrder in it.

SELECT ID,(ROW_NUMBER() OVER (ORDER BY f.Depth,f.SortOrder,r.SortOrder)) * 100 as SortOrder
FROM someTable r
JOIN @Folders f
ON r.FolderID = f.ID
ORDER BY SortOrder;

Happy Coding!

How to add a custom user agent in the header using a webview and Xamarin Forms

I am writing an app using Xamarin Forms and wanted to control the user agent for my webview. It’s a little hacky way to have the website render differently when it see that it’s my app coming in without having to use session cookies or other crap like that.

It was pretty easy once I found the code, but finding the code was the pain. Well, Add this renderer to your IOS project.


using Foundation;
using PrazeMeApp.iOS.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(WebView), typeof(MyWebViewRenderer))]
namespace PrazeMeApp.iOS.Renderers
    public class MyWebViewRenderer : WebViewRenderer
            protected override void OnElementChanged(VisualElementChangedEventArgs e)
            NSDictionary dictionary = NSDictionary.FromObjectAndKey(NSObject.FromObject("myuseragentgoeshere"), NSObject.FromObject("UserAgent"));


Happy Coding!

Xamarin PCL – How to URL Encode since there is no HttpUtility

Looking for the HTTPUtility class? Ha, you don’t get it. PCL doesn’t have it. Fret not, though, you can still URL Encode.

It’s easy, just in a different spot.

How to URLEncode in Xamarin Forms PCL

var encodedData = System.Net.WebUtility.UrlEncode(stuffToEncode);

Now you know, and now hopefully I will remember!

Happy coding!

Where is the Hosts file location in Windows 8?

The Hosts files is a file that allows you to override the DNS lookups for specific domains.

Say you want to test your application that has brianseekford.com hardcoded but you actually want to run it against your local computer IP

You edit the hosts file and simply add the entry:      brianseekford.com

ALL dns lookups will now return when looking for that domain, so your browsers etc will now all redirect. It was also the old school way to do ad blocking, put in a domain you never want to resolve. i.e. ads.joe.com

Anyway, now that you know what it does, this is where to find it:


Remember, open notepad as Administrator FIRST, otherwise you wont be able to save.


Temporary fix for internet for Frontier FIOS after Verizon takeover

Did you lose internet access after Fronter screwed the pooch on the Verizon take over? Personally, I am pissed at both Verizon and Frontier. Verizon was doing a fine job but got money hungry for quick capital and sold us to these clowns.

Businesses all over lost internet, phone, etc because they screwed up big time.

Well, it’s possible you might be able to get your internet working again with a little self-help.

I found that two things got me working again, but these are somewhat temporary fixes depending on how bad Frontier messes things up.

  1. You should change your DNS to googles public DNS. This means changing the way your computer/device looks up website names.

i.e. when you type in google.com it has to look up google.com in the DNS system to get the IP address of the website. Then you go to the IP. Frontiers DNS seems to suck a  big nut and not work, so you get a “domain not found” etc error. If you are getting that error, this may resolve your problem.

If you are a somewhat tech: The DNS IP’s are simple. and

If you need more help setting it, Here is a link so I don’t have to type it all out:

How to Switch to OpenDNS or Google DNS to Speed Up Web Browsing


Now the second thing you will need to do is log in to your router. I hope you remember the credentials. If not, reset the bad boy and use the defaults for your router model. You should be able to look those up.

I use a Verizon ActionTec router.

What you need to do is release and renew the lease on the IP address in your router on the WAN. Sounds complicated right? It isn’t. It’s more complicated getting to the screen.

Here is a link that may help:



Realistically, just type in your Router model on the back of the router and google How to Release IP Address on X.


I wish I could help more, but I am pretty slammed and just wanted to point out there may be a fix. It worked for me. At least my stuff works now, but only the devices I can change the DNS on. I still have to release and renew every few days as well.


So, in summary:

Change your DNS to and

Release and Renew your IP on your Router.

Ideally, also set the DNS on the router on the WAN and LAN to the IP addresses above as well for devices that automatically use the DHCP supplied IP.


-Happy Networking


Oh yeah, Frontier SUCKS and they haven’t changed my mind on that.






Visual Studio 2015 error “Object reference not set to an instance of an object”

This fixed my razor intellisense problem and the error after installing the latest ASP.NET tools.

Here is how to fix it.

Delete the contents from the following folders:

Navigate to the command line now and run devenv from either of these paths:
[x64] C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
[x86] C:\Program Files\Microsoft Visual Studio 14.0\Common7\IDE

run devenv /resetuserdata from the command prompt.

Thanks to fka for the steps!


Happy Coding!

Reset performance counters when getting errors in Perfmon or Load Center

Old thing I was working on over a year ago. Well, maybe it is useful to someone:


PS C:\Windows\system32> cmd
Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.

C:\Windows\system32>lodctr /R

Error: Unable to rebuild performance counter setting from system backup store, error code is 2
C:\Windows\system32>cd ..

C:\Windows>cd syswow64

C:\Windows\SysWOW64>lodctr /R

Info: Successfully rebuilt performance counter setting from system backup store
C:\Windows\SysWOW64>winmgmt.exe /RESYNCPERF