Author Archives: Patrick McGoohan

Changing the timezone of your Amazon Linux EC2 instance

You’ll need SSH access to your EC2 instance before we do anything, so if you don’t have it already (or you don’t know what it is), here’s a handy guide. SSH into your instance, then use the date command to see what timezone is currently configured: $ date Sun Dec 23 21:36:49 UTC 2018 The […]

Validating the format of a universally unique identifier

Here’s a function to validate the format of a universally unique identifier, or UUID: function uuid_is_valid( $uuid ) { // check string length if( strlen( $uuid ) != 36 ) return false; // no good // check formatting return preg_match( ‘/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[89AB][0-9a-f]{3}-[0-9a-f]{12}$/i’, $uuid ) ? true : false; } It’s expecting a 36-character UUID. Adjust this […]

Securely transferring files between hosts with SCP

scp (or “secure copy“) is a method of securely transferring files between two hosts. Unlike wget, the files to be transferred do not need to be publicly accessible via either HTTP or FTP. To put it another way, ssh + cp = scp. Some caveats: You must specify a target file. If you don’t, scp […]

What to do when “Another update is already in progress”

You’re right in the middle of updating your install of WordPress to the latest version when suddenly there’s a solar flare! — and everything stops. When you reload the Updates page, instead of the expected blue “Update Now” button, there are these words: Another update is already in progress. Huh? You check the front end […]

Useful Homebrew Commands

Here are the Homebrew commands I use all the time: Update Homebrew’s core files and check for updates to any currently-installed packages: brew update Note: This won’t update any of your currently-installed packages. (See upgrade, below.) Instead, this will just show you a list of all packages that have been updated in the main repository, […]

Getting the number of results from a filtered, ordered ng-repeat

The best way to return the number of results from a filtered ngRepeat (ordered or not) is by assigning an alias to it. Let’s say we have a list of books. We use ngRepeat to output the list like so: <ul>     <li ng-repeat=”book in books”>         <p>{{book.title}}</p> </li> </ul> At this point, returning the […]

Searching for world-writable files and directories from the command-line

World-writable permissions are the equivalent of an unlocked door. They require trust and nothing online should bear the weight of that expectation. Why are they so bad? World-writable permissions are also commonly referred to by their binary equivalent of “777”, for which the digits represents the permission level for each of the three possible users: […]

Generating a password-protected archive

Generating an archive file from either a file or directory is a cinch using the command-line. Here’s the structure: zip [options] [archive name] [file or folder to be archived] While there are many options available, the one we’re interested in is -e, for “encrypted”, like so: zip -e example.txt To create a password-protected archive […]

Showing all files in the Finder

By default the Finder only displays visible files and public directories. This excludes any files that begin with a period (such as .htaccess or .htpasswd) as well as any non-public directories, such as /private/etc/ (containing useful files like hosts) or /usr/local/Cellar, where Homebrew-managed packages are installed. One can easily access all of these files and […]

Using your hosts file to preview a site before changing the DNS

Even if your web host does offer a method of previewing a site before you’ve changed the DNS, it’s usually more trouble than it’s worth, particularly if the method is a proxy and your site code includes hardcoded paths or URLs. (I’m looking at you, GoDaddy, with your PreviewMyWebSiteNow). As an alternate, you can configure […]