If you couldn’t tell, we’re big fans of open source software. We like it so much that we recently released our First Responder Kit, including sp_Blitz, under the MIT license. So when we were building Paste The Plan, our free tool to share SQL Server execution plans, there was no question that we were going to use a bunch of open source software. Here’s the rundown of which open source tools we used and why we chose it.
Open Source Tools In the Presentation Layer
HTML Query Plan – This fantastic piece of code allows the XML query plan to be displayed graphically. If this little gem wasn’t around I’d still be figuring out how to draw a line between plan operators. A big thanks to Justin Pealing for making this available to all.
Bootstrap – Ahh Bootstrap, how do I love thee? Created by the folks at Twitter, Bootstrap is a front-end framework that makes it easy to create great looking websites. Paste The Plan’s tabs and messages utilize Bootstrap. Bootstrap also has a great grid system that makes it easy to position UI elements on the page. At this point, I’m not sure I’d build a website without Bootstrap.
Clipboard.js – Clipboard.js allows us to put content in the user’s clipboard thus allowing a one-click copy. We used to have to do this with a tiny Flash application. Thankfully, by using Clipboard.js, Flash-based copying is a thing of the past.
Code Prettify – Reading code is a tedious task. In order to help the reader read crazy amounts of XML we’re color coding the XML using Code Prettify. Created by Google, it does the heavy lifting of making text output more readable. It supports a vast amount of languages (including Mumps and Nemerle if you’re into that kind of thing) and easy to get working.
Bluebird.js – We’re using API Gateway in AWS for the Paste The Plan API. In order to communicate with the PasteThePlan API, we are using code that API Gateway makes available (thanks Amazon). This code is using a new-ish feature called promises. Now, every modern browser supports promises, but wouldn’t you know it Internet Explorer doesn’t, so this is where Bluebird comes in. Bluebird allows older browsers like IE to use promises. Instead of rewriting the communication code to API Gateway, we used Bluebird and had an early lunch.
Open Source Tools in the Application Layer
libxmljs/node-libxslt – For our application layer, we’re using AWS Lambda with Node.js. Node is an interesting language in that, unlike Java or C#, most of your base functionality isn’t baked into the language. In order to parse the query plan XML, we need to either write the parser ourselves or find a library to do it. This is where libxmljs and node-libxslt come in. We’re using these tools to not only parse the XML but to format, to traverse, and to transform the query plan into HTML.
shortId – Generating unique ids are a pain. This is how why we get fun stuff like guids in our databases. Our problem was how do we generate a unique readable id. Shortid creates small, non-sequential, url-friendly unique ids which solved our problem perfectly.
ADM-ZIP – We wanted to use zip compression on the JSON files that we’re storing in S3. This not only minimalizes storage size in S3 but it also minimizes transport size too. ADM-ZIP allows us to compress the JSON object in memory before we save it to S3. Best of all is that it doesn’t have any additional dependencies.
dotenv – We have Paste The Plan installed in multiple environments. In order to let the application know which database to connect to or which S3 bucket to use we’re using an environment file. With dotenv you can declare an .env file and have the application read it at run-time with just one line of code. This saves a bunch of time from having to read and parse the file yourself.
Brent says: just reading this reminds me of why I gave up doing development work. My hat is off to Richie for continuing to challenge himself by embracing new technologies, picking up different tools, and figuring out creative ways to get problems solved. Throughout this, I kept asking Richie, “Do you want to keep going with this, or switch back to the Microsoft stack?” He kept right at it, and I think the result is worth it.