<?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>meloncholy</title> <atom:link href="http://meloncholy.com/feed/" rel="self" type="application/rss+xml" /><link>http://meloncholy.com</link> <description>Andrew Weeks</description> <lastBuildDate>Thu, 26 Jan 2012 20:08:13 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Aaarg!</title><link>http://meloncholy.com/blog/aaarg-web-pages-that-suck/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=aaarg-web-pages-that-suck</link> <comments>http://meloncholy.com/blog/aaarg-web-pages-that-suck/#comments</comments> <pubDate>Thu, 26 Jan 2012 20:07:50 +0000</pubDate> <dc:creator>Andrew</dc:creator> <category><![CDATA[Comment]]></category> <guid
isPermaLink="false">http://meloncholy.com/?p=234</guid> <description><![CDATA[A few years ago, I came across a couple of sites on Web Pages That Suck. (Both of which, I&#8217;m delighted to say, are still in more or less their original states five years after that post was published.) While &#8230; <a
class="more-link" href="http://meloncholy.com/blog/aaarg-web-pages-that-suck/">Keep&#160;reading&#160;<span
class="meta-nav">&#62;</span></a>]]></description> <content:encoded><![CDATA[<p>A few years ago, I came across a couple of sites on <a
href="http://www.webpagesthatsuck.com/10-worst-web-pages-featured-on-web-pages-that-suck-in-2006.html">Web Pages That Suck</a>. (<a
href="http://www.hrodc.com/index.htm">Both</a> of <a
href="http://www.dokimos.org/ajff/">which</a>, I&#8217;m delighted to say, are still in more or less their original states five years after that post was published.)</p><div
id="attachment_237" class="wp-caption alignnone" style="width: 570px"><a
href="http://meloncholy.com/wordpress/wp-content/uploads/hrodc-postgraduate-training-courses.jpg"><img
src="http://meloncholy.com/wordpress/wp-content/uploads/hrodc-postgraduate-training-courses-thumb.jpg" alt="" title="HRODC postgraduate training courses" width="560" height="300" class="size-full wp-image-237" /></a><p
class="wp-caption-text">HRODC postgraduate training courses</p></div><div
id="attachment_239" class="wp-caption alignnone" style="width: 570px"><a
href="http://meloncholy.com/wordpress/wp-content/uploads/accept-jesus-forever-forgiven.jpg"><img
src="http://meloncholy.com/wordpress/wp-content/uploads/accept-jesus-forever-forgiven-thumb.jpg" alt="" title="ACCEPT JESUS, FOREVER FORGIVEN!" width="560" height="300" class="size-full wp-image-239" /></a><p
class="wp-caption-text">ACCEPT JESUS, FOREVER FORGIVEN!</p></div><p>While both are, of course, fine examples of important web design maxims, surely their impact would be much greater if they could be finessed into one great web page? After all, who could resist combining the eloquent brevity of a 1.2MB page full of tables with the understated finesse of animated rainbow gifs and autoplaying music?</p><p>Turns out I couldn&#8217;t. And, having just rediscovered the result, I thought I&#8217;d stick it up here.</p><p><a
href="http://bits.meloncholy.com/aaarg/">Aaarg!</a></p><p><em>To enjoy the full experience, including the music and a bird that follows your cursor around, please view in an old version of IE.</em></p> ]]></content:encoded> <wfw:commentRss>http://meloncholy.com/blog/aaarg-web-pages-that-suck/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>On fanboy theory</title><link>http://meloncholy.com/blog/marco-on-fanboy-theory/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=marco-on-fanboy-theory</link> <comments>http://meloncholy.com/blog/marco-on-fanboy-theory/#comments</comments> <pubDate>Thu, 05 Jan 2012 17:46:53 +0000</pubDate> <dc:creator>Andrew</dc:creator> <category><![CDATA[Comment]]></category> <guid
isPermaLink="false">http://meloncholy.com/?p=214</guid> <description><![CDATA[Marco Arment on fanboy theory Why is it that your choice of smartphone platform incites so much irrational anger and so many accusations of being a &#8220;fanboy&#8221; from people who use a different one? [...] When people get defensive over &#8230; <a
class="more-link" href="http://meloncholy.com/blog/marco-on-fanboy-theory/">Keep&#160;reading&#160;<span
class="meta-nav">&#62;</span></a>]]></description> <content:encoded><![CDATA[<p>Marco Arment on <a
href="http://www.marco.org/2012/01/04/fanboy-theory">fanboy theory</a></p><blockquote><p> Why is it that your choice of smartphone platform incites so much irrational anger and so many accusations of being a &#8220;fanboy&#8221; from people who use a different one? [...]</p><p>When people get defensive over their choices that you inadvertently cast doubt upon, and they don&#8217;t want to admit (to themselves or anyone else) that they made the wrong decisions, they will often attempt to convince themselves (and possibly everyone else) that your opinions are invalid by discrediting you.</p><p>Hence, <strong>fanboy</strong>: a derogatory term that means <em>someone who is blindly and irrationally devoted to a product that I believe is inferior to what I bought when faced with a similar choice, and whose opinions and arguments can therefore be completely disregarded.</em></p></blockquote><p>There&#8217;s certainly truth to this, but the thing that bugs me about the whole fanboy thing really comes from the definition given in <a
href="http://www.loopinsight.com/2011/12/12/definition-of-an-apple-fanboy-and-those-that-use-the-term/">The Loop</a> that Marco linked to a few days ago.</p><blockquote><p> <strong>Apple fanboy</strong>: Someone who is tired of technology being difficult and knows there is something better; someone that loves to get the job done instead of working on their machine; a person that isn’t afraid of breaking the status quo; someone that appreciates quality design and workmanship; a person that realizes cheapest isn’t always best.</p><p>Apple fanboys are commonly confused with the sensible people of society.</p></blockquote><p>The problem with fanboys &#8211; and often Apple fanboys in particular &#8211; is not that they think their choice of gadget is better than yours, it&#8217;s that they think owning that gadget makes them better than you. <span
id="more-214"></span></p><p><em>For the record, I like OS X but own a Windows PC. Next time I may buy a Mac. I use an old iPhone, though I don&#8217;t really like it as it&#8217;s so damned slow. I&#8217;m a big fan of Metro and Windows Phone 7, though there&#8217;s a good chance I&#8217;d buy an iPhone if I were in the market for a new smartphone right now. Not, I imagine, that this matters one bit. :)</em></p> ]]></content:encoded> <wfw:commentRss>http://meloncholy.com/blog/marco-on-fanboy-theory/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Serving up random-but-consistent sample videos</title><link>http://meloncholy.com/blog/serving-up-random-but-consistent-sample-videos/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=serving-up-random-but-consistent-sample-videos</link> <comments>http://meloncholy.com/blog/serving-up-random-but-consistent-sample-videos/#comments</comments> <pubDate>Tue, 03 Jan 2012 16:01:28 +0000</pubDate> <dc:creator>Andrew</dc:creator> <category><![CDATA[.htaccess]]></category> <category><![CDATA[Code]]></category> <category><![CDATA[PHP]]></category> <guid
isPermaLink="false">http://meloncholy.com/?p=181</guid> <description><![CDATA[Need to serve up some sample images or videos that are apparently random, but remain consistent each time you show them? Download source I recently uploaded a Video Gallery web app I&#8217;d made (demo, code download). Unfortunately I don&#8217;t have &#8230; <a
class="more-link" href="http://meloncholy.com/blog/serving-up-random-but-consistent-sample-videos/">Keep&#160;reading&#160;<span
class="meta-nav">&#62;</span></a>]]></description> <content:encoded><![CDATA[<p>Need to serve up some sample images or videos that are apparently random, but remain consistent each time you show them?</p><p><a
href="https://github.com/meloncholy/consistent-random" class="source-link">Download source</a></p><p>I recently uploaded a <a
href="http://meloncholy.com/portfolio/video-gallery/">Video Gallery</a> web app I&#8217;d made (<a
href="http://bits.meloncholy.com/video-gallery/">demo</a>, <a
href="https://github.com/meloncholy/video-gallery">code download</a>). Unfortunately I don&#8217;t have the real videos and pictures that it was supposed to use, so I thought I&#8217;d cut some clips from the silent-but-gorgeous <a
href="http://www.theycallusanimals.com/">They Call Us Animals</a> music video footage. But the Video Gallery has about 300 different videos in the database, and I really didn&#8217;t want to make 900 sample clips (each one in 720p, 480p and 360p). So I made about 10, which seems enough to give a little variety.</p><p>But I couldn&#8217;t just serve up any video. Using the HTTP pseudostreaming support in <a
href="http://www.longtailvideo.com/players/">JW Player</a>, the site lets users change video sizes while they&#8217;re watching, and the player will switch to a different resolution source file if one is available to improve the viewing experience. It looks good, but the effect was rather spoiled when the video selector returned a higher resolution version of a completely different clip.</p><p>So I wrote a little PHP script that would serve up an apparently random sample video consistently. <span
id="more-181"></span></p><h2>Using the code</h2><p>First set <code>$folder</code> to point at the folder where the files you want to serve are located. It&#8217;s currently set up to use the folder where the file is uploaded.</p><p>The file selector will serve up jpegs, pngs and flv files from the box. If you want to allow others, add their file extensions and MIME types to the <code>$ext_list</code> array. There are examples for CSS, PDF and HTML files in the source. (On a side note, please don&#8217;t add PHP to the list and use <code>$folder = '.'</code> unless you don&#8217;t mind it returning itself sometimes.)</p><p>To get a random-but-consistent file, link to it as any other file</p><pre>
&lt;a href="http://example.com/rotate.php?file=kittens.flv"&gt;link&lt;/a&gt;
</pre><pre>
&lt;img src="http://example.com/rotate.php?file=kittens.jpg" /&gt;
</pre><p>The file returned will be of that same type (flv or jpg above). It will not be kittens.flv, but you will get the same one every time you ask for kittens.flv.</p><h2>The code</h2><p>After performing a few checks on the file type and allowed extensions, I used <a
href="http://php.net/manual/en/function.crc32.php"><code>crc32</code></a> to convert the supplied filename into an integer and ran it through the modulus operator to get a number in the range of the file count in the current folder. Then it reads the chosen file and we&#8217;re done. And that&#8217;s it.</p><pre>
$ext_list = array();
$ext_list['gif'] = 'image/gif';
$ext_list['jpg'] = 'image/jpeg';
$ext_list['jpeg'] = 'image/jpeg';
$ext_list['png'] = 'image/png';
$ext_list['flv'] = 'video/x-flv';
$file = null;
$vid = null;
$vids = null;
$content_type = null;
if (!isset($_GET['file'])) return;
$file = pathinfo($_GET['file']);
// Just in case there's other stuff in the folder too (like this file)
if (!array_key_exists($file['extension'], $ext_list)) return;
if (substr($folder, -1) != '/') $folder .= '/';
// Select a file based on the given extension.
$vids = glob($folder . '*.' . $file['extension']);
$vid = $vids[abs(crc32($file['basename'])) % count($vids)];
$content_type = 'Content-type: ' . $ext_list[$file['extension']];
header ($content_type);
readfile($vid);
</pre><h2>Fun with .htaccess</h2><p>Supplying random-but-consistent videos like this changes their path, as it&#8217;s now necessary to include (at least) <code>consistent-random.php?file=</code>. Not ideal, but a few lines added to .htaccess can point the original paths at the new placeholder files.</p><pre>
RewriteBase /video-gallery/
RewriteRule ^images/thumb/([-_a-zA-Z0-9\.]+)$ placeholder/images/thumb/consistent-random.php?file=$1 [L]
RewriteRule ^images/full/([-_a-zA-Z0-9\.]+)$ placeholder/images/full/consistent-random.php?file=$1 [L]
RewriteRule ^videos/([-_a-zA-Z0-9\.]+.flv)$ placeholder/videos/consistent-random.php?file=$1 [L]
</pre><p>And we&#8217;re done! The Video Gallery now thinks it&#8217;s supplying the videos and images as originally intended, not the placeholder ones it&#8217;s actually showing.</p><p><a
href="https://github.com/meloncholy/consistent-random" class="source-link">Download source</a></p> ]]></content:encoded> <wfw:commentRss>http://meloncholy.com/blog/serving-up-random-but-consistent-sample-videos/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
