Monday, January 20, 2014

SSH on Windows


Make sure your .ssh folder is in your home path. If your home path is wrong or not set try to set the HOME environment variable. From cmd you can check if your home is set by running the set home command. If your in a domain and the HOME path is set by active directory, you can do the following in a startup script:

set HOME=c:\users\...

As long as the ssh keys are correct, they should be used.

This isn't magic.

Saturday, January 18, 2014

Web.config Transformations Reminder

To save me more future frustration, Web.config transformations from Web.Release.config and/or Web.Debug.config don't seem to work when ran locally within VS. At one point I even think I saw a reference confirming this somewhere but I can't seem to find it now.

You can test your transformations in a couple of ways.
  • Use the right click context menu that pops up when you click on one of the transformations and select "Preview Transform" to test your transformation.
  • Publish your web app to a local folder as explained here and take a look at the resulting Web.config.

Friday, February 1, 2013

Show what's going on when running TeamCity web tests

We run automated web tests from within a browser

I say this very matter of factually almost as if this statement needs no clarifying. The reality is though that running fully automated tests using a browser has proven to be very difficult. Of all the singular problems we've applied our time to, automating web tests has been one of the most frustrating and time consuming. Our current solution includes a mash up of the following:

Now when we add TeamCity to the mix and have these test run on a remote machine we don't even get to see what's going on as the service is running in the background. This makes troubleshooting almost impossible.

The point of this post is to remind me that when we need to see why these web tests are failing on a remote machine we can get a little help by doing the following.

1. Stop the TeamCity Build Agent service
2. Open a command prompt and run the build agent manually.

C:\TeamCity\buildAgent\bin>agent.bat start

Helpful Links

Thursday, January 24, 2013

CacheRepository Use Case - Reading From (Somewhat) Unstructured Text File

Yesterday I was given a text file with a rather weird format that contained several hundred lines like this.

I needed to pull out the first sequence of numbers after the "work place name". I was able to use CacheRepository for this quite easily. I created an entity with the same name as the text file. Then it was just a matter of parsing a string (line) to get out the data I wanted.

Friday, January 18, 2013

CacheRepository Introduction (Why I Made It)

From time to time I have the need to write ETL programs to move data from one data source (sometimes sql server) to another data source (often times sql server). If things are going good this usually is because I'm migration data from a legacy app to one of our newer applications. Performance tends to be very high on my list of requirements. Ensuring a quick turn around time between making a change and seeing the result is very important in these types of apps.

Although these applications are typically .net console apps that are created to ultimately run one time the reality is that they can turn into pretty complex programs and I feel they must be coded with "production" code. I don't typically create unit test for them but that has not always been out of the question.

With that said though I don't want to use "heavy" tooling like NHibernate or Entity Framework to extract and load data from the data sources. When I first started writing these programs I used ADO .Net but quickly fell victim to loads of duplication from copy and pasting. When .net Micro ORM's started to become more popular it seemed like these would be a perfect fit and for some time I felt they were.

Switching to a micro ORM help my code writing and reading significantly which allowed me to focus on other aspects of these programs. Performance bottlenecks from querying and inserting data became more and more frustrating. I found myself writing caches for my query results which helped but often seemed clumsy and inconsistent. Caching my query results did speed up my queries but it then became very apparent that I needed to start bulk inserting data because my inserts were taking way too long.

That's when I created CacheRepository. The tool is essentially just a wrapper over top the micro orm Dapper .Net and it extension Dapper-Extensions. The truth is though I could have wrote this using just about any micro orm.

I've tried to stress usability as much as possible so go try it out.

Tuesday, January 8, 2013

Sending Anonymous Emails

I'm creating an application within Appharbor and wanted to configure Elmah to send emails to me when an application error occurs. Configuration for this is done from the errorMail tag within the Web.config file. The problem is that this tag expects a user name and password and I obviously don't want to set these in plain text.

While researching this I discovered this article which stated that you didn't need to authenticate when sending an email to a Google apps account.

I really didn't believe that this was possible but I gave it a try and it worked. I happen to have a Goggle Apps account so I was able to use the same MX record that was used in the article.

I looked into this more and made the following observations:

1. Anonymous emails can be sent to all gmail and Google apps users. When I say anonymous I mean that you don't have to supply credentials at all. All you need is a valid MX record which can be looked up quite easily.

2. Not only can anonymous emails be sent, you can actually send an email with a from address of or of another Google apps domain (or any domain for that matter). This is interesting because when I tried this the Google gravatar of the fake address was actually displayed right in my gmail app. I would have thought that Google would have at least authenticated its' own users.

3. You can't use the smtp server "" without enabling ssl and authenticating yourself with a valid user name and password. This is true for either relaying emails to outside domains (not gmail or a Google apps account) which makes perfect sense but also for sending a an email within the domain.

I haven't tried this with other popular email hosts but I suspect that this behavior is not unusual. It was just surprising to me. Use the following code to try this on your own:

Helpful Links

Monday, December 17, 2012

Coding Beliefs #1

Code is read far more often than it is written. Creating code that is easy to read and easy to understand gives it a higher likelihood of being easier to change. That is far more important than how quickly you can write the code the first time.