<?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>corprewland &#187; php</title>
	<atom:link href="http://www.corprew.org/blog/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.corprew.org</link>
	<description>(dis)information organization</description>
	<lastBuildDate>Fri, 19 Feb 2010 23:38:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>What I am up to at the moment</title>
		<link>http://www.corprew.org/blog/2009/03/08/what-i-am-up-to-at-the-moment/</link>
		<comments>http://www.corprew.org/blog/2009/03/08/what-i-am-up-to-at-the-moment/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 19:12:40 +0000</pubDate>
		<dc:creator>corprew</dc:creator>
				<category><![CDATA[computer programming]]></category>
		<category><![CDATA[location-based]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[geolocations]]></category>
		<category><![CDATA[hacketyhackhack]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.corprew.org/?p=191</guid>
		<description><![CDATA[This is more or less a good guide to what I am up to at the moment, although it should be noted that I&#8217;ve written this same code fragment in three languages in the last while (this is ruby, the others were PHP and Java, although the Java one was a festival of reflection due [...]]]></description>
			<content:encoded><![CDATA[<p>This is more or less a good guide to what I am up to at the moment, although it should be noted that I&#8217;ve written this same code fragment in three languages in the last while (this is ruby, the others were PHP and Java, although the Java one was a festival of reflection due to type wackiness.)</p>
<p>I actually have another version of the same code that puts a URL in the debug log that can be used to click directly to google maps.  Why?  I don&#8217;t know.  I&#8217;m beginning to value Aptana Studio&#8217;s remix of Eclipse more and more as time goes on though because I now have Java, PHP, and Ruby/Rails all in the same highly (mostly) performing IDE.  The alleged iPhone mode doesn&#8217;t work on my computer but I have CRAZY LIBERRIES installed at the moment and I suspect that that&#8217;s in large part my own fault &#8212; the apple tools still work.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#9966CC; font-weight:bold;">def</span> geo_desc <span style="color:#006600; font-weight:bold;">&#40;</span> geo_loc, extended = <span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span>
     <span style="color:#008000; font-style:italic;">#</span>
     <span style="color:#008000; font-style:italic;">#  specialized pretty printer for address types.</span>
     <span style="color:#008000; font-style:italic;">#  note that there is pretty much a standard mixin for geo stuff and</span>
     <span style="color:#008000; font-style:italic;">#  this works across all the geocoding packages and model types.</span>
     <span style="color:#008000; font-style:italic;">#</span>
     <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#996600;">&quot;[nil location]&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> geo_loc.<span style="color:#0000FF; font-weight:bold;">nil</span>?
     desc = <span style="color:#996600;">&quot;[&quot;</span> 
     desc <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> geo_loc.<span style="color:#9900CC;">country_code</span>.<span style="color:#9900CC;">downcase</span> <span style="color:#9966CC; font-weight:bold;">unless</span> geo_loc.<span style="color:#9900CC;">country_code</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>?
     desc <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;.&quot;</span> <span style="color:#006600; font-weight:bold;">+</span> geo_loc.<span style="color:#9900CC;">state</span>.<span style="color:#9900CC;">downcase</span> <span style="color:#9966CC; font-weight:bold;">unless</span> geo_loc.<span style="color:#9900CC;">state</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>?
     desc <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;.&quot;</span> <span style="color:#006600; font-weight:bold;">+</span> geo_loc.<span style="color:#9900CC;">city</span>.<span style="color:#9900CC;">downcase</span> <span style="color:#9966CC; font-weight:bold;">unless</span> geo_loc.<span style="color:#9900CC;">city</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>?
     desc <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;.&quot;</span> <span style="color:#006600; font-weight:bold;">+</span> geo_loc.<span style="color:#9900CC;">zip</span> <span style="color:#9966CC; font-weight:bold;">unless</span> geo_loc.<span style="color:#9900CC;">zip</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>?
     desc <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;] &quot;</span>
     desc <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;[&quot;</span>
     desc <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> geo_loc.<span style="color:#9900CC;">lat</span>.<span style="color:#9900CC;">to_s</span> <span style="color:#9966CC; font-weight:bold;">unless</span> geo_loc.<span style="color:#9900CC;">lat</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>?
     desc <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;,&quot;</span>
     desc <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> geo_loc.<span style="color:#9900CC;">lng</span>.<span style="color:#9900CC;">to_s</span> <span style="color:#9966CC; font-weight:bold;">unless</span> geo_loc.<span style="color:#9900CC;">lng</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>?
     <span style="color:#9966CC; font-weight:bold;">unless</span> geo_loc.<span style="color:#9900CC;">precision</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>? <span style="color:#9966CC; font-weight:bold;">or</span> geo_loc.<span style="color:#9900CC;">precision</span> == <span style="color:#996600;">&quot;unknown&quot;</span>
       desc <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot; (&quot;</span> <span style="color:#006600; font-weight:bold;">+</span> geo_loc.<span style="color:#9900CC;">precision</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot;)&quot;</span> 
     <span style="color:#9966CC; font-weight:bold;">else</span>
       desc <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot; ?&quot;</span>
     <span style="color:#9966CC; font-weight:bold;">end</span>
     desc <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;]&quot;</span>
     <span style="color:#9966CC; font-weight:bold;">if</span> extended
       desc <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot; &quot;</span> <span style="color:#006600; font-weight:bold;">+</span> geo_loc.<span style="color:#9900CC;">full_address</span> <span style="color:#9966CC; font-weight:bold;">unless</span> geo_loc.<span style="color:#9900CC;">full_address</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>?
     <span style="color:#9966CC; font-weight:bold;">end</span>
     <span style="color:#0000FF; font-weight:bold;">return</span> desc
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.corprew.org/blog/2009/03/08/what-i-am-up-to-at-the-moment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>being liberal in what you accept &#8212; implementation interoperability semantics</title>
		<link>http://www.corprew.org/blog/2008/04/04/being-liberal-in-what-you-accept-implementation-interoperability-semantics/</link>
		<comments>http://www.corprew.org/blog/2008/04/04/being-liberal-in-what-you-accept-implementation-interoperability-semantics/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 19:35:30 +0000</pubDate>
		<dc:creator>corprew</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[bloom]]></category>
		<category><![CDATA[conservative]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[implementation details]]></category>
		<category><![CDATA[interoperability]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[liberal]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[msft]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[property semantics]]></category>
		<category><![CDATA[rfc1122]]></category>
		<category><![CDATA[robustness]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[strcasecmp]]></category>

		<guid isPermaLink="false">http://www.corprew.org/blog/2008/04/04/being-liberal-in-what-you-accept-implementation-interoperability-semantics/</guid>
		<description><![CDATA[I&#8217;ve been working for the scientists over at the North Atlantic Bloom 08 as part o the team making their collaboratory. This project has mostly been based on Drupal, which is a content management system (in the web sense, not the ECM sense) based largely on PHP. One part of this is taking a lot [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working for the scientists over at the <a href="http://bloom.apl.washington.edu/">North Atlantic Bloom 08</a> as part o the team making their collaboratory.  This project has mostly been based on <a href="http://www.drupal.org/">Drupal</a>, which is a content management system (in the web sense, not the ECM sense) based largely on PHP.</p>
<p>One part of this is taking a lot of content over email &#8212; the scientists creating a lot of the content on the site are <a href="http://bloom.apl.washington.edu/content/map">in the middle of the North Atlantic</a>.  Because of this, I&#8217;ve been using the drupal module mailhandler for a lot of things that would normally be done directly through the site.</p>
<p>Basically, changing the comparison from <code>$data[0]=='taxonomy'</code> to a case-insenstive comparison:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">==</span><span style="color: #990000;">strcasecmp</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'taxonomy'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></pre></div></div>

<p>allows users to send in messages and have their mostly unambiguous intention followed.  This is, in general, a good thing, and reflects the general net protocol practice of &#8220;be conservative in what you send, be liberal in what you accept.&#8217;  This is a general guide to good behavior and successful implementation and is generally called the <a href="http://en.wikipedia.org/wiki/Robustness_Principle">Robustness Principle</a>.  I advise everyone to check out <a href="http://tools.ietf.org/html/rfc1122">RFC 1122</a>, because it has many entertaining things to say about the nature of the Internet at the protocol level.</p>
<p>Anyway, so when you can actually figure out what the person meant to be doing, you should probably accept it.  This is a generic problem that pops up every now and then with computers.  Surprisingly often, it pops up with case sensitivity at the protocol level.  Here&#8217;s another <a href="http://markmail.org/message/hmhlvwq3bvlnqg36">moment for me with that same issue from about 7 years ago in Apache SOAP</a>:</p>
<p>I proposed changing it to:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> pds.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span> 
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">==</span> propertyName.<span style="color: #006633;">compareToIgnoreCase</span><span style="color: #009900;">&#40;</span>pds<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
      <span style="color: #009900;">&#123;</span> 
        <span style="color: #000000; font-weight: bold;">return</span> pds<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getWriteMethod</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>from:</p>
</pre>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> pds.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span> 
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>propertyName.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>pds<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
      <span style="color: #009900;">&#123;</span> 
        <span style="color: #000000; font-weight: bold;">return</span> pds<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getWriteMethod</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This does more or less the same thing, but is in Java.  This was a case where the apache implementation wasn't interoperating with the Microsoft implementation because the MSFT implementation had a different valid interpretation of the SOAP specification than the Apache server did.  Both implementations had completely reasonable behavior, but when the MS SOAP implementation responded to Apache, it did so with its own capitalization semantics (based on COM -- PropertyName) instead of the Apache SOAP capitalization semantics (based on Java -- propertyName).  So, this is an ongoing problem that keeps showing up again and again.</p>
<p>I appear to be destined to run into it and advocate for the robustness principle in every technology i use, apparently.  Either that, or it's just a slow day and I'm rambling.</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.corprew.org/blog/2008/04/04/being-liberal-in-what-you-accept-implementation-interoperability-semantics/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

