Programming

The JavaScript NIFE Pattern

Posted on

Most JavaScript developers are very familiar with the Immediately Invoked Function Expression (IIFE): (function () { var x = ‘loaded’; console.log(x); }()); In this expression, we create a function that wraps all the enclosed code in its scope, and at the end we execute the function with the parentheses. If you aren’t super-careful though, you […]

Automation

Highlight Versions on Octopus Deploy Dashboard

Posted on

Unless you enjoy carefully comparing numbers, the Octopus Deploy Dashboard is a bit of a pain when it comes to seeing what version is one what environment. What follows is a terribly hacky trick you can use to colourise the version numbers on the dashboard (a feature that I imagine will eventually become a graceful […]

Programming

A JavaScript resizeDone Event for jQuery

Posted on

If you have ever handled a resize event in JavaScript, you will have noticed that when a user manually resizes their browser window by dragging the edges… you get a lot of events. This is because the resize event fires constantly as the user resizes the window. $window.on(‘resize’, function () { // Your code gets […]

Programming

Cross Domain Iframe Resizing

Posted on

If you have ever integrated third party components on your website, you will have found a dazzling variety of integration methods, from JavaScript snippets, to iframes, to server-side APIs. Many of the integrations seek to inject content onto your page, but I sincerely advise against this. You don’t need to spend long reading the OWASP […]

Programming

JavaScript Key Constants

Posted on

If you are fed up of looking up JavaScript key mappings every time you want to deal with a keyboard press, and each time you read someone else’s keyboard event handler… and every time you revisit a keyboard event handler that you wrote a while back – here is a set of constants you can […]

Programming

Help People Cite Your Work With JavaScript

Posted on

This is a little script that helps people to cite your work by placing the URL on the clipboard along with the text they are stealing referencing. It works by cloning the selection into a hidden element just before the copy-to-clipboard, and then reverting the selection just after. The example below is for modern browsers […]