CartMetrix - Do you know yours?

11/5/2007

OSX Scrollbars Top and Bottom

In Terminal:

defaults write “Apple Global Domain” AppleScrollBarVariant DoubleBoth

Popularity: 74%

8/31/2007

Quickly Copy MySQL Database to Remote Host

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 get mashed together. You could specify the password on the command line like

-pPASSWORD

but your shell may keep the password in its history so that anyone with access to your account could pick through your shell history and retrieve the password. Using the MySQL password prompt doesn’t do this.

Popularity: 100%

8/7/2007

SSH-Keygen For Public Key Authentication

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:
d2:32:02:4e:25:27:53:8f:c1:ab:80:02:0f:25:da:af root@host.domain.com

Then copy in any public keys into ~/.ssh/authorized_keys

Popularity: 38%

6/28/2007

Exim Queue Snippets

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 to key on. For example, my Apache runs as nobody so I want to freeze all messages sent from the user nobody@domain.com so I can look through them to see if I can deduce where the insecure formmail script is.

Delete frozen messages

exiqgrep -z -i | xargs exim -Mrm

Popularity: 27%

6/27/2007

Recursive Chmod Tricks

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 extension .php)

find . -type f -name ‘*.php’ -exec chmod 644 {} \;

Popularity: 32%

6/25/2007

Grep Replace and Word Processing

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 for the current project. My trusty BBEdit with Grep search and replace support yield the following search and replacement patterns to make quick work of the list.

Search Grep Pattern

<li><a href=“(.*)”>(.*)<\/a> ?<strong> ?\((.*)\)<\/strong><\/li>

Replace Grep Pattern

\2\t\(\3\)\r\1\r

Turned this

<li><a href=“http://www.agentb.com/”>AgentB</a> <strong> (Deals)</strong></li>

into this

AgentB (Deals)
http://www.agentb.com/

I always keep an empty BBedit window for text processing like this. Its easy to paste a chunk of text, process it and then paste it back into your word processor.

Note:
I’m almost good enough at Grep search patterns to make this viable in all situations. It used to take me 5 minutes to debug and expression that would have taken 2 minutes to cut and paste manually. I had this one whipped out in much less time than it would have taken to manually cut and paste a hundred of these.

Popularity: 23%

Next Page »


damonparker.org is proudly powered by WordPress
Entries (RSS) and Comments (RSS).

copyright © 2002-2008 damonparker.org. all rights reserved.

Close
E-mail It