<?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>Clarity Amidst Chaos</title>
	<atom:link href="http://clarityamidstchaos.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://clarityamidstchaos.com</link>
	<description>Notes from Moments of Clarity in a Chaotic Mind</description>
	<lastBuildDate>Tue, 20 Sep 2011 19:40:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>I tried, Chrome, I really did.</title>
		<link>http://clarityamidstchaos.com/2011/09/20/i-tried-chrome-i-really-did/</link>
		<comments>http://clarityamidstchaos.com/2011/09/20/i-tried-chrome-i-really-did/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 15:45:47 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://clarityamidstchaos.com/?p=354</guid>
		<description><![CDATA[I held off on trying Chrome for a while because I know things tend to change rapidly after being released. I finally had occasion to really use it (in more than a testing capacity) and was pretty quickly in love. But as the weeks went on, I find myself increasingly frustrated with some of the [...]]]></description>
			<content:encoded><![CDATA[<p>I held off on trying Chrome for a while because I know things tend to change rapidly after being released.  I finally had occasion to really use it (in more than a testing capacity) and was pretty quickly in love.  But as the weeks went on, I find myself increasingly frustrated with some of the design choices made that I really just don&#8217;t understand.  Ultimately, I&#8217;ve decided that Chrome is just not right for me.</p>
<h1>Stability</h1>
<p>Chrome is fast and stable <em>most</em> of the time.  But as a web developer, I work with a lot of flaky websites with flaky markup and flaky JavaScript.  And in about a month of using Chrome as my primary browser, I&#8217;ve encountered a handful of cases where a tab would lock up for an inordinate amount of time, often requiring me to just kill it.</p>
<p>It&#8217;s very likely, almost guaranteed, that bad JavaScript was at fault.  It&#8217;s also possible that I just happened to find some Chrome weaknesses, and of course every browser has their own.  But at the end of the day I am looking for a browser I can use, not debug, and I&#8217;m going to use the one that performs most stably without hiding problems that need fixing.</p>
<h1>Non-standard ports</h1>
<p>Ugh.  This again.  Firefox seems to think that ports 80 and 443 are the only ports the Internet runs on, but at least they have the common decency to <a href="http://www.haqthegibson.com/article/12">let me disable this</a>.  Chrome doesn&#8217;t and this heavy-handed approach to security is just bad.  Bad bad bad.</p>
<p>I understand that most people will only need ports 80 and 443.  I understand that most people need security settled for them, and don&#8217;t want to know about it under the hood.  I understand that security almost always comes at the cost of convenience.  But at the end of the day, I want a web browser, not a ports 80 and 443 browser.</p>
<p>The only way to explicitly allow other ports is with <a href="http://douglastarr.com/how-to-allow-unsafe-ports-in-chrome"><em>command line switches</em></a>!  For such a modern browser made by such a  modern company, I&#8217;m baffled as to why they would use such an archaic means of enabling a feature that &#8211; let&#8217;s face it &#8211; a lot of us are going to want.  We may be a minority, but we&#8217;re a big one.</p>
<h1>Case-sensitive search</h1>
<p>When I&#8217;m searching a page for a certain string, I usually want case sensitivity.  Again, as a programmer, I&#8217;m often interested in finding instances of &#8220;Do&#8221;, but not every instance of &#8220;do&#8221; as well.  The lack of case sensitivity makes the page search feature absolutely useless in many situations, leaving me instead with the only option of scouring through the page by hand looking for what I&#8217;m after.</p>
<p>If I understand any good reason why this feature was omitted, I might be more forgiving.  But I don&#8217;t see any reason for a technical limitation, and the <a href="http://code.google.com/p/chromium/issues/detail?id=8717">thread in the issue tracker</a> doesn&#8217;t shed much light, either.  The final note on it states that</p>
<h1>URL / History / Search / LOOK HOW MANY THINGS FIT INSIDE THIS BAR Bar</h1>
<p>I love the Firefox &#8220;Awesome Bar&#8221;.  It&#8217;s awesome.  I don&#8217;t love the Chrome URL bar.  It tries too hard to be everything and in my experience, usually fails.  Whereas Firefox&#8217;s URL bar gets me to pages I frequent with one or two keystrokes, with Chrome I usually find myself trying to work with it, eventually giving up, and just digging through my history or searching for what I was after the hard way.</p>
<p>If I have a local machine named &#8220;fudd&#8221; and I type &#8220;fudd&#8221; into Chrome&#8217;s URL bar, I get search results about &#8220;fudd&#8221;.  If I really want to visit &#8220;fudd&#8221;, I have to either include the &#8220;http://&#8221;, or <a href="http://www.google.com/support/forum/p/Chrome/thread?tid=64d48fe65ee313c5&amp;hl=en">create a wonky default search engine</a> to trick it into constructing the URL I asked for.</p>
<p>Okay, okay, you can point out that an actual URL needs to include the &#8220;http://&#8221;, and this is a PEBKAC situation.  But the fact is that every web browser I&#8217;ve ever used implies the &#8220;http://&#8221; if one isn&#8217;t typed, and maybe I just fear change, but I kinda liked it that way.  It makes sense.  You could also point the finger at me for calling it the &#8220;URL bar&#8221; when it&#8217;s apparently called the &#8220;omni box&#8221;, but <em>that&#8217;s where the URL goes so that is the URL bar</em>.</p>
<p>I see the value in combining the URL bar with the search bar, but I see the value in not doing that, too.  Simply put, the previous link is a perfectly viable hack that I shouldn&#8217;t have to do to fake-disable a feature that I don&#8217;t want.  If the options let me control just how omni my omni box was, I would be satisfied, but they don&#8217;t without the aforementioned hack.</p>
<h1>Until next time&#8230;</h1>
<p>I gave it the old college try.  Chrome is an awesome browser and is definitely on my list to try again in several months when they&#8217;ve hopefully broadened their target audience a bit.  It&#8217;s fast, it&#8217;s as modern as it gets in terms of supporting new technologies, and its integrated developer toolbar has been great.  I really wanted this to be my new browser.</p>
<p>But it seems to me that either they&#8217;re making a browser for the common user &#8212; and only the common user &#8212; or they still have a bunch of refining to do.  As someone who does a lot of atypical but perfectly valid stuff with my browser, stuff that I imagine a lot of other programmers are doing as well, it doesn&#8217;t meet my needs.  It almost does.  I wish it did.  But alas&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://clarityamidstchaos.com/2011/09/20/i-tried-chrome-i-really-did/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending data from PHP to Javascript</title>
		<link>http://clarityamidstchaos.com/2011/09/09/sending-data-from-php-to-javascript/</link>
		<comments>http://clarityamidstchaos.com/2011/09/09/sending-data-from-php-to-javascript/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 21:36:31 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://clarityamidstchaos.com/?p=350</guid>
		<description><![CDATA[It&#8217;s easy to add PHP data to a page as JavaScript data using json_encode, but sometimes you to relate that data to a specific element. For example, while rendering a series of objects in a for loop, you might want to way to associate an object ID with each of their containing &#60;divs&#62; for use [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s easy to add PHP data to a page as JavaScript data using <code>json_encode</code>, but sometimes you to relate that data to a specific element.  For example, while rendering a series of objects in a <code>for</code> loop, you might want to way to associate an object ID with each of their containing <code>&lt;divs&gt;</code> for use by the JavaScript on the page.</p>
<p>One way to do this is by using PHP to generate a JavaScript variable mapping object ID to a set of data about the object, and then including the ID in the markup in some way, such as <code>&lt;div class="id-123"&gt;...</code>.  This works, but it complicates the implementation and is just not elegant.</p>
<p>The solution I found was to include a small snippet of JS at the top of every page that allowed me to add PHP data to the markup in such a way that it would be associated with specific elements.  It looks like this:</p>
<blockquote><p>&lt;div class=&#8221;address&#8221;&gt;<br />
	&lt;div class=&#8221;jsdata&#8221; title=&#8221;address-id&#8221;&gt;&lt;?php echo $id;?&gt;&lt;/div&gt;<br />
	&lt;span&gt;123 Lollipop Lane, Mushroom Kingdom 84297&lt;/span&gt;<br />
&lt;/div&gt;</p></blockquote>
<p>In this case it&#8217;s just a numeric value, but it could just as easily contain a JSON-encoded object using <code>json_encode</code>.  Supporting this is incredibly simple and gracefully degrades if support isn&#8217;t there.  First, this needs to be included in the stylesheet:</p>
<blockquote><p>.jsdata {display:none;}</p></blockquote>
<p>This way nobody sees this data ever.  Next, you include the JavaScript to do the work.  My implementation is below, using jQuery, but it could be implemented without it without must more effort.</p>
<blockquote><p>
jQuery(function($) {<br />
	$(&#8216;.jsdata&#8217;).each(function() {<br />
			var node = $(this).parent(),<br />
				raw = $(this).text(),<br />
				parsed = $.parseJSON(raw),<br />
				title = $(this).attr(&#8216;title&#8217;) || &#8216;jsdata&#8217;;</p>
<p>			node.data(title, parsed);<br />
			$(this).remove();<br />
		});<br />
});
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://clarityamidstchaos.com/2011/09/09/sending-data-from-php-to-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PlentyOfFish.com: how not to handle accounts</title>
		<link>http://clarityamidstchaos.com/2011/08/31/plentyoffish-com-how-not-to-handle-accounts/</link>
		<comments>http://clarityamidstchaos.com/2011/08/31/plentyoffish-com-how-not-to-handle-accounts/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 19:48:16 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[passwords]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://clarityamidstchaos.com/?p=343</guid>
		<description><![CDATA[While working on a contract job I needed to create an account at Plenty of Fish.  I was so shocked by some pretty obviously missing security features that I just had to dig further.  In doing so, I found that their website was hacked (egad!) earlier this year, and found this gem of a blog [...]]]></description>
			<content:encoded><![CDATA[<p>While working on a contract job I needed to create an account at <a href="http://www.plentyoffish.com" target="_blank">Plenty of Fish</a>.  I was so shocked by some pretty obviously missing security features that I just had to dig further.  In doing so, I found that their website was hacked (egad!) earlier this year, and found <a href="https://plentyoffish.wordpress.com/2011/01/31/plentyoffish-hacked/">this gem</a> of a blog post from founder and CEO Markus Frind.  The comment thread below is as entertaining as the post itself, where it appears from my end like the Markus just shot the messenger.  This is a pretty common scenario for people who report vulnerabilities, and is the unfortunate result of the fact that hackers often can&#8217;t talk directly to the technical folks who would be more likely to understand what they were being told.</p>
<p>Anyhow, this is old news that I&#8217;m only posting about because it seems from here like they haven&#8217;t learned anything from the experience.</p>
<p><strong>Plain text password fields</strong>.</p>
<p>During registration you are asked for a password.  Unlike on <em>every other place on the web that I&#8217;ve ever visited in the history of ever</em>, they use use text fields for this instead of the masked password field you&#8217;re used to seeing.</p>
<p><em>Risk:</em> Anyone looking over your shoulder can see your password in plain text.</p>
<p><em>Solution:</em> This one is mind-boggling easy.  Their text field just needs to be a password field.</p>
<p><strong>Non-secure transmission of credentials.</strong></p>
<p>When you register, log in, or update your profile, all of this is done over HTTP as opposed to HTTPS.  If you manually add the HTTPS you can access securely, and it looks like the form will submit securely as well.  Otherwise, you&#8217;re out of luck.  I want to give them a point or two for using proper password fields when changing your password, but it seems to vary from password field to password field.</p>
<p><em>Risk</em>: Anyone who can snoop your network traffic can see your password every time you login, register, or change your password.  That&#8217;s probably a lot of people, unless you&#8217;re plugging right into POF&#8217;s web server, in which case unplug quick before your computer catches something.</p>
<p><em>Solution</em>: They seem to have a working and current SSL certificate.  Maybe they forgot about it?  The solution is for them to require HTTPS for all authenticated traffic.  On top of preventing their users&#8217; passwords from being common knowledge, it is also a necessary step in preventing various session-related attacks.</p>
<p><strong>Plain-text transmission of passwords, probably storage too.</strong></p>
<p>Did you forgot your POF password?  Let them know and they&#8217;ll generate a cryptographically token that they email you, requiring you to click it before emailing you a randomly generated password that you can use once to log in before changing your password.  No, I&#8217;m just kidding, they just email you your password in plain text.</p>
<p><em>Risk:</em> Anyone who can snoop traffic between POF&#8217;s mail servers and your mail servers can see your password.  Further, since this is <em>your password</em> they send, and not a randomly generated one, users are not encouraged to change their password.  Thus, a user&#8217;s leaked password is likely to stay their password because they have no reason to change it.</p>
<p>In addition, if they have your password in plain text it likely means they&#8217;re storing it that way, or at least they have an automated way of acquiring it that way.  In either case, it means that if somebody breaks into their database (like they did a few months ago), they immediately have a list of usernames and passwords to have fun with.</p>
<p><em>Solution:</em> Passwords should always be stored using a one-way hashing algorithm with a salt.  This way if someone steals 10M usernames and passwords, they have to spend a lot of time (depending on the strength of your users&#8217; passwords) cracking each one.  Time that POF could use to notify users and engage in damage recovery.  This is so easy to accomplish that I&#8217;ll never understand why any professional website stores passwords in plain text.</p>
<p>As for emailing passwords in plain text, don&#8217;t.  Ideally they would use a random token emailed to your inbox to confirm intent, and then would use some other shared secret (&#8220;Security Questions&#8221;) to confirm that you are who you are, before prompting you to update your password.</p>
<p><strong>Summary</strong></p>
<p>For a website that claims on their website to &#8220;[work] hard to make sure our users&#8217; accounts are safe and secure,&#8221; I&#8217;m skeptical where all that hard work is going.  I see security WTFisms around the web all the time, but this is the first time I&#8217;ve cared enough to write about it simply because of the level of inattention shown here combined with how popular the site is.  These are Security 101 rules that are being broken, and there&#8217;s no good reason for it.</p>
<p>In addition to that, there&#8217;s the fact that they <em>were</em> breached earlier this year.  According to Markus&#8217; blog post:</p>
<blockquote><p>Plentyoffish is bringing on several security companies to perform an external security audit, and will take all measures necessary to make sure our users are safe.</p></blockquote>
<p>However I have to question either the capabilities of all of these security companies, or POF&#8217;s commitment to following through on recommendations that came out of these audits.  As someone who has conducted security audits for businesses and government institutions, I can say that the three holes I mentioned above would be reported on day one of the audit.</p>
]]></content:encoded>
			<wfw:commentRss>http://clarityamidstchaos.com/2011/08/31/plentyoffish-com-how-not-to-handle-accounts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Guild Wars 2 is gonna be big</title>
		<link>http://clarityamidstchaos.com/2011/08/27/why-i-think-guild-wars-2-will-be-big/</link>
		<comments>http://clarityamidstchaos.com/2011/08/27/why-i-think-guild-wars-2-will-be-big/#comments</comments>
		<pubDate>Sat, 27 Aug 2011 22:24:03 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://clarityamidstchaos.com/?p=335</guid>
		<description><![CDATA[I&#8217;ll get right to it: I am a Guild Wars fan so I was biased before Guild Wars 2&#8242;s parents even fornicated.  However I acknowledge that the first game&#8217;s unique style is something you either love or hate, and most people I have asked about it don&#8217;t seem to like it.  But I think Guild [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll get right to it: I am a Guild Wars fan so I was biased before Guild Wars 2&#8242;s parents even fornicated.  However I acknowledge that the first game&#8217;s unique style is something you either love or hate, and most people I have asked about it don&#8217;t seem to like it.  But I think Guild Wars 2 is going to step it up and bring appeal to a broad range of gamers.  If you&#8217;re only peripherally aware of the game and are a fan of MMORPGs, it&#8217;s worth going to <a title="New window to Guild Wars 2 Official Website" href="http://www.guildwars2.com" target="_self">their website</a> where they have all kinds of cool videos showing off skills, environment, and other stuff.  Personally, I find the quality of it all to be highly polished and slick.</p>
<p>I recently read this article about <a title="New window to PvP article" href="http://www.guildwars2.com/en/the-game/pvp/pvp-overview/" target="_blank">PvP in Guild Wars 2</a>, by John Peters, and it introduced a new level of excitement for me.  For as long as Guild Wars 2 has been on my radar, I&#8217;ve also been playing Team Fortress 2, and over time I&#8217;ve noticed TF2 becoming more and more role-playing-ish with the ability to collect and equip weapons that offer a direct in-game advantage.  And I&#8217;ve thought to myself, wouldn&#8217;t it be terrific to mesh traditional MMORPG-style gameplay with the quick-action style of a FPS like TF2.  And to my delight, as you can see, they&#8217;ve done exactly that.</p>
<p>One of the important similarities between TF2 and GW2 is that you continue to play on the server you choose until you decide to leave, and in that time teams can be shuffled around.  As opposed to a game like World of Warcraft, where the Alliance and Horde are always the opposing sides, in Guild Wars 2 you&#8217;re all part of the same overall community.  Forget gameplay for a minute; from a <em>social</em> standpoint this just breeds a better game.  Sure, there&#8217;s always trolls, but in general it&#8217;s been my experience that people are a lot nicer to each other when they know that the guy who just wtfpwned them might be on their team next round, or that their absolutely moronic teammate might be on the <em>other</em> team next round.</p>
<p>Personally I think it sounds great on paper, and based on my time playing TF2, I expect it to play out just as well.  I&#8217;m betting the player base will agree as well.  You can also note that many gameplay elements demo&#8217;d for Guild Wars 2 are starting to show up in bits and pieces in World of Warcraft as well.  Just sayin.</p>
]]></content:encoded>
			<wfw:commentRss>http://clarityamidstchaos.com/2011/08/27/why-i-think-guild-wars-2-will-be-big/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Useful benchmarking information at GarfieldTech</title>
		<link>http://clarityamidstchaos.com/2011/08/20/useful-benchmarking-information-at-garfieldtech/</link>
		<comments>http://clarityamidstchaos.com/2011/08/20/useful-benchmarking-information-at-garfieldtech/#comments</comments>
		<pubDate>Sat, 20 Aug 2011 18:56:43 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[benchmarking]]></category>
		<category><![CDATA[efficiency]]></category>

		<guid isPermaLink="false">http://clarityamidstchaos.com/?p=333</guid>
		<description><![CDATA[I found and wanted to the share the following link, which contains a lot of useful benchmarking stats.  I&#8217;ll admit, I was surprised by a lot of these, and didn&#8217;t realize how much slower some of these calls are. http://www.garfieldtech.com/blog/magic-benchmarks At the same time, while it&#8217;s true to say it takes longer to use one [...]]]></description>
			<content:encoded><![CDATA[<p>I found and wanted to the share the following link, which contains a lot of useful benchmarking stats.  I&#8217;ll admit, I was surprised by a lot of these, and didn&#8217;t realize how much slower some of these calls are.</p>
<p><a href="http://www.garfieldtech.com/blog/magic-benchmarks">http://www.garfieldtech.com/blog/magic-benchmarks</a></p>
<p>At the same time, while it&#8217;s true to say it takes longer to use one method over another, it&#8217;s worth keeping in most cases the time spent over <strong>2 million</strong> iterations was still around three seconds or less.  A three second cost would mean .0015 millisecond cost each, on average.  If it&#8217;s not something you&#8217;re likely to do thousands of times (call_user_func), you&#8217;re looking at a completely reasonable cost.  If you&#8217;re doing it more than that, you might want to consider refactoring your code to do it less.</p>
]]></content:encoded>
			<wfw:commentRss>http://clarityamidstchaos.com/2011/08/20/useful-benchmarking-information-at-garfieldtech/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pattern for one permissions layer for front-end and back-end resource access</title>
		<link>http://clarityamidstchaos.com/2011/05/12/pattern-for-one-permissions-layer-for-front-end-and-back-end-resource-access/</link>
		<comments>http://clarityamidstchaos.com/2011/05/12/pattern-for-one-permissions-layer-for-front-end-and-back-end-resource-access/#comments</comments>
		<pubDate>Thu, 12 May 2011 22:19:00 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://clarityamidstchaos.com/?p=315</guid>
		<description><![CDATA[Terrible title, I know. If you managed to get here to read this, congratulations on searching whatever convoluted phrase might have matched mine. On to business&#8230; One sentence version Access resources by RESTful URL internally as well as on the front-end, and apply permissions layer there. I like to hear myself talk I am working [...]]]></description>
			<content:encoded><![CDATA[<p>Terrible title, I know.  If you managed to get here to read this, congratulations on searching whatever convoluted phrase might have matched mine.  On to business&#8230;</p>
<p><strong>One sentence version</strong><br />
Access resources by RESTful URL internally as well as on the front-end, and apply permissions layer there.</p>
<p><strong>I like to hear myself talk</strong><br />
I am working on user-generated content publishing website.  One of the important features is granular control over who does or does not have access to a resource.  The application was already constructed to be RESTful, meaning each resource (content, author, category, etc&#8230;) had its own URL, like http://www.example.com/content/this-one-time-at-band-camp.  Normally, a RESTful application means it provides a RESTful interface to visitors, but is not used internally.</p>
<p>What I came up with was a single function for fetching a resource, either internally or for an end-user.  Thus a visitor would request &#8220;/content/foobar&#8221; by entering that into their browser.  The application would load that story by requesting &#8220;/content/foobar&#8221; from the same function that would handle the end-user request as well.  This function would see if a handler was registered for that URL pattern, fetch the object, and return it in some format: HTML for front-end requests, or the actual object for internal requests (incidentally, this also made it easy to return resources in other formats as well, like XML, JSON, CSV, plain-text, graphic, and so on).</p>
<p>I constructed a permissions layer at the at that function.  Basically, when some library (ie. the &#8220;content&#8221; library) wants to claim URL space (&#8220;/content/*&#8221;), it registers a handler object capable of responding with the resource in the requested format.  The handler also must define an authorization method that gets checked first, and must return true to allow the request.  This way, publicly or internally, User A can&#8217;t access User B&#8217;s content if this isn&#8217;t explicitly allowed by the implementation.  The default behavior is to deny it, which serves the purpose of being a very obvious problem that needs to be solved, removing the likelihood of negligence.</p>
<p>Now, I should point out that in my implementation, this is basically just a polite front-end to the data layer, but not a gate.  If there&#8217;s some truly legitimate reason why I feel I need access to a resource for purely internal reasons and promise to be good with it, I can access the data layer directly to get it.  I haven&#8217;t found a need to do this, however.</p>
]]></content:encoded>
			<wfw:commentRss>http://clarityamidstchaos.com/2011/05/12/pattern-for-one-permissions-layer-for-front-end-and-back-end-resource-access/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Doing your part in politics</title>
		<link>http://clarityamidstchaos.com/2010/11/02/doing-your-part-in-politics/</link>
		<comments>http://clarityamidstchaos.com/2010/11/02/doing-your-part-in-politics/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 12:08:26 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://clarityamidstchaos.com/2010/11/02/doing-your-part-in-politics/</guid>
		<description><![CDATA[As the voting season is reaching full force, I&#8217;m having a harder and harder time visiting any web page without being bombarded with somebody else&#8217;s opinion on who I should vote for, usually delivered with catchy, mud-slinging tag lines like &#8220;The competition eats babies.  Do you hate babies?  Vote for our guy/girl/mutant.&#8221; So I like [...]]]></description>
			<content:encoded><![CDATA[<p>As the voting season is reaching full force, I&#8217;m having a harder and harder time visiting any web page without being bombarded with somebody else&#8217;s opinion on who I should vote for, usually delivered with catchy, mud-slinging tag lines like &#8220;The competition eats babies.  Do you hate babies?  Vote for our guy/girl/mutant.&#8221;</p>
<p>So I like to do my part and click on all political banners I see, and then close them almost immediately.  It gives me peace of mind knowing that they&#8217;re paying for a visit I don&#8217;t make, and probably off-setting their election predictions which makes me doubly happy.</p>
<p>Don&#8217;t give in to voter apathy.  Do your part and click all the political banners you see, and then close them right away before you catch something.</p>
]]></content:encoded>
			<wfw:commentRss>http://clarityamidstchaos.com/2010/11/02/doing-your-part-in-politics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Various test cases for assigning variables using or &#124;&#124; statements.</title>
		<link>http://clarityamidstchaos.com/2010/10/12/various-test-cases-for-assigning-variables-using-or-statements/</link>
		<comments>http://clarityamidstchaos.com/2010/10/12/various-test-cases-for-assigning-variables-using-or-statements/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 16:32:12 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://clarityamidstchaos.com/?p=258</guid>
		<description><![CDATA[console.clear(); function test(x1, x2, x3, x4, x5) { x1 = 0 &#124;&#124; 1; console.log(&#8216;X1: %o&#8217;, x1); // 1 x1 = x1 &#124;&#124; 2; console.log(&#8216;X1: %o&#8217;, x1); // 1 x2 = x2 &#124;&#124; true ? 1 : 2; console.log(&#8216;X2: %o&#8217;, x2); // 1 x2 = x2 &#124;&#124; &#8216;false&#8217;; console.log(&#8216;X2: %o&#8217;, x2); // 1 x2 = x3 [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>console.clear();</p>
<p>function test(x1, x2, x3, x4, x5) {<br />
x1 = 0 || 1;<br />
console.log(&#8216;X1: %o&#8217;, x1); // 1</p>
<p>x1 = x1 || 2;<br />
console.log(&#8216;X1: %o&#8217;, x1); // 1</p>
<p>x2 = x2 || true ? 1 : 2;<br />
console.log(&#8216;X2: %o&#8217;, x2); // 1</p>
<p>x2 = x2 || &#8216;false&#8217;;<br />
console.log(&#8216;X2: %o&#8217;, x2); // 1</p>
<p>x2 = x3 || false ? 1 : 2;<br />
console.log(&#8216;X2: %o&#8217;, x2); // 2</p>
<p>//   null || 1  || 2  || null || null<br />
x3 = x4   || x1 || x2 || x3   || x5;<br />
console.log(&#8216;X3: %o&#8217;, x3); // 1<br />
}</p>
<p>test();</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://clarityamidstchaos.com/2010/10/12/various-test-cases-for-assigning-variables-using-or-statements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Think before you serialize.</title>
		<link>http://clarityamidstchaos.com/2010/07/06/think-before-you-serialize/</link>
		<comments>http://clarityamidstchaos.com/2010/07/06/think-before-you-serialize/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 17:57:56 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.clarityamidstchaos.com/?p=228</guid>
		<description><![CDATA[I recently ran into an interesting problem as a result of using PHP&#8217;s serialize/unserialize functionality in a &#8230; well, a stupid way. Background For a brief background, I was working on a feature using a bunch of different classes. These classes could be manipulated by the end-user by changing around options, adding and removing items [...]]]></description>
			<content:encoded><![CDATA[<p>I recently ran into an interesting problem as a result of using PHP&#8217;s serialize/unserialize functionality in a &#8230; well, a stupid way.</p>
<p><strong>Background</strong><br />
For a brief background, I was working on a feature using a bunch of different classes.  These classes could be manipulated by the end-user by changing around options, adding and removing items from lists, and so on.  I thought it would be simple and convenient to just serialize these objects right into the database (I was working within a schema and was limited to using a single text blob, so one way or another I was going to be serializing data).</p>
<p><strong>The problem</strong><br />
Originally, my classes used nothing but private members and accessors where needed.  More recently, I wanted to change some of these private members to public, and when I did so my existing serialized objects broke!  What I found was this:</p>
<blockquote><p>When PHP attempts to unserialize() data containing private members into a class that contains public members of the same name, it produces an object that has both the private and public members of the same name.</p></blockquote>
<p>So I ended up with an object who had two members, both with the same name, and $this-&gt;member was only returning the public member.  The private member, which actually held information, was inaccessible.  I looked for some magic __wakeup hackery to work around this but failed.  Ultimately, since my code changes were now relying on public behavior, I used __get and __set to mimic it, along with a comment block explaining why I have all private members, and all exposed directly via __get and __set.  Ugly, ugly stuff.</p>
<p><strong>The lesson</strong><br />
Be careful what you do with serialized data, especially if you&#8217;re planning to keep it around for a while.  You can modify the methods of your serialized class all you want, since methods are not serialized, but your data structure (the members) may become much trickier to update in the future.</p>
<p>I didn&#8217;t test this all fully, so I&#8217;m not sure what exactly is required to trigger this problem.  For example, I know that replacing serialized public members with private members causes problems&#8230; what about the other direction?  What about removing a public member from the class &#8211; would this cause the serialized public member to show up anyhow?  I&#8217;m guessing it would.</p>
]]></content:encoded>
			<wfw:commentRss>http://clarityamidstchaos.com/2010/07/06/think-before-you-serialize/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I never understood&#8230;</title>
		<link>http://clarityamidstchaos.com/2010/06/19/i-never-understood/</link>
		<comments>http://clarityamidstchaos.com/2010/06/19/i-never-understood/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 13:54:22 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Social commentary]]></category>

		<guid isPermaLink="false">http://www.clarityamidstchaos.com/?p=219</guid>
		<description><![CDATA[I never understood why people begin sentences with &#8220;I never understood why people&#8221; when they totally do.]]></description>
			<content:encoded><![CDATA[<p>I never understood why people begin sentences with &#8220;I never understood why people&#8221; when they totally do.</p>
]]></content:encoded>
			<wfw:commentRss>http://clarityamidstchaos.com/2010/06/19/i-never-understood/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

