<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Elliott C. Back &#187; Code</title>
	<atom:link href="http://elliottback.com/wp/category/computers-technology/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://elliottback.com/wp</link>
	<description>Internet &#38; Technology</description>
	<lastBuildDate>Tue, 03 Nov 2009 23:59:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Fixing Bugs with Genetic Algorithms</title>
		<link>http://elliottback.com/wp/fixing-bugs-with-genetic-algorithms/</link>
		<comments>http://elliottback.com/wp/fixing-bugs-with-genetic-algorithms/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 00:27:58 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Errors]]></category>

		<guid isPermaLink="false">http://elliottback.com/wp/?p=3242</guid>
		<description><![CDATA[Wow, check out this preprint:  A Genetic Programming Approach to Automated Software Repair.  Essentially, the researchers used a suit of positive and negative unit tests as the distance scoring function for a genetic algorithm which operated on code to mutate branches.  More interestingly, they did this on off-the-shelf legacy C programs.
Genetic programming [...]]]></description>
			<content:encoded><![CDATA[<p>Wow, check out this preprint:  <a href="http://www.cs.virginia.edu/~weimer/p/weimer-gecco2009-preprint.pdf">A Genetic Programming Approach to Automated Software Repair</a>.  Essentially, the researchers used a suit of positive and negative unit tests as the distance scoring function for a genetic algorithm which operated on code to mutate branches.  More interestingly, they did this on off-the-shelf legacy C programs.</p>
<blockquote><p>Genetic programming is combined with program analysis methods to repair bugs in off-the-shelf legacy C programs. Fitness is defined using negative test cases that exercise the bug to be repaired and positive test cases that encode program requirements. Once a successful repair is discovered, structural differencing algorithms and delta debugging methods are used to minimize its size. Several modifications to the GP technique contribute to its success: (1) genetic operations are localized to the nodes along the execution path of the negative test case; (2) high-level statements are represented as single nodes in the program tree; (3) genetic operators use existing code in other parts of the program, so new code does not need to be invented. The paper describes the method, reviews earlier experiments that repaired 11 bugs in over 60,000 lines of code, reports results on new bug repairs, and describes experiments that analyze the performance and efficacy of the evolutionary components of the algorithm.</p></blockquote>
<p>Literally, they wrote some small samples of code that said &#8220;here&#8217;s what I want this buggy program to do&#8221; and then their genetic algorithm actually went off and hacked away at the code (much like many of us flesh-and-blood programmers) and made it work.  They have several nice examples, including one on automatically fixing the infamous Zune date bug.</p>
<blockquote><p>The dream of automatic programming has eluded computer scientists for at least 50 years. Although the methods described in this paper do not evolve new programs from scratch, they do show how to evolve legacy software to repair existing faults.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://elliottback.com/wp/fixing-bugs-with-genetic-algorithms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WP SuperCache .htaccess mod_rewrite rules for Blogs in Subdomains/Subdirectories</title>
		<link>http://elliottback.com/wp/wp-supercache-htaccess/</link>
		<comments>http://elliottback.com/wp/wp-supercache-htaccess/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 02:00:59 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Mod_Rewrite]]></category>
		<category><![CDATA[WP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://elliottback.com/wp/?p=3165</guid>
		<description><![CDATA[I have a unique problem, which is that I have installed my wordpress to a subdirectory, and symlinked httpdocs from several subdomains to that directory.  The structure looks like this:
httpdocs/wp/ -&#62; WP Install
subdomains/gadgets/httpdocs/ -&#62; /elliottback.com/httpdocs/wp/
subdomains/books/httpdocs/ -&#62; /elliottback.com/httpdocs/wp/
This means that from my domain, we&#8217;re always sticking an extra /wp onto things, but from the subdomains, [...]]]></description>
			<content:encoded><![CDATA[<p>I have a unique problem, which is that I have installed my wordpress to a subdirectory, and symlinked <strong>httpdocs</strong> from several subdomains to that directory.  The structure looks like this:</p>
<blockquote><p>httpdocs/wp/ -&gt; WP Install<br />
subdomains/gadgets/httpdocs/ -&gt; /elliottback.com/httpdocs/wp/<br />
subdomains/books/httpdocs/ -&gt; /elliottback.com/httpdocs/wp/</p></blockquote>
<p>This means that from my domain, we&#8217;re always sticking an extra /wp onto things, but from the subdomains, they go directly into the wp-content directories from the root , in both relative and absolute sense.  I consolidated my subdomains this way so that I could run a single WP install and maintain them together.  Here&#8217;s the .htaccess file that lets WP Super Cache work on either of them:</p>
<pre class="brush:apache"># BEGIN WPSuperCache
&lt;ifmodule mod_rewrite.c&gt;
RewriteEngine On
AddDefaultCharset UTF-8
RewriteBase /
RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_URI} ^(/wp)?/
RewriteCond %{DOCUMENT_ROOT}%1/wp-content/cache/supercache/%{HTTP_HOST}/%1/$1/index.html.gz -f
RewriteRule ^(.*) %1/wp-content/cache/supercache/%{HTTP_HOST}/%1/$1/index.html.gz [L]

RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{REQUEST_URI} ^(/wp)?/
RewriteCond %{DOCUMENT_ROOT}%1/wp-content/cache/supercache/%{HTTP_HOST}%1/$1/index.html -f
RewriteRule ^(.*) %1/wp-content/cache/supercache/%{HTTP_HOST}%1/$1/index.html [L]
&lt;/ifmodule&gt;
# END WPSuperCache</pre>
<p>Let me know what you think&#8211;performance stats show that it&#8217;s working fine for both the /wp subdirectory and the other subdomains!</p>
]]></content:encoded>
			<wfw:commentRss>http://elliottback.com/wp/wp-supercache-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Exclusive Single Process Mutex</title>
		<link>http://elliottback.com/wp/php-exclusive-single-process-mutex/</link>
		<comments>http://elliottback.com/wp/php-exclusive-single-process-mutex/#comments</comments>
		<pubDate>Sun, 31 May 2009 18:35:02 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://elliottback.com/wp/?p=3119</guid>
		<description><![CDATA[When running php via cron, there are certainly situations where you only want a single instance of the php file to be running at the same time.  Multiple processes shouldn&#8217;t be allowed.  For example, every 5 minutes, a process is launched to poll for weather updates, and publish them to Twitter.  If, [...]]]></description>
			<content:encoded><![CDATA[<p>When running php via cron, there are certainly situations where you only want a single instance of the php file to be running at the same time.  Multiple processes shouldn&#8217;t be allowed.  For example, every 5 minutes, a process is launched to poll for weather updates, and publish them to Twitter.  If, for some reason, this process takes more than 15m&#8211;because Twitter is very slow&#8211;I don&#8217;t want more to buildup.  At a rate of 12/hr, I would exhaust the number of MySQL connection on my box in a couple hours.</p>
<p>So, here&#8217;s the solution I used:</p>
<pre class="brush:php">
&lt;?php
class pid {
    protected $filename;
    protected $fp;
    public $already_running = false;
    function __construct() {
        $this-&gt;filename = dirname(__FILE__).'/'.basename($_SERVER['PHP_SELF']) . '.pid';
        $this-&gt;fp = fopen( $this-&gt;filename, 'w+ );

        if ( !flock( $this-&gt;fp, LOCK_EX + LOCK_NB ) )
        {
            echo "FAILED lock $this-&gt;filename\n";
            $this-&gt;already_running = true;
            fclose($this-&gt;fp);
        } else {
            echo "Acquired lock $this-&gt;filename\n";
        }
    }
    public function __destruct() {
        if( !$this-&gt;already_running )
        {
            echo "Releasing lock $this-&gt;filename\n";
            flock($this-&gt;fp, LOCK_UN);
            fclose($this-&gt;fp);
        }
    }
}
?&gt;
</pre>
<p>It works fine from command line, but for some reason, doesn&#8217;t work when invoked via Apache over the web.  But since I&#8217;m just using it for cron jobs, this is good enough for now.  If you know why FLOCK( LOCK_EX + LOCK_NB ) won&#8217;t work when invoked through Apache, let me know!!  I&#8217;m running PHP 5.2.6 (cli) and Apache/2.2.9 (Unix).</p>
]]></content:encoded>
			<wfw:commentRss>http://elliottback.com/wp/php-exclusive-single-process-mutex/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP MySql Database Class / Library</title>
		<link>http://elliottback.com/wp/php-mysql-database-class-library/</link>
		<comments>http://elliottback.com/wp/php-mysql-database-class-library/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 04:55:55 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://elliottback.com/wp/?p=2956</guid>
		<description><![CDATA[I was looking for a good out of the box library or class I could use as a singleton to manage database interactions in one of my PHP projects, and after rejecting Pear MDB2, PDO, ADODB and dbFacile I came across just what I was looking for: DbSimple, which satisfies all the requirements I have:

Easy [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for a good out of the box library or class I could use as a singleton to manage database interactions in one of my PHP projects, and after rejecting Pear MDB2, PDO, ADODB and dbFacile I came across just what I was looking for: <a href="http://en.dklab.ru/lib/DbSimple/">DbSimple</a>, which satisfies all the requirements I have:</p>
<ul>
<li>Easy to use interface functions</li>
<li>Conditional queries, escaped arguments for secure queries and prevention of database injection attacks</li>
<li>Error handling, connection management</li>
<li>Open source license</li>
</ul>
<p>It looks daunting at first because the package comes with numerous files, but the usage is quite simple after you upload it; something like this is enough to get started:</p>
<pre class="brush:php;">require_once('DbSimple/Generic.php');
$DB = DbSimple_Generic::connect("mysql://user:pass@localhost/db");
$DB-&gt;query( "DROP TABLE table");</pre>
<p>A feature which I probably won&#8217;t use as much is the transactionality&#8211;you can open, commit, and rollback mysql transactions to bundles your queries together.</p>
]]></content:encoded>
			<wfw:commentRss>http://elliottback.com/wp/php-mysql-database-class-library/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Bank Identification Number (BIN) List</title>
		<link>http://elliottback.com/wp/bank-identification-number-bin-list/</link>
		<comments>http://elliottback.com/wp/bank-identification-number-bin-list/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 04:01:13 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Finance]]></category>

		<guid isPermaLink="false">http://elliottback.com/wp/?p=2767</guid>
		<description><![CDATA[A credit card number always contains a prefix of 6 digits known as the Issuer Identification Number (IIN) which identify the credit card network that issued the card.  I could only find three well-known places to find a list of bank identification numbers (BIN) online:

Mars Banks Base, a donateware application with about 60k BIN [...]]]></description>
			<content:encoded><![CDATA[<p>A credit card number always contains a prefix of 6 digits known as the Issuer Identification Number (IIN) which identify the credit card network that issued the card.  I could only find three well-known places to find a list of bank identification numbers (BIN) online:</p>
<ul>
<li><a href="http://www.mars-soft.net/banksbase.htm" rel="nofollow">Mars Banks Base</a>, a donateware application with about 60k BIN numbers for Visa, AMEX, and Mastercard</li>
<li>The now-defunct <a href="http://Dumpz.biz" title="http://Dumpz.biz" target="_blank">Dumpz.biz</a> and <a href="http://dumpz.us" title="http://dumpz.us" target="_blank">dumpz.us</a> binlist, another collection of BIN numbers</li>
<li>Wikipedia even has a <a href="http://en.wikipedia.org/wiki/List_of_Bank_Identification_Numbers" rel="nofollow">List of Bank Identification Numbers</a></li>
</ul>
<p>I&#8217;ve compiled them into a CSV file with the following information:  BIN, location, type, name, and phone number.  You can download <a href='http://elliottback.com/wp/wp-content/uploads/2009/01/bank-bin-list.zip'>bank-bin-list</a> and unzip it.</p>
<p>If you&#8217;re a merchant interested in a solution using the BIN/IIN numbers to <a href="http://credit-card-information.elliottback.com/">validate credit cards</a> to lower the risk of fraud, you should check out <a href="http://www.serviceobjects.com/products/dots_bin_validation.asp">Service Object&#8217;s DOTS BIN Validation</a> webservice, which can validate 95% of MasterCard and Visa card types.</p>
]]></content:encoded>
			<wfw:commentRss>http://elliottback.com/wp/bank-identification-number-bin-list/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
