<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Adam Fortuna</title>
	
	<link>http://adamfortuna.com</link>
	<description>Rants on technology, Ruby on Rails, Javascript and UI Design by Adam Fortuna</description>
	<lastBuildDate>Tue, 30 Mar 2010 01:47:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/adamfortuna" /><feedburner:info uri="adamfortuna" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>adamfortuna</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>jQuery Driven Tokenizing Additions</title>
		<link>http://feedproxy.google.com/~r/adamfortuna/~3/dnz6PIimniQ/</link>
		<comments>http://adamfortuna.com/2010/03/29/jquery-driven-tokenizing-additions/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 01:47:00 +0000</pubDate>
		<dc:creator>Adam Fortuna</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://adamfortuna.com/?p=505</guid>
		<description><![CDATA[Facebook got tokenized input right. If you&#8217;ve ever sent someone a message, or searched for someone a message you probably used what was previously a less user-friendly system to perform this same task. The idea is easy &#8211; you want to enter one or more names or other text and select matches. Gmail uses the [...]]]></description>
			<content:encoded><![CDATA[<p>Facebook got tokenized input right. If you&#8217;ve ever sent someone a message, or searched for someone a message you probably used what was previously a less user-friendly system to perform this same task. The idea is easy &#8211; you want to enter one or more names or other text and select matches. Gmail uses the same kind of auto-complete to allow you to email to multiple email addresses, as do a host of other sites, so it&#8217;s surprising there aren&#8217;t better solutions to this in the public. I came across one amazing solution for this when I was working on <a href="http://movief.ly">MovieFly</a> a few months ago, and was able to expand it with a few more options while working on <a href="http://sponsoredtweets.com">SponsoredTweets</a>.</p>
<p>The <a href="http://loopj.com/2009/04/25/jquery-plugin-tokenizing-autocomplete-text-entry/">jQuery Tokenizing Autocomplete</a> was released last year, with <a href="http://github.com/loopj/jQuery-Tokenizing-Autocomplete-Plugin">some nice additions to it</a> in December. It&#8217;s an extremely rich plugin that behaves very similar to the Facebook version. You can select previously entered tokens and delete them, navigate completely by keyboard, or with the mouse &#8211; it&#8217;s amazing. There&#8217;s a few things that came up that I&#8217;ve added to it:</p>
<h3>initialValues option</h3>
<p>First is the ability to pass in a javascript array of initial values via the <code>initialValues</code> option. This is real simple:</p>
<pre class="brush: javascript">
$(&quot;#tokenize3&quot;).tokenInput(&quot;response.txt&quot;, {
  initialValues: [{&quot;name&quot;:&quot;The Dark Knight (2009)&quot;, &quot;id&quot;:&quot;12345&quot;}, {&quot;name&quot;:&quot;Sweeny Todd (2008)&quot;, &quot;id&quot;:&quot;45334&quot;}]
});
</pre>
<p>Real straightforward. When the page loads, the token input will be created with these two tokens pre-created.</p>
<h3>defaultOptions</h3>
<p>On MovieFly when you&#8217;re entering a movie for a viewing (that would show up on your <a href="http://movief.ly/users/adamfortuna/viewings">recent viewings</a> page), one thing thing that made sense to do was to have a way to pre-fill the list with some commonly used movies. So maybe you want it to show &#8220;new releases&#8221;  since that&#8217;s what a large percentage of people are going to use. Another case might be if you want people to tag themselves (or something), and you want to show common tags. One easy way is for the &#8220;hint&#8221; to link to a list of common tags. Codewise it&#8217;s basically the same as <code>initialValues</code>.</p>
<pre class="brush: javascript">
$(&quot;#tokenize4&quot;).tokenInput(&quot;response.txt&quot;, {
  hintText: &quot;Type a movie title, or see the &lt;a href=&#039;#&#039; class=&#039;defaultOptions&#039;&gt;current releases&lt;/a&gt;.&quot;,
  defaultOptions: [{&quot;name&quot;:&quot;Hot Tub Time Machine (2010)&quot;, &quot;id&quot;:&quot;12345&quot;},
                             {&quot;name&quot;:&quot;Clash of the Titans (2010)&quot;, &quot;id&quot;:&quot;12345&quot;},
                             {&quot;name&quot;:&quot;Date Night (2010)&quot;, &quot;id&quot;:&quot;12345&quot;},
                             {&quot;name&quot;:&quot;Alice in Wonderland (2010)&quot;, &quot;id&quot;:&quot;12345&quot;}],
});
</pre>
<p>The key is the link with a class of &#8220;defaulOptions&#8221; in the hint text. The plugin finds this link and pre-fills the suggested matches when clicked. </p>
<p>The code is available on <a href="http://github.com/adamfortuna/jQuery-Tokenizing-Autocomplete-Plugin">github</a>, or check out an <a href="http://sandbox.adamfortuna.com/jQuery-Tokenizing-Autocomplete-Plugin/examples/demo.html">example</a> of these and the basic behavior of the plugin. There&#8217;s already some great forks of the initial code, so seeing what other great additions have been made.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/adamfortuna?a=dnz6PIimniQ:BU6uLO57m5c:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/adamfortuna?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/adamfortuna?a=dnz6PIimniQ:BU6uLO57m5c:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/adamfortuna?i=dnz6PIimniQ:BU6uLO57m5c:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/adamfortuna?a=dnz6PIimniQ:BU6uLO57m5c:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/adamfortuna?d=dnMXMwOfBR0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://adamfortuna.com/2010/03/29/jquery-driven-tokenizing-additions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://adamfortuna.com/2010/03/29/jquery-driven-tokenizing-additions/</feedburner:origLink></item>
		<item>
		<title>Getting Rails 3 Beta Setup</title>
		<link>http://feedproxy.google.com/~r/adamfortuna/~3/UEwuf0oSe2o/</link>
		<comments>http://adamfortuna.com/2010/02/06/getting-rails-3-beta-setup/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 03:40:37 +0000</pubDate>
		<dc:creator>Adam Fortuna</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://adamfortuna.com/?p=499</guid>
		<description><![CDATA[If you use Ruby on Rails, you&#8217;ve probably heard by now about the release of the Rails 3.0 betayesterday. There&#8217;s been a lot leading up to this release, so naturally most of the rails world is eager to jump in and give it a try. Saturday morning is a great time to get started, so [...]]]></description>
			<content:encoded><![CDATA[<p>If you use Ruby on Rails, you&#8217;ve probably heard by now about the release of the <a href="http://weblog.rubyonrails.org/2009/2/5/this-week-in-rails-3-0">Rails 3.0 beta</a>yesterday. There&#8217;s been <a href="http://www.engineyard.com/blog/2010/rails-3-beta-is-out-a-retrospective/">a lot leading up to this release</a>, so naturally most of the rails world is eager to jump in and give it a try. Saturday morning is a great time to get started, so I decided to give it a try.</p>
<p>First off, I wanted to make sure I had a more up to date version of Ruby. Rails 3.0 beta and up will require Ruby 1.8.7 or higher. If you&#8217;re running Snow Leopard you probably already have this, but can always do a <code>ruby -v</code> to check your current Ruby version. The easiest way I&#8217;ve found to run multiple versions of ruby is using the <a href="http://rvm.beginrescueend.com/install/">rvm</a> gem. It handles everything needed for running multiple versions of Ruby, including Rubygems. Just install the gem and go from there:</p>
<pre class="brush: bash">
link:~ adam$ sudo gem install rvm
link:~ adam$ rvm-install
link:~ adam$ mate ~/.bash_profile
link:~ adam$ ruby -v
link:~ adam$ rvm install 1.9.1
link:~ adam$ rvm use 1.9.1
link:~ adam$ sudo gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
link:~ adam$ sudo gem install rails --pre
</pre>
<p>At this point, I tried to create a new rails project using the usual <code>rails [projectname]</code>, but I ended up getting the following error:</p>
<pre class="brush: bash">
link:research adam$ rails beta
/Library/Ruby/Site/1.8/rubygems.rb:384:in `bin_path&#039;: can&#039;t find executable rails for rails-3.0.0.beta (Gem::Exception)
	from /usr/bin/rails:19
</pre>
<p>A <a href="http://www.rubyinside.com/how-to-install-rails-3-0-prerelease-beta-2955.html">lucky comment in another blog</a> showed a fix for this:</p>
<pre class="brush: bash">
sudo gem install railties --pre
</pre>
<p>After that I was able to create a project the usual way, and start messing around the latest version of Rails. Looking forward to upgrading some existing sites! </p>
<pre class="brush: bash">
link:research adam$ rails testsite
link:research adam$ cd testsite
link:testsite adam$ rails server
</pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/adamfortuna?a=UEwuf0oSe2o:TV-h7ndGy-8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/adamfortuna?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/adamfortuna?a=UEwuf0oSe2o:TV-h7ndGy-8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/adamfortuna?i=UEwuf0oSe2o:TV-h7ndGy-8:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/adamfortuna?a=UEwuf0oSe2o:TV-h7ndGy-8:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/adamfortuna?d=dnMXMwOfBR0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://adamfortuna.com/2010/02/06/getting-rails-3-beta-setup/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://adamfortuna.com/2010/02/06/getting-rails-3-beta-setup/</feedburner:origLink></item>
		<item>
		<title>Giving Heroku a Try</title>
		<link>http://feedproxy.google.com/~r/adamfortuna/~3/WoSRKQao1O4/</link>
		<comments>http://adamfortuna.com/2009/11/24/giving-heroku-a-try/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 04:59:53 +0000</pubDate>
		<dc:creator>Adam Fortuna</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://adamfortuna.com/?p=490</guid>
		<description><![CDATA[If you haven&#8217;t heard of Heroku, you&#8217;re not alone. Heroku is a cloud host for Ruby on Rails driven sites that is relatively new on the scene. They&#8217;ve been in private mode for nearly a year, but recently their growth has skyrocketed. This growth is based on a few core features of their platform which [...]]]></description>
			<content:encoded><![CDATA[<p>If you haven&#8217;t heard of <a href="http://heroku.com/">Heroku</a>, you&#8217;re not alone. Heroku is a cloud host for Ruby on Rails driven sites that is relatively new on the scene. They&#8217;ve been in private mode for nearly a year, but recently their growth has skyrocketed. This growth is based on a few core features of their platform which are typically pain points for getting projects deployed.</p>
<h3>What is Heroku</h3>
<p>The trouble with most sites and descriptions of Heroku, is that they boil the service down to too small a line. The description on their site even goes this far &#8212; &#8220;Ruby Cloud Platform as a Service&#8221;. To put it in laymans terms, they&#8217;re a Cloud host for ruby websites (Rails, Sinatra, Rack, Merb). All Heroku sites run the same base <a href="http://docs.heroku.com/technologies">base platform</a> which includes some familiar faces if you&#8217;ve looked into Ruby hosting.</p>
<ul>
<li><b>Operating System</b>: Debian 4.0</li>
<li><b>Ruby</b>: MRI 1.8.6</li>
<li><b>Ruby App Server</b>: Thin</li>
<li><b>Web Server</b>: Nginx 0.6.32</li>
<li><b>Database</b>: PostgreSQL 8.3.5</li>
<li><b>HTTP cache/accelerator</b>: Varnish 2.0.2</li>
</ul>
<p>One of the most important things to me is that Heroku handles keeping all of these running and up to date. You don&#8217;t have to worry about getting a call that the database server has crashed, or one of the servers is out of memory &#8212; they do all that for you. You can think of it as managed hosting, but they&#8217;re managing a cloud rather than single servers.</p>
<ul>
<li>Insanely easy setup</li>
<li>No Capistrano for Deployment &#8211; instead you just push to a git repository on their servers</li>
<li>No worrying about apache/nginx/mongrel/passenger &#8211; they just spin up a thin clients behind nginx.</li>
<li>Methods for simplifying many common tasks including database importing, exporting and site backups</li>
</ul>
<h3>Setup is Almost as Easy as They Say</h3>
<p>Setting up you application to get on Heroku doesn&#8217;t take very long. Actually, during lunch at work today I got a Heroku app setup, just to try it out. You can follow the <a href="http://docs.heroku.com/quickstart">Heroku Quickstart Guide</a>, so I won&#8217;t repeat it here.  My only advice is to do everything you can from from the command line, rather than editing settings on the website. If your local copy and the remote copy get out of date (like if you rename an app for example), you&#8217;ll hit a speedbump and have to sift through the docs. The web management interface for Heroku is a beauty though, and coupled with the robust heroku gem, you can do a lot right out of the gate.</p>
<p>So after you get your database on Heroku migrated, you&#8217;ll probably want to load some data in it. Heroku has a very helpful command to get you started.</p>
<pre class="brush: bash">
$ heroku db:push mysql://root@localhost/arcadefly_development?encoding=utf8
</pre>
<p>You only need db:push, but without the &#8220;utf8&#8243; encoding specification, you may run into some problems converting from mysql to PostgreSQL.  So far the only main difference in Mysql to Postgres for <a href="http://www.arcadefly.com">ArcadeFly</a> (temp Heroku url until dns updates) is that I used 1 or 0 for booleans as strings in a few places. I changed these to true/false instead, pushed out the change and it worked fine.</p>
<p>Pushed out? Yeah you can deploy a heroku site with a simple git push. The initial setup already added Heroku to your git setup, so deploying is just pushing.</p>
<pre class="brush: bash">
$ git push heroku master
</pre>
<p>They posted a Vimeo video about getting started that should help get an idea of just how easy setup is:</p>
<p><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=6916740&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=d7bbfc&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=6916740&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=d7bbfc&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>
<p><a href="http://vimeo.com/6916740">Creating an app on Heroku in < 5min</a> from <a href="http://vimeo.com/heroku">heroku</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<h3>Limitations when Using Heroku</h3>
<p>Under Heroku you&#8217;re set a very specific set of server software, as you know from the above listing. These luckily cover the vast majority of Rails sites, so there&#8217;s nothing wrong with that. What you don&#8217;t get is full SSH access to the server that you may have become used to. Instead, most access is done using the Heroku gem. Here&#8217;s a few things that you can do.</p>
<p>You can jump right into a console on production:</p>
<pre class="brush: bash">
link:arcadefly adam$ heroku console
Ruby console for arcadefly.heroku.com
- a = Arcade.first
=- #&lt;Arcade id: 1, created_at: &quot;2008-07-27 21:30:09&quot;, updated_at: &quot;2008-07-27 21:30:09&quot;, name: &quot;Rocky&#039;s Replay&quot;, permalink: &quot;rockys-replay&quot;, phone: &quot;(407) 260-0043&quot;, website: nil, notes: nil, profile_id: nil, playables_count: 44, frequentships_count: 3, owner_email: nil, owner_name: nil&gt;
</pre>
<p>Using the <code>heroku logs</code> command, you can get the last bit of your production log real fast. Running rake tasks is as simple as <code>heroku rake db:migrate</code>. You never need to specify environment with Heroku &#8212; everything on Heroku is production.</p>
<p>Probably the biggest limitation is that there is no access to the filesystem except in /tmp. In order to save and manage files, you should instead use S3. Since Heroku runs on EC2, there is no file transfer charge for files between your S3 account and your Heroku servers since they are both in the same data center.</p>
<h3>Expanding Heroku</h3>
<p>It&#8217;s free to get started on Heroku. You can create a rails site with 1 Dyno (1 Thin server), have a daily cron job, get a PostgreSQL database and even point your own custom domain there. You can expand this with more thin clients, delayed_jobs and <a href="http://addons.heroku.com/">much more</a> at a price. I like the idea of having delayed_job processes running in the cloud rather than possibly slowing down the site. Unfortunately there&#8217;s no public memcache yet, although it&#8217;s in private beta. I&#8217;m still just getting my feet wet with Heroku, but look forward to seeing how <a href="http://www.arcadefly.com">ArcadeFly</a> does there.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/adamfortuna?a=WoSRKQao1O4:LyEJBtiN568:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/adamfortuna?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/adamfortuna?a=WoSRKQao1O4:LyEJBtiN568:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/adamfortuna?i=WoSRKQao1O4:LyEJBtiN568:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/adamfortuna?a=WoSRKQao1O4:LyEJBtiN568:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/adamfortuna?d=dnMXMwOfBR0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://adamfortuna.com/2009/11/24/giving-heroku-a-try/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://adamfortuna.com/2009/11/24/giving-heroku-a-try/</feedburner:origLink></item>
		<item>
		<title>Naming Conventions the Fun Way</title>
		<link>http://feedproxy.google.com/~r/adamfortuna/~3/n6LiUE8HlPY/</link>
		<comments>http://adamfortuna.com/2009/10/07/naming-conventions-the-fun-way/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 04:44:27 +0000</pubDate>
		<dc:creator>Adam Fortuna</dc:creator>
				<category><![CDATA[Organization]]></category>
		<category><![CDATA[conventions]]></category>
		<category><![CDATA[home]]></category>
		<category><![CDATA[matrix]]></category>
		<category><![CDATA[naming]]></category>
		<category><![CDATA[office]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://adamfortuna.com/?p=483</guid>
		<description><![CDATA[Most people don&#8217;t think about what they name their computers. It&#8217;s just not important enough in peoples lives to be a question of relevance. But for us programmers who set naming conventions and coding standards, prefering convention over configuration, it seems like the next step to use see how these rules apply to naming other [...]]]></description>
			<content:encoded><![CDATA[<p>Most people don&#8217;t think about what they name their computers. It&#8217;s just not important enough in peoples lives to be a question of relevance. But for us programmers who set naming conventions and coding standards, prefering convention over configuration, it seems like the next step to use see how these rules apply to naming other things in our lives. Remember &#8211; it&#8217;s all about having fun. You wouldn&#8217;t have a variable named <b>Batman</b>, but what&#8217;s to stop you from naming your computers after superheroes?</p>
<h2>Naming Computer at Work</h2>
<p>At <a href="http://www.fceco.com" target="_blank" rel="nofollow">one job I worked</a> they took naming very seriously, in the fun way. All servers would be named after characters from The Matrix. So we might have a development server called <b>Agent-Smith</b>, or a database server called <b>Trinity</b>. If you&#8217;re connecting to a small set of servers, you won&#8217;t soon be confused over the names. It&#8217;s a great improvement over application-1, application-2, etc if you&#8217;re naming a small set of servers. There&#8217;s <a href="http://en.wikipedia.org/wiki/The_Matrix_character_names" target="_blank">plenty of names to choose from</a>. I wouldn&#8217;t recommend using the alternate Agent names though, unless you want to get <strong>Agent-Smith</strong>, <strong>Agent-Jones</strong> and <strong>Agent-Brown</strong> confused.</p>
<p>Desktop computers throughout the office were then named after Transformers. There&#8217;s plenty to select from, and it adds a personal touch to everyone&#8217;s computer. You could even take it a step farther and couple each computer with a Transformer. <img src='http://adamfortuna.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  You could split the office into Decepticons and Autobots if you have a clear divide, and then the two sides can go to war &#8212; or something like that. It&#8217;s a lot easier to look at the network and see <strong>Starscream</strong> than &#8220;pc-rover-2245&#8243;. You can have all kinds of fun with this &#8212; big transformers are power computers, flying transformers are laptops.</p>
<h2>Naming Computers at Home</h2>
<p>My naming convention for devices in my home is largely copied from one of the above. All computers in my home are named after Matrix characters (aside from a few of my girlfriends devices which still need to fall inline). My computers that I use are named after human males &#8211; <strong>Link</strong> and <strong>Bane</strong> (Bane is the Windows partition on my Mac).  Other devices of mine around the house that are named after male programs. So <strong>Keymaker</strong> is my router, my Drobo is <strong>Merovingian</strong>, portable hard drive is <strong>Seraph</strong>, my airport express is <strong>Trainman</strong> and our shared media center Mac Mini is <strong>Persephone</strong> (always coupled with <strong>Merovingian</strong>, you see?). At home you probably don&#8217;t have enough devices to really need much in the way of naming conventions, but if you have a few USB drives it suddenly makes a lot more sense.</p>
<h2>Table of Elements</h2>
<p>I don&#8217;t remember where I heard it, but someone mentioned to me that they&#8217;d organized their servers based on the periodic table of elements. Domain controllers would be noble gasses, halogens might be file servers, transition metals (which are the bulk of elements) could be desktops used by everyone in the office. There&#8217;s a few more groups built in for you to use, so long as you don&#8217;t have too many devices. This allows for a little more &#8220;professional&#8221; sounding names, or at least a different kind of nerdy.</p>
<h2>Fun of Functional?</h2>
<p>Whether you go with a fun or functional naming convention, or even have one at all, will depend on the atmosphere of where the devices will be. If you have a chance to have a little fun, go for it! Anyone have any other fun naming conventions they use or have heard about? Always looking for more examples.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/adamfortuna?a=n6LiUE8HlPY:O-1SJzzSFb8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/adamfortuna?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/adamfortuna?a=n6LiUE8HlPY:O-1SJzzSFb8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/adamfortuna?i=n6LiUE8HlPY:O-1SJzzSFb8:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/adamfortuna?a=n6LiUE8HlPY:O-1SJzzSFb8:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/adamfortuna?d=dnMXMwOfBR0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://adamfortuna.com/2009/10/07/naming-conventions-the-fun-way/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://adamfortuna.com/2009/10/07/naming-conventions-the-fun-way/</feedburner:origLink></item>
		<item>
		<title>Resize a Crossdomain iFrame</title>
		<link>http://feedproxy.google.com/~r/adamfortuna/~3/uP1faoyG32I/</link>
		<comments>http://adamfortuna.com/2009/09/30/resize-a-crossdomain-iframe/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 00:55:01 +0000</pubDate>
		<dc:creator>Adam Fortuna</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[crossdomain]]></category>
		<category><![CDATA[frames]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://adamfortuna.com/?p=396</guid>
		<description><![CDATA[When it comes to crossdomain quirks with frames and Ajax, there&#8217;s not usually a &#8220;good&#8221; solution &#8212; there&#8217;s just one that works. Something I was working on the other week had a &#8220;well it works&#8221; moment, although the solution was far from ideal. 
The Problem
The page in question is the Sponsored These Tweeters page at [...]]]></description>
			<content:encoded><![CDATA[<p>When it comes to crossdomain quirks with frames and Ajax, there&#8217;s not usually a &#8220;good&#8221; solution &#8212; there&#8217;s just one that works. Something I was working on the other week had a &#8220;well it works&#8221; moment, although the solution was far from ideal. </p>
<h3>The Problem</h3>
<p>The page in question is the <a href="http://sponsoredtweets.com/tweeters/sponsor-these-tweeters/">Sponsored These Tweeters</a> page at SponsoredTweets. It&#8217;s a pretty basic Wordpress page with an iFrame that contains the list of Tweeters. Real easy way of adding a dynamic touch to a Wordpress site. The issue is that the iframe contains a dynamic amount of content, and could potentially grow or shrink based on the length of amount of tweeters being shown. The kicker? The page with the list of tweeters is at a subdomain, and under https. </p>
<h3>Monitoring with Jquery</h3>
<p>My first idea with anything like this is &#8220;Can I just listen for a jquery event on the element?&#8221;. Well, sure, but the height of the iframe won&#8217;t change. You&#8217;ll only be able to get the height/width of the iframe itself, not the content within it from the page itself, so watching for a resize or load event on the iframe won&#8217;t work. What you&#8217;re really wanting to listen for is a change in the height of the content </p>
<p><b>Works?</b> No.</p>
<h3>Reaching into the frame with contentWindow</h3>
<p>If your frame and the page containing it both exist on the same domain, you can reach into DOM of the frame and get the height that way. At anytime you can do something like this to get the height of the page:</p>
<pre class="brush: javascript">
document.getElementById(&quot;iframeid&quot;)
         .contentWindow.document.body.scrollHeight
</pre>
<p>This bit of code will return an integer &#8212; the height of the content of the frame in pixels. Even if the iframe has a height of (for example) 300px, the content itself could be smaller or larger. Unfortunately you can&#8217;t set a jQuery event watcher on <code>document.getElementById("iframeid").contentWindow.document.body</code> either (at least from what I&#8217;ve seen), so I can&#8217;t see a way to watch for a change in height.</p>
<p>The &#8220;not-so-nice&#8221; fix for this is to make a really fast function that repeatedly checks a change in the height, and resizes the iframe accordingly. Here&#8217;s some sample code for this using jQuery.</p>
<pre class="brush: javascript">
var $iframe = $(&quot;#iframeid&quot;);
function resize_iframe() {
  var current_height = $iframe.css(&quot;height&quot;);
  if(current_height != $iframe[0].contentWindow.document.body.scrollHeight) {
    $iframe.css(&quot;height&quot;, $iframe[0].contentWindow.document.body.scrollHeight);
  }
}
setInterval(&quot;resize_iframe();&quot;, 100);
</pre>
<p>Everytime I use <code>setTimeout()</code> or <code>setInterval()</code> in Javascript, it&#8217;s immediately a red flag. These (along with the evil-<code>eval</code>) can be an obvious code smell, but also a trigger that the code itself isn&#8217;t designed in the best way.</p>
<p>The problem with this though is that it won&#8217;t quite be realtime. Also the <code>contentWindow.document</code> object is not available cross-domain. Even doing things like <code>contentWindow.document.location.href</code> to get the current location of the frame doesn&#8217;t work if the calling page and the frame are on different domains/subdomains. This might work for some cases, but not if your iframe is on a different domain.</p>
<p><b>Works?</b> Yes.<br />
<b>Works on the same domain?</b> Yes.<br />
<b>Works on different subdomains on the same domain?</b> No.</p>
<h3>The document.domain hack</h3>
<p> If both your frame and your calling page exist on the same parent domain, there&#8217;s a little hack you can do to get this to work. Each page has a <code>document.domain</code> variable that contains the domain from which ajax calls can be made to. If you rails application is up at https://app.sponsoredtweets.com, then your document domain will be set to <strong>app.sponsoredtweets.com</strong>. Of course your main website sitting at http://sponsoredtweets.com will have a document.domain ot <strong>sponsoredtweets.com</strong>. Because of this they won&#8217;t be able to talk to each other. What you can do is manually change the <code>document.domain</code> value.</p>
<p>Surprisingly enough, you can tweak this value as long as you only get broader in your domain. For instance, if document.domain is <em>app.sponsoredtweets.com</em>, then you&#8217;ll be able to manually set this using something like this: <code>document.domain = "sponsoredtweets.com"</code> From that point on, that page will be treated as those requests were coming/going to that domain. Using this, you could set your iframe and the page containing the iframe to be on the same root domain, then reach into it&#8217;s contentHeight as described above. After you&#8217;ve set this to &#8220;sponsoredtweets.com&#8221; though, you won&#8217;t be able to change it again, as that&#8217;s the most general a <code>document.domain</code> can get.</p>
<p><b>Works on the same domain?</b> Yep.<br />
<b>Works on different subdomains on the same domain?</b> Yes.<br />
<b>Works crossdomain?</b> No.<br />
<b>Works across https?</b> No.</p>
<h3>Frame within a Frame within a Frame</h3>
<p>Unfortunately, none of this works across domain, of from http connections to https.  Here&#8217;s how it works for SponsoredTweets:</p>
<p>The main page is <b>http://sponsoredtweets.com/tweeters/sponsor-these-tweeters/</b>, aka, the parent page.<br />
Which has a frame to <b>https://app.sponsoredtweets.com/tweeters</b>, aka, the content page.<br />
Which has a frame to <b>http://sponsoredtweets.com/iframe.html</b>, aka, the placeholder page.</p>
<p>The middle frame is the one that will change in height of course.  For the same reasons as above, the middle frame cannot reach into it&#8217;s parent frame and call methods there either. It can, however, control it&#8217;s own iframe in a very limited sense. For instance, take this line from the </p>
<pre class="brush: javascript">
$(&quot;#parent_domain&quot;)[0].contentWindow.location = &#039;http://sponsoredtweets.com/iframe.html#&#039; + height;
</pre>
<p>Whenever the height of the content page changes, it updates the location of it&#8217;s frame to include a hash tag followed by the current height of the content. By itself this won&#8217;t do anything, but if that iframe.html page is watching for changes to it&#8217;s location, we can start from there.</p>
<p>The placeholder page is what makes this all possible. All it has to do is monitor for changes to it&#8217;s hash, and when it sees them, send them up to the parent page (that is, the top level page). Now, although the content page can&#8217;t talk to it&#8217;s parent page, the placeholder page can talk to it since they are both on the same domain. Is it a hack? Oh yeah, and of the worst kind.</p>
<pre class="brush: html">
&lt;html&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
  function sendHash() {
    var location = window.location.href.split(&quot;#&quot;)
    if(location.length != 2) { return; }
    parent.parent.receiveHash(location[1]);
  }
  setInterval(&quot;sendHash();&quot;, 100);
--&gt;
&lt;/script&gt;
&lt;body&gt;&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><i>parent.parent&#8230;</i>? Yeah, thanks HTML. All the receiveHash() function on the parent page does is take a number and set it as the height of it&#8217;s iframe. Real simple implementation, it&#8217;s just the craziness that is cross-domain security that makes it difficult to grasp.</p>
<p><b>Works across https?</b> Yes!</p>
<h3>Got a Better Solution?</h3>
<p>I can&#8217;t believe this would be the ideal way to do something as simple as resize an iframe. Do you know of a better way of doing this given that the pages exist on separate domains? I&#8217;d love to hear about it.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/adamfortuna?a=uP1faoyG32I:I-PE3zYku5s:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/adamfortuna?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/adamfortuna?a=uP1faoyG32I:I-PE3zYku5s:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/adamfortuna?i=uP1faoyG32I:I-PE3zYku5s:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/adamfortuna?a=uP1faoyG32I:I-PE3zYku5s:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/adamfortuna?d=dnMXMwOfBR0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://adamfortuna.com/2009/09/30/resize-a-crossdomain-iframe/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://adamfortuna.com/2009/09/30/resize-a-crossdomain-iframe/</feedburner:origLink></item>
	</channel>
</rss>
