Posts tagged with “cheatsheet

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 […]

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, […]

The Gzip Basics

Gzip is data compression software used to compress a file into an archive, as well as expand an already-compressed archive back into a file. One common use for gzip is to compress a tarball. [One could use Zip both to collapse and compress a directory, instead of tar / gzip, but the compression isn’t as […]

Disabling platform-specific default styles

Both WebKit and Mozilla browsers have introduced default styles for certain specific element types, in an effort to impose some degree of design consistency across the platform. You might be tempted to assume a well-placed !important will override those default styles but not necessarily so. Depending on the type (like “search” for example) only certain […]

Simple vertical alignment for text

It’s not often that I miss tables but when I have to center something vertically I definitely find myself getting wistful for good ole VALIGN. There are lots of different ways of handling vertical centering, depending on what’s being centered. The method for centering a single line of text is, by far, the simplest. The […]

Image Path in CSS File

Image paths are relative to the CSS file that contains them. If, for example, you had your images and css files each in their own subdirectories within the theme (i.e. “img/” and “css/”, respectively), here’s the path one would use: .navigation { background-image: url(../img/navigation.png); }

Disabling Comments on Posts and Pages

By default commenting is enabled on both Posts and Pages in WordPress. Here’s how to disable it: Existing Posts Click Posts in the left navigation. Click the checkbox in the section header (to the left of Title) to select all pages. Select Edit from the Bulk Actions dropdown and click the Apply button. Select Do […]

Strip all non-alphanumeric characters from a string

Here’s a very handy little snippet for stripping all non-alphanumeric characters from a string: $string = preg_replace(“/[^A-Za-z0-9]/”, “”, $string); This will leave all letters (whether they are capitalized or lowercase) as well as numbers 0 through 9.

Changing ownership with chown

Need to CHange the OWNer of a file or directory? chown [new owner] [file or directory] If, for example, I wanted to change the owner of /var/www/vhosts/my_website/tmp to “root” I’d run this: chown root /var/www/vhosts/my_website/tmp If you want to apply the ownership change recursively — that is, to all subdirectories and/or files within — add […]

The Tar basics

Tar is a compression utility used to generate a single archive, known as a “tarball”, out of multiple files and subdirectories. It can also be used, inversely, to extract these same subdirectories and files out of the archive. I want to create a tarball: tar cvf [archive-name].tar [source-directory] Here’s what the options mean: c = […]