Trimming Strings; Stripping Text in JavaScript

Strings are one of the most basic structures in any development language. Developing with strings happens in common ways across languages. Sometimes languages don’t offer the common gamut of tools and leave the developer to implement their own methods.  One of these cases occurs with a proper `strip` method in JavaScript. JavaScript added the `String.Trim`[1] with EcmaScript5, which is a specialized version of a generic `strip`, so that leaves developers to implement it themselves.

Continue reading Trimming Strings; Stripping Text in JavaScript

The HTML5 Input Event

In the DOM a special event occurs on an <input> or <textarea> element known as the `change` event [1] [2]. The `change` event gives a developer the ability to catch input changes. However, it falls short when instant feedback is needed because it will only trigger once the input has lost focus. Immediate feedback could be handled using the `keydown` or `keyup` events. Those events are costly (happening often and requires the code to keep state to know of changes actually occurring) and are potentially buggy due to extra logic needed.
Continue reading The HTML5 Input Event

Setting up Ansible for multiple environment deployments

Ansible is a tool for automating the task of installing software via SSH. You can run it against a server, a VM or even a desktop; anything that can be a target of SSH!  If you haven’t had the chance to use Ansible then go get a basic understanding before attempting to follow the things I will talk about.

The goal of Ansible is to be able to setup a server the same way, every time (immutability). This fits well with code development and the need to have production-like servers. Ansible does not smooth the transition between different environments, however. In fact, there is a special variable (environment) that has nothing to do with the concept that I’m writing about, making it a confusing thing to describe.

Continue reading Setting up Ansible for multiple environment deployments

My must have grunt plugins of 2014

Over the course of the year, I’ve been tracking what Grunt plugins that I have enjoyed the most.

Time-Grunt
Time-Grunt plugin
Time adds really helpful charts to the grunt process to allow for a visual inspection of where things are being slowed down. The graphs keep a very clear indicator of what is taking up time in the grunt processes. When caching layers are involved, is tends to show off the difference as well.
Continue reading My must have grunt plugins of 2014

Automating tasks based on file changes

Triggering scripts to run when a file or folders change is a common advanced task. Recent applications like Dropbox and BitSync have grown from the days of rsync magic, but what about triggering code when a sync occurs. It could be as simple as emailing a photo to your parents once 5 pictures are updated in Dropbox or as advanced as rebuilding a static blog based on content changes of configuration files in a folder. This post focuses on the Linux tool for handling these events that relies on inotify; but there are similar (not covered here) ways on BSD/OSX/Windows too (FSEvents/kqueue).

I ran into this when setting up a Dropbox sync to cause a Grunt process to build a stage server. The Dropbox sync would need to trigger an Assemble.io process to turn Yaml files (that are held in the Dropbox path) into HTML.

Inotify is the systems way to event filesystem changes, but to be able to tap into inotify events it’s easiest to install another daemon called incrond (inotify cron daemon) that abstracts inotify system calls in a manageable way.

Continue reading Automating tasks based on file changes