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

It has been /interesting/ working with Entity Framework (EF).  With my first couple of sites I used Linq to SQL, and I really liked it.  It’s pretty simple once you get the gist of it.  Though now Microsoft recommends the use of Entity Framework (EF) and Linq to Entities.  Well using Linq against EF is really no different then Linq to SQL so the transition was pretty simple.  Here is a good beginner walk-through I ran into.

The part I like most about EF is Code First.  I can define my classes, relationships and inheritance and EF creates the database for me.  Need to add some properties, no problem, add them and remap (or recreate) the database.

Sure there are a few short comings like no foreign key constraints on none primary keys.  This is a pretty big deal, but nothing that can’t be handled in code (at least for my small sites).  I wonder how it’s handled with database first models, I’ll have to experiment with that some day.

The other shortcoming I found is with date fields.  It seems EF automatically works with database datetime2 field types but only creates datetime field types in its database create scrips.  This perplexed me for some time until I discovered what was really going on, and the temporary fix is pretty darn simple.

Each time you create a new script by running “Generate database from model…”–the script which is created is opened in Visual Studio (eg. myModel.edmx.sql).  Before you run it or close it, do a find and replace on the file.  Yes you guessed it, find datatime and replace it with datetime2.  Simple straight forward and works like a charm, as long as you remember to do it.

Happy coding!

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!

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.

For months and months now I have asked myself, “Self, what language next, Ruby, Python, something else?” and has driven me crazy.  Someday I will ask myself why I spent so much time thinking about it instead of just digging in to something.  Well the real truth to that is time.  Sure I have spent time on the Ruby site going through browser-enabled 15 minute intro and some general reading.  It never really sticks until you throw together a couple of apps.

Over the last eight months I have been on a big web front end kick, getting myself up to speed on web display stuff like CSS, JavaScript, and jquery.  It’s been a lot of fun, but I really am not a good page designer, so besides reproducting current layouts there wasn’t a real lot for me to do.  

And there is always ASP.NET MVC which I have been following and learning off and on since August of 2008.  Having the web skills when putting together some learning MVC sites was really useful.  Don’t worry, I wont go on another, “I love MVC…”, rant.

Saturday morning I was in our local library with my two sons picking out movies reading some books, messing around and found myself at the card catalog computer screen.  Hey do you remember actual card catalogs, the rows and rows of drawers which contained cards of all the books in the library.  Here is one area computers help one-billion percent.  Anyway, I did my usual search for ASP.NET, came up with the same books as usual.  A 2008 book I had already checked out (and didn’t like too much) during my web learning, and some older stuff.  Oh hum I thought….

Than I had an idea and started typing

ruby programming

A match, wow a match and a recent book too.  I was was feeling a bit excited.  Okay, let’s try another

python programming

Ah, nothing on that one.  Well that settles it—right, wrong or indifferent, I will start with Ruby.  Well, I have always been leaning this way anyhow.  The exposure I have had, I have liked, now to come up with an app to put together.  Then of course if I get my arms around the language I will have to move on to Rails, and Iron Ruby (Uses .NET’s DLR).

Hey look, ASP.NET has made it’s first live-supported release!  This is great!

I have been using the MVC pattern for a good 8 months now and I just love it.  It just makes so much sence to the way I think. Sure there is a learning curve to get started with ASP.NET MVC, whatever, it’s worth the trip.

I read about it here first.  Phil Haack wrote about the release.
You can get the release from here.

Remember if you have a previous version of ASP.NET MVC loaded, you will have to unistall it first.  A short time ago, Phil Haack, Scott Hanselman, Rob Conery, and ScottGu release a FREE tutorial to MVC, as a fist “Chapter” to their upcomming book, ASP.NET MVC 1.0.



Just the other day I decided to sign up with dreamhost for SVN and web hosting.  This hosting service is setup really well.  They have one very reasonably priced plan, and charge for extras from there.  Not that I need any.  They are running an unlimmited storage and bandwidth special right now.  Normally 50G (not sure on bw);  5 MySql databases, unlimited email and shell/ftp users,unlimited mail, imap access, webmail client, etc., etc.  Truly full service hosting. You can setup a virtual private server for on $15 per month extra!

Programming support for PHP5, Perl, Python, Full Unix Shell (one of my favorite parts), Crontab access, Full CGI access, Ruby On Rails, SSI, CVS and SVN reopos, and they have mod_dav_svn installed!

Running on Debian Linux, friends have told me that they have had very little down time with the service.

You cannot go wrong with all they provide for the price they charge ($9/month?), easily the best Linux based hosting I have come across.  Only time will truly tell me how reliable the service is.  The word on the street is good!

Oh yeah, and they are a green hosting center 🙂

I am diving head-first into the world of .NET 3.5.  And not having the support of my employer, I am flying solo, using the Express versions of Visual studio.

I ordered this, and hoping it will be a promising reference for me.

Pro C# 2008 and the .NET 3.5 Platform, Fourth Edition (Windows.Net).

Update (10/23/2008):
Well truth be told the book is excellent, a very good reference to add to my collection.  It doesn’t have a lot of ASP.NET information in it and I really need help in this area.  See, simply, I am UI challenged.  When it comes to writing web front ends, forget it.  Sure I have done a good bit of web work, but most of it was hacking on stuff already put together.

No I wonder my next step.  Apress has two C# ASP.NET books and I am not sure which one to get.  There is a Pro book and a Beginners book.

Beginning ASP.NET 3.5 in C# 2008: From Novice to Professional, Second Edition (Beginning from Novice to Professional)

Pro ASP.NET 3.5 in C# 2008, Second Edition (Windows.Net)

They both have good ratings but I wonder if the Pro version will just be more information that I care about and may skip over some basic things I don’t understand about web UI design.  On the other hand the basic book may be too basic and not add any “meat” to its explainations.  I don’t learn as well if I don’t understand why something is doing what it is.  I guess it’s time for a trip to the bookstore and flip throuh some pages.  I wonder if my family will ever let me out to do that…

Not sure on the accuracy of these, but I needed this info, found it, and wanted somewhere to stick it.

File Ext: Content Type:
docm application/
docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
dotm application/
dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template
ppsm application/
ppsx application/vnd.openxmlformats-officedocument.presentationml.slideshow
pptm application/
pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
xlsb application/
xlsm application/
xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
xps application/

Thanks to:
Doug mahugh, on msdn blog

//Get response
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

StreamReader sr = new StreamReader(response.GetResponseStream());
result = sr.ReadToEnd();

As I log into My Yahoo! account I am greeted with a message that a new updated version of My Yahoo! site is available as a beta site. Since Yahoo! usually lets you go back to the old version again, I thought I would check it out. Basically it has become the typical AJAX’d to hell big font “Web2.0” site. Fooy. I don’t get the new interfaces with all this Javascript, big-ass fonts, and bubbly edges, they are just such bloated pigs. The new font resolutions make it really difficult to use anything but a full-screened browser, which I hate to do. The UI is windowed for a reason. The My Yahoo! beta reminds me a lot of the new mail interface Yahoo! designed a few years ago. No I don’t use it either, it was just to slow and clunky of an interface back then, though I haven’t tried it again.  Another part that irked me is that many of the modules I had on My Yahoo! page no longer worked on the new site.  Why would you offer a new layout if many of the items which are used, aren’t available any longer?  I don’t get that.

FogCreek Software’s FogBugz has done the same thing with their latest release, 6.0. Changed to this really fat font and some other layout changes. I understand UI changes always take some time to get used to, but even after three weeks using the product, it still doesn’t feel natural. Funny, reading Joel Spolsky’s blog, when he returned to New York after his first demo tour for FogBugz 6.0 he himself the UI has been stripped down way to much and it’s just horrible. It happens, anyone in development knows it. At least he is being smart about it and re-doing it from step one.

I have to say that I am happy that so far Yahoo! hasn’t forced me into using their new interfaces for their products. I don’t think that I am that stubborn when it comes to changes, I just expect at least to have the same functionality that I did in a previous version. Don’t make me take two steps backwards in functionality when you introduce a new product.

I would really like to know why web designers are thinking this new larger font is the way to go on web pages? I am seeing it more and more, and I still find it less appealing and usable.

Twitter Updates

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

%d bloggers like this: