Archive for the ‘General’ Category

ASP.NET Dropin DLL Plugin – Part Two

Tuesday, July 9th, 2013

ASP.NET Dropin DLL Plugin – Part One

The first post was a quick intro to the project. In this post, we will cover this works in more detail. So let’s just jump right in.

Typically in ASP.NET MVC, the framework knows where to look for files based on the conventions of the framework. Views are in view folder. With a plugin, the framework needs to be told if a files exists in a plugin DLL and be given a stream to the file. This where the System.Web.Hosting.VirtualPathProvider and System.Web.Hosting.VirtualFile come into play.

In the example there are two class that inherit from the above two classes: AssembleVirtualPathProvider and AssembleVirtualFile. These are Terrible implementations because they are only looking for the one plugin dll. This is a major area for improvement as these classes should look within any DLL that is a plugin. There are many options for this but that is another topic.

The AssembleVirtualPathProvider main job is to see if a view exists within a dll. To do this a number of methods need to be overridden. These methods by default look for views following MVC default naming and file location conventions. In order to check inside of the assembles, these methods need to be overridden and code added to look for the views within the DLLs. Make sure to call the base methods! If you don’t MVC will not be able to find the files local to main MVC project.

The AssembleVirtualFile is a representation of the a file being loaded from a plugin. It has one job, to open a file stream to the file that is in a dll and return it. That is it. This class is used by the AssembleVirtualPathProvider to return a file when GetFile method is called.

Once these are created, the main MVC project must be told to use these providers. In the main MVC project’s global.asax, the new path provider needs to be registered.

System.Web.Hosting.HostingEnvironment.RegisterVirtualPathProvider(new Lib.AssembleVirtualPathProvider());

Now there is a catch to this. Plugins must be in the main MVCs project’s bin directory. I have tried multiple ways to get around this but have not had any luck. The reason is when DLLs are in the bin directory, the website’s process does a deep inspection of all the files in the bin directory. It keeps tabs on what files exist, exception model and controllers. If the DLLs are not in the bin directory, MVC will not be able to resolve the models and controller classes.

Moving on, serving static files from the DLLs. One of the goals of this was that the code in the plugins was written as close as possible to a normal MVC application. I did not want to have some special syntax for plugins vs non plugins. In order for this works, images and files need to be handled by a HTTP handler. In this case a static handler. Bring in the System.Web.StaticFileHandler. This will serve files from DLLs or the file system. It is pretty handy. In the web.config of the main MVC project an entry needs to be added for each static file type you would like to serve from the plugins.

<add name="AspNetStaticFileHandler-GIF" path="*.gif" verb="GET,HEAD" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-JPG" path="*.jpg" verb="GET,HEAD" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-PNG" path="*.png" verb="GET,HEAD" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-JS" path="*.js" verb="GET,HEAD" type="System.Web.StaticFileHandler" />

On top of this, routes need to be ignored for static file extensions that are going to be handled by the StaticFileHandler.

routes.IgnoreRoute("{*staticfile}", new { staticfile = @".*\.(css|js|gif|jpg)(/.*)?" });

But wait, another catch! System.Web.StaticFileHandler does not correctly set the HTTP response headers correctly for caching when serving files from plugins. It works perfectly when serving files from the file system. In order to fix this, a http module needs to be created that looks to see if the file was served from the StaticFileHandler and set the cache headers or use a different StaticFileHandler. Super secret 3rd option (which is sort not good), is to serve all static files from the main MVC project.

Generally speaking that is it. No hidden projects, mirrors or DLL references. A bonus is the plugins will run independently from the main MVC project when doing development if needed.

Some areas that can be improved.
-Better assembly handling in the file and path providers.
-Loaded routes, filters, ect from plugins using MEF (or similar)
-Use/write a better static file handler

Github repo with example:

Enabling Twitter cards

Monday, June 24th, 2013

Twitter cards are summary widgets that show up for links to websites that have them enabled. There are a few types of cards: summary, summary with image, photo, product, and a few others. To enable twitter cards a few things need to happen. First, the website must include meta info in the page header to tell twitter what to put in the card. Next, the website must request to have cards activated for the site.

This evening I set up twitter cards for this blog.  This blog runs on WordPress. Luckily there are a handful of plugins that take care of inserting the meta data into the page header. I installed JM Twitter Cards plugin. It had the most downloads and 5 stars. Install was painless, and setup was easy. Just filled out the forms for the summary cards in the settings JM Twitter Cards plugin.

Next I logged into Twitter’s dev site where there is a Twitter Cared Validator and validated that the plugin was working. Sure enough  everything looked good. So I clicked the submit button for approval. I filled out the form will a few easy questions about my website. Upon submission was told to expect a response within weeks.  It took about 5mins to get a response.

That is it.



Throttle upload bandwidth in Windows (QoS)

Friday, May 24th, 2013

I have digital cable service from Time Warner. It is not the great but still decent. Currently my upload speeds are limited by Time Warner at 1Mbps. The highest I can get in my area is 5Mbps but it is costly. My point is I have an upstream problem. If I want to share files of  any sort of size, it takes forever and slows everything else down as you need both up and down to do anything on the internet.

Recently I have found a solution and it has been in Windows since Vista. Also in Win7, Win8, Server 2008 and 2008R2. Windows ships with Bandwidth throttling specifically for uploads. The following is how to set it up.

Start off by opening up the group policy editor. To do this open the start menu, type “gpedit.msc” , and hit enter. The edit should open, just navigate to “Policy-based QoS” which is found in Computer Configurations -> Windows Settings. This can also be for the user configuration too.


Right Click on “Policy-based QoS” and select “Create New Policy…” This will start the wizard.

In the following windows you can setup how and what the policy will throttle. In step 1, the policy is named and this is where the maximum outbound (upload) speed is set.


In step 2, an specific application or url can be setup to be throttled.


In step 3 the source or destination IP can be set.


And lastly in step 4, the source and/or destination port can be setup to be throttled.


For me, I can typically set limits on an application or just the computer as a whole as I have such little bandwidth to go around. This has become really useful for applications like Google Drive Sync that does not have native support for throttling bandwidth.

A side note, more and more consumer routers are able to do QoS and bandwidth management but that is a different post altogether.

EDIT: In some cases, a registry key may need to be changed in order for this to work. More info can be found at the following link.

Short overview of living with Dyslexia.

Wednesday, May 15th, 2013

I have 3 learning Disabilities: Dyslexia, Dysnomia, and Dysgraphia. What follows is what it has been like for me over the course of my life.

During the first years of my schooling, I mirror wrote perfectly. My teachers claimed this was a phase and I would grow out of it. To some extent this is true but it is also a sign of a learning disability. At this time, I was not reading at a the level I should have been. My teachers told my parents they needed to read with me more. So they did. For 1st and 2nd grade, things followed the same path. My parents and I were frustrated.

Then I got lucky. My 3rd grade teacher, at the risk of her job, told my parents that I should be tested for Dyslexia. Her husband has it and I showed many of the signs. My parents had me tested by independent testing center and I was diagnosed with severe Dyslexia. I was lucky because I was on the path of falling through the cracks. To this day, after meetings and being tested many times, the school district I attended does not admit to me having any learning disability. I don’t know why but point is I was lucky. Many others are not as fortunate.

Since then, I was tutored outside of school. Since the district has never acknowledged my Dyslexia they did not help. Yes we tried. At a very early age, I knew what college I was going to. UW-Oshkosh. Why? Because they have one of the best programs for learning disabled students. I graduated with honors, a fair amount of student loan dept, and a Job. Fast forward to present day, I am working as a Software Engineer doing product development for a small IT shop.

During the years before college, there was a distinct difference between how teachers acted and how administration staff acted. To this day, I don’t know why the school district worked so hard to keep me from being labeled as LD. Even with that, all the teachers I had were more than willing to accommodate my disability. It was refreshing. It was the little things that made a big difference. Like most of them let me type papers instead of hand write them. Remember this was the days before computers were in every house.

In college, things got even better. Attending a school with a high percentage of learning disabled students was great. There was already a process in place set by the school to help LD students and the entire staff knew about it. On top of that, for the first time I was among other students who were like me. Since I was never in any special ed classes until college, I rarely met people like me. This was awesome. I had peers. I was not alone.

I have always been comfortable with telling people of my disabilities and have never tried to hide it. This continued as I entered my professional life. I don’t hide and in fact I am upfront with any potential employers. I explain to them what I have, how it affects me, and how it likely be show up in my day to day activities. Again, I have found that being up front is a lot less stressful than worrying about being “caught”.

Generally speaking, I have found that that being open and honest about being Dyslexic is the best course of action. People will generally do the right thing. It also helps that I don’t use my disabilities to take advantage of people kindness. Just because I have Dyslexia doesn’t mean I want to be treated differently. What I want is to do tasks I am good at and can do well.

Not everything is unicorns and rainbows. I still read and write at a very low grade level. It has been a while since I have been tested but I would guess I am still below a High School level. Not being able to speak a simple word in front of a customer is always fun. Then there is the issue of when people try to sympathise.

I know people mean well when they say things like “I read slow too” or “My spelling sucks too” but they have no idea what it is like. Worse than that is when people try to marginalize what it is like. For example: I dislike doing software documentation, well any documentation. I know it needs to get done and it is part of my job. It gets done but I hate it. Really hate. When I explain this to people, some will tell me they hate it too or everyone hates it. What they don’t understand is I don’t hate because it is documentation, I hate it because writing for me is terribly difficult for me. I would much rather being doing stuff I am good at. Unfortunately trying to explain this to people comes off as whining or excuses. Someday I will figure it out.

All in all, these are small gripes in the grand scheme of life.

This was very brief and could easily go in great detail. I know. This is the start of a topic I hope to cover as I write more. Comments or questions always welcome.

For more infomation on the learning disabilities that I and many others live with check out the followng links:

Why slow is fast.

Saturday, May 14th, 2011

Recently, I have been thinking about an old fable. I am sure that is was read to you as a toddler or maybe you read it as a kid. The Tortoise and the Hare is a fable about a hare who challenges a tortoise to a race. The story ends with the slow and steady tortoise beating the hare in the race. One of the interpretation of this story is haste makes waste. I believe this fable has some serious lessons for any one who works with software development.

In college, Computer Science students learn about software development models like Waterfall or Agile Development. The students learn why structure is needed to effectively develop software. They are also taught the downfalls of the lack of structure. I, like may students, learned all of this in college. Recently, this lesson was brought home and I learned first hand why the tortoise is so damn fast.

The hare from the fable has some very appealing attributes on first look. In terms of software development, The hare starts off strong. He produces code sooner and boy can he code. He can also adjust to changes in design and requirements faster. This sounds great doesn’t? I mean who wouldn’t want all of this?

The tortoise on the flip side has to gather requirements and write designs. This is all before coding can even begin. The tortoise has one thing, a process. He knows that following his process will result in a solid product what out anything missed. So he just plugs away, slow and steady.

The devil is in the details. Or so they say. A deeper look at the hare and the flaws become visible. The hare relies on sheer speed. The sheer speed can only continue for a finite amount of time. There is no time for a process or any structure. This means requirements are missed, code is sloppy, and technical dept is being added at a crazy rate. At some point, the hare will hit a wall. This wall has many forms. In my case, the wall is an endless loop of adding and removing requirements and bug fixes.

The tortoise on the other hand is consistent. The code is produced in a consistent manner. The Tortoise’s output is also consistent. Since he has a process, he can accurately estimate when a feature or fix will be completed. In the end, the tortoise will pass by the hare and will do so with a generally better product.

I always knew having a process was needed. Hell, we wouldn’t learn it in college or have people much smarter than me publish books on the subject if it wasn’t important. The thing I didn’t know is the subtleness of the problems that start to creep up. At first it is minor annoyances like having to to fix brittle tests. Before you know it, the Hare will start to cause full blown production problems.

Watch out for the hare. He causes problems.

Android Development: The Fail

Monday, February 7th, 2011

So back in October I started the process of learning to do development for to android. Sadly, I am here today to admit that went poorly. This is my reflection on why it went badly and how I expect to better next time.

Problem 1: Me. Yup, that is right. The first problem I ran into was me. I have a lot of ideas for applications for Android and in general. The problem isn’t that I jumped right into development, it was when I jumped I landed in a spot that was over my head and that made me instantly frustrated. With in days of installing the tools and SDK my drive had died. I just got over whelmed with all the new that I didn’t take the time to learn.

Solution: While I hate doing the typical “Hello World” type apps, it is a necessary evil. It is the steps needed to ramp up understanding of the environmental. What I was trying to do was not hard but because I didn’t know the basics of Android development, it was difficult to find help. The process isn’t hard and takes a bit of time but ramping up is needed to keep from being overwhelmed.

Problem 2: Holy cow, embedded application development is slow. Let me be clear, development isn’t slow but getting you application to run via emulator or on a device is painful. When it takes a few minute for my application to run, this just kills the fun and drive to continue. Especially when learning. When I was waiting, it was so easy to get side tracked.

Solution: I hear the sdk and emulators are getting better and faster. I am also in needed of a new PC which is pushing 5 years old or at least an upgrade or 2. Other than that, I am not sure what else I can do.

So the biggest problem was me. Once I can get through them, it should be pretty easy to continue. I plan on starting this again as I think there is some positive applications I could contribute to the community. However this is on hold for the moment. Need to get caught up on technologies related to my job, mainly ASP.NET MVC

Android Development: The Install

Wednesday, October 6th, 2010

I recently picked up my first smart phone. After years of wanting to move up to a smartphone but holding off because of price, I finally caved and picked up a HTC Desire. It is running Android 2.1 out of the box. It is a pretty slick phone. So far I have enjoyed my prechuse.

One of the reason I decided to pull the trigger was the idea of creating application for the phone. By day I am a .NET developer. Mainly C#. I was sort of excited to learn a new development environment and langue because I have been in .NET land for so long. I figure it is time to branch out. Yeah java is not much different than .NET but you have to start somewhere. 🙂

So I had some time to get the Eclipse IDE setup and ready to go to start my journey. I went to and followed the instructions on getting started. I am starting from scratch. The machine (win7) I am working on didn’t even have the Java runtime installed yet. Since I am a novice when it comes to Java and Eclipse, I followed the installation steps for the Android SDK. They seemed straight forward.

First step: Get eclipse. Sounds easy enough. Read through the section for ecplise which stated…

A Java or RCP version of Eclipse is recommended. For Eclipse 3.5, the “Eclipse Classic” version is recommended.

What does that even mean? So I want to the Eclipse site and downloaded the Java version of Eclipse 3.6 and continued to the section to install the Android Develipment Tools (ADT).  This is where things get more confusing because I was greated with…

Caution: There are known issues with the ADT plugin running with Eclipse 3.6. Please stay on 3.5 until further notice.

Grrrrrr…. But I just downloaded 3.6.1!! To limit the number of issues I run into I decide to follow what Google recommends and found a copy of Eclipse 3.5. No big deal. I go to run Eclipse and it promptly fails stating it can not find the JVM. At this point I was confused because I had thought that I installed Java at some point in the past. Yeah, I was wrong. Whoops. Over to the Oracle to get the JRE/JDK.

I am running win7 x64 and did what anyone running x64bit OS would do. I download the x64 windows binary. Install Java. Run eclipse. Eclipse fails again. Still stating that it could not find the JVM. Ugh. The message box suggest to add the path to the JVM to my system path. A few clicks later and it should be good to go right? Nope, now Eclipse crashs but with a log/debug message.

At this point I was about ready to give up. That is until it dawned on me. “Hey stupid! You probably can’t run 32bit Eclipse with 64bit JRE!” An uninstall and reinstall of the JRE and eclipse is running!

From here on out everything seem to work correctly. Totally elapsed time: ~2 hours. No really 2 hours.

My enthusiasm has lessened alot because of the frustrating install. I mean I have not even started to write a hello world Android app yet. I am planning on sharing my experience as I go and comparing it to how I view the .NET start up experience.

Google Analytics and Spammers

Monday, May 18th, 2009

I decided to try out Google Analytics over the weekend. My web host’s web stats leave something to be desired. Since Google already knows everything about me and my site already, I figure it was a safe things to do. With a WordPress blog, it is very easy to set up. Here are the steps.

  1. Sign up for Google Analytics
  2. Added a bit of JavaScript to footer.php
  3. ???
  4. Profit! 🙂

It literally took five minutes to set up.  Google Analytics has some very cool features.  For example, it keeps track of return visitors vs new visitors. It is pretty neat.

Google Analytics comes with a free side effect! The stat tracking requires the client to have JavaScript execution enabled. What this means is that clients without JavaScript enabled do not get tracked. So if you have a lot of users that disabled JavaScript, this could be back. However there is a an upside, Spam bots do not run JavaScript! I know this because Google Analytics only tracked me for the first day that I had it installed. However during that same time frame I had ~20 spam comments caught. I am happy about this because I get a more accurate view of the visitors to the blog.


Windows 7 Feature

Saturday, May 16th, 2009

So I was getting my oil changed today. While I waited I took advantage of the free WiFi. I had to download Adobe Reader because of the new install of Windows 7. Below is a screenshot of one of the new features of the task bar. It appears applications can change the button on the task bar. The screenshot is of the progress bar for a download in IE8. I think it is pretty cool and will be more useful than flashing that task bar buttons to get my attention.

Progress bar

Stack Overflow is programmer crack!

Sunday, March 29th, 2009

Stack Overflow is a Q&A wiki site for programmers. People can post questions, answer questions, and search for questions. Question and Answers get voted up or down based on what the community thinks of them. As people ask and answer questions, karma is gained. As karma is gained by a user they can do more on the site like editing, voting Cuarzo up, and voting down.

The site is the fairly popular among developers. The 100,000 question was recently asked with many added everyday. The community looks to 調布飛行場での開発拠点の確保 be pretty strong and oddly mature. I say oddly mature because it is the Internet after all.

Stack Overflow is programmer crack. I find myself setting at the questions wholesale jerseys page hitting refresh over and over again waiting for new questions to be asked. Its fun to see what roadblocks Is other programmers are Warrior stack at. It is also a good feeling to get voted up on question and/or answers on the site. The ultimate joy is when your question is Hello accepted as the answer. It some how validates you as a programmer when one of your questions get marked as an  answer or is up voted. Stack Overflow addicting nature is what keeps me coming back day after day to see what has been posted.

Stack Overflow is currently working out great for many people. Questions (depending on wholesale nba jerseys complexity) will have answers or suggestions shortly after posting because the community seems eager to help. And yes the answers are cheap mlb jerseys normally helpful in someway, shape, or form. In the end Stack Overflow comes highly recommended from this developer.