<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Beautiful Pixel - Home</title>
  <id>tag:beautifulpixel.com,2010:mephisto/</id>
  <generator version="0.8.0" uri="http://mephistoblog.com">Mephisto Drax</generator>
  <link href="http://beautifulpixel.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://beautifulpixel.com/" rel="alternate" type="text/html"/>
  <updated>2010-06-22T00:10:06Z</updated>
  <entry xml:base="http://beautifulpixel.com/">
    <author>
      <name>Squeegy</name>
    </author>
    <id>tag:beautifulpixel.com,2010-06-22:7333</id>
    <published>2010-06-22T00:04:00Z</published>
    <updated>2010-06-22T00:10:06Z</updated>
    <category term="iPhone / Objective-C"/>
    <category term="Projects"/>
    <link href="http://beautifulpixel.com/2010/6/22/timeless-reminders" rel="alternate" type="text/html"/>
    <title>Timeless Reminders</title>
<content type="html">
            &lt;p&gt;I haven&#8217;t posted in forever, but I have good news!&lt;/p&gt;


	&lt;p&gt;We just released an iPhone app side freelance project I have been poking for the last 9 months or so called &lt;a href=&quot;http://itunes.apple.com/us/app/timeless-reminders/id377300020?mt=8&quot;&gt;Timeless Reminders&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;It allows you to create multimedia presentations of things that mean something to you, and then schedule that they be sent to yourself at scheduled times.  It sounds odd, but it can be very powerful when you get a slideshow of your wife in the middle of the Wednesday afternoon doldrums at work.  You should check it out.  It&#8217;s &lt;span class=&quot;caps&quot;&gt;FREE&lt;/span&gt; after all.&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://itunes.apple.com/us/app/timeless-reminders/id377300020?mt=8&quot;&gt;&lt;img src=&quot;http://beautifulpixel.com/assets/iTunes-20100621-170930.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://beautifulpixel.com/">
    <author>
      <name>Squeegy</name>
    </author>
    <id>tag:beautifulpixel.com,2009-12-14:7021</id>
    <published>2009-12-14T04:27:00Z</published>
    <updated>2009-12-14T04:28:11Z</updated>
    <category term="FlexImage"/>
    <category term="Ruby"/>
    <link href="http://beautifulpixel.com/2009/12/14/fleximage-news-gem-s3-and-heroku" rel="alternate" type="text/html"/>
    <title>Fleximage News - gem, S3 and Heroku</title>
<content type="html">
            &lt;p&gt;First of all, yes I am a douchebag for no posting anything in forever.  Life has been busy, but I&#8217;m starting to recollect my voice, and we will see how it goes.&lt;/p&gt;


	&lt;p&gt;So, Fleximage!  recently a few things have gone into the popular image plugin.&lt;/p&gt;


	&lt;h3&gt;1. Ruby Gem&lt;/h3&gt;


	&lt;pre&gt;&lt;code&gt;gem install fleximage&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;Currently just 1.0.0, but you no longer need to install fleximage as a plugin.  It now works as a gem.  Just install the gem and add a &lt;code&gt;config.gem 'fleximage'&lt;/code&gt; to your app&#8217;s initialization and you have finer version control and an all around cleaner way to manage your fleximage installation.&lt;/p&gt;


	&lt;h3&gt;2. Amazon S3&lt;/h3&gt;


	&lt;p&gt;You can now use Amazon S3 as a store for your master images.&lt;/p&gt;


&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;Photo&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ActiveRecord&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Base&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  acts_as_fleximage &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    s3_bucket &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mywebsite-com-user-uploads&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;c&quot;&gt;# a new initializer&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;require &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;aws/s3&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;co&quot;&gt;AWS&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;S3&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Base&lt;/span&gt;.establish_connection!(&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;sy&quot;&gt;:access_key_id&lt;/span&gt;     =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;my_s3_key_here&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;sy&quot;&gt;:secret_access_key&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;my_s3_secret_here&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Now new Photos will be uploaded to and read from your Amazon S3 account.  This isn&#8217;t super fast, but with proper page caching it shouldn&#8217;t be a big problem.  And there are some server configurations where file system storage is not possible, and database storage is impractical.&lt;/p&gt;


	&lt;p&gt;Which brings us to&#8230;&lt;/p&gt;


	&lt;h3&gt;3. Heroku&lt;/h3&gt;


	&lt;p&gt;The S3 support now allows fleximage to run on &lt;a href=&quot;http://heroku.com&quot;&gt;Heroku&lt;/a&gt; without database image storage.  Use S3 for storing your images, and you are done!&lt;/p&gt;


	&lt;p&gt;&lt;em&gt;What about cacheing?&lt;/em&gt; you ask.  Well Heroku uses &lt;code&gt;Cache-Control&lt;/code&gt; headers to auto cache your content.  And fleximage will automatically render it&#8217;s images with a 24 hour cache header.  So it should just work.  Just note that it&#8217;s not simple to expire a cached image.  So i usually construct my fleximage models so that the image on a particular model will never change.  Meaning that if I want a new image, I probably just want to delete that model and upload a new image to a new one.  or you can just wait a day for the new image to reappear.&lt;/p&gt;


	&lt;p&gt;I&#8217;ll be working on better solutions to Heroku caching when I can, but for now this should work well enough for most apps.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://beautifulpixel.com/">
    <author>
      <name>Squeegy</name>
    </author>
    <id>tag:beautifulpixel.com,2009-08-05:6682</id>
    <published>2009-08-05T18:29:00Z</published>
    <updated>2009-08-11T02:11:19Z</updated>
    <category term="iPhone / Objective-C"/>
    <category term="Projects"/>
    <category term="void"/>
    <link href="http://beautifulpixel.com/2009/8/5/void-update-coming-with-new-ui" rel="alternate" type="text/html"/>
    <title>VOID update coming with new UI</title>
<content type="html">
            &lt;p&gt;I don&#8217;t really know what I was think when I designed the flight UI for &lt;span class=&quot;caps&quot;&gt;VOID&lt;/span&gt;.  Someone once described it as &#8220;it likes a clown threw up on my iphone&#8221;.  Awesome.&lt;/p&gt;


	&lt;p&gt;Well the good news is that there is an update coming out soon with something far less intrusive and much easier on the eyes.  Stay tuned for that and more, soon.&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://beautifulpixel.com/assets/VOID_ui_hotness-20090805-112814.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://beautifulpixel.com/">
    <author>
      <name>Squeegy</name>
    </author>
    <id>tag:beautifulpixel.com,2009-07-31:6602</id>
    <published>2009-07-31T23:23:00Z</published>
    <updated>2009-07-31T23:27:54Z</updated>
    <category term="Ruby"/>
    <link href="http://beautifulpixel.com/2009/7/31/ruby-tricks-you-probably-knew-but-i-didn-t-array-2" rel="alternate" type="text/html"/>
    <title>Ruby Tricks you Probably knew but I didn't: Array#&amp;</title>
<content type="html">
            &lt;p&gt;I had to intersect 2 arrays today.  Basically I had 2 arrays and wanted to only the objects that both arrays contain.  Yeah, I could have done some &lt;code&gt;select&lt;/code&gt; or &lt;code&gt;reject&lt;/code&gt; loop, but I stumbled upon&#8230;&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;[:a, :b, :c, :d] &#38; [:a, :c, :e]
#=&amp;gt; [:a, :c]&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;Who knew?  I think I should really use operator overloading more often, and just so pleasing using an operator for an operation.  Go figure.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://beautifulpixel.com/">
    <author>
      <name>Squeegy</name>
    </author>
    <id>tag:beautifulpixel.com,2009-05-01:4279</id>
    <published>2009-05-01T23:18:00Z</published>
    <updated>2009-05-01T23:22:35Z</updated>
    <category term="FlexImage"/>
    <category term="Ruby"/>
    <link href="http://beautifulpixel.com/2009/5/1/fleximage-meets-aviary-phoenix" rel="alternate" type="text/html"/>
    <title>Fleximage meets Aviary Phoenix</title>
<content type="html">
            &lt;p&gt;&lt;a href=&quot;http:/aviary.com&quot;&gt;Aviary&lt;/a&gt; has been some cool stuff lately.  Recently they offered up an &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; that allows external images to be edited, and pushed back to the server they came from.  I thought that it would be awesome if Fleximage made this easy, so here you go.&lt;/p&gt;


	&lt;p&gt;It&#8217;s fairly simple and only involves three lines of code added to your app, and I think it&#8217;s pretty badass.  I&#8217;ve created a page all about how to take advantage of this new feature in the &lt;a href=&quot;http://wiki.github.com/Squeegy/fleximage/aviary-phoenix-online-image-editor-integration&quot;&gt;github wiki&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://wiki.github.com/Squeegy/fleximage/aviary-phoenix-online-image-editor-integration&quot;&gt;Aviary Phoenix integration guide&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://beautifulpixel.com/">
    <author>
      <name>Squeegy</name>
    </author>
    <id>tag:beautifulpixel.com,2009-04-02:3396</id>
    <published>2009-04-02T17:26:00Z</published>
    <updated>2009-04-02T17:28:46Z</updated>
    <category term="iPhone / Objective-C"/>
    <link href="http://beautifulpixel.com/2009/4/2/what-we-re-playing-the-void" rel="alternate" type="text/html"/>
    <title>What we're playing: The VOID</title>
<content type="html">
            &lt;p&gt;&lt;img src=&quot;http://beautifulpixel.com/assets/whatwereplayingisVOID-20090402-102628.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;Thanks Apple!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://beautifulpixel.com/">
    <author>
      <name>Squeegy</name>
    </author>
    <id>tag:beautifulpixel.com,2009-03-14:3155</id>
    <published>2009-03-14T16:58:00Z</published>
    <updated>2009-03-14T17:28:20Z</updated>
    <category term="iPhone / Objective-C"/>
    <category term="appstore"/>
    <link href="http://beautifulpixel.com/2009/3/14/app-store-yes-you-could-but-now-you-cant" rel="alternate" type="text/html"/>
    <title>App store: Yes you could, but now you cant!</title>
<content type="html">
            &lt;p&gt;I&#8217;ve spent the past 6 months working on an iPhone game.  In January I released a lite version of the game, to be followed by the full game a bit later on.  Then I update the Lite version to fix bugs and add a feature or two.  No problems, no rejections.&lt;/p&gt;


	&lt;p&gt;Lite version: &lt;a href=&quot;http://void.beautifulpixel.com/app_store/lite&quot;&gt;http://void.beautifulpixel.com/app_store/lite&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;So I finally finish full game 1.0 and submit to Apple.  I&#8217;m thinking it should pass approval fine since the Lite version was approved without an issue and the full game is just like the Lite version except bigger.&lt;/p&gt;


	&lt;p&gt;This morning I get my rejection email.  The issue they cite is improper use of a built in control that goes against the &lt;span class=&quot;caps&quot;&gt;HIG&lt;/span&gt; (Human Interface Guidelines).  That specific thing has some validity, and that is not what I am about to complain about.  The problem here is that my app got rejected based on an unchanged feature that was once approved.  Timelines, sale dates, and review line ups, they all now need to be pushed back, mostly because Apple didn&#8217;t do a thorough enough job the first time.&lt;/p&gt;


	&lt;p&gt;I don&#8217;t think it&#8217;s fair to developers for Apple to reject an update based on an issue that exists is previously approved builds of that application.  This is actually the second time this has happened.  I have a free social app for a small community that had an update rejected because it did not have a graceful failure if there was no internet connection.  But this was update 1.4, and that part of the app had not changed since 1.0 launch.&lt;/p&gt;


	&lt;p&gt;My point, Apple, if you insist on enforcing this level quality control over your apps, then you really need to be thorough and consistent.  As an iPhone developer, it just feels like I am trying to hit a moving target.  Except it takes a week for my arrow to get from my bow to where I think the target might have been a week ago.&lt;/p&gt;


	&lt;p&gt;App store submissions are like a box of chocolates: You never know what you&#8217;re gonna get.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://beautifulpixel.com/">
    <author>
      <name>Squeegy</name>
    </author>
    <id>tag:beautifulpixel.com,2009-03-12:3139</id>
    <published>2009-03-12T05:48:00Z</published>
    <updated>2009-03-12T06:09:09Z</updated>
    <category term="iphone"/>
    <link href="http://beautifulpixel.com/2009/3/12/the-void-is-imminently-near" rel="alternate" type="text/html"/>
    <title>The VOID is imminently near</title>
<content type="html">
            &amp;lt;object height=&quot;360&quot; width=&quot;480&quot;&gt;&amp;lt;param&gt;&amp;lt;/param&gt;&amp;lt;param&gt;&amp;lt;/param&gt;&amp;lt;embed src=&quot;http://www.youtube.com/v/JVhURgVc7Vo&amp;amp;#38;ap=%2526fmt%3D18&quot; height=&quot;360&quot; width=&quot;480&quot;&gt;&amp;lt;/embed&gt;&amp;lt;/object&gt;
          </content>  </entry>
  <entry xml:base="http://beautifulpixel.com/">
    <author>
      <name>Squeegy</name>
    </author>
    <id>tag:beautifulpixel.com,2009-03-01:3030</id>
    <published>2009-03-01T01:13:00Z</published>
    <updated>2009-03-01T01:40:15Z</updated>
    <category term="FlexImage"/>
    <category term="Ruby"/>
    <link href="http://beautifulpixel.com/2009/3/1/fleximage-displays-virtual-images" rel="alternate" type="text/html"/>
    <title>Fleximage displays virtual images</title>
<content type="html">
            &lt;p&gt;In the past, Fleximage has been constrained to rendering uploaded images from uploaded sources.  Resize, crop, apply effects, and send out to the client.  Well what if you want to render an image, but the model data you want to render is not really image based?  Introducing &lt;code&gt;Fleximage::Blank&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;Lets say you have a &lt;code&gt;Comment&lt;/code&gt; model.  A &lt;code&gt;Comment&lt;/code&gt; &lt;code&gt;belongs_to&lt;/code&gt; a &lt;code&gt;User&lt;/code&gt;.  For whatever reason, you need an image that represents any comment.  This image might looks like this:&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://beautifulpixel.com/assets/fleximage_virtual_image_demo.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;A template like this might create this image:&lt;/p&gt;


&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;30&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;31&lt;tt&gt;
&lt;/tt&gt;32&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# app/views/comments/show.png.flexi&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;co&quot;&gt;Fleximage&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Blank&lt;/span&gt;.new(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;400x150&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)).operate &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |image|&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# Start with a chat bubble image as the background&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  image.image_overlay(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;public/images/comment_bubble.png&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# Assuming that the user model acts_as_fleximage, this will draw the users image.&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  image.image_overlay(&lt;span class=&quot;iv&quot;&gt;@comment&lt;/span&gt;.user.file_path,&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;sy&quot;&gt;:size&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;50x50&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;sy&quot;&gt;:alignment&lt;/span&gt; =&amp;gt; &lt;span class=&quot;sy&quot;&gt;:top_left&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;sy&quot;&gt;:offset&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;10x10&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  )&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# Add the author name text&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  image.text(&lt;span class=&quot;iv&quot;&gt;@comment&lt;/span&gt;.author,&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;sy&quot;&gt;:alignment&lt;/span&gt; =&amp;gt; &lt;span class=&quot;sy&quot;&gt;:top_left&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;sy&quot;&gt;:offset&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;10x10&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;sy&quot;&gt;:color&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;sy&quot;&gt;:font_size&lt;/span&gt; =&amp;gt; &lt;span class=&quot;i&quot;&gt;24&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;sy&quot;&gt;:shadow&lt;/span&gt; =&amp;gt; {&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;sy&quot;&gt;:blur&lt;/span&gt; =&amp;gt; &lt;span class=&quot;i&quot;&gt;1&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;sy&quot;&gt;:opacity&lt;/span&gt; =&amp;gt; &lt;span class=&quot;fl&quot;&gt;0.5&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;    }&lt;tt&gt;
&lt;/tt&gt;  )&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# Add the comment body text&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  image.text(&lt;span class=&quot;iv&quot;&gt;@comment&lt;/span&gt;.body, &lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;sy&quot;&gt;:alignment&lt;/span&gt; =&amp;gt; &lt;span class=&quot;sy&quot;&gt;:top_left&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;sy&quot;&gt;:offset&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;10x90&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;sy&quot;&gt;:color&lt;/span&gt; =&amp;gt; color(&lt;span class=&quot;i&quot;&gt;128&lt;/span&gt;, &lt;span class=&quot;i&quot;&gt;128&lt;/span&gt;, &lt;span class=&quot;i&quot;&gt;128&lt;/span&gt;),&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;sy&quot;&gt;:font_size&lt;/span&gt; =&amp;gt; &lt;span class=&quot;i&quot;&gt;14&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  )&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Note that the &lt;code&gt;Comment&lt;/code&gt; does not need a call to &lt;code&gt;acts_as_fleximage&lt;/code&gt;.  The &lt;code&gt;Comment&lt;/code&gt; model itself has no image data in itself, but now it has an easy way to create an image based view of itself.&lt;/p&gt;


	&lt;p&gt;Checkout the &lt;a href=&quot;http://wiki.github.com/Squeegy/fleximage/virtualimages&quot;&gt;wiki entry on GitHub&lt;/a&gt; for more info.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://beautifulpixel.com/">
    <author>
      <name>Squeegy</name>
    </author>
    <id>tag:beautifulpixel.com,2009-01-26:2945</id>
    <published>2009-01-26T04:30:00Z</published>
    <updated>2009-01-26T04:30:48Z</updated>
    <category term="Random"/>
    <link href="http://beautifulpixel.com/2009/1/26/costa-rica-zip-line" rel="alternate" type="text/html"/>
    <title>Costa Rica Zip Line</title>
<content type="html">
            &lt;p&gt;This is turning out to be one hell of a vacation.&lt;/p&gt;


&amp;lt;object height=&quot;344&quot; width=&quot;425&quot;&gt;&amp;lt;param&gt;&amp;lt;/param&gt;&amp;lt;param&gt;&amp;lt;/param&gt;&amp;lt;param&gt;&amp;lt;/param&gt;&amp;lt;embed src=&quot;http://www.youtube.com/v/Cgs-aw8Z_4Y&amp;amp;#38;hl=en&amp;amp;#38;fs=1&quot; height=&quot;344&quot; width=&quot;425&quot;&gt;&amp;lt;/embed&gt;&amp;lt;/object&gt;
          </content>  </entry>
  <entry xml:base="http://beautifulpixel.com/">
    <author>
      <name>Squeegy</name>
    </author>
    <id>tag:beautifulpixel.com,2008-12-16:2783</id>
    <published>2008-12-16T17:32:00Z</published>
    <updated>2008-12-16T17:34:37Z</updated>
    <category term="iPhone / Objective-C"/>
    <link href="http://beautifulpixel.com/2008/12/16/void-teaser" rel="alternate" type="text/html"/>
    <title>VOID Teaser</title>
<content type="html">
            &lt;p&gt;Coming soon to an iPhone near you&#8230;&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://beautifulpixel.com/assets/2008/12/16/VOID-12-15-teaser.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://beautifulpixel.com/assets/2008/12/16/VOID-12-16-teaser.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://beautifulpixel.com/">
    <author>
      <name>Squeegy</name>
    </author>
    <id>tag:beautifulpixel.com,2008-09-09:2202</id>
    <published>2008-09-09T16:44:00Z</published>
    <updated>2009-08-11T06:05:52Z</updated>
    <category term="iPhone / Objective-C"/>
    <category term="Projects"/>
    <link href="http://beautifulpixel.com/2008/9/9/first-iphone-app" rel="alternate" type="text/html"/>
    <title>First iPhone app</title>
<content type="html">
            &lt;p&gt;I created my first &lt;a href=&quot;http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=287316743&amp;amp;#38;mt=8&quot;&gt;iPhone application&lt;/a&gt; recently.  It&#8217;s been an interesting road.&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://beautifulpixel.com/assets/2008/8/11/loading.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;It&#8217;s a small app for browsing the chat threads of a specific community, &lt;a href=&quot;http://shacknews.com&quot;&gt;Shacknews.com&lt;/a&gt;, which is a gaming news site with a following of interesting people that like to play games.&lt;/p&gt;


	&lt;p&gt;Memory management, and cryptic stack traces continue to be the biggest issues for me in this whole Objective-C venture.  That, and the app store approval process is incredibly frustrating.  Updates seem to be taking &lt;span class=&quot;caps&quot;&gt;AT LEAST&lt;/span&gt; a week to be approved, which really sucks when you need to fix a critical bug.  And recently, I got denied because a new feature in the update didn&#8217;t work.  Turns out, this was because of a temporary failure in the website that feature connects to that happened to coincide with when they were doing the testing.  That was all fixed pretty quickly, but my app is still rejected, and I imagine it will take at least a week for them to respond to my email.&lt;/p&gt;


	&lt;p&gt;Come on Apple, I know you can do better than this.&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=287316743&amp;amp;#38;mt=8&quot;&gt;iTunes App Store Link&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Next up, I&#8217;m gonna try to learn some OpenGL and see if I can muster some cool game or something.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://beautifulpixel.com/">
    <author>
      <name>Squeegy</name>
    </author>
    <id>tag:beautifulpixel.com,2008-08-11:1750</id>
    <published>2008-08-11T20:12:00Z</published>
    <updated>2008-08-11T20:13:57Z</updated>
    <category term="iPhone / Objective-C"/>
    <link href="http://beautifulpixel.com/2008/8/11/why-every-community-needs-an-api" rel="alternate" type="text/html"/>
    <title>Why every community needs an API</title>
<content type="html">
            &lt;p&gt;I&#8217;ve been working on an iPhone application for the community of &lt;a href=&quot;http://shacknews.com&quot;&gt;Shacknews.com&lt;/a&gt;.  It&#8217;s an app that allows access to the comments areas that are attached to the news stories.  Simple enough, but I ran into the problem in that the site had no &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;I started to examine the tools I had in the iPhone frameworks to parse html content.  It quickly became a chore.  &lt;a href=&quot;http://code.whytheluckystiff.net/hpricot/&quot;&gt;Hpricot&lt;/a&gt; has spoiled me.  So I did what any Rails developer would do: I wrote a small Rails webservice to scrape the &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt;, and return organized semantic &lt;span class=&quot;caps&quot;&gt;XML&lt;/span&gt;.  This stuff was much easier to parse on the iPhone.&lt;/p&gt;


	&lt;p&gt;I told the community of my progress on the iPhone app, and they were excited.  As a minor aside, I also informed them that the &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; was open for whatever anyone else wanted to do with it.&lt;/p&gt;


	&lt;p&gt;This is when something magical happened.  I didn&#8217;t think much would come from the &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt;, other than me being able to use it for the iPhone app.  But almost overnight, there were a multiple projects being cooked up by some tech savvy members.  Very quickly they began to release their work.  Suddenly it felt like a mini renaissance as the community interaction began to spread like a virus into new domains.  Suddenly, you can post from the beach with ease, or report the score of a sports game to your buddies from your seat in the bleachers.  Or you can post from work via a command line terminal that doesn&#8217;t look like your wasting time posting about video games as your boss walks by.&lt;/p&gt;


	&lt;p&gt;When you have an &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt;, you give the community a way to improve your offering for you.  And the best thing is, people do it for &lt;span class=&quot;caps&quot;&gt;FREE&lt;/span&gt;, because they want to.  You can pay some developer to make an iPhone app for you, or you can have an &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; and let someone else decide to do it for free.  Overall, community participation is up, because people can do it easier, and in more situations.  As a result, you get more traffic, and more importantly, more user activity in your site.&lt;/p&gt;


	&lt;p&gt;There are lots of smart people out there.  Give them the chance to make cool stuff for you, and if they are passionate about your site, they will.  And you will reap the benefits.&lt;/p&gt;


&lt;hr /&gt;


	&lt;p&gt;After a week or so of the &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; being available, this is list of ways you can now participate in the community beyond a computer based web browser.&lt;/p&gt;


	&lt;p&gt;&lt;em&gt;(List compiled by a community member)&lt;/em&gt;&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;/assets/2008/8/4/lol.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;h3&gt;LatestChatty.app&lt;/h3&gt;


&lt;strong&gt;Pros:&lt;/strong&gt;
	&lt;ul&gt;
	&lt;li&gt;Best UI and features&lt;/li&gt;
	&lt;/ul&gt;


&lt;strong&gt;Cons:&lt;/strong&gt;
	&lt;ul&gt;
	&lt;li&gt;iPhone only&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://homepage.mac.com/brianluft/img/ZZ431DCC94.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;h3&gt;LatestChatty Command Line App&lt;/h3&gt;


	&lt;p&gt;For Windows 3.11 and later, a command line interface.  This is probably the most impressive, to be honest.&lt;/p&gt;


&lt;strong&gt;Pros:&lt;/strong&gt;
	&lt;ul&gt;
	&lt;li&gt;36K!&lt;/li&gt;
		&lt;li&gt;Work safe!&lt;/li&gt;
	&lt;/ul&gt;


&lt;strong&gt;Cons:&lt;/strong&gt;
	&lt;ul&gt;
	&lt;li&gt;Code will probably make your head hurt when he releases it&lt;/li&gt;
		&lt;li&gt;Probably not going to display images any time soon&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://dave-a.shackspace.com/LatestChatty/newwmshack.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;h3&gt;LatestChatty for Windows Mobile&lt;/h3&gt;


	&lt;p&gt;Why does the iPhone get to have all the mobile fun?&lt;/p&gt;


&lt;strong&gt;Pros:&lt;/strong&gt;
	&lt;ul&gt;
	&lt;li&gt;Makes Windows Mobile slightly less embarrassing to own&lt;/li&gt;
	&lt;/ul&gt;


&lt;strong&gt;Cons:&lt;/strong&gt;
	&lt;ul&gt;
	&lt;li&gt;Fairly feature light at this point &#8211; color-coding of tagged posts would be nice&lt;/li&gt;
		&lt;li&gt;Navigation is not the best&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


	&lt;h3&gt;2 mobile optimized web apps for mobile browsers&lt;/h3&gt;


	&lt;p&gt;Why does the iPhone get to have all the mobile fun?&lt;/p&gt;


&lt;strong&gt;Pros:&lt;/strong&gt;
	&lt;ul&gt;
	&lt;li&gt;Nothing to install&lt;/li&gt;
		&lt;li&gt;Works broadly on small screen sizes&lt;/li&gt;
	&lt;/ul&gt;


&lt;strong&gt;Cons:&lt;/strong&gt;
	&lt;ul&gt;
	&lt;li&gt;Less powerful UI and features than a native mobile app.&lt;/li&gt;
	&lt;/ul&gt;
          </content>  </entry>
  <entry xml:base="http://beautifulpixel.com/">
    <author>
      <name>Squeegy</name>
    </author>
    <id>tag:beautifulpixel.com,2008-07-21:1717</id>
    <published>2008-07-21T02:23:00Z</published>
    <updated>2008-07-21T19:07:13Z</updated>
    <category term="iPhone / Objective-C"/>
    <link href="http://beautifulpixel.com/2008/7/21/objective-c-syntax" rel="alternate" type="text/html"/>
    <title>Objective-C Syntax</title>
<content type="html">
            &lt;p&gt;I&#8217;m still trying to learn Objective-C and Cocoa here, and coming from Ruby, its an interesting experience.&lt;/p&gt;


	&lt;h3&gt;Method calling Syntax&lt;/h3&gt;


	&lt;p&gt;I simultaneously love and hate the method calling syntax.  Take this for example:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;[UIColor colorWithRed:1.0 green:1.0 blue:1.0];&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;This create an instance of the UIColor class with red green and blue values as specified, in this case white.  I do like that the parameters are labeled, and I like that better than simply passing in a list of anonymous argument that most languages give you.&lt;/p&gt;


	&lt;p&gt;But what I don&#8217;t like is the method name being forced to mingle with the arguments.  Semantically, red, green, and blue are all equal things.  However I am forced to prepend the declaration of the red value with this &lt;code&gt;colorWith&lt;/code&gt; prefix.  The named parameters actually &lt;em&gt;are&lt;/em&gt; the method name.  According to the langauge internals, the name of this method is:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;colorWithRed:green:blue:&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;Here&#8217;s how I might do the same thing in ruby:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;UIColor.new(1.0, 1.0, 1.0)&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;Although, this requires some formal knowledge that the order of arguments is red, then green, then blue.  But I can easily remember this since its a basic language feature.&lt;/p&gt;


	&lt;p&gt;Usually I don&#8217;t mind long method names, but when handling things as simple as initialization, it seems like I should have to look up the syntax.  Long ruby method names aren&#8217;t too much of a problem, because they only have one part.  Objective-C methods tend to be more verbose, and its hard to know where the arguments go and what type the arguments are supposed to be.&lt;/p&gt;


	&lt;p&gt;The result is that I can&#8217;t possibly imagine writing Objective-C without a code completing &lt;span class=&quot;caps&quot;&gt;IDE&lt;/span&gt;.  I have written huge amounts of ruby in Textmate, and really don&#8217;t miss code completion much.  Maybe I just have to get used to the &lt;span class=&quot;caps&quot;&gt;IDE&lt;/span&gt; mindset.&lt;/p&gt;


	&lt;h3&gt;Objects and non-Objects&lt;/h3&gt;


	&lt;p&gt;Ruby has spoiled me.  Everything is an object in ruby.  A string, a number, a chunk of code, everything.  Even a class is an instance of the class &lt;code&gt;Class&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;In Objective-C the story is different.  An object is an instance of a class that inherits from the &lt;code&gt;NSObject&lt;/code&gt; class.  Basically this means that the only things that are objects are things that are provided by Cocoa.  Other things that are provided by the underlying C, like floats, strings and whatnot are not objects.  Although, to be fair, Cocoa provides object based wrappers for most of the C non object primitives, but its not always worth the overhead to use them for simple stuff.&lt;/p&gt;


	&lt;p&gt;This makes the syntax a bit of a mess.  The bracket method calling syntax only works on objects, because a non object (I dont even know what to call it) cant have methods at all.  And then you have calls to C functions like:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;UIGetCurrentGraphicsContext()&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;Which doesn&#8217;t even use the bracket syntax at all.  I&#8217;m sure I will get used to all this, but I can&#8217;t help but feel this language would be a lot more fun if everything was an object.  I think most people go from something like C to ruby, but I am going the other way around, and it&#8217;s odd.  We&#8217;ll see where this goes.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://beautifulpixel.com/">
    <author>
      <name>Squeegy</name>
    </author>
    <id>tag:beautifulpixel.com,2008-07-20:1716</id>
    <published>2008-07-20T19:36:00Z</published>
    <updated>2008-07-20T20:40:46Z</updated>
    <category term="FlexImage"/>
    <category term="Ruby"/>
    <link href="http://beautifulpixel.com/2008/7/20/ie7-header-issues" rel="alternate" type="text/html"/>
    <title>IE7 header issues</title>
<content type="html">
            &lt;p&gt;I got to deploy a new build to &lt;a href=&quot;http://thewinespies.com&quot;&gt;TheWineSpies.com&lt;/a&gt; this weekend, which among many other things, upgraded the app to rails 2.1.  This process had me refactoring the admin to be RESTfull-er, and incorporating the latest version of Fleximage.  I thought everything was dandy.&lt;/p&gt;


	&lt;h3&gt;The Problem&lt;/h3&gt;


	&lt;p&gt;My client was doing some testing on this code with &lt;span class=&quot;caps&quot;&gt;IE7&lt;/span&gt;, their browser of choice.  But something odd was happening.  They would click a link triggering a resources &lt;code&gt;show&lt;/code&gt; action, and instead of a html page about that resource, they would just get the image.  At first I was stumped.  I never thought cross browser issues could change server behavior.  Firefox got a page of &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; and &lt;span class=&quot;caps&quot;&gt;IE7&lt;/span&gt; got an image.  And I confirmed that the server was actually sending different content to the different browsers.  The truly bizarre part, was that after clicking a link to this page, you could refresh and get the content you were expecting.&lt;/p&gt;


	&lt;p&gt;What the hell?&lt;/p&gt;


	&lt;h3&gt;The Code&lt;/h3&gt;


	&lt;p&gt;The Wine Spies uses Fleximage enahnced models across a few different resources, but here is a simple action that was causing me grief.&lt;/p&gt;


&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;show&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;iv&quot;&gt;@product&lt;/span&gt; = &lt;span class=&quot;co&quot;&gt;Product&lt;/span&gt;.find(params[&lt;span class=&quot;sy&quot;&gt;:id&lt;/span&gt;])&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  respond_to &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |format|&lt;tt&gt;
&lt;/tt&gt;    format.html&lt;tt&gt;
&lt;/tt&gt;    format.jpg  { render &lt;span class=&quot;sy&quot;&gt;:template&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/some/path/small.flexi&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;    format.xml  { render &lt;span class=&quot;sy&quot;&gt;:xml&lt;/span&gt; =&amp;gt; &lt;span class=&quot;iv&quot;&gt;@product&lt;/span&gt;.to_xml }&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;This is pretty straightforward.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;If &lt;code&gt;html&lt;/code&gt; is requested, render the default template&lt;/li&gt;
		&lt;li&gt;If &lt;code&gt;jpg&lt;/code&gt; is requested, render some &lt;code&gt;.flexi&lt;/code&gt; template&lt;/li&gt;
		&lt;li&gt;If &lt;code&gt;xml&lt;/code&gt; is requested, dump the object to xml and send it out&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;But still, &lt;span class=&quot;caps&quot;&gt;IE7&lt;/span&gt; on a url of &lt;code&gt;/products/123&lt;/code&gt; would trigger the &lt;code&gt;jpg&lt;/code&gt; format renderer.  Somehow rails was thinking that &lt;span class=&quot;caps&quot;&gt;IE7&lt;/span&gt; &lt;em&gt;wanted&lt;/em&gt; a jpeg image instead of &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt;.  Where other browser were making rails think they want &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; unless overridden by a format extension on the url.&lt;/p&gt;


	&lt;h3&gt;Tracking down the cause&lt;/h3&gt;


	&lt;p&gt;I began to think back to the &lt;span class=&quot;caps&quot;&gt;DHH&lt;/span&gt; keynote &#8220;World of Resources&#8221; and some of the early stuff that was forming around rails, and luckily, I remembered something important.  I tend to use this format pattern a lot, and I usually trigger it by url extensions like &lt;code&gt;/products/123.jpg&lt;/code&gt; or &lt;code&gt;/products/123.xml&lt;/code&gt;.  But rails looks at something else too.&lt;/p&gt;


	&lt;p&gt;Your browser, or any &lt;span class=&quot;caps&quot;&gt;HTTP&lt;/span&gt; client, sends along a header named &lt;code&gt;HTTP_ACCEPT&lt;/code&gt; with any request.  I decided to add some debug code to my action to see what was in this header:&lt;/p&gt;


&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;raise request.headers[&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;HTTP_ACCEPT&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;]&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;In Firefox 3, the result was (minor edit for simplicity):&lt;/p&gt;


&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;text/html,application/xhtml+xml,application/xml,*&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;This is a comma separated list of &lt;span class=&quot;caps&quot;&gt;MIME&lt;/span&gt; types.  The purpose of this header is to let to receiver know what kind of data the client wants, or what it will &#8220;accept&#8221;.  It&#8217;s a prioritized list where the first items are wanted &lt;em&gt;more&lt;/em&gt; then the items at the end of the list.  Firefox is saying &#8220;Please give me html.  If you don&#8217;t have that give me xhtml.  But I guess xml would be ok too if that&#8217;s all you got.  You got none of those?  Well give me whatever you got then, I don&#8217;t care.&#8221;&lt;/p&gt;


	&lt;p&gt;Ok what does &lt;strong&gt;&lt;span class=&quot;caps&quot;&gt;IE7&lt;/span&gt;&lt;/strong&gt; send?&lt;/p&gt;


&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/ag-plugin, *&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Until I refreshed the page, instead of clicking a link to this page, and got:&lt;/p&gt;


&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;*&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;What the hell?&lt;/p&gt;


	&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;IE7&lt;/span&gt; doesn&#8217;t say it wants &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; at all!  It says it would rather have a gif, bitmap, jpg, flash, or even a plugin, rather than any other &lt;span class=&quot;caps&quot;&gt;MIME&lt;/span&gt; type, including html.  Rails gets this header, and sees that is no explicit format on the &lt;span class=&quot;caps&quot;&gt;URL&lt;/span&gt;, so it goes down the list:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Does this action respond to the &lt;code&gt;image/gif&lt;/code&gt; format? nope.&lt;/li&gt;
		&lt;li&gt;How about the &lt;code&gt;image/x-bitmap&lt;/code&gt; format? no.&lt;/li&gt;
		&lt;li&gt;Maybe the &lt;code&gt;image/jpeg&lt;/code&gt; format? Oh look at that yes it does!&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;The item that would have matched the html renderer &lt;code&gt;*/*&lt;/code&gt; is too far down the list, and we don&#8217;t get to it before a suitable responder is found.&lt;/p&gt;


	&lt;p&gt;Since &lt;span class=&quot;caps&quot;&gt;IE7&lt;/span&gt; sends a different &lt;code&gt;HTTP_ACCEPT&lt;/code&gt; of &lt;code&gt;*/*&lt;/code&gt; on a refresh, it is declaring it has no preferred format at all.  Rails then renders the default: html.&lt;/p&gt;


	&lt;h3&gt;The Solution&lt;/h3&gt;


	&lt;p&gt;After trying many ways to capture the damn header, override it somehow, shoving some &lt;code&gt;Mime::Type&lt;/code&gt; object into &lt;code&gt;request.format&lt;/code&gt;, and other failed solutions, here is what I finally ended up with:&lt;/p&gt;


&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;c&quot;&gt;#application.rb&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;before_filter &lt;span class=&quot;sy&quot;&gt;:set_default_format&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;set_default_format&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  params[&lt;span class=&quot;sy&quot;&gt;:format&lt;/span&gt;] ||= &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;This basically tells rails to ignore the &lt;code&gt;HTTP_ACCEPT&lt;/code&gt; header.  If a format is not explicitly declared on the &lt;span class=&quot;caps&quot;&gt;URL&lt;/span&gt;, then force it to be &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt;.  It&#8217;s as if every html page on the site has a &lt;code&gt;.html&lt;/code&gt; appended to the &lt;span class=&quot;caps&quot;&gt;URL&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;And finally salvation from that circle of hell.&lt;/p&gt;


	&lt;h3&gt;Conclusions&lt;/h3&gt;


	&lt;p&gt;What makes a good &lt;code&gt;HTTP_ACCEPT&lt;/code&gt; header?  I think Firefox has it right.  Being a web browser, its main job is to display &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt;, with embedded media.  So it should want &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; more than anything since the images are just there in support of the html (mostly anyway).&lt;/p&gt;


	&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;IE7&lt;/span&gt; makes 2 mistakes:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;It sends different headers depending on how the page was loaded&lt;/li&gt;
		&lt;li&gt;It states that is prefers images over &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt;&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;HTTP&lt;/span&gt; headers are a powerful tool.  They can make interfacing with web applications and &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt;&#8217;s much cleaner.  But as we depend on them increasingly, we need have a level of trust with the clients that people use to connect.  &lt;span class=&quot;caps&quot;&gt;IE7&lt;/span&gt; said it wanted one thing, and I forced to create a hack in order to tell &lt;span class=&quot;caps&quot;&gt;IE7&lt;/span&gt; &#8220;No, you don&#8217;t really want that.  You really want something else.&#8221;  And that makes me sad.&lt;/p&gt;


	&lt;p&gt;I thought clients who don&#8217;t know what they want are pain, but now browsers have the same problem.  &lt;span class=&quot;caps&quot;&gt;IE7&lt;/span&gt; is a &lt;em&gt;huge&lt;/em&gt; improvement over &lt;span class=&quot;caps&quot;&gt;IE6&lt;/span&gt;, however it obviously still has its issues for web developers.  The simple fact is that both versions of this browser have cost me way too much time, and that means it cost me money.  The number of hours I have spent troubleshooting issues like this, as well as &lt;span class=&quot;caps&quot;&gt;CSS&lt;/span&gt; and javascript issues, is way more than I want to admit to.&lt;/p&gt;


	&lt;p&gt;And that makes cranky.  So tell your parents, &#8220;Save a web developer.  Switch to Firefox.&#8221;  Then maybe the world will be a better place.&lt;/p&gt;
          </content>  </entry>
</feed>
