ASP.NET MVC Model Generator

In making the switch to ASP.NET MVC, I’ve moved away from using my old Data Access Layer that I’ve used for years and have opted to use Dapper as my ORM of choice in the quest for optimal performance. My DAL was actually pretty optimized for WinForms and WebForms (using straight SQL Queries and SQL parameters) but mapping it to models wasn’t something I had in mind when I created it. I’m finding Dapper takes some getting used too but it is still pretty fast. The downside is that writing the code for Models to wire it up is proving to be a little tedious.

To that effect, I wrote a little application that has helped me generate the models from a database dynamically. It’s in it’s infancy stages and something I cobbled together in less than 8 hours but it works. I’ll add more features too as time goes on if there’s enough interest or to satisfy my own needs. In the meantime, I’m open sourcing the project as it may help others and I’d love to see it become something grander if others are willing to contribute to it. There’s also some useful bits of code that others may find useful to reference like dynamically reading fields from a database, pluralization/singularization of words, amongst others.

You can find the repository on Github:

How to Get Browser Name and Version via JavaScript

Today I ran into a strange issue where Firefox version 28 and below rendered style widths different than Firefox 29 and above. Firefox 29 and above appear to have fixed the issue and render sizes to match Chrome/IE8+/Opera/Safari. Unfortunately, as old as Firefox 28 is, our client’s legal review team is stuck on that version as IT refuses to let them upgrade. As such, we needed to add a kludge fix to the site to add a style to fix the issue for those running older Firefox versions. JQuery removed the version support from version 1.9 so here’s a handy script that will allow you to detect the browser and version without any extra dependencies.

Usage is very simple:

BONUS: If you need to detect a specific version and add special classes, here’s a quick snippet that will allow you to add a class to the HTML tag  using plain old vanilla.js.


SourceTree Crashes on Load

sourcetree errorI’ve recently started using Git for development and while I am getting used to the command line tools on Windows, I have been using Atlassian’s free tool, SourceTree to help manage my code. Recently I’ve run into an issue where SourceTree crashes on start up.”Oh dear. We’re sorry, but SourceTree just crashed. How terribly embarrassing.”

I submitted an issue ( and received a response that didn’t solve the issue. I submitted a follow up but never heard back so I did some further digging and found that SourceTree was crashing because it corrupted a repo and was still trying to load it back up on start up. The application does not exit gracefully or even give you the option to start in a safe mode which loads nothing.

To prevent it from opening the repo on start up:

Open %localappdata%/Atlassian/SourceTree/opentabs.xml in notepad or another editor.
Delete the problem repo.

Viola! No more SourceTree crashes on start up.

How to Reset Sitecore 7.1 & Sitecore 7.5 Forgotten/Lost Admin Password

In working on implementing a Sitecore site into an existing code base inherited from another vendor, I discovered that the admin password had been modified and the vendor would not share it. Not being able to login to the admin section of Sitecore was not ideal to say the least. After scouring the web, most articles contained instructions on how to reset the password, but almost all of them applied to Sitecore 6 and below. For Sitecore 7 and above, most articles were not applicable as they introduced the PasswordSalt field into the database which Sitecore uses to hash the password.

If you’ve run into a similar situation, or you’ve forgotten or lost your admin account password, getting access back to everything is pretty simple. Load SQL Management (or your favorite SQL editor) and execute this query against your Core database:

This will now reset the default admin password to ‘b’ so that you may login to the Sitecore desktop. Happy editing!

How to Import Multiple VCF contacts into iCloud

One of my users recently came to me with an interesting problem this week. She had left her old job but had left all her contacts on her work account. Once the account was deleted, all the addresses were wiped out as well. By sheer luck, her iPad had a copy of the contacts since she never connected it to a new network which prevented any type of sync. We managed to export the contacts off the iPad to VCF cards but were now left with the tedious task of importing them all into iCloud for her to use on her phone. I tried dragging and dropping all the VCF cards into the browser but iCloud displayed 300+ errors saying the card could not be imported, without specifying which ones were a problem. The import would error out after clicking OK at around 300 times and not actually import a single one.

I remembered that the format of the cards is simple text and you can easily merge the files into one big file to import.

  1. Copy the VCF cards to a folder like c:\temp\vcf.
  2. Right mouse click on c:\temp\vcf while holding shift and you’ll see an option that says “Open with Command Prompt”
    1. You can also open command prompt by clicking Start -> Run, or windows button + r and type cmd to launch it.
  3. Enter the command copy /a *.vcf merge.vcf in the command prompt.

This will merge all cards into a single VCF file. Now return to iCloud Contacts, click on the gears icon on the bottom left, and click “Import Contact” and choose the generated VCF card. iCloud will now display a progress bar of the import and any errors. In a strange coincidence, importing the contacts this way only prompted me with three or so errors. I’m not exactly sure why the error count was reduced doing it this way. (There were over 1500 contacts to import and I wasn’t about to sift through them to see what was different since it was for personal contacts.)


Soylent Logo

If you haven’t heard of Soylent, you’ve probably been living under a rock. It’s a meal replacement that’s become a hot topic of discussion on many sites and forums from Reddit to Tim Ferris’ own blog.

I bought into the craze and decided to give it a go for a month to see if it works for me. I honestly have no expectations or assumptions as most products and gimmicks always end up failing for me despite working for everyone else. I’ve tried the Slow Carb diet but found it unsustainable for myself for long-term use for multiple reasons. The diet works but quickly becomes very expensive. Unless you have serious will-power, it becomes very hard to stick with it for long durations since it’s such a significant lifestyle change for a foodie like myself.

I’m going to log my experience with Soylent here for a month and see how it works out for me.


Mac Outlook 2011 Reply All Includes My E-mail (with solution)

I’ve started a new job and was assigned a Macbook for my daily work. I’ve found equivalents for most of my applications. Personally, I find the native Mac apps are just extremely underpowered for my computing needs. I hate Mail especially, and even more so how all the apps are split out into separate apps. Luckily I have Office for Mac. Not so luckily, Outlook Mac 2011 is not as well designed as Outlook for Windows in so many ways.

One of the bugs I ran into was the “Reply All” bug where your e-mail is included in the CC field. It’s rather annoying having to choose from having to manually delete your address or having an extra e-mail to delete from your inbox.

The fix turned out to be rather simple for me. It turns out that Outlook for Mac isn’t very smart. It doesn’t seem to be able to tell which address you’re sending the e-mail from even though it’s doing the sending. When my account was initially setup, the company set it up with one of their subsidiary domains which was incorrect. Rather than creating a new inbox, they simply created an alias for the domain but never updated my configuration.

To fix the issue, do the following:

  1. Go to Tools -> Accounts.
  2. Ensure that your e-mail address field is set to match the address you are sending from.

My e-mail address had been set to the old one and still worked due to the aliasing. As soon as I updated the address to match the corrected domain, the reply all stopped including my e-mail address.


Safari Prompts Authorization for Video in Password Protected Folders

Safari Sucks - Use a Real BrowserUsing Safari 6 and trying to password protect a site with videos? You might run into issue where Safari prompts you for a password. Unexpectedly, you’ll find that you’re unable to interact with the fields to re-authenticate or even move the box to get it out-of-the-way.

If you run into this issue, check your folder structure. If your videos are in a password protected folder and inherit from the parent like below, you’ll have to move the video files out of the password protected folder to get the videos to play.

—Password Protected Folder

Your new folder structure will need to be similar to something like:

—Password Protected Folder

Once you do that, your videos should play with no issues. I’ve already reported the issue to Apple when I first encountered the issue but there’s been no fix to date.

Photography Blog is Now Live

It’s been a while since I’ve updated this blog but I’ll be adding more posts about thoughts and technology soon. On an unrelated note, I’ve gotten heavily into photography and am becoming quite proud of the art I’ve created. With the amount of photos I’ve taken, I’ve decided to split the photography into its own blog that’s more suited for showcasing the work. The wolf picture above is one of the latest pictures I’ve taken and there’s plenty more that you can see at

How to Capture Google Analytics Before Redirect

Up until today, everyone I know has struggled to capture a Google Analytics event on redirect links. We’ve all had to come up with hacks and workarounds to ensure that the initial landing page is tracked. Today I finally figured out a solution that works. Google analytics now offers a callback event which lets you fire the redirect (or any custom functionality after the main tracking event fires.

The snippet to add after the Google analytics tracking code setup is below: