Snippets

Quickly Copy MySQL Database to Remote Host

31 August 2007

Copy an entire database: mysqldump LOCAL_DBNAME | ssh USER@REMOTE_HOST mysql -p REMOTE_DBNAME Copy a single table: mysqldump LOCAL_DBNAME LOCAL_TABLE | ssh USER@REMOTE_HOST -p REMOTE_DBNAME REMOTE_TABLE This shortcut only works if you can access the local DB without a password. If you have to login to both local and remote MySQL servers, the MySQL password prompts [...]

Read the full article →

SSH-Keygen For Public Key Authentication

7 August 2007

ssh-keygen -t dsa -b 1024 [root@titan .ssh]# ssh-keygen -t dsa -b 1024 Generating public/private dsa key pair. Enter file in which to save the key (/root/.ssh/id_dsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_dsa. Your public key has been saved in /root/.ssh/id_dsa.pub. The key fingerprint is: [...]

Read the full article →

Exim Queue Snippets

28 June 2007

These are all useful when trying to track down an open formmail script. List bounce messages exiqgrep -f ‘^<>$’ Freeze bounce messages exiqgrep -i -f ‘^<>$’ | xargs exim -Mf Freeze messages from user@domain.com exiqgrep -i -f user@domain.com| xargs exim -Mf Find out what user your webserver runs as. Use this as the email address [...]

Read the full article →

Recursive Chmod Tricks

27 June 2007

Recursively chmod only directories find . -type d -exec chmod 755 {} \; Similarly, recursively set the execute bit on every directory chmod -R a+X * The +X flag sets the execute bit on directories only Recursively chmod only files find . -type f -exec chmod 644 {} \; Recursively chmod only PHP files (with [...]

Read the full article →

Grep Replace and Word Processing

25 June 2007

I spend so much time in a text editor, its hard to get my head around a word processor sometimes. Text and formatting at the same time? Moving some content around I found myself with a ton of links formatted in an unordered list. I only needed the plaintext of the name and link separate [...]

Read the full article →

Adding Human Readable Date to MySQL Query

15 May 2007

SELECT *, FROM_UNIXTIME( ‘t_stamp_column’) AS date FROM ‘tablename’ For formatting the date see MySQL’s date functions information.

Read the full article →

Qmailscan Report

7 May 2007

more /var/spool/qmailscan/quarantine.log | grep "`date ‘+%d %b %Y’`" | cut -f5 | sort | uniq -c | sort

Read the full article →

Centering a Page with CSS

4 May 2007

Add this to your stylesheet: body    {     text-align: center; } div#main    {     margin: 10px auto;     width: 600px;       text-align: left; } Use this for the page body: <body> <div id="main"> … main body html … </div> </body>

Read the full article →

WordPress Hack to Debug Themes on a Live Site

9 April 2007

How can a WordPress them be debugged privately without showing the wizard behind the curtain to everyone else? This simple hack will use the specified theme only for one remote IP… yours. This can be used when creating a new theme by configuring WordPress to present the original theme and specifying your new theme in [...]

Read the full article →

Selecting Filenames with Non-Standard Characters in the Filename from the Shell

20 March 2007

An erroneous cut and paste in an iTerm left me with a group of empty files named after hex color codes. -rw-r–r– 1 root root 0 Mar 20 16:54 #ffffb0, -rw-r–r– 1 root root 0 Mar 20 16:54 #ffd850, -rw-r–r– 1 root root 0 Mar 20 16:54 #ff50a8, -rw-r–r– 1 root root 0 Mar 20 [...]

Read the full article →