My New Gig

Back in April, I finally found a company willing to take a chance on a .Net developer looking to make the leap to Ruby on Rails. The company is called Virtual Racebags. We build and distribute virtual goody bags for endurance races.

It’s been a wonderful experience so far. I have enjoyed working in Ruby full time. I have also enjoyed my two new favorite tools Git and Vim.

My position is lead developer. The application was built by a company that specializes in getting start-up companies off the ground with their applications. Once a start-up gets mature enough, the idea is to then build their own teams to take over development. That’s where I come in. It’s now my job to help the product move forward.

It’s been fun so far, and I hope to write more posts about my adventure soon.

Upgrade a Web App to VS2010

I had a very tough battle with Visual Studio 2010 this week. I wanted to upgrade an old web app from VS2003 to VS2010. After trying this many many times, I think I finally got the wizard to convert my project successfully.

Read More

Habit or List Addiction

A little over a year ago, I read the book Getting Things Done by David Allen. Since that time, I’ve been trying to improve on my processes for, well, getting things done. Really, my biggest concern was that something big was going to slip my mind and cause me trouble. I don’t know if I was losing my memory, or if I finally had so many tasks that they weren’t fitting in my short term memory any more. Whatever it was, I felt like I needed a change. The book really helped lay out some processes that I’ve been using ever since.

Read More

Recursion in Project Euler

Project Euler is a website for programming geeks to hone their algorithm writing skills using challenging mathematical problems. Most of the problems are significantly complex to the point that a computer is required to solve the problem. Many of the problems also involve large enough numbers that a brute force approach would require time equivalent to the known history of the universe to solve. These types of problems require an elegant approach.

I want to write today about one pattern that I’ve used to solve many of these ungodly un-brute-forceable problems. In the spirit of Project Euler, I won’t be spoiling the answers to any questions, but I will demonstrate a pattern that works well for many types of problems.

Read More

Vim config on Windows with Git

One of my goals for this year is to get better at using vim as an editor. I’ve tried it in the past, but I never really grokked the power of it until recently. Now that I’m understanding it better, I want to use it for everything. Every time I use another editor, I find myself typing the commands I would use in vim. Of course then the other editor can’t even do what I want to do, and I end up deleting a bunch of characters like ‘wwww’ or ‘dd’. I can’t believe how long I’ve gone before discovering how awesome this tool is.

Another of my goals for this year is to get better with git as a version control tool. So I figured that I might as well start versioning my vim configuration with git. I run both vim and git from Windows XP so there were a few subtleties in the process. Vim looks in my home directory for a file called _vimrc for my customizations, and it looks for a directory vimfiles for custom plugins and color schemes. What I wanted to do was create a separate directory for my vim files so that I could use it as a git repository. I probably could have just used my home directory as a repo but the .gitignore file would have been hard to keep up with. So what I needed was some symlinks or whatever the Windows equivalent would be.

As I understand it, Windows Vista and newer Windows versions support symlinks with a command called mklink. I however am still on Windows XP so I had to use something different. For the file, Windows XP supports “hardlinks” that can be made with a tool called fsutil. For the directory, there is something called a “junction”.

I created a VIM folder in my home directory. Then I moved _vimrc and vimfiles into that directory.

To create the symlink in Windows for the _vimrc file:

fsutil hardlink create _vimrc VIM\_vimrc

To create the junction for the vimfiles directory I first downloaded this junction tool from Windows  Sysinternals. The call to junction looked like this:

junction vimfiles VIM\vimfiles

Once those links are created, vim works like a charm. Vim can edit the _vimrc file via the hardlink and never knows the difference.

dumpbin

I was working on an ActiveX product recently, and I ran into some issues when it came around to testing the installation. The product was written in C++ and is probably about 12 years old. I have updated it to support the latest in OPC technology, OPC UA. The OPC SDK that I used requires a specific version of the C Runtime Libraries (CRT). I knew about this dependency and included that version of the runtime in my InstallShield project. The thing that I did not know at the time was that my ActiveX dll was also dependent on a different version of the CRT.

The problem showed up in the part of the installation script where the ActiveX gets registered via regsvr32. In a word, it failed. The first step to take when regsvr32 fails is to make sure that all the dependencies are present. I did this by putting Dependency Walker on the target machine. Dependency Walker told me right away that my dll was in trouble because it was dependent on two versions of the CRT, one of which was not installed. Installing the second version of the CRT was not an option because depending on multiple versions of the CRT is a big No-No.

My next step was to look in the manifest file that was generated during the building of my dll. Sure enough there were two versions of CRT listed. The dependency section of the manifest file looked like this:

<dependency>
<dependentAssembly>
  <assemblyIdentity type=’win32’ name=’Microsoft.VC90.CRT’ version=’9.0.21022.8’ processorArchitecture=’x86’ publicKeyToken=’1fc8b3b9a1e18e3b’ />
</dependentAssembly>
 </dependency>
 <dependency>
<dependentAssembly>
  <assemblyIdentity type=’win32’ name=’Microsoft.VC80.CRT’ version=’8.0.50727.4053’ processorArchitecture=’x86’ publicKeyToken=’1fc8b3b9a1e18e3b’ />
</dependentAssembly>
 </dependency>

So now my dll required the CRT from both Visual Studio 2005 and Visual Studio 2008? How the heck did that happen? The next step was to go through all of the lib files that my dll was linking to and figure out which one was the culprit. The tool to do this is called dumpbin, and it comes with Visual Studio. I ran dumpbin with the /directives option on all of the third party lib files. Sections in the output of the files in question looked like this:

Linker Directives
————————-
   /manifestdependency:”type=’win32’
   name=’Microsoft.VC80.CRT’
   version=’8.0.50727.4053’
   processorArchitecture=’x86’
   publicKeyToken=’1fc8b3b9a1e18e3b’”
   /DEFAULTLIB:”MSVCRT”
   /DEFAULTLIB:”OLDNAMES”

It turned out that sure enough one of the third party libs was the culprit. It stated very clearly in their help file that linking statically would result in a dependence on the VS 2005 CRT. Once I changed to using the dynamic version of that library, everything was fixed. Of course, now I had to install their dll next to mine.

My Patent

Earlier this week I learned that a product I worked on at a former employer has been issued a patent. I was aware that they had applied for the patent, but I had not heard anything about it for a couple of years.

I first heard about the patent application from Google. I was searching myself, as everyone should occasionally do, when I came across the patent application. I would have eventually found out about it though because the company contacted me to get updated contact information.

I first heard about the actual patent acceptance because of some junk mail I received. Not just one but two different companies sent me pamphlets with information about getting framed copies of the patent. It’s kind of a silly thing, but it’s also kind of like being in an exclusive club. I mean how many people in the world have ever seen patent-related junk mail?

The product was known commercially back then as DriveWorksEZ. I’m not sure if they’re still calling it that now. The US Patent number is 7881085. It’s basically a graphical programming system for customizing the drive functionality of an AC inverter.

I’m listed 4th out of 5 on the inventors on the patent. Which means I was pretty low on the totem pole. To be completely honest, I didn’t really invent anything. I just helped with the implementation.

When I left the company, we had applied for a patent in Japan and were not really considering applying in the US. They didn’t really think it was patentable. I guess they were wrong. Anyway, I’m not complaining. it’s a cool thing to have on a resume.

My Work

I work for a company called Software Toolbox, which is a sort of catalog of off the shelf industrial automation software products. Some of the products we sell are developed by third-party vendors, and some of the products we sell are developed in house. I work on the stuff we develop in house.

Many of the products my company sells center around “OPC” which is an automation industry standard. It is based in DCOM, but the latest flavor, OPC UA, uses more of a SOA model. These are the two products (my step children) that I’ve spent most of my time on recently: 

  1. OmniServer which is a very solid app that is like 15 years old. I have mainly just added features and implemented its OPC UA interface.
  2. OPC Data Logger which is an OPC client that can log data to various database types, MySQL, Access, SQLServer, Oracle, and ODBC. I came in during the design/coding stages and helped put on the finishing touches to make it a releasable product.

The other major part of my job is maintaining internal webpages and the online registration system. This is mainly done in ASP.NET with a few WCF services.

My Path to Becoming a Programmer

The first programming I ever did was way back in 5th grade. The school had a computer lab full of Apple IIs. The AT, which I believe stood for “Academically Talented”, kids got to sign up for special after school programs where we’d learn extra stuff that wasn’t available to non-AT kids. I remember specifically taking a model rocketry class, a Spanish class, a German class, and of course a Computer class.

The computer class taught us some BASIC. I remember it being pretty simple stuff that we would program like PRINTing to the screen, little loops with GOTO, and stuff like that. I’m sure we learned some simple logic for doing text based Q&A, but that stuff didn’t really stick. I do remember that for a long time after that class, whenever I was in front of an Apple II, I would “program” it to do something silly like PRINT my name to the screen or the word “fart” a hundred times.

The real value that we got out of that class was in the games. The teacher had a subscription to this magazine that had source code to games. Each student picked a game from this magazine and would type out the code. We had about zero idea of what the code was doing. We just knew that if we typed everything in just right, the game would work. If there was a typo in there somewhere, good luck. There was no debugging, there was only hunt down the typos and fix them. Once the game was working properly the teacher would help us load the code onto a floppy, and by the end of the class we had a pretty good collection of games. I specifically remember Hangman and Lemonade Stand. We had an Apple II at home, and I remember playing those games for a long time after that class was over.

In 7th grade, we had another class that involved programming in BASIC on Apple IIs. The class was called Math Science Lab, and it was definitely one of my favorite classes of all time. The big project that we all did was to create these little stories with animated graphics.  I remember that our project was called “Gaylord Perry’s Last Spitball”. Gaylord Perry was way before my time and at this point had probably been retired for 10 years, but the spit was key to the animation. We had a little glob of something on the ball that flew off as it approached the plate.

I remember being pretty good with writing programs in BASIC, but I don’t remember geeking out about it ever. I don’t know if it wasn’t explained to us or if I was just too dense, but it never occurred to me that one could write programs as a job.

I never took any computer classes in high school. I think they offered them, but I never took them because they weren’t honors classes. I felt I had to take all, or as many as possible, honors classes because they were GPA weighted. I was near the top of my class, and I needed to get A’s in honors classes to maintain that status. In hindsight, that’s a really stupid reason to not take a class, but I don’t remember feeling left out at all.

In college, I was completely clueless about what I wanted to do for a career. (I still am, by the way.) I started out in a sort of Physics/Pre-Med kind of track, but the Pre-Med was just something I felt I was supposed to do. My dad was a doctor and I was good at school, so I just figured I was supposed to be a doctor. At some point, I had a heart-to-heart with my dad, and he helped me to realize that I was not interested in being a doctor. At the end of my freshman year of college, I switched out of the college of arts and sciences and into the engineering school. I was definitely different because this was a time when many of my friends were giving up and transferring out of the engineering school and into the business school. I guess I was a glutton for punishment.

That summer before my sophomore year, I studied the curriculum book very hard. I had basically wasted almost an entire year studying the wrong things for someone on an engineering path. Luckily I had enrolled in physics and calculus as those were two of my favorite subjects. The only engineering major that I could switch to at that point and still finish in 4 years was Mechanical Engineering, so that’s what I did.

As an engineer, you get exposed to computers quite a bit. Excel is your friend. To this day, there are very few math problems I come across that don’t get fleshed out in a spreadsheet before doing anything else. As far as programming though, there was only one required class. It was a C++ class called Programming for Engineers. I enjoyed it, but once again I was too dense to realize that it might be something I could make a career out of.

In the spring of my junior year of college, I was scrambling to find some kind of internship for the summer. I sort of knew that you could never get a job without any experience and the only way to get experience without a “job” was to do an internship. I found this place in my hometown that was willing to hire me for the summer. They basically had two things that were considering assigning me. They had some Autocad work and they had some programming work. My CAD class was in some non-Autocad program, so they decided try me out on the programming stuff. I wrote some macros for these obscure spectral analysis packages using DDE. I also did some LabView, and some Visual Basic. I was very good at everything they assigned me, and I loved it. It finally hit me that programming was something I could really get into.

I may have briefly considered changing majors, but I knew how expensive it would have been. So, I finished out my senior year in mechanical engineering. That year, all kinds of employers came to campus. The employers would get a flood of resumes from all the seniors and schedule interviews with the ones they liked.

All the hits I would get on my resume were related to the programming internship and not the 4 years I had just spent learning about mechanical engineering. So, I just went with it. I got a job as a programmer and never looked back.

StackOverflow

StackOverflow is the greatest programming Q&A website that I know of. If you write any kind of code in your day job or in your hobbies, you NEED to have a StackOverflow account. Go there right now and get started: stackoverflow.com.

I go to SO at least once a day. I don’t ask a ton of questions, but that’s mainly because most of the stuff I need help with has been already asked and answered. Even when googling for answers to questions, many times the SO answers are the top rated results. That’s part of what makes the site so great. There is a huge developer community, and most problems you encounter have already been experienced, asked about, and answered by other SO users.

I am very humbled by the knowledge and talent demonstrated by the users of SO. I try to be as helpful as I can, but the places where I’m useful represent a very small piece of the SO universe. Most of the questions that I can answer are quite easy, and therefore they get answered very quickly. In order to answer these types of questions, I would have to be very quick on the draw and probably have to set aside some free time in order to keep refreshing the page. The niche where I’ve had the most success in answering questions has been in the tag Winforms. This is the realm of Windows programming that I’ve worked in for the last couple years, and it’s where I’m probably most knowledgeable. My SO bookmark takes me directly to the unanswered questions that are tagged Winforms. Every once in a while, I’ll go to the site and there will be a question near the top that I can add value to the answer. That’s where most of my reputation points come from.