<?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>Chris Morrell &#187; Misc</title>
	<atom:link href="http://cmorrell.com/misc/feed" rel="self" type="application/rss+xml" />
	<link>http://cmorrell.com</link>
	<description>The personal home page of Chris Morrell</description>
	<lastBuildDate>Thu, 02 Feb 2012 16:34:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Introducing Zit, an object-oriented dependency injection container</title>
		<link>http://cmorrell.com/misc/zit-dependency-injection-container-976</link>
		<comments>http://cmorrell.com/misc/zit-dependency-injection-container-976#comments</comments>
		<pubDate>Thu, 02 Feb 2012 16:34:13 +0000</pubDate>
		<dc:creator>Chris M.</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://cmorrell.com/?p=976</guid>
		<description><![CDATA[I&#8217;ll admit right now that I&#8217;m fairly new to the world of dependency injection containers.  I usually do my dependency injection &#8220;manually&#8221; and have always thought that there must be a better way. Then I came across Pimple, which is &#8230; <a href="http://cmorrell.com/misc/zit-dependency-injection-container-976">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll admit right now that I&#8217;m fairly new to the world of dependency injection containers.  I usually do my dependency injection &#8220;manually&#8221; and have always thought that there must be a better way.</p>
<p>Then I came across <a href="http://pimple.sensiolabs.org/" target="_blank">Pimple</a>, which is a wonderfully simple solution to the problem.  The only thing about it is that I hate its array-oriented interface.  Something about <code>$container['session_storage']</code> rubs me the wrong way.  So I decided to implement Pimple in a more object-oriented way, and what I came up with was <a href="https://github.com/inxilpro/Zit" target="_blank">Zit</a>.</p>
<p><span id="more-976"></span></p>
<p>Zit works <em>almost</em> identically to Pimple, but with an object-oriented interface.  I think it&#8217;s easier to show than tell, so let&#8217;s start with a code example:</p>
<pre class="brush: php; title: ; notranslate">
// Include and instantiate Zit
require_once '/path/to/lib/Zit/Container.php';
$c = new \Zit\Container();

// Set config parameters
$c-&gt;setParam('db_user', 'username');
$c-&gt;setParam('db_pass', 'password');
$c-&gt;setParam('db_host', 'localhost');
$c-&gt;setParam('db_name', 'test');

// Set up objects
$c-&gt;set('db', function($c) {
  $db = $c-&gt;getDbName();
  $host = $c-&gt;getDbHost();
  $user = $c-&gt;getDbUser();
  $pass = $c-&gt;getDbPass();
  $dsn = sprintf('mysql:dbname=%s;host=%s', $db, $host);
  return new PDO($dsn, $user, $pass);
});
$c-&gt;setUser(function($c, $id)) {
    $user = new User($id);
    $user-&gt;setDb($c-&gt;getDb());
    return $user;
});

// Use container
$user1 = $c-&gt;getUser(1);
$sameUser = $c-&gt;getUser(1);
$newUser = $c-&gt;newUser(1);
$user2 = $c-&gt;getUser(2);
</pre>
<p>Some comments about the code:</p>
<ul>
<li>The setParam() method is used for any non-object, so if you want to store scalars or an array, you use this method.</li>
<li>All object instantiation functions are passed an instance of the Container as their first parameter.  That way all functions have access to other objects and parameters in the container.</li>
<li>Zit automatically translates underscores to camel case depending on whether you&#8217;re using a string or a method to access that object/parameter.</li>
<li>Zit is quite flexible in its interface.  For example, if you compare line 12 to line 20, you&#8217;ll see that you can set objects in a few different ways: set(&#8216;db&#8217;, &#8230;), setDb(&#8230;) or set_db(&#8230;) all work exactly the same.  This means you can use Zit however you like (or according to the coding standards of the project you&#8217;re working on).</li>
<li>By default, Zit shares object instances.  $user1 from line 27 is the exact same object as $sameUser on line 28 ($user1 === $sameUser).  If you want to create a new instance of an object, use the &#8220;new&#8221; methods.  <em>Note: because &#8220;new&#8221; is a reserved keyword, there is no new() method on the Zit container object.  Instead, this method is called fresh().  This means that new objects can be created with any of the following methods:</em></li>
<ul>
<li>fresh(&#8216;user&#8217;, &#8230;)</li>
<li>freshUser(&#8230;)</li>
<li>fresh_user(&#8230;)</li>
<li>newUser(&#8230;)</li>
<li>new_user(&#8230;)</li>
<li><strong>But not:</strong> new(&#8216;user&#8217;, &#8230;)</li>
</ul>
<li>Instantiation methods can be passed parameters, which is helpful if you need to pass those parameters on to the object&#8217;s constructor, or the the constructor of one of the object&#8217;s dependencies.</li>
</ul>
<p>As you can see, Zit does its very best to provide all the functionality and flexibility that you need without going overboard.  It acts almost exactly like Pimple, except for 3 important distinctions:</p>
<ol>
<li>It has an object-oriented interface rather than an array-oriented one</li>
<li>All objects are <em>shared by default</em></li>
<li>Objects can be passed constructor/instantiation parameters</li>
</ol>
<p>This is the first release of Zit.  The unit tests cover most scenarios, so it should be fairly safe to use, but it hasn&#8217;t been used in production yet (I&#8217;m using it in two projects that will go into production shortly, though).</p>
<p><a title="Zit" href="http://cmorrell.com/downloads/13">Download the latest release</a></p>
<p>Or, <a href="https://github.com/inxilpro/Zit" target="_blank">view on GitHub</a></p>
<div class="su-linkbox" id="post-976-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://cmorrell.com/misc/zit-dependency-injection-container-976&quot;&gt;Introducing Zit, an object-oriented dependency injection container&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://cmorrell.com/misc/zit-dependency-injection-container-976/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Steve Jobs went to Cupertino, and all I got were these lousy revolutions…</title>
		<link>http://cmorrell.com/misc/steve-jobs-cupertino-lousy-revolutions-971</link>
		<comments>http://cmorrell.com/misc/steve-jobs-cupertino-lousy-revolutions-971#comments</comments>
		<pubDate>Wed, 28 Dec 2011 14:59:08 +0000</pubDate>
		<dc:creator>Chris M.</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://cmorrell.com/?p=971</guid>
		<description><![CDATA[I came up with a great tee shirt idea.  I&#8217;m going to print a few.  You can buy one if you want. Link to this post!]]></description>
			<content:encoded><![CDATA[<p><a href="http://cmorrell.com/products/lousy-steve"><img class="size-full wp-image-953 alignnone" title="Steve Jobs went to Cupertino…" src="http://cdn1.cmorrell.com/wp-content/uploads/lousysteve.jpg" alt="" width="506" height="485" /></a></p>
<p>I came up with a <a title="Lousy Steve" href="http://cmorrell.com/products/lousy-steve">great tee shirt idea</a>.  I&#8217;m going to print a few.  <a title="Lousy Steve" href="http://cmorrell.com/products/lousy-steve">You can buy one if you want.</a></p>
<div class="su-linkbox" id="post-971-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://cmorrell.com/misc/steve-jobs-cupertino-lousy-revolutions-971&quot;&gt;Steve Jobs went to Cupertino, and all I got were these lousy revolutions…&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://cmorrell.com/misc/steve-jobs-cupertino-lousy-revolutions-971/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Modulo Operations for Even-Enough Distribution</title>
		<link>http://cmorrell.com/misc/modulo-operations-even-enough-distribution-910</link>
		<comments>http://cmorrell.com/misc/modulo-operations-even-enough-distribution-910#comments</comments>
		<pubDate>Fri, 22 Oct 2010 13:18:51 +0000</pubDate>
		<dc:creator>Chris M.</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://cmorrell.com/?p=910</guid>
		<description><![CDATA[If you don&#8217;t have to deal with large groups of data, this post is not for you.  But if you do, and aren&#8217;t familiar with the modulo operator, read on. The modulo operation essentially calculates the remainder of a division.  &#8230; <a href="http://cmorrell.com/misc/modulo-operations-even-enough-distribution-910">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you don&#8217;t have to deal with large groups of data, this post is not for you.  But if you do, and aren&#8217;t familiar with the modulo operator, read on.</p>
<p><span id="more-910"></span>The modulo operation essentially calculates the remainder of a division.  For example:</p>
<pre>5 % 4 = 1</pre>
<p>What&#8217;s very useful, is that you can take any number, and easily group it into any size group.  For example, if you needed to separate 6 items into 3 groups (OK—obviously you would do this differently, but it&#8217;s just for demonstration), you can do the following:</p>
<pre>1 % 3 = 1
2 % 3 = 2
3 % 3 = 0
4 % 3 = 1
5 % 3 = 2
6 % 3 = 0
</pre>
<p>Now your numbers are in group 0, 1, or 2.  This gets much more useful when you think about how almost all RDBMS tables have a numeric primary key value.  Need to split all the users in your system into 10 batches?  Just calculate the <code>user ID % 10</code> and you have all your users evenly (or, evenly enough) split.</p>
<p>This is a great way to implement sharding.  For example, WordPress 3.0 and higher support multiple sites running on the same codebase.  It does this by creating special tables for each site, in the format of PREFIX + ID + TABLE NAME (so a database might look like <code>wp_322_posts</code>).  Well, when you have a thousand sites, each with 10 or more tables, you start running into trouble keeping them all in one database.  That&#8217;s where the modulo operator comes into play:</p>
<pre class="brush: php; title: ; notranslate">
function db_callback($query, &amp;$wpdb) {
	// $wpdb-&gt;base_prefix = 'wp_';
	// $wpdb-&gt;table = 'wp_322_posts';
	if (preg_match(&quot;/^{$wpdb-&gt;base_prefix}(\d+)_/i&quot;, $wpdb-&gt;table, $matches)) {
		// Pretend we have 3 databases
		// Will return 'database0', 'database1' or 'database2'
		return 'database' . ($matches[1] % 3);
	}
}
</pre>
<p>Another recent way I&#8217;ve used the modulo operator is sending out a weekly batch email to a large number of users.  In this case, I had hundreds of thousands of records to read, parse, and then send out an email based on the results.  Rather than do all 600,000 records at once, I split them up into 7 batches, based on day.  Here&#8217;s a simplified version of that query:</p>
<pre class="brush: php; title: ; notranslate">
$sql = 'SELECT * FROM table
        WHERE user_id MOD 7 = ' . date('w');
</pre>
<p>Then I just set up the script to run daily through my crontab, and each user gets their email once a week, on the same day each week.  Alternately, you could send the message every hour to break it into 168 separate blocks throughout the week:</p>
<pre class="brush: php; title: ; notranslate">
$sql = 'SELECT * FROM table
        WHERE user_id MOD 168 = ' . ((date('w') * 24) + date('H'));
</pre>
<p>It&#8217;s something that you don&#8217;t necessarily use often, but it&#8217;s very handy to have in your repertoire.</p>
<div class="su-linkbox" id="post-910-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://cmorrell.com/misc/modulo-operations-even-enough-distribution-910&quot;&gt;Using Modulo Operations for Even-Enough Distribution&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://cmorrell.com/misc/modulo-operations-even-enough-distribution-910/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Optimize Legibility in Safari 5</title>
		<link>http://cmorrell.com/misc/optimize-legibility-safari-5-810</link>
		<comments>http://cmorrell.com/misc/optimize-legibility-safari-5-810#comments</comments>
		<pubDate>Tue, 29 Jun 2010 16:27:00 +0000</pubDate>
		<dc:creator>Chris M.</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[extensions]]></category>
		<category><![CDATA[safari]]></category>

		<guid isPermaLink="false">http://cmorrell.com/?p=810</guid>
		<description><![CDATA[Just saw this (via Daring Fireball): Cross-browser kerning-pairs &#38; ligatures And thought, &#8220;there&#8217;s gotta be an extension for that.&#8221;  Well, looks like there isn&#8217;t… so I made one: Enjoy! Link to this post!]]></description>
			<content:encoded><![CDATA[<p>Just saw this (via <a href="http://daringfireball.net/linked/2010/06/29/optimizelegibility" target="_blank">Daring Fireball</a>):</p>
<p><a href="http://www.aestheticallyloyal.com/public/optimize-legibility/" target="_blank">Cross-browser kerning-pairs &amp; ligatures</a></p>
<p>And thought, &#8220;there&#8217;s gotta be an extension for that.&#8221;  Well, looks like there isn&#8217;t… so I made one:</p>
<a href="http://cmorrell.com/downloads/8" title="Version 1.0, Downloaded 2310 times">Optimize Legibility [4.64 kB]</a>
<p>Enjoy!</p>
<div class="su-linkbox" id="post-810-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://cmorrell.com/misc/optimize-legibility-safari-5-810&quot;&gt;Optimize Legibility in Safari 5&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://cmorrell.com/misc/optimize-legibility-safari-5-810/feed</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Safari Toolbar CSS</title>
		<link>http://cmorrell.com/misc/safari-toolbar-css-805</link>
		<comments>http://cmorrell.com/misc/safari-toolbar-css-805#comments</comments>
		<pubDate>Wed, 09 Jun 2010 16:18:53 +0000</pubDate>
		<dc:creator>Chris M.</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://cmorrell.com/?p=805</guid>
		<description><![CDATA[By default, Safari extension toolbars are just plain old HTML. That means that your toolbar is going to look a lot like: Wouldn&#8217;t it be nice if instead it looked like: I&#8217;ve developed a (very) simple CSS file that styles &#8230; <a href="http://cmorrell.com/misc/safari-toolbar-css-805">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>By default, Safari extension toolbars are just plain old HTML.  That means that your toolbar is going to look a lot like:</p>
<p><img class="alignnone size-full wp-image-803" title="safari-css-before" src="http://cdn1.cmorrell.com/wp-content/uploads/2010/06/safari-css-before.png" alt="" width="328" height="39" /></p>
<p>Wouldn&#8217;t it be nice if instead it looked like:</p>
<p><img class="alignnone size-full wp-image-802" title="safari-css" src="http://cdn1.cmorrell.com/wp-content/uploads/2010/06/safari-css.png" alt="" width="328" height="39" /></p>
<p>I&#8217;ve developed a (very) simple CSS file that styles links (and &lt;button&gt; elements) to look like native Safari toolbar items.  <a href="http://cmorrell.com/safari-extensions">Download it now</a>.</p>
<div class="su-linkbox" id="post-805-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://cmorrell.com/misc/safari-toolbar-css-805&quot;&gt;Safari Toolbar CSS&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://cmorrell.com/misc/safari-toolbar-css-805/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Mobile App Development for Web Developers</title>
		<link>http://cmorrell.com/misc/mobile-app-development-for-web-developers-696</link>
		<comments>http://cmorrell.com/misc/mobile-app-development-for-web-developers-696#comments</comments>
		<pubDate>Thu, 25 Feb 2010 05:00:34 +0000</pubDate>
		<dc:creator>Chris M.</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www1.cmorrell.com/?p=696</guid>
		<description><![CDATA[On February 23rd I gave a talk at PANMA&#8216;s Mobile App Development Demystified event. My talk was titled Mobile App Development from a Web Developer&#8217;s Perspective. Here are my slides: I want to say thanks to everyone who came out &#8230; <a href="http://cmorrell.com/misc/mobile-app-development-for-web-developers-696">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>On February 23rd I gave a talk at <a href="http://www.panma.org/">PANMA</a>&#8216;s <em>Mobile App Development Demystified</em> event.  My talk was titled <em>Mobile App Development from a Web Developer&#8217;s Perspective</em>.  Here are my slides:</p>
<div style="width:425px" id="__ss_3265945">
<object width="405" height="339"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=mobileappdevelopment-100224102557-phpapp01&#038;rel=0&#038;stripped_title=mobile-app-development-3265945" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=mobileappdevelopment-100224102557-phpapp01&#038;rel=0&#038;stripped_title=mobile-app-development-3265945" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="405" height="339"></embed></object>
</div>
<p><span id="more-696"></span></p>
<p>I want to say thanks to everyone who came out to the event!  Also thanks to Joe Kaufman and Rob Hall for their fantastic presentations.  We ran a little long and some folks had to leave before seeing Joe&#8217;s demo, so I just wanted to mention it here.  For those of you who haven&#8217;t see it, <a href=" http://gamesalad.com/">GameSalad</a> is pretty magical, and the demo definitely got more than one round of applause.  Check it out (take a minute or two to watch the demo video—you&#8217;ll be blown away).  You should also check out Rob&#8217;s <a href="http://itunes.apple.com/us/app/phillygeekcentral/id357413307?mt=8">PhillyGeekCentral app</a> (written entirely in ActionScript 3 and compiled using Flash CS5).</p>
<p>Beyond that I just wanted to open up the comments for any feedback anyone might have on my talk, and to answer any questions that came up after we finished with Q&#038;A.  Feedback is particularly useful to me (and don&#8217;t be afraid to criticize—I can handle it) because I haven&#8217;t done much presenting and am still trying to get a sense for what works and what doesn&#8217;t.</p>
<p>There are two things that came up in private after the presentation that I think are worth sharing with everyone:</p>
<ol>
<li>A couple people asked me about styling applications written for PhoneGap or Titanium.  In the case of PhoneGap you don&#8217;t really get any built-in styles because it&#8217;s really just a web page running in a chrome-less browser.  That means if you want to mimic the iPhone&#8217;s UI or create something similar, you have to do it all with CSS and JavaScript.  Luckily there are a number of frameworks out there that do that for you, and when I get my slides online I&#8217;ll have a bunch of resources to start with.  For right now I would recommend checking out XUI and jQTouch.  These tools help you get a nice mobile UI up and running in no time.  (It&#8217;s worth mentioning that in the case of Titanium this is less of an issue because you can use native components.)</li>
<li>I also noticed that the question of local storage came up a few times, and I just wanted to clarify there.  Mobile Web Apps, PhoneGap Apps and Titanium Apps all have access to local storage.  Even in a web app, you can save settings to the phone that will still be there when the user closes Mobile Safari and reopens it.  You don&#8217;t have to talk to a web server at all if you don&#8217;t want to.</li>
</ol>
<p>Finally, I wanted to talk a little about choosing whether you should build a web app or a native app.  This is something I&#8217;ve been thinking about a lot and just didn&#8217;t have time to talk about last night.  Right now everyone is trying to get on Apple&#8217;s App Store.  It seems like most major web sites either have native apps on the store already, or are planning to do so soon.  But in the case of services that aren&#8217;t used daily (or at least weekly) I don&#8217;t think this makes any sense.  There&#8217;s a reason that Kayak.com (thanks to Andy Mroczkowski for this perfect example) is a web site and not a program that you download for your computer; For services that you only use time-to-time, it doesn&#8217;t make any sense to use a dedicated application.  So why would you want a dedicated application on your phone?  Well, you probably don&#8217;t.  But because everyone needs to be on the App Store today, that&#8217;s where you&#8217;ll find Kayak&#8217;s best mobile interactions.</p>
<p>That&#8217;s not to say that there aren&#8217;t a ton of instances where a native app wouldn&#8217;t be worth it.  I just think that far too many people are trying to develop native apps when they really aught to be working on great mobile web sites (or web apps).  Just like anything else, think about your users and their needs and choose the best option for them, even if it&#8217;s not 100% buzzword friendly.</p>
<p>Well, this post came out a lot longer than anticipated.  If you can&#8217;t tell, mobile development is a topic that I&#8217;m happy to talk about, so if you have question feel free to ask.</p>
<p>Here are some of the resources I mentioned for mobile app development:</p>
<ul>
<li><a href="http://bit.ly/4Fkdnp">Safari Mobile Web Programming</a></li>
<li><a href="http://www.w3.org/TR/2010/CR-mwabp-20100211/#bp-viewport">Viewport Meta Element</a></li>
<li><a href="http://www.w3.org/TR/css3-mediaqueries/">CSS3 Media Queries</a></li>
<li><a href="http://phonegap.com/">PhoneGap</a></li>
<li><a href="http://www.appcelerator.com/">Titanium Mobile</a></li>
<li><a href="http://developer.apple.com/iphone/">Apple iPhone Dev Center</a></li>
<li><a href="http://dev.w3.org/geo/api/spec-source.html">W3C Geolocation API</a></li>
<li><a href="http://bit.ly/bvlVJ8">Offline Storage &#038; Caching</a></li>
<li><a href="http://webkit.org/blog/138/css-animation/">CSS3 Transitions</a></li>
</ul>
<div class="su-linkbox" id="post-696-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://cmorrell.com/misc/mobile-app-development-for-web-developers-696&quot;&gt;Mobile App Development for Web Developers&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://cmorrell.com/misc/mobile-app-development-for-web-developers-696/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Find oversized files in *nix</title>
		<link>http://cmorrell.com/misc/find-oversized-files-in-nix-288</link>
		<comments>http://cmorrell.com/misc/find-oversized-files-in-nix-288#comments</comments>
		<pubDate>Thu, 30 Apr 2009 17:22:13 +0000</pubDate>
		<dc:creator>Chris M.</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://cmorrell.com/?p=288</guid>
		<description><![CDATA[Every once in a while I run the following command on my servers to hunt out the largest files to make sure nothing&#8217;s taking up too much space.  For example, it&#8217;s been very useful in hunting down over sized log &#8230; <a href="http://cmorrell.com/misc/find-oversized-files-in-nix-288">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Every once in a while I run the following command on my servers to hunt out the largest files to make sure nothing&#8217;s taking up too much space.  For example, it&#8217;s been very useful in hunting down over sized log files or email accounts.  It searches everything over 20MB and outputs the list to <code>bigfiles.txt</code> ordered by size (in MB) descending.</p>
<p><code>find / -type f -size +20000k -exec ls -la {} \; | sort +4 -nr | awk '{ printf "%-20s %s\n", $5/1048576, $9 }' &gt; bigfiles.txt &amp;</code></p>
<p>You can exclude a path by adding a little more to the command.  The following will do the same as above but exclude the <code>/backup</code> directory:</p>
<p><code>find / -path '/backup' -prune -o -type f -size +20000k -exec ls -la {} \; | sort +4 -nr | awk '{ printf "%-20s %s\n", $5/1048576, $9 }' &gt; bigfiles.txt &amp;</code></p>
<p>You can also change the <code>20000k</code> to whatever you want the smallest files to be.</p>
<p>It&#8217;s a fantastic little command and I just thought I&#8217;d share it with the world.</p>
<div class="su-linkbox" id="post-288-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://cmorrell.com/misc/find-oversized-files-in-nix-288&quot;&gt;Find oversized files in *nix&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://cmorrell.com/misc/find-oversized-files-in-nix-288/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&quot;Get it right&quot; = Procrastination</title>
		<link>http://cmorrell.com/business/get-it-right-procrastination-121</link>
		<comments>http://cmorrell.com/business/get-it-right-procrastination-121#comments</comments>
		<pubDate>Fri, 05 Dec 2008 17:15:45 +0000</pubDate>
		<dc:creator>Chris M.</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[procrastination]]></category>

		<guid isPermaLink="false">http://cmorrell.com/?p=121</guid>
		<description><![CDATA[&#8220;I&#8217;m not going to do [a] because I need to get [b] right first.&#8221; I, like most people, am a master of procrastination.  I clean my desk, file my e-mail, make a few phone calls, write a blog entry, etc, &#8230; <a href="http://cmorrell.com/business/get-it-right-procrastination-121">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<blockquote><p>&#8220;I&#8217;m <strong>not</strong> going to do <em>[a]</em> because I need to get<em> [b]</em> right first.&#8221;</p></blockquote>
<p>I, like most people, am a master of procrastination.  I clean my desk, file my e-mail, make a few phone calls, <em>write a blog entry</em>, etc, just to avoid whatever it is I <em>should</em> be doing.  Recently I discovered a new*, and troubling form of procrastination: &#8220;getting it right.&#8221;</p>
<p>For the past few months I&#8217;ve been working on a major restructuring of one of <a href="http://www.nachi.org">InterNACHI</a>&#8216;s core web systems.  Lately I&#8217;ve found myself not moving forward because I want to make sure the architecture is right, or I have some concerns about how certain decisions will affect search rankings, or I&#8217;m not sure if it will perform well, etc.  So instead of sitting down and finishing the project, I pull out a pad of paper and start outlining or graphing or whatever it is I convince myself I need to be doing.</p>
<p>Now that&#8217;s not to say that preparation isn&#8217;t important, but I&#8217;m starting to think that the <a href="http://en.wikipedia.org/wiki/Agile_software_development">agile</a> guys got it right: build early and build often.  And I realize that this is nothing new.  Heck, nearly all of &#8220;web 2.0&#8243; is built on the constant &#8220;beta&#8221; principal.  But I also know that as businesses grow, there&#8217;s a tendency to add unnecessary formality to otherwise simple things; at least I know that&#8217;s what we&#8217;ve done.  It&#8217;s almost like you get into this mentality of &#8220;this is how the big guys do it,&#8221; when it&#8217;s the little guys who are more compelling and innovative.</p>
<p>And on top of it all, &#8220;getting it right&#8221; is just a fiction.  There&#8217;s no such thing.  Today&#8217;s &#8220;right&#8221; is tomorrow&#8217;s &#8220;what was I thinking?&#8221;  I might as well get something &#8220;close&#8221; today, and &#8220;better&#8221; tomorrow.</p>
<p>So where is this post going?  I&#8217;m not really sure… I think I&#8217;m done, but I really don&#8217;t feel like getting back to work <img src='http://cdn1.cmorrell.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>So what do you guys think?  Am I the only one who procrastinates this way, or is this a common thing?</strong></p>
<p><em> </em></p>
<p><span style="color: #808080;"><small>* By new, I mean newly identified.  I&#8217;ve been doing this for years.</small></span></p>
<div class="su-linkbox" id="post-121-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://cmorrell.com/business/get-it-right-procrastination-121&quot;&gt;&quot;Get it right&quot; = Procrastination&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://cmorrell.com/business/get-it-right-procrastination-121/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ohpleasepleaseplease&#8230;.</title>
		<link>http://cmorrell.com/misc/ohpleasepleaseplease-107</link>
		<comments>http://cmorrell.com/misc/ohpleasepleaseplease-107#comments</comments>
		<pubDate>Tue, 04 Nov 2008 21:59:20 +0000</pubDate>
		<dc:creator>Chris M.</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Politics]]></category>

		<guid isPermaLink="false">http://cmorrell.com/?p=107</guid>
		<description><![CDATA[Oh man&#8230; here goes. Link to this post!]]></description>
			<content:encoded><![CDATA[<p><script src="http://www.gmodules.com/ig/ifr?url=http://general-election-2008.googlecode.com/svn/trunk/results-gadget.xml&amp;up_state=us&amp;up_race=President&amp;up_countdown=1&amp;synd=open&amp;w=395&amp;h=420&amp;title=2008+Election+Results+from+Google&amp;lang=all&amp;country=ALL&amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;output=js"></script></p>
<p>Oh man&#8230; here goes.</p>
<div class="su-linkbox" id="post-107-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://cmorrell.com/misc/ohpleasepleaseplease-107&quot;&gt;ohpleasepleaseplease&#8230;.&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://cmorrell.com/misc/ohpleasepleaseplease-107/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple PHP Pavatar Method</title>
		<link>http://cmorrell.com/misc/simple-php-pavatar-method-57</link>
		<comments>http://cmorrell.com/misc/simple-php-pavatar-method-57#comments</comments>
		<pubDate>Thu, 21 Aug 2008 22:45:11 +0000</pubDate>
		<dc:creator>Chris M.</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://cmorrell.com/?p=57</guid>
		<description><![CDATA[Microsoft Passport was a good idea. OpenID is a better idea. Gravatar is a good idea. Pavatar is a better idea. I think whenever a system can be open and decentralized, it should be (see my upcoming post on decentralized &#8230; <a href="http://cmorrell.com/misc/simple-php-pavatar-method-57">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Microsoft Passport was a good idea.  <a href="http://openid.net/" target="_blank">OpenID</a> is a better idea. <a href="http://en.gravatar.com/" target="_blank"> Gravatar</a> is a good idea. <a href="http://pavatar.com/" target="_blank"> Pavatar</a> is a better idea.  I think whenever a system can be open and decentralized, it should be (see my upcoming post on decentralized Twitter).  For those of you who like the idea and want to use it, here&#8217;s a quick and dirty PHP method to get the Pavatar image for a given URL (supports all three Pavatar techniques)&#8230;<br />
<span id="more-57"></span></p>
<pre class="brush: php; title: ; notranslate">
/**
 * Determines a URL's associated Pavatar (http://pavatar.com/)
 * Returns a URL on success, FALSE on failure
 * Does NOT verify that the URL is a valid image
 *
 * @author Chris Morrell (http://cmorrell.com)
 * @param string $url
 * @return mixed
 */
function getPavatar($url)
{
    // Grab Data
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_HEADER, 1);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $page = curl_exec($curl);
    curl_close($curl);

    // On Fail
    if (!$page)
    {
        return false;
    }

    // X-Pavatar Header Method
    elseif (preg_match('/X-Pavatar:\s*(.*?)(\s|\n)/i', $page, $matches))
    {
        return $matches[1];
    }

    // &lt;link&gt; Method
    elseif (preg_match('/&lt;link.*?rel=&quot;pavatar&quot;.*?&gt;/i', $page, $matches))
    {
        preg_match('/href=&quot;(.*?)&quot;/i', $matches[0], $matches);
        return $matches[1];
    }

    // Default URL Method
    else
    {
        $info = parse_url($url);
        return &quot;{$info['scheme']}://{$info['host']}/pavatar.png&quot;;
    }
}
</pre>
<p>Usage:</p>
<pre class="brush: php; gutter: false; title: ; notranslate">
$pavatar = getPavatar('http://cmorrell.com');
</pre>
<p>Enjoy!</p>
<div class="su-linkbox" id="post-57-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://cmorrell.com/misc/simple-php-pavatar-method-57&quot;&gt;Simple PHP Pavatar Method&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://cmorrell.com/misc/simple-php-pavatar-method-57/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 18/48 queries in 0.248 seconds using disk: basic
Object Caching 1256/1349 objects using disk: basic
Content Delivery Network via cdn1.cmorrell.com

Served from: cmorrell.com @ 2012-02-09 16:16:33 -->
