Safely Creating Custom Handlebars Helpers For Ghost Blogs

I'm fairly new to Handlebars, the templating system that the blogging system Ghost uses, but my initial impressions are that it's a pretty sweet tool to use. However, it's somewhat limited when you're developing a Ghost blog, due to the fact that Ghost only implements certain definitions. Odds are that some of you have been wishing you could implement your own definitions somehow. Obviously you could just edit the Ghost source, but that isn't update-safe, and you would have to remember to change it every time you updated. According to the official Ghost documentation, both the index.js file and…

Keep reading →

A New Beginning With DigitalOcean and Node.js

I finally worked up the effort to move this site over to DigitalOcean, something I have been intending to do for sometime. Yes, that is a big ol' referral link, but you can rest assured that I'm telling you to use them for all the right reasons. Setting up this new blog was relatively painless - deploying a site on DigitalOcean is as cheap as $5 a month (billed by hour), and as easy as hitting a couple of buttons due to their prebuilt images. I highly recommend them to anyone looking for either smaller hosting, or larger hosting (since…

Keep reading →

Neek - A faster way to remove duplicates in files

You may be aware of the *nix tool uniq, used to filter duplicate values from within files. Uniq is a simple way to remove duplicated lines within a file via a simple command. The downside to uniq is that it requires the input to be sorted, which can be a huge downfall, and sometimes isn't even an option. Due to this, many people prefer to use another *nix tool; sort. Sort has the ability to filter out duplicated text without the need for the file to be sorted in advance, however it does this by sorting the text during the…

Keep reading →

Asynchronous Test Loops With Mocha Using it-each

Nowadays people are using Mocha more and more for testing their JavaScript/NodeJS code. One major limitation of Mocha is that there is no real way to loop tests asynchronously and maintain the ability to keep track of what's happening (such as realising which iteration a test fails on). Due to this, I created a module to allow the use of asynchronous test loops with Mocha. Currently, it's trivial to loop tests in Mocha provided your code is synchronous - literally just a typical JavaScript loop. Consider the synchronous example code below (I know, it can never fail): describe('A…

Keep reading →

Redirecting An InputStream To An OutputStream In Java

After working with NodeJS, Streams have always been an annoyance for me in Java (especially when I was first learning), simply due to the fact that you had to wait for the input to buffer and be fed through the abstract read() method of the InputStream interface. Most examples around use the BufferedReader in order to demonstrate how to do this. Let's take such an example to exercise what I mean. The following code simply "pipes" (for want of a better word), the content from the ByteArrayInputStream to STDOUT. This is typically regarded as the way to redirect some output…

Keep reading →

Andrest - A Simple REST Client Implementation For Android

It's still surprising for me that there's no nice way to use REST in Android. Most libraries are either too complex or too slow, so recently I took a look at writing a small client which can be used easily to make REST calls. It's surprisingly simple, and makes use of the Apache Commons library (for better structuring/performance). The source is hosted on GitHub. Basic Usage: It's pretty easy to get the Client up and running; we start by just creating and storing a new Client: AndrestClient rest = new AndrestClient(); From there, all that's required is a call to…

Keep reading →

Migrating From Subversion To Git The Easy Way

Until recently, I was a big fan of using Subversion for most of my private projects. Now, however, I'd rather be using Git. This is all well and good for new projects, but how do I move the mature projects from my repository to Git (specifically GitHub)? Turns out, it's actually possible although the known methods aren't very friendly/reliable. Because of this I've written a simple script for converting a Subversion repository to Git, which will pretty much go through the entire process for you - including the migration of branches and tags. It's written in Shell, and should…

Keep reading →

Starting Mocha Tests Programmically With Runner.js

Since I've been using Mocha, I realised there's no good way to include multiple files efficiently via the command line. What happens if you want to add files in nested directories and want to ignore specific files? This isn't really an issue for the typical test suite, but for larger products there could be hundreds of test cases. Due to this, I created a script I like to call Runner.js, which allows flexibility of running different files via Mocha pretty easily in NodeJS. This post is going to explain how you would go about starting Mocha tests programmatically with…

Keep reading →

Sorting An Object Recursively By Key In Node.JS/JavaScript

Sorting an object is one of those little things which nobody ever considers useful to know (until it becomes so), but it's proven particularly useful to me in the last few months - not necessarily for the comparison of two objects at runtime (which, thankfully, there are much quicker things for in NodeJS/JavaScript), but for the ease of reading logged data stores efficiently - especially large amounts of JSON, like that returned from certain requests. For example, if I'm looking for a specific key inside a logged object which has keys added asynchronously, I might end up looking for…

Keep reading →

Twitter Toolbox - A Look At Learning Chrome Extensions

Yesterday I revisited a project I began a couple of years ago when I was learning JavaScript, named Twitter Toolbox. I decided to run over it and make it work (properly). It's a Chrome extension, built with HTML/JavaScript, with allows you to customise the layout of your Twitter (somewhat) via dynamically injected CSS and JavaScript. It's not the most exciting project in the world, but it does give some insight into the creation of a Chrome extension, and the ways you can modify page CSS from an extension. Even if you don't use Chrome, Firefox extensions will work in…

Keep reading →