Mike Wills Podcast 2017-08-01 – Dog Days of Podcasting 2017-01

Here is my first installment of the Dog Days of Podcasting podcast. I dusted off the equipment and I took you on a journey to figure out what the hell this Dog Days of Podcasting will be about.

Forcing SSL in IIS without being annoying

When we recently launched our site, and with everything going to HTTPS only, I wanted to force as much to HTTPS only as possible. There are many, many links on how to force HTTPS on an IIS server. The issue is that when you debug your application locally, you have to comment out that section of code, do your debugging and changes, then hope you don’t forget to uncomment out that section of code. I have finally found out to the force HTTPS and allow you to debug on localhost. Here is the code that you need in your web.config:

<system.webServer>
  <rewrite>
    <rules>
      <rule name="HTTP to HTTPS redirect" stopProcessing="true">
        <match url="(.*)" />
        <conditions>
          <add input="{HTTPS}" pattern="off" ignoreCase="true" />
          <add input="{HTTP_HOST}" matchType="Pattern" pattern="^localhost(:\d+)?$" negate="true" />
          <add input="{HTTP_HOST}" matchType="Pattern" pattern="^127\.0\.0\.1(:\d+)?$" negate="true" />
        </conditions>
        <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}{REQUEST_URI}" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>

The HTTP_HOST lines are what need to be added then it will work! Reference

Add Visual Studio Code to your context menu

After the release of the new Visual Studio Code, I took a look at it and figured out that the target market is those that are currently using Sublime Text. I want to give it the ol’ college try, but the one big thing that was missing for me is the ability to right-click on any file and open it in Visual Studio Code, like I can with Sublime Text.

Here is how to add this functionality. In the registry add the key HKEY_CLASSES_ROOT\*\shell\Open with Visual Studio Code\command with the value of @="C:\\Users\\USERNAME\\AppData\\Local\\Code\\app-0.1.0\\Code.exe \"%1\"" replacing USERNAME with your username. That is it!

A Fix for PDF Display Issues in Chrome

We came across an interesting bug in Chrome two days in a row, a PDF wouldn’t display correctly. It would be missing either an entire page or just some of the information on the page. There are published work-arounds to disable the built-in Chrome PDF viewer and instead utilize Adobe Acrobat Reader instead and also notices to maybe use a different browser. Let’s be honest here, the fault is the person/company that creates the PDF to make sure to optimze the PDF for the best viewing experience on the web.

Here is the problem, the Chrome PDF viewer cannot work with layered PDF files. I didn’t know layers was possible until just yesterday. Apparently, though I don’t yet know how, you can turn on and off layers (think of Google Maps with turning on and off features on the map). So how do you fix it? In both our our instances, we needed to flatten the PDF. Once we flattened the PDF and optimized it for the web, it showed up correctly in Chrome.

Don’t get me wrong, sometimes you will want those features and then you will need to provide a disclaimer stating that some PDFs may not render correctly in the Chrome browser. At least until Chrome adds support for layers.

A Responsive Google Map Application Template

At work, I am working on rewriting a bunch of maps so that they are consistent and mobile-friendly (a.k.a. responsive). When I starting searching for some basic how-tos I turned up nothing. I did find how to make Google Maps itself responsive. My issue was how do I add a legend and form that will filter or add content to the map and keep it mobile-friendly. Since I couldn’t find anything, I set forth to make something myself. In one weekend, I created a basic framework utilizing Bootstrap, the following week I refined and finalized the application and I think it turned out well.

I made the template open-source so that others can benefit from what I learned and help make this a better template in the future. I hope others can help me make this even more accessible and improve the template further.

I used Bootstrap because that is what I am most familiar with. In the future, if I have time, I want to try to eliminate Bootstrap to reduce the overhead. Once our new website launches, I’ll add some examples of what I created with the template so you can see why I felt this was important.

Here is what the large-screen version looks like:

Large screen view of application
Large screen view of application

Here is the mobile views:

Mobile View of Application
Mobile view of application
Mobile View of Legend
Mobile view of legend
Mobile View of Filter
Mobile view of filter

Do Not Use Comments

This came across my Hacker News feed the other day, “I’ve never seen a language’s style guide recommend avoiding comments before.” After reading the link it became clear that the HN title was link bait. What the Haskel documentation was stating is something any good programmer already knows. Don’t document every line of code.

x = x + 1; // Increment x by 1

This comment is not required as it is obvious what it is doing. My rule of thumb for commenting is; if it’s complicated or was problematic, it requires a comment explaining the why or why not. A good programmer should be able to read through the simple code and know what is going on. However, commenting on why you wrote something the way you did would help yourself or the next guy to know what you were thinking.

This comes to light not only when I am looking at code I wrote 5 years ago, but recently I had a co-worker leave. He didn’t write many (read any) comments in his code. Now in some cases I am running debug just to see what the application is doing before I can think of fixing that bug or making that change.

So do your future self or co-worker a favor and comment… but not too much.