<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>mrclay.org</title>
	
	<link>http://www.mrclay.org</link>
	<description>Steve Clay on programming, music, public policy and other junk</description>
	<lastBuildDate>Sun, 22 Jan 2012 21:50:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/mrclay_org" /><feedburner:info uri="mrclay_org" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>29.713911</geo:lat><geo:long>-82.295914</geo:long><feedburner:feedFlare href="http://www.plusmo.com/add?url=http%3A%2F%2Ffeeds.feedburner.com%2Fmrclay_org" src="http://plusmo.com/res/graphics/fbplusmo.gif">Subscribe with Plusmo</feedburner:feedFlare><feedburner:feedFlare href="http://www.thefreedictionary.com/_/hp/AddRSS.aspx?http%3A%2F%2Ffeeds.feedburner.com%2Fmrclay_org" src="http://img.tfd.com/hp/addToTheFreeDictionary.gif">Subscribe with The Free Dictionary</feedburner:feedFlare><feedburner:feedFlare href="http://www.bitty.com/manual/?contenttype=rssfeed&amp;contentvalue=http%3A%2F%2Ffeeds.feedburner.com%2Fmrclay_org" src="http://www.bitty.com/img/bittychicklet_91x17.gif">Subscribe with Bitty Browser</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2Fmrclay_org" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare href="http://mix.excite.eu/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fmrclay_org" src="http://image.excite.co.uk/mix/addtomix.gif">Subscribe with Excite MIX</feedburner:feedFlare><feedburner:feedFlare href="http://www.webwag.com/wwgthis.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fmrclay_org" src="http://www.webwag.com/images/wwgthis.gif">Subscribe with Webwag</feedburner:feedFlare><feedburner:feedFlare href="http://www.podcastready.com/oneclick_bookmark.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fmrclay_org" src="http://www.podcastready.com/images/podcastready_button.gif">Subscribe with Podcast Ready</feedburner:feedFlare><feedburner:feedFlare href="http://www.wikio.com/subscribe?url=http%3A%2F%2Ffeeds.feedburner.com%2Fmrclay_org" src="http://www.wikio.com/shared/img/add2wikio.gif">Subscribe with Wikio</feedburner:feedFlare><feedburner:feedFlare href="http://www.dailyrotation.com/index.php?feed=http%3A%2F%2Ffeeds.feedburner.com%2Fmrclay_org" src="http://www.dailyrotation.com/rss-dr2.gif">Subscribe with Daily Rotation</feedburner:feedFlare><item>
		<title>Convert Google Maps embed HTML to Street View URL</title>
		<link>http://feedproxy.google.com/~r/mrclay_org/~3/0gXUtRdIFNo/</link>
		<comments>http://www.mrclay.org/2012/01/22/convert-google-maps-embed-html-to-street-view-url/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 21:50:15 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Maps]]></category>
		<category><![CDATA[Street View]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.mrclay.org/?p=1425</guid>
		<description><![CDATA[You can use the form below to convert the HTML embed code Google Maps gives you to a usable Street View URL loading&#8230; Why do I need this? The new Google Maps layout has a chain-link icon on the left that gives you a URL to what you&#8217;re looking at. If you&#8217;re in Street View, sometimes [...]]]></description>
			<content:encoded><![CDATA[<p>You can use the form below to convert the HTML embed code Google Maps gives you to a usable Street View URL</p>
<p id="street-view-link-widget" class="has-data-src" data-src="/js/street-view-link-widget.js">loading&#8230;</p>
<h3>Why do I need this?</h3>
<p>The new Google Maps layout has a chain-link icon on the left that gives you a URL to what you&#8217;re looking at. If you&#8217;re in Street View, sometimes the given URL doesn&#8217;t include the proper parameters and you end up back on the top-down map view. This converter pulls a valid Street View URL out of the embed HTML.</p>
<p><a href="/js/street-view-link-widget.js">source code</a></p>
<img src="http://feeds.feedburner.com/~r/mrclay_org/~4/0gXUtRdIFNo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mrclay.org/2012/01/22/convert-google-maps-embed-html-to-street-view-url/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.mrclay.org/2012/01/22/convert-google-maps-embed-html-to-street-view-url/</feedburner:origLink></item>
		<item>
		<title>Untitled 2011-12-29</title>
		<link>http://feedproxy.google.com/~r/mrclay_org/~3/9sUzXRMaytg/</link>
		<comments>http://www.mrclay.org/2011/12/29/untitled-2011-12-29/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 15:18:50 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Music]]></category>
		<category><![CDATA[Noteflight]]></category>

		<guid isPermaLink="false">http://www.mrclay.org/?p=1422</guid>
		<description><![CDATA[The first two bars I used to play on the electric piano but couldn&#8217;t figure out how to make it into a (pop) song. This is more fun.]]></description>
			<content:encoded><![CDATA[<p><object width="640" height="253"><param name="movie" value="http://www.noteflight.com/scores/embed"></param><param name="FlashVars" value="id=d3bfa4134520f82498297be7a25ebaee02a8ed7d&#038;scale=1"></param> <embed src="http://www.noteflight.com/scores/embed" type="application/x-shockwave-flash" FlashVars="id=d3bfa4134520f82498297be7a25ebaee02a8ed7d&#038;scale=1" width="640" height="253"></embed></object></p>
<p>The first two bars I used to play on the electric piano but couldn&#8217;t figure out how to make it into a (pop) song. This is more fun.</p>
<img src="http://feeds.feedburner.com/~r/mrclay_org/~4/9sUzXRMaytg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mrclay.org/2011/12/29/untitled-2011-12-29/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.mrclay.org/2011/12/29/untitled-2011-12-29/</feedburner:origLink></item>
		<item>
		<title>ElggCollection Proposal</title>
		<link>http://feedproxy.google.com/~r/mrclay_org/~3/oZJ6fnWiJZA/</link>
		<comments>http://www.mrclay.org/2011/12/25/elgg-collection-proposal/#comments</comments>
		<pubDate>Mon, 26 Dec 2011 00:16:46 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Elgg]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Specification]]></category>

		<guid isPermaLink="false">http://www.mrclay.org/?p=1393</guid>
		<description><![CDATA[An ElggCollection entity would store an ordered set of integers optimized for filtering and/or ordering SQL queries of entities, annotations, or other tables with integer primary keys. Use Cases Filtering with ordering: setting visibility and order of group widgets; photo albums; user&#8217;s favorite entities Ordering without filtering: sticky items/comments; setting top pages to display in [...]]]></description>
			<content:encoded><![CDATA[<p>An ElggCollection entity would store an ordered set of integers optimized for filtering and/or ordering SQL queries of entities, annotations, or other tables with integer primary keys.<span id="more-1393"></span></p>
<h3>Use Cases</h3>
<ol>
<li>Filtering <em>with</em> ordering: setting visibility and order of group widgets; photo albums; user&#8217;s favorite entities</li>
<li>Ordering <em>without</em> filtering: sticky items/comments; setting top pages to display in widgets</li>
<li>Filtering <em>without</em> ordering: list of users from whom a user does not want to see activity; list of users who can access a resource (possible replacement of separate ACL tables)</li>
</ol>
<p>The logic of how a collection filters/orders a result set could be stored in the collection to specify a default behavior, but this logic could be overridden to allow, e.g., ordering in reverse order or <em>excluding</em> items in the collection.</p>
<h3>Data Model</h3>
<p>ElggCollection would extend ElggEntity, storing the following attributes in a new table {prefix}<strong>collections_entity</strong>:</p>
<ul>
<li>key_id (int): metastring id of the key (case-insensitive) used to locate the collection within its container. A container may have only one collection under a given key.</li>
<li>items_type (tinyint, default 0): 0 = entity, 1 = annotation</li>
<li>order_direction (tinyint, default 1): 0 = no order, 1 = ASC, 2 = DESC</li>
<li>filter_type (tinyint, default 0) 0 = do not filter items, 1 = fetch only collection items, 2 = fetch only non-collection items</li>
<li>items_first (tinyint, default 1) 0 = non-collection items appear first, 1 = collection items appear first</li>
<li>title (varchar 255, optional)</li>
<li>description (text, optional)</li>
</ul>
<p>Note: The collection key eliminates the need for a separate metadata/relationship entity to tie a collection to an entity, and gives a predictable method of finding a collection. It&#8217;s likely that keys will be identical among many entities so the metastrings are a good use here.</p>
<p>The table {prefix}<strong>collection_items</strong> would provide storage for the collection:</p>
<ul>
<li>id (AUTOINC): primary key</li>
<li>guid (int): the collection&#8217;s GUID</li>
<li>item (int): an integer in the collection (e.g. an entity GUID, an annotation id)</li>
<li>priority (int, optional): the ranking of the stored item.</li>
</ul>
<h3>Usage and Permissions</h3>
<p>To access a collection directly, user code would access its container entity, then access the associated collection (which may have a different ACL) via its key:</p>
<pre><code class="php">$stickyItems = elgg_get_collection($group, 'stickyItems');</code></pre>
<p>To use the collection, code would pass the ElggCollection object (or an array of them) to any of the elgg_get_entities() family of functions via the options key &#8220;collections&#8221;.</p>
<pre><code class="php">$content = elgg_list_entities(array(
    'collections' =&gt; elgg_get_collection($group, 'stickyItems'),
    /* other options */
));</code></pre>
<p>During query generation, the order_direction, filter_type, and items_first attributes of the collections would be used to specify how the collection_items table is joined and how the query is ordered.</p>
<h3>Creation and Editing</h3>
<p>Only users who <code>canEdit()</code> the container entity are permitted to create or alter associated collections.</p>
<pre><code class="php">$faves = elgg_create_collection($user, 'faves', ElggCollection::ENTITIES);
$faves-&gt;order_direction = ElggCollection::ORDER_DESC;
$faves-&gt;save();
$faves-&gt;appendItem($entity_or_guid); // ...alteration methods TBD</code></pre>
<h3>Integration Without Rewriting Code</h3>
<p>By naming their query and calling a plugin hook like &#8220;collections:apply&#8221;, an author could allow other authors to add collections to be applied. The following is an example of enabling this in the pages widget query:</p>
<pre><code class="php">$collections = elgg_trigger_plugin_hook(
    'collections:apply',
    'entity',
    array(
        'container' =&gt; $vars['entity'],
        'query_name' =&gt; 'pages_widget_content'),
    array()
);
$options = array(
    /* ...existing pages widget content options... */
    'collections' =&gt; $collections,
);
$content = elgg_list_entities($options);</code></pre>
<p>A less verbose API might allow passing the query_name and container directly into <code>elgg_get_entities()</code>, which could trigger the plugin hook:</p>
<pre><code class="php">$options = array(
    /* ...existing pages widget content options... */
    'collections_query_name' =&gt; 'pages_widget_content',
    'collections_container' =&gt; $vars['entity'],
);
$content = elgg_list_entities($options);</code></pre>
<h3>Notes</h3>
<ul>
<li>Tying collections (and their editing permissions) to a container (and its canEdit() method) I think makes sense. Only group owners can alter collections tied to their groups. Users can still make their own collections about anything, but cannot hijack a group&#8217;s &#8220;official&#8221; collection by simply knowing its key.</li>
<li>How do we apply multiple collections?</li>
<li>If the applied collections just provide order, which collection&#8217;s ORDER BY clause comes first?</li>
<li>A plugin hook could remove/reorder collections. Should they be able to?</li>
<li>What happens if a collection cannot be accessed? Some queries will not make sense without the collection. Considering this, a collection that&#8217;s meant to filter out all non-collection items is a special case where the query should not run at all. What makes the problem harder is that, if the collection can&#8217;t be accessed, we also <em>can&#8217;t know that it is this type</em> of collection!</li>
<li>The above point makes me suspect that it&#8217;s folly to store the join/ordering attributes. A better idea might be to require the user to specify join/order attributes whenever the collection is fetched. That way, depending on need, an empty, non-savable collection could be substituted.</li>
</ul>
<img src="http://feeds.feedburner.com/~r/mrclay_org/~4/oZJ6fnWiJZA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mrclay.org/2011/12/25/elgg-collection-proposal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.mrclay.org/2011/12/25/elgg-collection-proposal/</feedburner:origLink></item>
		<item>
		<title>Obama’s ONDCP still can’t be trusted</title>
		<link>http://feedproxy.google.com/~r/mrclay_org/~3/aPOIhS2m0HY/</link>
		<comments>http://www.mrclay.org/2011/12/04/obamas-ondcp-still-cant-be-trusted/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 02:50:26 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Policy]]></category>
		<category><![CDATA[Drug Policy]]></category>

		<guid isPermaLink="false">http://www.mrclay.org/?p=1321</guid>
		<description><![CDATA[The Office of National Drug Control Policy under Bush, led by John Walters, was notorious for flat-out lies and evidence bending, especially regarding cannabis (it was a holy culture war for Ashcroft as well), but under Obama the office has mostly put focus on prescription drug abuse and &#8220;drugged driving&#8221;. With 2012 bringing a host [...]]]></description>
			<content:encoded><![CDATA[<p>The Office of National Drug Control Policy under Bush, led by John Walters, was notorious for flat-out lies and evidence bending, especially regarding cannabis (it was a holy culture war for Ashcroft as well), but under Obama the office has mostly put focus on prescription drug abuse and &#8220;drugged driving&#8221;.</p>
<p>With 2012 bringing a host of cannabis-related ballot initiatives to voters, Walters&#8217; style of deception is making a comeback. Look at <a href="http://www.tennessean.com/article/20110822/COLUMNIST0150/308220002/Movement-legalized-marijuana-ignores-dangers">this editorial</a>.</p>
<blockquote><p>Data also reveal that marijuana potency has almost tripled in the past 20 years. This is especially troubling for use among teens because the earlier a person begins to use drugs, the more likely they are to develop a more serious abuse and addiction problem later in life.</p></blockquote>
<p>No studies I&#8217;m aware of link an increase in THC potency to anything mentioned in the second sentence. Also note that cannabis regulation could actually dictate potency, and kids are getting pot earlier <em>under the current policy</em>. The irony here is that higher THC potency reduces the amount of smoking (a good thing) the user needs to do to achieve the desired level of intoxication.</p>
<blockquote><p>Would marijuana legalization make Tennessee healthier or safer? One needs to look no further than Tennessee’s current painful experience with prescription drug abuse.</p></blockquote>
<p>Prescription drugs (generally highly pure synthetic opiates) are not cannabis.</p>
<blockquote><p>&#8230;prescription drugs are legal, regulated, and taxed — and yet rates of the abuse&#8230;</p></blockquote>
<p>Proposed cannabis regulation is generally not by prescription, so this sentence seems purely a distraction. Prescription drugs are scary!</p>
<blockquote><p>Nationally, someone dies from an unintentional drug overdose — driven in large part by prescription drug abuse — on average every 19 minutes.</p></blockquote>
<p>Prescription drug abuse is deadly, and is not cannabis use. Surely he forgot to mention cannabis is practically non-toxic.</p>
<blockquote><p>What would America look like if we had just as many people using marijuana as we currently have smoking cigarettes, abusing alcohol, and abusing prescription drugs?</p></blockquote>
<p>Why would we have that? It&#8217;s true that legalized cannabis would broaden the base of users, but there&#8217;s just not a lot of reason to cue scary music.</p>
<blockquote><p>The bottom line is that laws that control substances have had a real and lasting effect on keeping drug use rates relatively low.</p></blockquote>
<p>A gem of truth! Prohibition <em>does</em> reduce use, which is only one of many metrics by which you should judge public policy. We could certainly reduce alcohol use, premarital sex, masturbation, swearing, blasphemy and other ills by making them all illegal and giving police endlessly increasing funding and power to stamp them out.</p>
<blockquote><p>Moreover, other addictive substances like alcohol and tobacco, which are already legal and taxed, cost much more in social costs than the revenue they generate.</p></blockquote>
<p>It&#8217;s true, drugs that are not cannabis are not cannabis, and alcohol excise taxes should be raised considerably. Why has the ONDCP never taken up this cause? As Mark Kleiman put it, a drug policy that ignores alcohol is like a naval policy that ignores the Pacific. Further, you&#8217;ll not find a study that shows cannabis causes more damage than alcohol/tobacco.</p>
<blockquote><p>This isn’t to say that we believe we can arrest our way out of our nation’s drug problem.</p></blockquote>
<p>AFAIK in no way has the ONDCP or DEA promoted any policy that would lead to fewer arrests, and the federal grant programs that built up local drug task force militarization are still in place (with a nice boost in the stimulus act).</p>
<blockquote><p>[blah blah diversion treatment programs]</p></blockquote>
<p>Yes, a small percentage of daily cannabis users will find it difficult to quit, experiencing problems with sleeping, mood, and discomfort (think quitting tobacco). IMO introducing the criminal justice system as executed in the U.S. does not, on net, improve <em>any</em> user&#8217;s situation.</p>
<p>(BTW, evidence suggests that involuntary treatment is a waste of money for most people, who can and do quit even highly addictive substances by themselves with a credible threat of an immediate and short jail sentence. Sending cannabis users who happen to get caught to treatment is an incredible waste of money and hard-to-find treatment space.)</p>
<blockquote><p>Marijuana legalization would be disastrous public health policy, because it would increase availability and increase the use of a substance that we know to be harmful.</p></blockquote>
<p>While increase in availability and use is a certainty of commercial legalization (it&#8217;s not my preferred policy), there&#8217;s only a sliver of the accounting on display here. This may come as a shock, but people can enjoy and benefit from cannabis use, and of course the removal of the damaging aspects of prohibition reduce future damage.</p>
<p>On whole I see commercial &#8220;legalization&#8221; as being a small net win, and a large win if its mandated that users may only use vaporizers (or e-cigarettes); that higher CBD/THC ratios are required; and that it remains illegal to &#8220;spike&#8221; foods for unsuspecting eaters, which I suspect to be the leading cause of people &#8220;freaking out&#8221; and seeking ultimately unnecessary ER visits. There&#8217;s also some encouraging evidence that suggests that, in medical marijuana states, young adults and teens are substituting cannabis for alcohol use resulting in notable drops in traffic fatalities.</p>
<blockquote><p>Decades of experience have shown that there are no “silver bullet” approaches to addressing our national drug problem.</p></blockquote>
<p>So true, but discovering silver bullets requires firing a few; unless I&#8217;m mistaken <em>we haven&#8217;t actually tried</em> any other approaches over those decades regarding cannabis on the federal level. I think we should.</p>
<img src="http://feeds.feedburner.com/~r/mrclay_org/~4/aPOIhS2m0HY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mrclay.org/2011/12/04/obamas-ondcp-still-cant-be-trusted/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.mrclay.org/2011/12/04/obamas-ondcp-still-cant-be-trusted/</feedburner:origLink></item>
		<item>
		<title>Mad Men Theme Chords</title>
		<link>http://feedproxy.google.com/~r/mrclay_org/~3/iTenTkDD7Ik/</link>
		<comments>http://www.mrclay.org/2011/10/30/mad-men-theme-chords/#comments</comments>
		<pubDate>Sun, 30 Oct 2011 22:53:51 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Music]]></category>
		<category><![CDATA[Music Transcriptions]]></category>

		<guid isPermaLink="false">http://www.mrclay.org/?p=1353</guid>
		<description><![CDATA[I know there&#8217;s a full R2J2 song I haven&#8217;t heard yet, but since we&#8217;re marathoning MM I had to figure out at least this part. With capo on the 4th fret it&#8217;s easier to work the melody in. x-0-2-2-1-1 C#m x-0-2-2-1-0 (x 2) x-2-3-2-x-0 D#m7-5 x-2-3-2-3-x (x 2) 0-x-3-2-3-x C#m/G# 0-x-2-2-1-x (x 2) x-x-1-2-1-x D#7-9/G [...]]]></description>
			<content:encoded><![CDATA[<p>I know there&#8217;s a full R2J2 song I haven&#8217;t heard yet, but since we&#8217;re marathoning MM I had to figure out at least this part. With capo on the 4th fret it&#8217;s easier to work the melody in.</p>
<pre>x-0-2-2-1-1  C#m
x-0-2-2-1-0  (x 2)
x-2-3-2-x-0  D#m7-5
x-2-3-2-3-x  (x 2)
0-x-3-2-3-x  C#m/G#
0-x-2-2-1-x  (x 2)
x-x-1-2-1-x  D#7-9/G
x-x-1-2-0-x  (x 2)
0-x-0-1-1-x  G#7+
0-x-0-1-0-x  (x 2)
x-0-4-2-1-0  C#m6 (C#m the 2nd time)</pre>
<p>The final synth harmony is a low C# and slightly flat B with rich harmonics implying a C#7 (major).</p>
<img src="http://feeds.feedburner.com/~r/mrclay_org/~4/iTenTkDD7Ik" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mrclay.org/2011/10/30/mad-men-theme-chords/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.mrclay.org/2011/10/30/mad-men-theme-chords/</feedburner:origLink></item>
		<item>
		<title>String Subtypes for Safer Web Programming</title>
		<link>http://feedproxy.google.com/~r/mrclay_org/~3/jg-MJkDZUck/</link>
		<comments>http://www.mrclay.org/2011/09/28/string-subtypes-for-safer-web-programming/#comments</comments>
		<pubDate>Wed, 28 Sep 2011 04:58:12 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Escaping]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Random Ideas]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Usability]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.mrclay.org/?p=1341</guid>
		<description><![CDATA[Valid HTML markup involves several different contexts and escaping rules, yet many APIs give no precise indication of which context their string return values are escaped for, or how strings should be escaped before being passed in (let&#8217;s not even get into character encoding). Most programming languages only have a single String type, so there&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Valid HTML markup involves several different contexts and escaping rules, yet many APIs give no precise indication of which context their string return values are escaped for, or how strings should be escaped before being passed in (let&#8217;s not even get into character encoding). Most programming languages only have a single String type, so there&#8217;s a strong urge to document function with <code>@param string</code> and/or <code>@return string</code> and move on to other work, but this is rarely sufficient information.</p>
<p>Look at the documentation for WordPress&#8217;s <a href="http://codex.wordpress.org/Function_Reference/get_the_title">get_the_title</a>:</p>
<blockquote><p><strong>Returns</strong></p>
<dl>
<dt><tt>(string)</tt> </dt>
<dd>Post title. &#8230;</dd>
</dl>
</blockquote>
<p>If the title is <code>Stan "The Man" &amp; Capt. &lt;Awesome&gt;</code>, will <code>&amp;</code> and <code>&lt;</code> be escaped? Will the quotes be escaped? &#8220;string&#8221; leaves these important questions unanswered. This isn&#8217;t meant to slight WordPress&#8217;s documentation team (they at least frequently give you example code from which you can guess the escaping model); the problem is endemic to web software.</p>
<p>So for better web security&#8212;and developer sanity&#8212;I think we need a shared vocabulary of string subtypes which can supply this missing metadata at least via mention or annotation in the documentation (if not via actual types).</p>
<h3>Proposed Subtypes and Content Models</h3>
<p>A basic set of four might help quite a bit. Each should have its own URL to explain its content model in detail, and how it should be handled:</p>
<dl>
<dt><a href="/string-subtypes/unescaped/">Unescaped</a></dt>
<dd>Arbitrary characters not escaped for HTML in any way, possibly including nulls/control characters. If a string&#8217;s subtype is not explicit, for safety it should be assumed to contain this content.</dd>
<dt><a href="/string-subtypes/markup/">Markup</a></dt>
<dd>Well-formed HTML markup matching the serialization of a <a href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-B63ED1A3">DocumentFragment</a></dd>
<dt><a href="/string-subtypes/tagless-markup/">TaglessMarkup</a></dt>
<dd>Markup containing no literal less-than sign (U+003C) characters (e.g. for output inside title/textarea elements)</dd>
<dt><a href="/string-subtypes/attr-value/">AttrValue</a></dt>
<dd>TaglessMarkup containing no literal apostrophe (U+0027) or quotation mark (U+0022) characters, for output as a single/double-quoted attribute value</dd>
</dl>
<h3>What would these really give us?</h3>
<p>These subtypes cannot make promises about what they contain, but are rather for making explicit <em>what they should contain</em>. It&#8217;s still up to developers to correctly handle input, character encoding, filtering, and string operations to fulfill those contracts.</p>
<p>The work left to do is to define how these subtypes should be handled and in what contexts they can be output as-is, and what escaping needs to be applied in other contexts.</p>
<h4>Obvious Limitations</h4>
<p>For the sake of simplicity, these subtypes shouldn&#8217;t attempt to address notions of input filtering or whether a string should be considered &#8220;clean&#8221;, &#8220;tainted&#8221;, &#8220;unsafe&#8221;, etc. A type/annotation convention like this should be used to assist&#8212;not replace&#8212;experienced developers practicing secure coding methods.</p>
<img src="http://feeds.feedburner.com/~r/mrclay_org/~4/jg-MJkDZUck" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mrclay.org/2011/09/28/string-subtypes-for-safer-web-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.mrclay.org/2011/09/28/string-subtypes-for-safer-web-programming/</feedburner:origLink></item>
		<item>
		<title>RotURL: Rot13 for URLs</title>
		<link>http://feedproxy.google.com/~r/mrclay_org/~3/uh13sdCpUN0/</link>
		<comments>http://www.mrclay.org/2011/09/15/roturl-rot13-for-urls/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 03:58:15 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Cipher]]></category>
		<category><![CDATA[Encoding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[RotUrl]]></category>

		<guid isPermaLink="false">http://www.mrclay.org/?p=1334</guid>
		<description><![CDATA[RotURL is a simple substitution cipher for encoding/obscuring URLs embedded in other URLs (e.g. in a querystring). Also, common chars that need to be escaped (:/?=&#38;%#) are mapped to infrequently used capital letters, so this generally yields shorter querystrings, too. /**  * Rot35 with URL/urlencode-friendly mappings. To avoid increasing size during * urlencode(), commonly encoded [...]]]></description>
			<content:encoded><![CDATA[<p>RotURL is a simple substitution cipher for encoding/obscuring URLs embedded in other URLs (e.g. in a querystring). Also, common chars that need to be escaped (<code>:/?=&amp;%#</code>) are mapped to infrequently used capital letters, so this generally yields shorter querystrings, too.</p>
<pre><code class="php">/**
 * Rot35 with URL/urlencode-friendly mappings. To avoid increasing size during
 * urlencode(), commonly encoded chars are mapped to more rarely used chars.
 */
function rotUrl($url) {
    return strtr($url,
        './-:?=&#038;%# ZQXJKVWPY abcdefghijklmnopqrstuvwxyz123456789ABCDEFGHILMNORSTU',
        'ZQXJKVWPY ./-:?=&#038;%# 123456789ABCDEFGHILMNORSTUabcdefghijklmnopqrstuvwxyz');
}

rotUrl('https://en.wikipedia.org/w/index.php?title=Special%3ASearch&amp;search=Base64#foo')
    == '8MMGLJQQ5EZR9B9G5491ZFI7QRQ9E45SZG8GKM9MC5VxG5391CPcjx51I38WL51I38Vk1L5fdY6FF';
rotUrl(rotUrl($anyUrl)) = $anyUrl;
</code></pre>
<p>You could save a few more bytes by encoding the schema (e.g. &#8220;h&#8221; for <code>http://</code>, &#8220;H&#8221; for <code>https://</code>). Since your end encoding has to be URL-safe, there&#8217;s not much you can do beyond this to compress a URL embedded in a URL.</p>
<img src="http://feeds.feedburner.com/~r/mrclay_org/~4/uh13sdCpUN0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mrclay.org/2011/09/15/roturl-rot13-for-urls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.mrclay.org/2011/09/15/roturl-rot13-for-urls/</feedburner:origLink></item>
		<item>
		<title>Validate Private Page Bookmarklet</title>
		<link>http://feedproxy.google.com/~r/mrclay_org/~3/6XmVXV6XP8o/</link>
		<comments>http://www.mrclay.org/2011/09/13/validate-private-page-bookmarklet/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 16:22:13 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Bookmarklets]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Validation]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.mrclay.org/?p=1327</guid>
		<description><![CDATA[ValidatePrivatePage &#60;&#8211; validates in current window ValidatePrivatePage &#60;&#8211; validates in new window (your pop-up blocker may complain) If you need to validate the markup of a page that&#8217;s not public (e.g. on localhost), you can now use this bookmarklet to auto-submit the current page source to the validator (instead of viewing source, copying, opening the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="javascript:(function(d){var b=new XMLHttpRequest;b.onreadystatechange=function(){function c(b,c){var e=d.createElement('input');e.name=b;e.value=c;e.type='hidden';a.appendChild(e)}if(b.readyState==4){var a=d.createElement('form');a.action='http://validator.w3.org/check';a.method='post';a.enctype='multipart/form-data';c('fragment',b.responseText);c('prefill','0');c('doctype','Inline');c('prefill_doctype','html401');c('group','1');d.body.appendChild(a);a.submit();d.body.removeChild(a)}};b.open('GET', location.href,!0);b.send('')})(document);">ValidatePrivatePage</a> &lt;&#8211; validates in current window</p>
<p><a href="javascript:(function(d){var b=new XMLHttpRequest;b.onreadystatechange=function(){function c(b,c){var e=d.createElement('input');e.name=b;e.value=c;e.type='hidden';a.appendChild(e)}if(b.readyState==4){var a=d.createElement('form');a.action='http://validator.w3.org/check';a.method='post';a.enctype='multipart/form-data';a.target='_blank';c('fragment',b.responseText);c('prefill','0');c('doctype','Inline');c('prefill_doctype','html401');c('group','1');d.body.appendChild(a);a.submit();d.body.removeChild(a)}};b.open('GET', location.href,!0);b.send('')})(document);">ValidatePrivatePage</a> &lt;&#8211; validates in new window (your pop-up blocker may complain)</p>
<p>If you need to validate the markup of a page that&#8217;s not public (e.g. on localhost), you can now use this bookmarklet to auto-submit the current page source to the <a href="http://validator.w3.org/#validate_by_input">validator</a> (instead of viewing source, copying, opening the validator, pasting in, and pressing &#8220;check&#8221;).</p>
<p>Note: this gets the page source making an XMLHTTPRequest to the current URL, so it does not get interpreted by the browser; i.e. this is NOT based on innerHTML(). If the request made returns a different page (e.g. you were logged out in the meantime), <em>that</em> page&#8217;s source will be sent to the validator. Not much can be done about that. I once wrote a crusty PHP4 class/bookmarklet combo that helped do this, but thanks to the standardization of XMLHTTPRequest, this is easy in JS now. You should also thank W3C for allowing cross-domain POSTs to the validator :)</p>
<img src="http://feeds.feedburner.com/~r/mrclay_org/~4/6XmVXV6XP8o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mrclay.org/2011/09/13/validate-private-page-bookmarklet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.mrclay.org/2011/09/13/validate-private-page-bookmarklet/</feedburner:origLink></item>
		<item>
		<title>NetBeans Love &amp; Hate</title>
		<link>http://feedproxy.google.com/~r/mrclay_org/~3/92zAKsXTViM/</link>
		<comments>http://www.mrclay.org/2011/08/18/netbeans-love-hate/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 23:43:16 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[Netbeans]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.mrclay.org/?p=1315</guid>
		<description><![CDATA[For those cases where you have to work on remote code, NetBeans&#8216; remote project functionality seems to put it ahead of other PHP IDEs. It pulls down a tree of files and uploads files that you save. Having a local copy allows it to offer its full code comprehension, auto-complete, and great rename refactoring for &#8220;remote&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>For those cases where you have to work on remote code, <a href="http://www.netbeans.org/">NetBeans</a>&#8216; remote project functionality seems to put it ahead of other PHP IDEs. It pulls down a tree of files and uploads files that you save. Having a local copy allows it to offer its full code comprehension, auto-complete, and great rename refactoring for &#8220;remote&#8221; code. In contrast Eclipse allows you to open remote files using Remote System Explorer, but you only get PHP syntax highlighting, not the excellent PDT.</p>
<p>But NetBeans is not all smiles and sunshine.<span id="more-1315"></span></p>
<ul>
<li>It does <em>not</em> check that a remote file has been changed before uploading, making it really <strong>easy to overwrite changes made by someone else</strong> since you downloaded last. It could mitigate this a bit by auto-downloading a file when you open it, but it doesn&#8217;t do this either. This makes it dangerous for a team working on the same codebase.</li>
<li>It sometimes (lately multiple times a day) turns off its &#8220;Upload on Save&#8221; functionality with no warning.</li>
<ul>
<li>There&#8217;s no way to know it&#8217;s off other than to start noticing your changes aren&#8217;t affecting the server! The preferences checkbox remains checked.</li>
<li>Even worse, you have to exit/reopen NetBeans to turn it back on.</li>
<li>Recent changes in 7.1 make uploading faster, but no longer is all SFTP activity logged in the &#8220;output&#8221; pane, meaning it&#8217;s <em>even harder</em> to tell when Upload on Save turns off.</li>
</ul>
<li>It will recognize file changes made by other processes, but won&#8217;t auto-upload those changes, even when &#8220;Upload on Save&#8221; is on (forgivable, but annoying).</li>
<ul>
<li>Similarly, when you diff between files and transfer changes across, the changed file won&#8217;t be uploaded unless to know to click a green button that looks like a &#8220;refresh&#8221; icon. Who would suspect [refresh] to upload a file?</li>
</ul>
<li>About 10% of the time when you first open the IDE it gets stuck scanning for changes in your files, especially if you have a lot of them in your projects, which of course you do.</li>
<ul>
<li>When this happens, auto-complete doesn&#8217;t work.</li>
<li>If you create a new file/folder while it&#8217;s scanning, the IDE will often freeze.</li>
<li>Killing its process and reopening NetBeans is the only way to get it working again.</li>
</ul>
</ul>
<p>Some of these bugs are, to put it dramatically, totally devastating for the world&#8217;s PHP developers. NetBeans is&#8212;when it&#8217;s working&#8212;an astoundingly great environment to code in, but, with the latest updates, infrequent annoyances are starting to become regular fist shakers. It sucks that I can&#8217;t currently recommend NetBeans to anyone working on remote servers, especially in a team.</p>
<p>As I mentioned, Eclipse&#8217;s remote editing lacks code comprehension; I tried Apatana recently and managing remote projects was painful&#8230;might as well keep a separate SFTP client open.</p>
<p>How are Zend Studio and PHPStorm for working on remote codebases? I&#8217;m on OSX at work, but I&#8217;ll run Windows if it means getting a better editor.</p>
<p><small>Aside: Yes, I&#8217;m aware source control is the solution to the team-building-a-single-codebase problem. I use git/svn wherever possible, but setting up a proper environment takes time and developer coordination that&#8217;s lacking at the moment.</small></p>
<img src="http://feeds.feedburner.com/~r/mrclay_org/~4/92zAKsXTViM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mrclay.org/2011/08/18/netbeans-love-hate/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.mrclay.org/2011/08/18/netbeans-love-hate/</feedburner:origLink></item>
		<item>
		<title>Helping Netbeans/PhpStorm with Autocomplete/Code-hinting</title>
		<link>http://feedproxy.google.com/~r/mrclay_org/~3/uQqHQNI2DCQ/</link>
		<comments>http://www.mrclay.org/2011/07/18/helping-netbeans-with-autocomplete-code-hinting/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 19:08:04 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Netbeans]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PhpStorm]]></category>

		<guid isPermaLink="false">http://www.mrclay.org/?p=1305</guid>
		<description><![CDATA[Where Netbeans can&#8217;t guess the type/existence of a local variable, you can tell it in a multiline comment: /* @var $varName TypeName */ After this comment (and as long as TypeName is defined in your project/project&#8217;s include path), when you start to type $varName, Netbeans will offer to autocomplete it, and will offer TypeName method/property suggestions. [...]]]></description>
			<content:encoded><![CDATA[<p>Where Netbeans can&#8217;t guess the type/existence of a local variable, you can tell it in a multiline comment:</p>
<pre><code class="php">/* @var $varName TypeName */</code></pre>
<p><em>After</em> this comment (and as long as <code>TypeName</code> is defined in your project/project&#8217;s include path), when you start to type <code>$varName</code>, Netbeans will offer to autocomplete it, and will offer <code>TypeName</code> method/property suggestions. If you rename the variable with Ctrl+r (rename refactoring), Netbeans will change the comment, too.</p>
<p>I usually forget this syntax because type comes first in <code>@param</code> declarations.</p>
<p><strong>Update:</strong> PhpStorm supports a similar syntax, but reversing the type and variable name:</p>
<pre><code>/* @var TypeName $varName */</code></pre>
<img src="http://feeds.feedburner.com/~r/mrclay_org/~4/uQqHQNI2DCQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mrclay.org/2011/07/18/helping-netbeans-with-autocomplete-code-hinting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.mrclay.org/2011/07/18/helping-netbeans-with-autocomplete-code-hinting/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.177 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-01-22 16:50:25 --><!-- Compression = gzip -->

