Mike Shannon blogs http://www.mikeshannon.com/blog en How to Print Prime Numbers, a C++ Example http://www.mikeshannon.com/how-to-print-prime-numbers <p>The following code uses the <a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes">Sieve of Eratosthenes</a> 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.</p> <p><a href="http://www.mikeshannon.com/how-to-print-prime-numbers" target="_blank">read more</a></p> http://www.mikeshannon.com/how-to-print-prime-numbers#comments Code Examples How To Mon, 21 Sep 2009 02:18:20 +0000 admin 95 at http://www.mikeshannon.com How to Recursively Copy Files from a Remote Host using wget and FTP http://www.mikeshannon.com/recursively-copy-files-remote-host-using-wget-and-ftp <p>wget -r <a href="ftp://username:password@your.ip.address/dir/*" title="ftp://username:password@your.ip.address/dir/*">ftp://username:password@your.ip.address/dir/*</a></p> <p>OR</p> <p>wget -r &ndash;user=your_username &ndash;password=your_password <a href="ftp://ftp.yoursite.com/dir/*" title="ftp://ftp.yoursite.com/dir/*">ftp://ftp.yoursite.com/dir/*</a></p> <p>Note the * at the end of the commands, you will need this else wget just retrieves the single, index file&nbsp;</p> http://www.mikeshannon.com/recursively-copy-files-remote-host-using-wget-and-ftp#comments How To Thu, 20 Aug 2009 01:03:15 +0000 admin 93 at http://www.mikeshannon.com How to get the last created auto-increment ID from a MySQL table http://www.mikeshannon.com/get-last-created-auto-increment-id-mysql-table <p>If you&rsquo;re like me then you&rsquo;re developing like crazy.&nbsp; 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.&nbsp; Yea&hellip; when you insert a new row into a mysql table there is no apparent way to just return the ID from the row&rsquo;s auto-increment field.&nbsp; So to do this using PHP, simply use the</p> <p><a href="http://us.php.net/mysql_insert_id">mysql_insert_id()</a></p> <p>functin, which will return the last created ID as an interger.</p> <p><a href="http://www.mikeshannon.com/get-last-created-auto-increment-id-mysql-table" target="_blank">read more</a></p> http://www.mikeshannon.com/get-last-created-auto-increment-id-mysql-table#comments How To SQL / Database Fri, 10 Apr 2009 01:01:30 +0000 admin 92 at http://www.mikeshannon.com How to Help Eliminate Spam with SPF Records http://www.mikeshannon.com/how-to-help-eliminate-spam-with-spf-records <p>I really hate spam.&nbsp; I&rsquo;m sure just about everyone does.&nbsp; 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!&nbsp; Ouch, talked about a breakdown in communication.</p> <p><a href="http://www.mikeshannon.com/how-to-help-eliminate-spam-with-spf-records" target="_blank">read more</a></p> http://www.mikeshannon.com/how-to-help-eliminate-spam-with-spf-records#comments How To Tips Wed, 04 Mar 2009 19:10:05 +0000 admin 91 at http://www.mikeshannon.com Mac vs PC, OS X vs Windows and why OS X just Rocks http://www.mikeshannon.com/mac-vs-pc-os-x-vs-windows-and-why-os-x-just-rocks <p>I grew up using&nbsp;<a href="http://en.wikipedia.org/wiki/WordStar">wordstar</a>&nbsp;on dos as a kid.&nbsp; 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.&nbsp; 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&hellip; so there was never a reason to use it.</p> <p><a href="http://www.mikeshannon.com/mac-vs-pc-os-x-vs-windows-and-why-os-x-just-rocks" target="_blank">read more</a></p> http://www.mikeshannon.com/mac-vs-pc-os-x-vs-windows-and-why-os-x-just-rocks#comments OS Fri, 13 Feb 2009 00:59:06 +0000 admin 90 at http://www.mikeshannon.com Searching for a string in a gz compressed file http://www.mikeshannon.com/searching-for-string-in-gz-compressed-file <p>Gzip is a compression technology available on most unix/linux systems. &nbsp;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&hellip; I know some popular web server programs, such as&nbsp;<a href="http://httpd.apache.org/">apache</a>, compress old log files to save space&hellip;</p> <p>If you need to search through a .gz file, just use the zcat command (similar to cat):</p> <p>zcat file.gz</p> <p><a href="http://www.mikeshannon.com/searching-for-string-in-gz-compressed-file" target="_blank">read more</a></p> http://www.mikeshannon.com/searching-for-string-in-gz-compressed-file#comments How To Tips Wed, 11 Feb 2009 00:58:20 +0000 admin 89 at http://www.mikeshannon.com Linux: change a large number of file names, all at once http://www.mikeshannon.com/linux-change-large-number-file-names-all-once <p>How do I change a lot of file names all at once, and using the linux command line? &nbsp;Look no further. &nbsp;Let&rsquo;s say you have a bunch of images in your current directory (let&rsquo;s create them like so for testing purposes):</p> <p>for x in {1..100}; do touch &ldquo;image$x.gif&rdquo;; done</p> <p>Now that you have all 100 gif images files, just run the following command to change them to have the .jpg file extension:</p> <p>for x in *.gif; do mv &ldquo;$x&rdquo; &ldquo;${x%.gif}.jpg&rdquo;; done</p> <p><a href="http://www.mikeshannon.com/linux-change-large-number-file-names-all-once" target="_blank">read more</a></p> http://www.mikeshannon.com/linux-change-large-number-file-names-all-once#comments How To Linux Fri, 06 Feb 2009 00:57:07 +0000 admin 88 at http://www.mikeshannon.com The Semantic Web, Oh So Cool http://www.mikeshannon.com/semantic-web-oh-so-cool <p>I&rsquo;ve recently taken an interest in the&nbsp;<a href="http://www.semanticreview.com/">semantic web</a>&nbsp;because I keep hearing about how it will revolutionize the word wide web.&nbsp; After doing a bit of research I&rsquo;m certain it will.</p> <p><a href="http://www.mikeshannon.com/semantic-web-oh-so-cool" target="_blank">read more</a></p> http://www.mikeshannon.com/semantic-web-oh-so-cool#comments News Thu, 29 Jan 2009 00:53:19 +0000 admin 87 at http://www.mikeshannon.com What is the difference between GET and POST? http://www.mikeshannon.com/what-is-difference-between-get-and-post <p>I&rsquo;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.</p> <p><a href="http://www.mikeshannon.com/what-is-difference-between-get-and-post" target="_blank">read more</a></p> http://www.mikeshannon.com/what-is-difference-between-get-and-post#comments Web Development Fri, 28 Nov 2008 19:02:11 +0000 admin 86 at http://www.mikeshannon.com GET and POST variables using PHP, the lazy way http://www.mikeshannon.com/get-and-post-variables-using-php-lazy-way <p>If you want to catch form variables in $&lt;variable name&gt; format instead of the $_GET['variable name'] or $_POST['variable name'] format, just call&nbsp;<a href="http://us3.php.net/variables.external">import_request_variables</a>() at the start of your script and supply either a &lsquo;p&rsquo; or a &lsquo;g&rsquo; argument for post or get respectively.&nbsp; Kind of nice for those lazy programmer out there.</p> <p><a href="http://www.mikeshannon.com/get-and-post-variables-using-php-lazy-way" target="_blank">read more</a></p> http://www.mikeshannon.com/get-and-post-variables-using-php-lazy-way#comments Tips Web Development Thu, 23 Oct 2008 00:51:26 +0000 admin 85 at http://www.mikeshannon.com