You are currently browsing the category archive for the ‘nerdiness’ category.

After spending my Saturday getting my new Windows Home Server 2011 server setup just right (I am plowing and installing over WHS v1) I came to the realization that the workgroup is stuck at WORKGROUP.  Stuck you ask? Yes, stuck.  Since WHS2011 is using certificate services you can’t change the workgroup name through computer properties. Plus for some reason the setup wizards never asked.

I did come across a post that said you can press <alt>+<f10> at the computer name screen and set it, but I was way to far into my fourth load to start over again now (Yes I would have if I didn’t find this great little video).  Using PowerShell type in the following two lines of script.  Your workgroup name will be updated.  Remember no spaces etc.

$sysinfo = Get-WmiObject Win32_ComputerSystem

Of course now that I am done, this shows up in search from TechNet:

I am simply listing this that it may assist someone, I have no idea if this may break something on other systems. It worked for me very well, but I must express, use at your own risk.

Being an IT Slug, I find myself using a lot of different tools.  Many tools are ‘first installs’ when starting to use a new box.  Since I have been thinking about changing jobs, which means a full forklift of my toolbox to a new machine, I decided to start writing down what I have installed, sitting in the tools folder, etc.  I was about to put the list in my regular notes system, Google Docs, but decided to put them in the  blog instead. There are boat-loads of tool lists out there, so why shouldn’t I have my own?  🙂

The list is in no particular order, just as I found them in my head or on my system.  Perhaps I will organize them some day…

It just didn’t look complete without the links to the products.  Not that its hard to get these days with the efficiency of Google search.

Add a link to your toolbox in the comments!

While working on Blog by Email ( I came across the necessity to create my own HTML helper class.  For those who don’t know helper classes “…reduce the amount of tedious typing of HTML tags that you must perform to create a standard HTML page.”

The registration request form on the site was getting hit pretty hard by spam bots and I was getting tired of cleaning up the mess, so I decided to add a captcha.

ReCaptcha is what I decided on and started down the rabbit hole.  First of all there was only ASP.NET examples.  Since I was writing this in ASP.NET MVC, I wanted to use a more, “MVC” approach to it.  I came across an post on named Using ReCaptcha with Asp.Net MVC.  The post covered exactly everything I need, what it was missing is details around its steps, specifically Step 5 – Create a Html Helper to build and render the Captcha control. It shows the current code and nothing else:

public static string GenerateCaptcha( this HtmlHelper helper )
  var captchaControl = new Recaptcha.RecaptchaControl
      ID = "recaptcha",
      Theme = "blackglass",
      PublicKey = -- Put Public Key Here --,
      PrivateKey = -- Put Private Key Here --
  var htmlWriter = new HtmlTextWriter( new StringWriter() );
  return htmlWriter.InnerWriter.ToString();

My first thought, is cool, I can just add an HTML helper to the view to generate the captcha, this is a good approach.

First stumble, that is a method, that needs to go into a class–what class should it go in to?

No problem, I’ll just look up creating helper methods.  That was an easy search which rendered an ASP.Net site page, Creating Custom HTML Helpers.  Great, now I have my examples.  I matched it to an extension method; okay, I get that, I have used those before.  I learned the syntax and added it to my site.

It doesn’t come up in Inteli-sense.  What can it be.  I changed all kinds of things around, from renaming the class, to changing the method name.  I was wondering if it followed some naming scheme like controllers and models do.  I don’t recall it needing to.

I decided to browse though the comments, see if anyone else ran into this.  And there is was, someone named, ianchadwick mentioned a way to make the namespace global in the web.config.  Well, damn, that is it, the view doesn’t know about my namespace BlogByEmail.Helpers.  I added @using BlogByEmail.Helpers; to the top of the page, and everything fell into place.

To use the helper in the view simply use @Html.Raw(Html.GenerateCaptcha())

Html.Raw is needed to keep MVC from HTML Encoding the output.

Damn I feel dumb sometimes.  …back to my code!

I learned something new over the last week which I not exactly sure of the benefit of.  Probably because I still not entirely sure on how it is implemented.

It seems that in IIS7 that the default functionality is that the web.config in the root website is inherited to the child webs.

Of course I found this the hard way.  I changed to a new web host and while setting up my base sites I wanted to try out a few new applications.  I setup Umbraco under a sub-domain and played around with that for a while and remembered Orchard from MVConf.  I setup a virtual directory, /orchard, and loaded up the site.

I kept receiving 500 errors when going to the site.  There was a whole round of support emails around figuring out where the errors where steaming from.  Once I found out I learned about the IIS7 inheritance.

For starters I want to list the ways I found to disable the inheritance and then move on to how this could be useful.  (Man it’s always something)

First was the instructions from the Arvixe staff (which I think they found on SO)

<location path="." inheritInChildApplications="false">     <system.web>      ...     </system.web> </location> 

There is also three examples in the IIS.NET bog:

  1. You can set the enableConfigurationOverride attribute to false for an application pool
  2. allowSubDirConfig=false (as above)
  3. inhertInChildApplications property

I haven’t tried all of these yet.  If you have leave a comment on how it well worked. It seems this functionality is enabled when the AppPool is set Integrated mode.

I just read one suggestion to use <clear /> what was inherited in certain sections.

Now for some reasoning on why this functionality was added

For now I just have this link from ASP.NET MSDN library.  It starts out with:

“You can distribute ASP.NET configuration files throughout your application directories to configure ASP.NET applications in an inheritance hierarchy. This structure allows you to achieve the level of configuration detail that your applications require at the appropriate directory levels without affecting configuration settings at higher directory levels.”

I have some reading to do…

Update (8/14/2011):
Reading an informative article on, Understanding Sites, Applications, and Virtual Directories on IIS 7

The only problem I have with the article is that there absolutely no details on any of the information provided.  Yet it’s a good overview of what they have done in the new version.

Now here are the details I have been looking for:


IIS7 Configuration Reference on IIS.NET


Reading on…

You would think it’s simple enough to get the file version information as it is set in Visual Studio’s UI setting, but it wasn’t for me.  Even after Googling around I only discovered how to the the Assembly version, not the file version.  Well not until I found this article. The information is at the end of it and it basically goes like this:

string fileVersion = FileVersionInfo

I then also wanted to get the date too.  This is how I did it:

string fileDate = System.IO.File
       .ToString("MMMM dd, yyyy")

FileVersionInfo is at System.Diagnostics
Assembly is at System.Reflection

The best thing is I no longer have to remember to set this stuff before packaging up my app for shipment.  Like I am doing right now:  BD File Hash version 1.0.10 going out right now.

Happy Summer!  The kids are out of school and already bored.  My oldest son though is really into reading this year, I mean REALLY into it.  He has probably read 10 books already on summer break.

His school has a degree program for reading books during the summer.  Basically the students get a star for each day they read more than twenty minutes.  My son has been doing much more than that I thought it would be great to keep track of it.  I am sure looking back at the list at the end of the Summer he would be pretty impressed by the list too.

My first thought is that I would set him up with a blog, and he could type in the books he read on any given day.  He and I have done some basic web page building together, so I thought he may get a kick out of this.

So I added a new blog to my account here at WordPress and picked a theme I hoped he didn’t think sucked.  When I went to add his as a contributor to the blog I discovered he needed an email address to that.  Hmm….

Well I have thought about setting him up with an email address in the past, but never did it as there was really no reason and he is only eight.  So I went to Comcast to set him up with a family account.  The didn’t have the name I wanted, damn.  Well I found one close enough and went with that.  At least Comcast has some parental controls, I’ll have to look deeper into that.

I set him up with a WordPress account and when there to log him in.  When I logged in with his account to verify everything I was greeted with a page of many, many blogs.  Well this is not good, he doesn’t need to be exposed to to this, too young yet, too dangerous.

Going to the next level

As I pondered this in a background processes it hit me, what about setting up a new domain and hosting the stuff myself!?  I checked at GoDaddy and shit, the domain is available, excellent.

$10.67 / year for the domain, not so bad.  $9.99 for privacy, what!  that’s a bit outside.  Then it hit me again, Dreamhost.  Dreamhost has a free domain with a paid subscription and I never used it, perfect.  Off to Dreamhost

I was able to create and host the the domain on my current account and loaded up a WordPress blog in about 10 seconds.  Added an email address and we are ready to go in a more “controlled” environment.

So a simple idea has bloomed into a fully hosted domain with private emails and sites, all for an eight year-old.  I am the Tim Allen of the Internet!

So my son and I went over some of the stuff I put together and he is pretty interested in it all.  As expected he is a bit overwhelmed.  That’s OK, we’ll take it a step at a time in what ever direction interests him most.

I just finished a new file hashing tool, BD File Hash, which is hosted on CodePlex under the Microsoft Public License (Ms-PL).

The goal behind this Windows tool is an easier way to verify files you download from the internet.  Many applications, ISO’s, and other files usually list a hash with them.  This hash is used to verify the file you downloaded is the same file the author meant you to download.  It prevents you from using corrupt or exploited downloads by allowing you to verify the file before you use it.

The problem I had with most file hashing tools, is that they needed to be run from a command line, or you had to open the hash value into a text editor and copy/paste it into the hashing application to be compared. So I wanted BD File Hash to be a convenient way to verify files using hashes.

BD File Hash has the following capabilities:

  • Right click any file and select BD File Hash from your Send To menu
  • Use a file picker to select the file with the authors hash value, it will automatically be parsed from the file and entered into the BD File has application
  • Easily hash to files to see if they are the same
  • Supports MD5, SHA-1, and SHA-256
    • Please recommend any other hashing algorithms you may need.
  • Save your default hash type to the one you use most often

BD File Hash requirements:

  • .NET 3.5 SP1
  • Windows Installer 3.1

Give BD File Hash a try today!

I have this really, really bad habit; I spend a lot of time searching and trying out new tools for my tool box.  Some times to such extent I never get around to actually using the tools to build something, and that is just silly.

On the positive side is have given me a lot of exposure to the many, many options available to us, but on the negative side I think I use it as a form of procrastination.  If I am looking for for something, than I don’t actually have to ‘work’ on something.  How convenient.

The toughest part, is that I really enjoy checking out different applications.  Experiencing what so many are putting their hard work into.

So I have started a list, it is by no means complete, nor do I really plan on making it complete.  Though it will give you a pretty good idea on all the different things I have checked out and played around with.

I have wondered for some time how to keep footers at the bottom of the page.  I have tried different methods of minimum heights, etc., but it only ever looked just “OK”.

On Stackoverflow today, the a question was asked about sticky footers and a method being used to achieve them.  I thought the solutions interesting so I wanted to post them so I might be able to find this later.

Stackoverflow entry:

The method referenced by the question’s author:

A suggestion made by someone else:

Unicode Characters converted to ASCII string

I hacking together a report today and discovered the Unicode text I received was actually in Unicode not ASCII.

Basically I have this:  こんにちは

And I want this:  

By using AscW(Char) you can convert a Unicode character into an integer value.  Add some delimiters to encode the string and you have a Unicode HTML Entity Reference.  It isn’t perfect, as AscW(Char) sometimes returns a negative number, which isn’t allowed, though this is an easy work around explained here.  It is used below.

Public Function UnicodeToAscii(sText As String) As String
  Dim x As Long, sAscii As String, ascval As Long

  If Len(sText) = 0 Then
    Exit Function
  End If

  sAscii = ""
  For x = 1 To Len(sText)
    ascval = AscW(Mid(sText, x, 1))
    If (ascval < 0) Then
      ascval = 65536 + ascval '
    End If
    sAscii = sAscii & "&#" & ascval & ";"
  UnicodeToAscii = sAscii
End Function

Now lets go the other way: ASCII string to Unicode

Now I have this:  

And I want this:  こんにちは

I remembered that ChrW(int) will convert character codes to their associated character.  I really wasn’t in the mood to write parsing logic and test it, but luckily I came across a class which does this.  I ripped out the method I needed and it worked great in all it’s simplicity.  I have included this function below:

Public Function AsciiToUnicode(sText As String) As String
  Dim saText() As String, sChar As String
  Dim sFinal As String, saFinal() As String
  Dim x As Long, lPos As Long

  If Len(sText) = 0 Then
    Exit Function
  End If

  saText = Split(sText, ";") 'Unicode Chars are semicolon separated

  If UBound(saText) = 0 And InStr(1, sText, "&#") = 0 Then
    AsciiToUnicode = sText
    Exit Function
  End If

  ReDim saFinal(UBound(saText))

  For x = 0 To UBound(saText)
    lPos = InStr(1, saText(x), "&#", vbTextCompare)

    If lPos > 0 Then
      sChar = Mid$(saText(x), lPos + 2, Len(saText(x)) - (lPos + 1))

      If IsNumeric(sChar) Then
        If CLng(sChar) > 255 Then
          sChar = ChrW$(sChar)
          sChar = Chr$(sChar)
        End If
      End If

      saFinal(x) = Left$(saText(x), lPos - 1) & sChar
    ElseIf x < UBound(saText) Then
      saFinal(x) = saText(x) & ";" 'This Semicolon wasn't a Unicode Character
      saFinal(x) = saText(x)
    End If

  sFinal = Join(saFinal, "")
  AsciiToUnicode = sFinal

  Erase saText
  Erase saFinal
End Function

I didn’t always understand why you wouldn’t just want to work with the Unicode characters themselves.  Well is seems that not all applications treat Unicode the same way and the characters may be changed.  If you are storing and passing around a text representation of the characters there is no way for them to be misinterpreted.

One of the neatest things I like about this is that I can just put the text represented Unicode in a web page and the browser will automatically convert it to Unicode characters.  This is the reason I needed to use an image above to show what the text represented Unicode looks like.  If I just put the string there, it is converted by the browser when displayed.

If you have been to this post in the past, you have probably noticed that it has changed a bit.  That is because I had it all backwards! Yeah well it happens.  I said I want wanted to change Unicode characters to Ascii string, but the code actually was for the other way around.  Well I finally got around to fixing this and made sure that code worked before displaying it.  I hope this helps someone out there.

Twitter Updates

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

%d bloggers like this: