Blog Spammer Shootin’ Match

The Stage

For some reason….. this blog — THIS blog! …..gets a crap ton of spam. So I went looking. I figured I’d share the bulk of what I found.

Yep. If you’re getting crazy spam, watch out for China, obama, and nofollow. They. Will. Destroy. Your. Sanity.

The Apology

If you legitimately are trying to comment and noted something about any of the three mentioned above, I owe you an apology. I’m sorry I shot your comment in the spam box with glee and a special kind of whimsy.

Looking at the Data, Again!

I kinda enjoy using this as a psuedo “comment honeypot” because it’s just so darn entertaining. Here are some other fun ways to look at your comment spam:

By number of comments posted per IP:

Original IP’s censored b/c I don’t wanna be a jerk to anyone but the guy at!

By my patented, foolproof, never wrong Offender Rating System®:

Again, original IP’s censored b/c I don’t wanna be a jerk to anyone but the guy at!


Wasn’t that fun?! =D

Don’t spam me, bro!

Getting a quick summary on your MySQL Database

Summary of yer tables

Sometimes, you just want to see what’s going on from a high level. “HOW CAN I GET A SUMMARY OF MY TABLES?!” you may have asked yourself…

To do this, you’ll need to do a simple query into the TABLES table in the information_schema database. Like this:

It’s a habit for me, but I always like to describe the table so I know what I’m looking at:

Now, we can see what we’re looking for. Here’s what I generally like to do:

Yeah, even my schema names are trendy and clever.</sarcasm>

Anyways, now you can sort and/or select however you want! Grok yer data, amigo. =]

I realize my code blocks are not blocking well enough. Will fix.

Greppin’ Baller Style

So you wanna find something in yer code? Yep. Grep.

There comes a time when you really just want to find something, but either the grep is going to take way too long or you just like being efficient down to the microsecond. Either way, I’m about to show you how I grep. /flex

Anytime I grep, this is generally how I roll:
grep -IirFn "What I'm looking for" .
Let’s break it down now! We’re grepping, but what are all those options?

  • -I – ignore binary files (ie: don’t grep through my images, bro)
  • -i – case insensitive. I know I grepped for “What I’m looking for”, but maybe it’s not capitalized
  • -r – recursively grep through this directory and each one inside it… recursively. Ahem. Bad joke.
  • -F – search for my string literally, no regex!
  • -n – prepend each found line with the corresponding line number – such help! =]
  • "What I'm looking for" . – so what I’m looking for and the dot at the end is to tell grep to start looking here (and sneaky tip, include hidden files!)

Ludicrous speed, ENGAGE

Nerd Remix! Betcha Picard wished he said that once in a while. #nerdage

So let’s say this is all well and good, but we gotta keep on rollin’ through a huuuuuge codebase with lots and lots of stuuuuuuff. What then?!

This is generally when I like to FIND the context of the files I can get at and only grep through those:
find . -name "*.php" -type f -exec grep -FnH "DOING_AJAX" {} \;
Wait… that’s different…. and the arguments aren’t the same. What just happened?! D=

All great questions! Thank you for asking, me! =D

  • find . – find is the command, the dot here is for the same reason (start looking here and include hidden files!)
  • -name "*.php" – this tells find to go find files with a .php extension in the name. Keep in mind, if you want to not bother with case sensitivity, you can replace “-name” with “-iname” =]
  • -type f – this tells find to only worry about FILES (as opposed to directories, etc…)
  • -exec blah blah – this is pretty cool. You can tell find to execute any command upon the matched item. So here we told it to execute a grep. Make sure you end your exec with a fully escaped semicolon too!
  • grep -FnH – We know about the -Fn already, but the -H allows our grep to also prepend the matched grep with the filename also. So -nH gives us the filename:linenumber: match.

I hope that helps you get to what you’re looking for just a little quicker =]

Quick way to check for php syntax errors via CLI

Need a quick way to run through all php files in a directory (recursively) and see which ones have syntax errors? Here you are my friend:
find . -name "*.php" -type f -print | xargs -I file php -l file | grep -v "No syntax errors detected"

Another way to do this (which if you’re as familiar with find as I am — ie: not very) you could do this as well:
find . -name "*.php" -type f -exec php -l {} \; | grep -v "No syntax errors detected"

Set Default Username and Password for your MySQL DB

Tired of always having to enter your username and password to do anything on your mysql database? I would only suggest using this on your local dev box for security purposes, but admittedly, it’s a nice timesaver =]

Warning: this assumes you can vim. If you’d prefer, you can replace any instance of “vim” with “nano”

From the *nix CLI:
vim ~/.my.cnf
If it’s blank, feel free to insert the following (with your user credentials of course!):
user = 'user_name'
password = 'secure_password-moreso_than_that_pls...well...this_is_ok'

Save that puppy and now from your *nix CLI you shouldn’t have to worry about those precious few keystrokes when interacting with mysql anymore… on second thought, if your password looks like that above, use this. It’ll save you buckets of time =\

Quick way to remove all tables in MySQL DB through *nix CLI


Here’s a quick time saver (if you dev like me, it’ll come in handy!) for when you just want to drop all of the tables in a database. Of course, test it first so you know what you’ll be dropping!

Test First:



The basic formula is a BASH for loop that grabs all of the tables in the desired database, filters the output using a combination of AWK and GREP so we can use just a simple list, then drops each table separately.


Make a Public SSH Key from your Private Key

Once you’ve found the private key you want to make a public key for (typically in ~/.ssh/ ), here’s the quick and easy command (in this example, we’re making a .pub for our id_rsa key):

ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/

Exporting a MySQL Database

For a MySQL database export:

mysqldump -u username -p database_name > /tmp/dump.sql
^^ from the *nix command line

For a particular table in a database

mysqldump -u username -p database_name table_name > /tmp/dump.sql
^^ also from the *nix command line

You will then be prompted for the password for the specified user, shortly thereafter, you’ll have your db export (or as some folks like to call it, a “db dump” — gah! Hate that name… gross!)

Tired of always typing in your username/password when using mysql via the CLI? Check out how to set up a .my.cnf!