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.
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).
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.
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 Array.prototype.map).
Use Array.prototype.filter to filter people with names greater than 4 characters.
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:
Or press “Control+C”.
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.
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 blog.jdwilson.ca on September 17, 2016.