Mac: Copy the current SVN URL to the clipboard from command line

If you are still using SVN (WHY HAVEN’T YOU SWITCHED TO GIT??), here’s a simple alias you can drop into your ~/.bash_profile . Then type `source ~/.bash_profile` on any current terminal windows to load the alias. Here’s how it works. Navigate to your SVN working copy and type `svnurl` and viola! it’s copied to your clipboard. This is extremely useful for copying/deleting/switching/merging branches via command line.
Continue…

Setting Proper WordPress Unix Permissions

One of the biggest black boxes of WordPress for newbies is file ownership/permissions. I’ve had numerous people ask me why they can’t use the default theme editor or install new plugins directly from wp-admin. The symptoms usually range from getting the FTP credentials screen to error messages that WordPress cannot create a specific directory, and more.

It took me a while to grasp the concept, so I hope the following explanation will help you. This, in no way, is a security tutorial. It is a simple tutorial on Unix users/groups and file permissions. You should also read Hardening WordPress. If you’re not sure about file permissions, read this article first.
Continue…

Automatic git status emails

This is a basic, elementary script to audit a git working copy. This is useful to keep a watchful eye on cowboy coding on a client server.

Save the following inside your git repo as .git-status.sh. Make sure to add ‘.git-status.sh’ to your .gitignore file.

#!/bin/sh
DOMAIN = "http://whatever.com"
SENDTO = "your@email.com"
MODIFICATIONS=`git status -s`
if [ ! -z "$MODIFICATIONS" ]
then
        SUBJECT = "git changes from $DOMAIN"
        EMAIL = "$SENDTO"
        BODY = "/tmp/emailbody.txt"
        echo "Changes found on the following paths:\n" > $EMAILBODY
        echo "$MODIFICATIONS" >> $EMAILBODY
        mail -s "$SUBJECT" "$EMAIL" < $EMAILBODY
        echo "$MODIFICATIONS"
fi

To automate, add a crontab:

30 15 * * * /path/to/your/script/.git-status.sh 2>&1>> /dev/null

Continue...

Restart the Mac VPN Service via Command Line

If your VPN connection is ever disrupted and you cannot reconnect, don’t restart your computer. Open up a shell window and use the following commands to stop/start the native VPN service.

sudo launchctl stop com.apple.racoon
sudo launchctl start com.apple.racoon 

Uploading folders via Terminal

There are times when I want to upload a chunk of files without logging into (S)FTP. If you’re on a Mac it’s a simple command that will upload everything in a specified folder.

scp -r LOCALPATH user@host:REMOTEPATH

Example:

scp -r ~/Desktop/folder/ user@domain.com:/var/www/path/