Code

Moving from Rails to Vue Saved Me Headaches — and $84/Year

20 minute read Modified:

I truly intended to use Rails' extra features. First life just got in the way. And then Rails did.

Grab a bowl of buttery popcorn because the saga continues! The end of the previous chapter saw our intrepid little Rails app camping happily on Heroku. This latest chapter in the hosting chronicles brings with it a twist: not just a change in host, but a complete migration from one programming language to another.

The app is no longer on Heroku, and it’s no longer written in Ruby or Rails. It’s written in JavaScript, hosted by Netlify, and it’s getting by with a little help from its new friend, Vue.js.

Onward for the Why’s, How’s, and Gottchas of the switch.

Beyond the Hype — Is Hugo the Right Fit for Your Site?

6 minute read Published:

Is Hugo the right match for your site, and is it worth the hype? Here's what you need to know, reader's digest style.

Static site generators aren’t new, but something about the fresh simplicity of Hugo is turning heads. We’re in the early stages of the Gartner Hype Cycle, but expect to see media outlets abuzz with tales of Hugo “making waves” and “disrupting stuff”. Even de facto strongholds like WordPress have begun losing ground to the inexorable spread of the Static Invasion.

But between all the skirmishes, turf wars, and soap-box-soliloquies, how do you know if Hugo is the right match for your site, or if it’s even worth the hype? Here’s what you need to know, reader’s digest style. (from Migrating WordPress to Hugo, Step-by-Step)

"Migrate from WordPress to Hugo, Step by Step": What to expect.

4 minute read Published:

You've got a WordPress site you want to migrate to the Hugo static site generator. Now there's a fun course that will help you do it, safely and efficiently. What should you expect from the course?
Hugo isn’t even at version 1.0 yet, and it’s already of the one of best static site generators in the world. A switch from WordPress to Hugo can save you money, improve site performance, and harden site security. For the shiny gopher-shaped cherry on top, do I dare say it? — Hugo is fun. With your current site stuck in WordPress, how do you get from point WP to point Hugo?

Essential markdown cheatsheet

2 minute read Published:

The only markdown you really need to know.

Markdown is a great way to format text inline, without getting in your way. i.e. it’s not ugly and cumbersome like HTML tags, and your hands don’t have to leave the keyboard to access formatting toolbars like they might in a traditional text editor. Personally, markdown helps keep me “in the zone” when I’m writing. That’s why this site uses markdown for nearly all its formatting needs.

You can learn markdown in about 5 minutes. Here’s a cheatsheet to get you started!

Brute-force all the things?

6 minute read Published:

These days it’s hard to tell whether the computer saves us more time than it wastes. However recently I had an experience programming in Ruby that demonstrated to me that the computer can be our modern time-saving friend, especially when wielding a language like Ruby, delicately designed to just “get out of your way” and let you program. The story involves number crunching, eyebrow scrunching, and in the end, an unabashed brute-force beauty.

OpenCover: ⟳ code coverage metrics with CI build

5 minute read Published:

OpenCover analyzes your .NET codebase and generates an XML report rich with detail about the extent and quality of your code coverage. You think you’ve covered your testing bases, but how do you know? What if there’s actually a sneaky runner leading off second base? If so, OpenCover will blow his cover wide open. In this post I will show you how to retrofit your automated build with OpenCover. Then we’ll make the output more human-readable with Report Generator.

If you read my article about Psake, you’ll recall that I started the open source project Resfit in order to experiment with Acceptance Test Driven Development. I started the project with NCrunch and though the 30 day trial ran out, my appreciation for NCrunch’s coverage metrics did not. I found OpenCover, which generates some amazing code coverage metrics. Only trouble is, they’re all in XML - Better suited to be read by a build server than a lowly Developer like myself. That’s where ReportGenerator comes in, which “converts XML reports generated by OpenCover, PartCover, Visual Studio or NCover into human readable reports in various formats”.

Git hooks, practical uses (yes, even on Windows)

7 minute read Published:

What are Git hooks? Can you do anything useful with them? Also, since Git hooks come from Linux, is there anything special you need to do to get them working on Windows?

What are Git hooks?

Git hooks allow you to run custom scripts whenever certain important events occur in the Git life-cycle, such as committing, merging, and pushing. Git ships with a number of sample hook scripts in the repo\.git\hooks directory, but they are disabled by default. For instance, if you open that folder you’ll find a file called pre-commit.sample. To enable it, just rename it to pre-commit by removing the .sample extension and make the script executable (chmod +x pre-commit if you’re on Linux, or just check your NTFS execute rights if you’re on Windows). When you attempt to commit using git commit, the script is found and executed. If your pre-commit script exits with a 0 (zero), you commit successfully, otherwise the commit fails.

If you take a look at the default sample pre-commit script, it does a few helpful things by default, like disallowing non-ascii filenames since they cause issues on some platforms, and checking for whitespace errors. This means that if you enable this script and have “whitespace errors”, like lines that end in spaces or tabs, you’ll fail to commit and have to remove the whitespace before you can commit.

What cool stuff can I do with Git hooks?

Since you’re working with scripts, you can do pretty much anything with Git hooks. That being said, just because you can do something… Yeah, you know. Git hooks can make the behavior of common Git tasks like committing, pushing and pulling nonstandard, which can annoy people, especially if they’re just trying to get used to the glories of Git. But here are a few examples of what you might accomplish with Git hooks.

Psake automates your .NET build using PowerShell. Here's how.

8 minute read Published:

What is Psake and why do you want it? Psake is a build automation tool written in PowerShell. That means you don’t have to mess around with MSBuild scripts and trying to force procedural code into a declarative XML format - which is just weird. Psake frees you from the shackles of awkwardness. But how does it work?

With Psake, you write a PowerShell script consisting of one or more build “tasks” which you can invoke from PowerShell, or even from a continuous integration build server. You invoke your build task via the Invoke-Psake function or, more commonly, via a build.ps1 or build.bat script. Each build task can depend on zero or more other build tasks, and it’s possible to set a default build task. Each build task can do whatever you’d like, including cleaning your solution, building your assemblies, running your acceptance tests, running your unit tests, generating code coverage reports, packaging the binaries in a zip file, a NuGet package, etc. If you dream it, Psake will build it.

In 18 seconds Psake builds it, tests it, and packages it. Boom.
In 18 seconds Psake builds it, tests it, and packages it. Boom.

PowerShell: An Introduction for Linux Afficionados

6 minute read Published:

Many of us cut our teeth on the elegant simplicity of the Linux command line, with its dazzling zero-based array of infinitely chainable commands. Then, with a dull thud you found yourself dumped rudely into the Windows environment, where things on the command line weren’t quite so peachy, to put it mildly. In fact, working in the old Windows command line was almost as fun as working in the trash compactor of the Death Star. Fortunately, with the advent of PowerShell, the dystopian landscape of the Windows console started to put forth a few shoots and sprigs of greenery. In this post I hope to show you some of our favorite Linux commands translated to their equivalent PowerShell cmdlets.