A colleague of mine just approached me and asked

How do I trigger the screensaver easier than moving my mouse to the corner of the screen?

And I already had the answer, by clicking on a dock icon! I do have another method, using a keyboard shortcut, but it’s a bit hit or miss. Here’s how to get a special icon on your dock which activates the screensaver when you click it.

Open Finder and navigate to the following directory


You can do this in Finder by using the shortcut cmd+shift+g or in the toolbar clicking Go > Go To Folder…

Find the ScreenSaverEngine icon, and simply drag it to the dock. Done! Now when you click it, the screensaver will activate, woop!

Screen Shot 2016-05-13 at 14.51.48

In my javascript code occasionally I have to loop through an array of objects, and keep a running total of one of their properties. Imagine having an array of objects such as:

var items = [{
  name: 'Shirt',
  count: 10
  name: 'Jumper',
  count: 12

And you want to have a total sum of the objects count. Now you could do this with a for loop:

var total = 0;
for(var i = 0; i < items.length; i++) {
  total += items[i].count;

But in fact, the reduce function in Array.prototype can do most of this legwork for you. The function call takes a callback function as the first parameter, which is executed with a few parameters, but the most important being the first two: the current reduced value, and the next item in the array to apply to that reduced value. The second reduce function parameter is an initial value; great when working with objects. So here’s a quick sum using reduce:

var total = items.reduce(function(value, item) { return value += item.count; }, 0);

To recap, total is assigned to the items array being reduced to a single value which is the sum of all the count properties in each object in the array. We start the count at zero else the very first time the anonymous inner function is executed, the value parameter would be the first object, not the number zero, and would essentially break the sum. Because I work in ES6, the code for me looks like this:

let total = items.reduce((value, item) => value += item.count, 0);

Which looks even neater. Take a look at the Mozilla developer documentation and this very useful Stack Overflow question to learn all you need to have reduce power your JavaScript code.

Normally, you would have to visit the Node JS website to download an updated version of Node. This can be a bit slow and a pain. Why can’t Node JS update itself if you want it to? Well here’s a stop-gap solution for now, updating using NPM itself. NPM has a packaged called ‘n’ which can be invoked to update Node to one of the various release streams (I recommend the stable release), and this is how you use it:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

These commands clean the npm cache, install the NPM module ‘n’ which is a node helper, and then invokes ‘n’ to install the latest stable version of Node. Additionally you can choose which version to install with a command like this:

sudo n 0.9.1

Making it much easier and quicker than visiting the website.

Source: DavidWalsh.name
Original: The Holmes Office

During development recently I’ve been seeing statements like this in Javascript:

var currentTime = +new Date();

What’s that plus (‘+’) symbol doing there, before the ‘new’¬†operator? Strangely, it wasn’t trivial to find out on google, as I only knew the symbol not the name, but I found it on this very useful and concise blog post. It is the unary + or unary add operator.

It does what I suspected. It looks like a mathematical plus which I’ve used to add two numbers together, or when creating strings with variables. This is a very concise use of it. When used on a variable, like new Date(), it converts that variable into a Number. It’s worth noting how it does this. First it will attempt to call .valueOf() on that variable, and convert to a number. If that fails, it will call .toString(), and convert that output into a Number. If all else fails, it will become NaN.

So in this example, the code above is achieves the same effect of:

var currentTime = (new Date()).getTime();

But looks nicer. Albeit a little unobvious.

Source: xkr.us

Wow, this old game I started working on during final year of university. I was making it in actionscript and flash, but somehow never completed it, and now it lives in dead technology. A game I should adapt to a new platform for sure. For now, it can live here.

Full Screen

I’ve started my own shop on Etsy now. With my huge collection of vintage and retro comic books, I though I would sell the books, or sell upcycles of them. If you would like to visit my store, please follow this image:

Hey all, I know I barely post but I chose a new and basic theme for my blog. Sometimes I think I have to spend time designing a whole theme or keep it quite snazzy but simple is best and that’s what I’m gonna stick with.