Welcome to Mike Shannon's website. Below you can read my blog about programming, Drupal, search, etc., learn more about me or visit my SEO business website. You can also read more of my thoughts on search marketing and related ideas here.

How to Print Prime Numbers, a C++ Example

The following code uses the Sieve of Eratosthenes method to print all prime numbers in the range of 2 to n, while n being the upper limit, command line integer you feed into the program. You could also just hard code n if you wanted to. Since it's in C++, this code can easily be ported to PHP or other languages that share similar syntax.

How to Recursively Copy Files from a Remote Host using wget and FTP

Tags:

wget -r ftp://username:password@your.ip.address/dir/*

OR

wget -r –user=your_username –password=your_password ftp://ftp.yoursite.com/dir/*

Note the * at the end of the commands, you will need this else wget just retrieves the single, index file 

How to get the last created auto-increment ID from a MySQL table

If you’re like me then you’re developing like crazy.  Once in a while you may need to retrieve the auto-increment ID value from the last created row you inserted into a particular mysql table.  Yea… when you insert a new row into a mysql table there is no apparent way to just return the ID from the row’s auto-increment field.  So to do this using PHP, simply use the

mysql_insert_id()

functin, which will return the last created ID as an interger.

How to Help Eliminate Spam with SPF Records

Tags:

I really hate spam.  I’m sure just about everyone does.  I really hate it though when spammers forge my own email address as the sender, then I mark it as spam, then I inadvertantly end up having legit emails dumping into my spam box!  Ouch, talked about a breakdown in communication.

Mac vs PC, OS X vs Windows and why OS X just Rocks

Tags:

I grew up using wordstar on dos as a kid.  I moved into windows 3.1, 95, 98, ME (very short lived), XP (and not Vista) and finally dabbled in linux with really, truly reaching that developer Zen.  I always really liked how windows was focused on the user GUI and how linux was very developer friendly - but Apple was always that weird proprietary OS with kind of a nice GUI (like windows) but was not at all developer friendly like linux… so there was never a reason to use it.

Searching for a string in a gz compressed file

Tags:

Gzip is a compression technology available on most unix/linux systems.  Once in a while you might see a file such as filename.gz or filename.tar.gz and you may need to search through that file… I know some popular web server programs, such as apache, compress old log files to save space…

If you need to search through a .gz file, just use the zcat command (similar to cat):

zcat file.gz

Linux: change a large number of file names, all at once

Tags:

How do I change a lot of file names all at once, and using the linux command line?  Look no further.  Let’s say you have a bunch of images in your current directory (let’s create them like so for testing purposes):

for x in {1..100}; do touch “image$x.gif”; done

Now that you have all 100 gif images files, just run the following command to change them to have the .jpg file extension:

for x in *.gif; do mv “$x” “${x%.gif}.jpg”; done

The Semantic Web, Oh So Cool

Tags:

I’ve recently taken an interest in the semantic web because I keep hearing about how it will revolutionize the word wide web.  After doing a bit of research I’m certain it will.

What is the difference between GET and POST?

I’ve actually been asked this question in interviews before and knowing when to use either GET or POST is a fundamental tool for web developers.

GET and POST variables using PHP, the lazy way

If you want to catch form variables in $<variable name> format instead of the $_GET['variable name'] or $_POST['variable name'] format, just call import_request_variables() at the start of your script and supply either a ‘p’ or a ‘g’ argument for post or get respectively.  Kind of nice for those lazy programmer out there.

Syndicate content