Mike Shannon - How To http://www.mikeshannon.com/taxonomy/term/11/0 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 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