Sign in

The mkfile command comes bundled on macOS. It creates a file on your computer of any size you choose. It can be used to create temporary files for testing.

The mkfile command takes 2 arguments, size and filename:

mkfile -n size[b|k|m|g] filename

To create a 1GB file called ‘useless_file’ type the following in the terminal:

mkfile -n 1g useless_file

A new 1GB file is created in the current working directory. It will be made up of all 0’s (this ties into using the rsync command below).

The rsync command also comes bundled on macOS. It can transfer files locally or…

Learning how to use the following built-in array prototype methods has been deemed by some as the gateway drug to functional programming.

  • Array.prototype.filter
  • Array.prototype.sort
  • Array.prototype.reduce


Filter iterates over each item in an array. If a condition is met (and returned true) the item is returned to the original array. Pretty simple. If false is returned (or nothing is returned), the item is thrown away.

This means if an array has 10 items and filter only matches 6, only 6 items will be returned (different than


Use Array.prototype.filter to filter people with names greater than 4 characters.

Create an…

Disable Sleep with Caffeinate in MacOS

Caffeinate has been bundled with MacOS since 10.8 Mountain Lion.

To temporarily disable sleep, run the following command:


While caffeinate is active, sleep is prevented.

To stop caffeinate:

killall caffeinate

Or press “Control+C”.

Prevent sleeping for a specified block of time

Add flags to prevent sleeping for a specified block of time:

caffeinate -t 7200 &

The number attached to the -t flag is the amount of time in seconds (7200 seconds = 2 hours). & runs the process in the background.

Prevent sleeping while a command is run

Caffeinate can also be attached to other commands to prevent the Mac from sleeping while that given command runs:

caffeinate [command_to_run] -arguments

This command will avoid sleep only as long as it takes to run the command provided, after which normal sleep rules apply.

Originally published at on September 17, 2016.

John Wilson

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store