Skip navigation

Category Archives: Stupid Dev Tricks

Try these at your own risk. I’m not a very good software developer.

For the way I use PhantomJS, it has a habit of hanging and leaving me with a bunch of zombie phantomjs.exe processes. My solution was to put together a timer that would periodically kill all phantomjs.exe processes (and all their descendants) which were older than a specified number of minutes. It’s mildly elegant, but also mildly brutish, and much more overhead than I wanted.

I can’t believe this didn’t occur to me sooner. The easier, cleaner way is to add the following to the script you’re having it run:

Now all my phantomjs.exe instances reliably off themselves once the timer elapses.

The last time I built a new rig for myself was in October 2005. Oh, sure, I upgraded its CPU, RAM, GPU, and so forth as time went on, but the motherboard (and thus the general core of the machine) lasted over a decade. Go me. But a lot has changed in the past decade, so I’ve finally built something new.

To the point: the motherboard I chose, the GIGABYTE GA-Z170X-Gaming 7, has a Sound Blaster Recon3Di as its onboard audio, but there appears to be a problem with Creative’s drivers when running a 5.1 Surround setup on Windows 10. Every time I reboot, the audio is disabled. To get it working again I have to open their control panel, switch to headphone mode, and switch back to 5.1 Surround. That’s all it takes, but it’s a pretty big annoyance and a huge embarrassment for Creative. Shame on y’all for not testing your drivers before releasing them!

My solution, though utterly ridiculous, is to use reliable old AutoHotkey. This little script has WOMM Certification, so your mileage may vary:

I compiled that and put the resulting executable in an out-of-the-way location. I figured I could create a shortcut that would run as admin in the Startup folder (Run → shell:startup) but soon learned that Windows 10 apparently skips any shortcuts with run as admin specified. I suppose this is to prevent a bunch of UAC blockages from popping up immediately after logging in? Not that it would matter to me, since I disabled UAC, but anyway… this means you have to use the Task Scheduler.

Create a new Task, name it “SBR3Di 5.1 Fix” or something, and make sure to check “Run with highest privileges”. The Trigger is “At log on of any user” and the Action is “Start a program” (your compiled executable). That should do it.

Did I mention this is utterly ridiculous?

Home Sweet Home

Home Sweet Home

I guess Sass happened a few years ago and I missed the memo. That’s bad news for me because since I didn’t hug it, and pet it, and squeeze it with such love as soon as it appeared, I missed the total-newb tutorial train. Everyone’s already supposed to know everything about it by now, so all the advanced Sass techniques and integrations assume you do. After all, how could you not? …unless you’ve been living under a rock. Which I have.

I get what Sass does and I know Foundation makes heavy use of it for customization. When I realized I wanted Foundation to render rows wider than 1000 pixels by default, I knew it was time to adopt Sass. I simply had no idea how to do it for my current setup, which is Visual Studio 2013 Update 3, Web Essentials 2013 for Update 3, and Foundation 5.

In my travels, I kept seeing mention of something called Compass (I have no idea what it is or why I would need it), but according to what I’ve been reading, Web Essentials recently supplanted much of that tool’s usefulness in Visual Studio. Fine with me: the less bloat, the better. Unfortunately, the web development community at large hasn’t really caught up with this turn of events, so tutorials for Compass are still all over the place like it’s the only option for this particular quest. And it’s not.

Without further ado, I will describe here the steps I followed in order to customize Foundation 5 via Sass in a new ASP.NET MVC 5 Web Application through Visual Studio 2013 Update 3 with Web Essentials 2013 for Update 3 installed.

  1. In Visual Studio, FILE → New → Project… → Installed → Templates → Visual C# → Web → ASP.NET Web Application → (name it whatever) → OK.
  2. MVC → OK.
  3. Right-click your new Web Application project in the Solution Explorer and select Manage NuGet Packages…
  4. Search for “foundation sass”. At the time of this writing, the most appropriate package was Zurb Foundation 5 (for Sites) Core Sass files. I guess you could alternatively do this in the Package Manager Console:
  5. Rename  /Content/Site.css to  /Content/Site.scss (CSS to SCSS) and replace its contents with the following, which puts a custom variable out there and then processes it against the core Foundation SCSS files to create a compiled CSS file:

    Let me briefly explain what’s going on here…

    • Line 4: If you don’t have this line, you can’t do stuff like rem-calc() in your customizations… which, as it turns out, is exactly what I need to widen the rows. This crucial little tidbit stole an hour of my life. It’s mentioned in the documentation, but it should just be there by default. I’ll explain the pathing in a sec.
    • Line 6: That’s me doing what I came here to do: I want Foundation to take advantage of wider screens. Instead of limiting itself to 1000 pixels, I want 1200 pixels. Much better. Also, super secret unobvious magic: order matters!
    • Lines 8-10: These three files are what actually build the Foundation CSS. Similar to what happened on line 4, we have to point Web Essentials to the files using paths. You’ll notice that the /sass/foundation/Site.scss file (which we didn’t use in this scenario) doesn’t have pathing because all those files are in the same directory. It’s also missing the ever-important line 4, which is just cruel if you’re trying to use it as an example. Ahem.
  6. Saving Site.scss generates Site.css.

    Saving Site.scss generates Site.css.

    As soon as you save your modified Site.scss, Web Essentials will compile Site.css and stick it under Site.scss.

  7. Run your project now and you’ll see that Foundation has been applied to the default ASP.NET hello world page. It’s not the best test in the world, but it’s quick and it shows it’s working. Change 1200 to 700 or something and refresh to see the effects.


The $row-width setting I modified is just one of the many things you can customize. Check /sass/foundation/_settings.scss for more options. The official Foundation documentation explains a few of them on a per-feature basis, too.

It’s not that this is terribly difficult… I just couldn’t find it explained the way I needed given my varying levels of proficiency with these tools. Hope this helps someone save a few hours and tears.

The Foundation Icon Fonts 3 pack is pretty cool. Not the best selection, and way too many stupid “social & brand icons” (MySpace? Really?), but I figure if I’m going to use Foundation anyway, why not. And since I’m living in ASP.NET MVC land these days, the official way to go about adding them to my web application is to chuck them into a bundle. That’s a nice, clean way to keep things organized and optimized. So, I did it, but it didn’t work very well once pushed to Azure. The icons wouldn’t load and I got weird 404s and 500s… What gives?

Well, I spent more time than I’d care to admit trying to figure out why something I figured was going to be simple and easy… wasn’t. Here’s what I discovered it took to get those icons working in this particular environment, and I hope it saves someone a little time.


First things first, the files need to be in there, so you’ll want something like the structure I’ve got.

Then comes bundling. You could just throw it into your primary Foundation bundle, but here it is in its own. Line 10 is the real magic because of the CssRewriteUrlTransform added to Include(). It’s kind of a big deal because it forces any URLs in your CSS file to cooperate with the MVC routing. And for being so crucial, it shouldn’t have been so hard to find.

Then make sure you actually call that bundle in your BundleConfig.cs:

Same deal in your _Layout.cshtml or wherever else you may want to do it:

And finally, one more “guess the password” type of requirement (that’s my way of saying you’d probably never, ever figure it out unless someone shared it with you). In your Web.config, you need to add these MIME mappings so everything will load correctly across all browsers. Why you have to explicitly set this instead of it being default behavior is stupid and beyond my comprehension:

Happy Happy Joy Joy

There you have it. After I did those magical things and published to Azure, the icons showed up. Ridiculous.

JSON Visualizer

Kind of needed that forever ago. But hey, no more external JSON viewers for me! Woo!

I don’t claim to be a good coder. Even less so when it comes to web development, which I consider to be icky poo-poo even with modern toys like Foundation and Knockout. My point: you’re about to see some stuff I’ve cobbled together. I don’t know if it’s any good, but I hope it helps someone.

So I’m really still a complete n00b when it comes to both Foundation and Knockout, but I’ve seen enough to know I like them both. I’ve also seen enough to have run into problems as I try to use them together. Here’s a fun one… suppose you want to use Tabs. At first glance, that’s no problem!

Nothing new or special there, and it works. Now, what if the array of Tabs might change mid-stream due to something the user’s done? You’d figure Knockout would take care of that for you like it takes care of everything else. But you’d be wrong. Well, half wrong. I think Knockout really does try. Foundation, however, is being stubborn.

Foundation and KnockoutIt’s not documented very well anywhere that I could find, but it looks like Foundation gets kind of drowsy after rendering the page, and you gotta poke it when something like this changes. I don’t know what’s special about Tabs and Accordions (yeah, it happens with them both, and possibly other stuff as well) when compared to all the other things Foundation does correctly in partnership with Knockout, but in any case, there is a solution:

Add that custom binding, and use it like so:

It took some digging to find it, but that reflow call is the poke of which I spoke. And don’t worry, it doesn’t look like it’ll really impact performance. In fact, it was written for this kind of thing. …and then never advertised.

I have done some terrible, terrible things over the past few months in my dealings with RavenDB. This one isn’t so bad.

Optimash Prime

I noticed early on that I was probably going to have to write a few Transformers. I’m lazy and didn’t want to have to actually do anything to maintain them or make sure they’re up-to-date if I change the underlying codebase, so I came up with a way to have it take care of itself for me.

This chunk of code is intended to be run just after you’ve initialized your static IDocumentStore, preferably in a web service or something that isn’t going to be starting and stopping a whole lot. The point is that this ought to happen infrequently, hopefully only once.

Pretty simple stuff. Get all the classes you’ve created which inherit from AbstractTransformerCreationTask, initialize one of each, convert all those instances to a list, and then dump each one into the IDocumentStore. Now the Transformers in the database are guaranteed to match their counterparts from your codebase.

Ready to download and install Visual Studio 2013? If you’re like me, you’ll want to clean things up first so you don’t have side-by-side installations… that’s right, it’s time to uninstall Visual Studio 2012 and as many of its buddies as possible. Of course this does mean you’ll lose a lot of your preferences, but hey, you knew what you were signing up for.

Frustratingly, Microsoft’s developer tools always leave a damn mess behind. I guess we’ll have to settle for mounting the VS 2012 iso and running this command:

…though I suppose the executable may have a different name depending on your edition of VS. Anyway, that’s as close to a one-stop-shop we’re going to get for clearing out VS 2012. You’ll still have to uninstall a few things manually, potentially delete the directory from Program Files (x86), and so on.

Chuck Norris ApprovesI’ve only used VS 2013 for a few minutes but I’m already very intrigued by this CodeLens thing. It’s a little distracting because it bumps the actual lines of code around to make room for its helpful little bits, but I’m thinking the trade-off may be worth it. I’m also enjoying the tiny bit of extra color Microsoft’s thrown back into the icons here and there. Thanks, dudes.

Another thing that is relevant to my interests regarding this upgrade is the move from MVC 4 & Web API to MVC 5 & Web API 2, since I have several projects using the former architecture. Luckily, there’s a nice walkthrough to help make that happen.

Don’t forget to cruise through all your *.sln files and change this bit at the top:

…to this:

…so they get the nifty new 12 icon (as opposed to the old 11 icon! so last year!).

Unfortunately, two of my favorite things didn’t get the memo and aren’t compatible with VS 2013 yet: the Productivity Power Tools extension, and StyleCop. Hurry it up, you are sorely missed!