Unhugeifying drupal database dumps

If you are moving a drupal 6 production database back to development, you really don't need to be hauling around years of logs and old sessions in your database.

Your first option is to use the Backup and Migrate module to leave these tables out of the export file in the first place.

However if someone helpfully delivers you a 700MB .sql file with all of the unnecessary tables still in it, you can trim it down to size with the following commands.

First make a backup. Note you will need the disk space for this.

cp databasedump.sql databasedump.sql.backup

Now, these commands destroy the insert statements for the uneeded data. The table creation statements are on separate lines, and so should be fine.

sed -i '/INSERT INTO `accesslog`/d' databasedump.sql
sed -i '/INSERT INTO `sessions`/d' databasedump.sql

Then import and see if everything works. Keep your backup file around just in case until development is finished, and everything is peachy.

Key madness!

Just got done moving some encryption keys around and I am ornery and tired at all of the silliness going on between all of the encryption toolkits out there. Gnupg and seahorse (the gnome frontend) don't recognize ssh keys even to import them, even though installing ssh keys is a feature of the seahorse program. OpenSSL talks to everything as far as I can tell, but still requires a ton of conversions and switches to do almost anything. It's like before the days of universal image editors when they each could only handle their own wierd binary bitmap formats. Today we are not only used to being able to say "save" and "open" directly, but we are used to cut and paste between compatible editors.

I understand if there is trouble recognizing the odd encryption certificate format or two, but most of these things are clear as day and have headers and everything. Let's get to the point where gpg and openssl recognize and offer to convert one another's formats at least, prompting you along the way if you are going from a cert to a key or need a passphrase or whatever. Or hell, just spit out a message saying, "this looks like X or Y format. You can export from X format to my format using the following commands" Job done.

I don't know if the GNU - BSD rivalry has something to do with this silliness, but until this page is a lot shorter, we're doing it wrong.

Run aegir queue immediately

I need to stop switching contexts when doing site building. Waiting for aegir to run a queue is too easy of a time to get distracted.

Here is how to run the queue immediately:

on the commandline, switch to aegir user

su -s /bin/bash aegir

the run the dispatch command manually:

drush '@hostmaster' hosting-dispatch -d

Paste unformatted

Tired of having to paste into a text editor as a middle step to get rid of text formatting when moving content between web and rich text documents, or between two richttext docs? It's as tiresome as reading the previous sentence.

Some recieving applications can handle this for you by having a command to paste unformatted:

Openoffice / Libreoffice
Ctrl+Shift+V (then Return)

Abiword
Ctrl+.

If anyone has a tool that will clean the clipboard directly, drop me a line.

Keep emacs from pooping ~ files about

Emacs craps little backup~ files all over the place. While this is great when you have no version control and you make a mistake, these days, we all use version control (right?). These backup files are just annoying, clutter up logs and searching, and can even be a security hole if you leave them in a web accessible directory or fail to clean up permissions.

So, put this in the .emacs file in your home directory (create it if it doesn't exist)

(setq backup-inhibited 'anyvaluebutnil )

This keeps emacs from writing any new backup files.

To clean up the ones~ that are already there, first make sure that you don't want anything out of those files (or even better, put the important parts under version control) then do:

find ./ -name '*~' -exec rm '{}' \; -print -or -name ".*~" -exec rm {} \; -print

This will delete them all.

Advanced Linux Programming as a single pdf

I'm not much of a low level systems guy, but saw this in a list of 20 free linux books, and decided to read it to understand something about C programming in a Unix environment.

Unfortunately, the book was distributed as a bunch of individual chapter pdfs. Fortunately, the book is under the Open Publications license, so I could do something about it. Enjoy.

Audit your apache configuration...

There are lots of ways that you can screw up your apache configuration... here is a way to at least see what apache thinks is going on..

on redhat try

httpd -S

on debian it's

apache2ctl -S

Output:


[Wed May 26 19:01:45 2010] [warn] NameVirtualHost 192.168.65.150:84 has no VirtualHosts
[Wed May 26 19:01:45 2010] [warn] NameVirtualHost 192.168.65.150:85 has no VirtualHosts
[Wed May 26 19:01:45 2010] [warn] NameVirtualHost *:84 has no VirtualHosts
VirtualHost configuration:
192.168.65.150:80       is a NameVirtualHost
         default server site1.dev (/srv/site1/etc/httpd.conf:1)
         port 80 namevhost site20.dev (/srv/site20/etc/httpd.conf:1)
         port 80 namevhost site15.dev (/srv/site15/etc/httpd.conf:1)
         port 80 namevhost site12.dev (/srv/site12/etc/httpd.conf:1)
         port 80 namevhost site4.dev (/srv/site4/etc/httpd.conf:1)
         port 80 namevhost site3.dev (/srv/site3/etc/httpd.conf:1)

*:80                   is a NameVirtualHost
         default server site50.dev (/etc/apache2/sites-enabled/010-site50:1)
         port 80 namevhost site50.dev (/etc/apache2/sites-enabled/010-site50:1)

That is virtual hosts, ports, warnings and named servers all in one command along with a path to the files where they are defined... Pretty awesome..