<?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>Sat, 21 Apr 2012 04:07:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</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>For the 4-20 folks</title>
		<link>http://feedproxy.google.com/~r/mrclay_org/~3/K_--cx92V0M/</link>
		<comments>http://www.mrclay.org/2012/04/21/for-the-4-20-folks/#comments</comments>
		<pubDate>Sat, 21 Apr 2012 04:07:58 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Policy]]></category>
		<category><![CDATA[Cannabis]]></category>
		<category><![CDATA[Drug Policy]]></category>

		<guid isPermaLink="false">http://www.mrclay.org/?p=1452</guid>
		<description><![CDATA[Another year it still deserves saying&#8230; It&#8217;s long been clear the risks and harms of cannabis use are mild, and with that knowledge it should sicken us that people are regularly pulled into our criminal justice system because of cannabis use, sales, production, or political speech (see the example made of Marc Emery). Shame on [...]]]></description>
			<content:encoded><![CDATA[<p>Another year it still deserves saying&#8230; It&#8217;s long been clear the risks and harms of cannabis use are mild, and with that knowledge it should sicken us that people are regularly pulled into our criminal justice system because of cannabis use, sales, production, or political speech (see the example made of <a href="http://en.wikipedia.org/wiki/Marc_Emery#2005_arrest_and_extradition_proceedings">Marc Emery</a>). <em>Shame on us</em> for keeping these unjustifiable laws on the books due to ignorance and inertia; each year they harm individuals far more than use of the drug, further erode our Fourth Amendment protections, and place otherwise law-abiding citizens at odds with the police.</p>
<img src="http://feeds.feedburner.com/~r/mrclay_org/~4/K_--cx92V0M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mrclay.org/2012/04/21/for-the-4-20-folks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.mrclay.org/2012/04/21/for-the-4-20-folks/</feedburner:origLink></item>
		<item>
		<title>Define namespace constants using expressions</title>
		<link>http://feedproxy.google.com/~r/mrclay_org/~3/qHtHco3lsiM/</link>
		<comments>http://www.mrclay.org/2012/04/16/define-namespace-constants-using-expressions/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 16:59:22 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PhpStorm]]></category>

		<guid isPermaLink="false">http://www.mrclay.org/?p=1450</guid>
		<description><![CDATA[Since const is parsed at compile-time, you can&#8217;t use expressions in namespace constants, but you can use define as long as the name argument is the full name from the global scope (run this): namespace Foo\Bar; const CONST1 = 1; define('CONST2', 1 + 1); // global define(__NAMESPACE__ . '\\CONST3', 1 + 1 + 1); // [...]]]></description>
			<content:encoded><![CDATA[<p>Since <code>const</code> is parsed at compile-time, you can&#8217;t use expressions in namespace constants, but you <em>can</em> use <code>define</code> as long as the name argument is the full name from the global scope (<a href="http://codepad.viper-7.com/aecIor">run this</a>):</p>
<pre><code class="php">namespace Foo\Bar;
const CONST1 = 1;
define('CONST2', 1 + 1); // global
define(__NAMESPACE__ . '\\CONST3', 1 + 1 + 1); // in namespace!
echo CONST1, " ", \CONST2, " ", CONST3; // echos '1 2 3'</code></pre>
<p>The bad: PHPStorm comprehends <code>const</code> and global <code>define</code>s, but not <code>define(__NAMESPACE__ . '\\CONST', $value)</code></p>
<img src="http://feeds.feedburner.com/~r/mrclay_org/~4/qHtHco3lsiM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mrclay.org/2012/04/16/define-namespace-constants-using-expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.mrclay.org/2012/04/16/define-namespace-constants-using-expressions/</feedburner:origLink></item>
		<item>
		<title>PHP RFC Preview: Dynamic Callback Expressions</title>
		<link>http://feedproxy.google.com/~r/mrclay_org/~3/f3djYtN35vM/</link>
		<comments>http://www.mrclay.org/2012/04/15/php-rfc-preview-dynamic-callback-expressions/#comments</comments>
		<pubDate>Sun, 15 Apr 2012 23:01:43 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Random Ideas]]></category>
		<category><![CDATA[RFC]]></category>

		<guid isPermaLink="false">http://www.mrclay.org/?p=1439</guid>
		<description><![CDATA[I&#8217;m posting this to get some initial feedback on this idea before I officially submit an RFC. Background Even with PHP&#8217;s growing object oriented and functional programming features, the callback remains a widely-used feature. However, forcing authors to create callbacks via strings and arrays presents difficulties: IDEs cannot recognize callbacks and so cannot offer autocompletion, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m posting this to get some initial feedback on this idea before I officially submit an RFC.</p>
<h3>Background</h3>
<p>Even with PHP&#8217;s growing object oriented and functional programming features, the callback remains a widely-used feature. However, forcing authors to create callbacks via strings and arrays presents difficulties:</p>
<ol>
<li>IDEs cannot recognize callbacks and so cannot offer autocompletion, rename refactoring, and other benefits of code comprehension.</li>
<li>Authors can easily misspell identifiers inside strings.</li>
<li>Authors can forget to include the current namespace since function calls within the namespace would not require it.</li>
</ol>
<h3>Proposal</h3>
<p><span id="more-1439"></span><br />
PHP should allow <strong>an expression containing a function identifier to evaluate as a callback at runtime</strong>. Define &#8220;function identifier&#8221; to be a syntactic expression that would normally invoke a function/method call at runtime, but lacking the parenthesis for invocation, similar to referencing a function in Javascript. The identifier would, at runtime, be evaluated as a static or dynamic callback. Examples:</p>
<ul>
<li><code>func</code></li>
<li><code>NS\func</code></li>
<li><code>CN::meth</code></li>
<li><code>NS\CN::meth</code></li>
<li><code>$this-&gt;meth</code></li>
<li><code>$this-&gt;{'meth'}</code></li>
</ul>
<p><strong>Note about namespaces:</strong> For the function and static method calls above, the callback produced at runtime would depend on the active namespace. E.g. <code>func</code> may evaluate to <code>'func'</code>, but would evaluate to <code>'NS\\func'</code> if the expression occurred within the namespace NS.</p>
<h3>Avoiding parser complexity</h3>
<p>Without context, a parser would have a difficult time distinguishing between constants and these function identifiers, so I propose the identifiers MUST be preceded by a special token.</p>
<p>If <strong><code>callablefor</code></strong> were to be chosen as that token, the following expressions would evaluate as true:</p>
<ul>
<li><code>callablefor func === 'func'; // within global namespace</code></li>
<li><code>callablefor func === 'NS\\func'; // within namespace NS</code></li>
<li><code>callablefor CN::meth === 'CN::meth';</code></li>
<li><code>callablefor self::meth === __CLASS__ . '::meth';</code></li>
<li><code>callablefor $this-&gt;meth === array($this, 'meth');</code></li>
<li><code>callablefor $anonymousFunc === $anonymousFunc;</code></li>
<li><code>callablefor $validCallback === $validCallback;</code></li>
</ul>
<h3>Example</h3>
<p>Consider this code:</p>
<pre><code class="php">namespace NS1;
use NS2\B;

class A {
    static function init() {
        $instance = new self;
        log(callbackfor $instance-&gt;bar);
        $instance-&gt;bar();
    }
    function bar() {
        log(callbackfor B::baz);
    }
}

function c() {
    return callbackfor c;
}

log(callbackfor log);
log(callbackfor A::init);
A::init();
log(c());</code></pre>
<p>At runtime, these values would be passed to the global function <code>log</code>:</p>
<ul>
<li><code>'log'</code></li>
<li><code>'NS1\\A::init'</code></li>
<li><code>array($instance, 'bar')</code></li>
<li><code>'NS2\\B::baz'</code></li>
<li><code>'NS1\\C'</code></li>
</ul>
<h2>Summary</h2>
<p>With this feature, IDEs and static analysis tools could provide far better support for a still very widely-used language feature.</p>
<h3>Notes</h3>
<ol>
<li>Callback expressions would not trigger autoloading.</li>
<li>Callbacks cannot reference the invocation of a parent class method from a child class instance, so <code>callablefor parent::method</code> should throw an exception.</li>
<li>It might be convenient if <code>callablefor $obj::meth</code> were to evaluate to a static method call on <code>get_class($obj)</code>.</li>
</ol>
<img src="http://feeds.feedburner.com/~r/mrclay_org/~4/f3djYtN35vM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mrclay.org/2012/04/15/php-rfc-preview-dynamic-callback-expressions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.mrclay.org/2012/04/15/php-rfc-preview-dynamic-callback-expressions/</feedburner:origLink></item>
		<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>
	</channel>
</rss><!-- Dynamic page generated in 0.347 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-04-21 00:08:11 --><!-- Compression = gzip -->

