<?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>Tnux.net</title>
	
	<link>http://tnux.net</link>
	<description>Blog of Tom Pesman</description>
	<lastBuildDate>Thu, 22 Jul 2010 11:12:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/tnuxnet" /><feedburner:info uri="tnuxnet" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Why is my KmlLayer in Google Maps v3 not working?</title>
		<link>http://feedproxy.google.com/~r/tnuxnet/~3/29R3hg9tckQ/</link>
		<comments>http://tnux.net/2010/07/22/why-is-my-kmllayer-in-google-maps-v3-not-working/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 10:45:37 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[KML]]></category>

		<guid isPermaLink="false">http://tnux.net/?p=127</guid>
		<description><![CDATA[If you use some code like this: &#60;script type=&#34;text/javascript&#34;&#62; function initialize() { var options = { mapTypeId: google.maps.MapTypeId.SATELLITE, streetViewControl: true }; var map = new google.maps.Map(document.getElementById(&#039;map&#039;), options); var kmlLayer = new google.maps.KmlLayer(&#039;http://127.0.0.1:3000/kmlfile.kml&#039;); kmlLayer.setMap(map); } function loadScript() { var script = &#8230; <a href="http://tnux.net/2010/07/22/why-is-my-kmllayer-in-google-maps-v3-not-working/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you use some code like this:</p>
<pre class="brush: javascript">
&lt;script type=&quot;text/javascript&quot;&gt;
  function initialize() {
    var options = {
      mapTypeId: google.maps.MapTypeId.SATELLITE,
      streetViewControl: true
    };
    var map = new google.maps.Map(document.getElementById(&#039;map&#039;), options);
    var kmlLayer = new google.maps.KmlLayer(&#039;http://127.0.0.1:3000/kmlfile.kml&#039;);
    kmlLayer.setMap(map);
  }

  function loadScript() {
    var script = document.createElement(&quot;script&quot;);
    script.type = &quot;text/javascript&quot;;
    script.src = &quot;http://maps.google.com/maps/api/js?sensor=false&amp;callback=initialize&quot;;
    document.body.appendChild(script);
  }
  window.onload = loadScript;

&lt;/script&gt;
</pre>
<p>In a typical Ruby on Rails development environment you will have your server running on your localhost on port 3000. The way Google Maps accesses your KML file is not directly from the script locally, but via Google itself. So the solution is to have your KML online accessible by Google Maps. I hope this tip saved you some valuable time! <img src='http://tnux.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://tnux.net/2010/07/22/why-is-my-kmllayer-in-google-maps-v3-not-working/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tnux.net/2010/07/22/why-is-my-kmllayer-in-google-maps-v3-not-working/</feedburner:origLink></item>
		<item>
		<title>Force file_column to regenerate the thumbnails</title>
		<link>http://feedproxy.google.com/~r/tnuxnet/~3/sNAlvpKaWZA/</link>
		<comments>http://tnux.net/2010/07/18/force-file_column-to-regenerate-the-thumbnails/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 17:12:46 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://tnux.net/?p=120</guid>
		<description><![CDATA[A small post to show how to let file_column to regenerate the already generated thumbnails. def update_attributes(att) self.path = File.new(self.path, &#34;r&#34;) self.save super(att) end When you put this piece of code in the model where the file_column is used, the &#8230; <a href="http://tnux.net/2010/07/18/force-file_column-to-regenerate-the-thumbnails/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A small post to show how to let file_column to regenerate the already generated thumbnails.</p>
<pre class="brush: ruby">
def update_attributes(att)
  self.path = File.new(self.path, &quot;r&quot;)
  self.save
  super(att)
end
</pre>
<p>When you put this piece of code in the model where the file_column is used, the only thing that needs to be changed is the &#8216;path&#8217; variable into the file_column name. The update_attributes method is often used in the update method in the controllers.</p>
]]></content:encoded>
			<wfw:commentRss>http://tnux.net/2010/07/18/force-file_column-to-regenerate-the-thumbnails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tnux.net/2010/07/18/force-file_column-to-regenerate-the-thumbnails/</feedburner:origLink></item>
		<item>
		<title>VMware ESXi 4.0 + QNAP TS-410</title>
		<link>http://feedproxy.google.com/~r/tnuxnet/~3/LHgasbmKJTc/</link>
		<comments>http://tnux.net/2010/07/10/vmware-esxi-4-0-qnap-ts-410/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 18:27:57 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Storage]]></category>
		<category><![CDATA[Virtualisation]]></category>
		<category><![CDATA[ESXi]]></category>
		<category><![CDATA[iSCSI]]></category>
		<category><![CDATA[NAS]]></category>
		<category><![CDATA[QNAP]]></category>
		<category><![CDATA[TS-410]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://tnux.net/?p=78</guid>
		<description><![CDATA[I&#8217;ve updated my server setup at home with some new hardware. First of all a new QNAP TS-410 NAS with 4 Western Digital Caviar Green 2TB disks attached to the NAS. For my new server I will use an old &#8230; <a href="http://tnux.net/2010/07/10/vmware-esxi-4-0-qnap-ts-410/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve updated my server setup at home with some new hardware. First of all a new QNAP TS-410 NAS with 4 Western Digital Caviar Green 2TB disks attached to the NAS. For my new server I will use an old HP dc7700 P4 with 5 Gb of RAM. To connect the NAS to the server I took a Cisco 8 port Gigabit switch (SLM2008).</p>
<p><strong>QNAP TS-410</strong><br />
First of all I installed the disks and booted the system for the first time. Using the configuration utility I configured the disks in a RAID 5 setup, so totally I have 6TB of disk space available. During this setup I also installed the latest firmware, which I took from the QNAP website. The synchronisation of the RAID 5 setup took over 24 hours! Which is quite long, but this is only done once. The reason I bought this TS-410 is because this is the cheapest 4 disk NAS with iSCSI enabled. The iSCSI we can use to connect the VMware ESXi 4.0 to the storage. In the QNAP web interface the iSCSI service should be enabled and a iSCSI target and LUN should be created. A target is similar to the SCSI card we used years ago and is used to connect the remote system with. The LUN&#8217;s are similar to physical disks, but with iSCSI these are virtual. Now we have created the basis of our storage network for the VMware ESXi 4.0 server.</p>
<p><strong>VMware ESXi 4.0</strong><br />
First I cleaned the old HP dc7700 pc and removed the hard disks. Next I inserted an flash drive of 1 Gigabyte, but this one turned out to be broken. So I took a 2 Gigabyte disk, but 1 is sufficient. I booted from the installation CD and installed the ESXi server on the flash drive. After rebooting I was able to connect with my browser to the server. Using the console a fixed IP was given to the server. Next we need to configure the VMware ESXi 4.0 server using the vSphere Client which can be downloaded from the management IP address.</p>
<p><strong>VMware vSphere Client</strong><br />
In VMware vSphere Client we need to get the data storage working as the server doesn&#8217;t have local storage. So open server -> configuration -> networking to add a VMkernel port to the virtual switch. This is to allow the storage adapter access the NAS.<br />
<a href="http://tnux.net/wp-content/uploads/2010/07/vmware-networking.png"><img src="http://tnux.net/wp-content/uploads/2010/07/vmware-networking-1024x726.png" alt="" title="vmware-networking" width="640" height="453" class="alignright size-large wp-image-98" /></a><br />
Now goto storage adapters and select the properties of the iSCSI adapter. Click configure and select enable to enable the iSCSI adapter, click on dynamic discovery and add your NAS ip:3260. It is now possible to see the device in the details below.<br />
<a href="http://tnux.net/wp-content/uploads/2010/07/vmware-storage.png"><img src="http://tnux.net/wp-content/uploads/2010/07/vmware-storage-1024x726.png" alt="" title="vmware-storage" width="640" height="453" class="alignright size-large wp-image-97" /></a><br />
<a href="http://tnux.net/wp-content/uploads/2010/07/vmware-storage-2.png"><img src="http://tnux.net/wp-content/uploads/2010/07/vmware-storage-2-1024x726.png" alt="" title="vmware-storage-2" width="640" height="453" class="alignright size-large wp-image-96" /></a><br />
<a href="http://tnux.net/wp-content/uploads/2010/07/vmware-storage-3.png"><img src="http://tnux.net/wp-content/uploads/2010/07/vmware-storage-3-1024x726.png" alt="" title="vmware-storage-3" width="640" height="453" class="alignright size-large wp-image-95" /></a></p>
<p>In the storage configuration we need to add the LUN to VMware so this LUN can be used in a virtual machine.<br />
<a href="http://tnux.net/wp-content/uploads/2010/07/vmware-storage-4.png"><img src="http://tnux.net/wp-content/uploads/2010/07/vmware-storage-4-1024x726.png" alt="" title="vmware-storage-4" width="640" height="453" class="alignright size-large wp-image-94" /></a></p>
<p><strong>Cisco Switch</strong><br />
To connect the NAS with all network interfaces to the switch, the switch has to be properly configured. The ports need to have the LACP option enabled.<br />
<a href="http://tnux.net/wp-content/uploads/2010/07/nas-network-2.png"><img src="http://tnux.net/wp-content/uploads/2010/07/nas-network-2-1024x711.png" alt="" title="nas-network-2" width="640" height="444" class="alignright size-large wp-image-100" /><br />
Once this is done in the management interface of the switch, the NAS needs to be configured to use the IEEE 802.3ad Dynamic Link Aggregation. </p>
<p><a href="http://tnux.net/wp-content/uploads/2010/07/nas-network-1.png"><img src="http://tnux.net/wp-content/uploads/2010/07/nas-network-1-1024x711.png" alt="" title="nas-network-1" width="640" height="444" class="alignright size-large wp-image-101" /></a></p>
<p>Finally the second network interface can be connected to the switch. Use the management interface on the switch to see if it is working correctly.<br />
</a><br />
<a href="http://tnux.net/wp-content/uploads/2010/07/nas-network-3.png"><img src="http://tnux.net/wp-content/uploads/2010/07/nas-network-3-1024x711.png" alt="" title="nas-network-3" width="640" height="444" class="alignright size-large wp-image-99" /></a></p>
<p>Now we have a nice system to experiment with. The only thing what I have to do now is to migrate my existing CentOS XEN server to this VMware system.</p>
]]></content:encoded>
			<wfw:commentRss>http://tnux.net/2010/07/10/vmware-esxi-4-0-qnap-ts-410/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tnux.net/2010/07/10/vmware-esxi-4-0-qnap-ts-410/</feedburner:origLink></item>
		<item>
		<title>Ruby on Rails MiniWiki plugin released</title>
		<link>http://feedproxy.google.com/~r/tnuxnet/~3/LcshWEWFqxA/</link>
		<comments>http://tnux.net/2010/01/17/ruby-on-rails-miniwiki-plugin-released/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 19:56:12 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://tnux.net/?p=63</guid>
		<description><![CDATA[To create a wiki in a Ruby on Rails app, I&#8217;ve created a plugin called: MiniWiki. With 3 simple steps it is possible to add a very basic wiki to your application. The only dependency is RedCloth and the generator &#8230; <a href="http://tnux.net/2010/01/17/ruby-on-rails-miniwiki-plugin-released/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>To create a wiki in a Ruby on Rails app, I&#8217;ve created a plugin called: MiniWiki. With 3 simple steps it is possible to add a very basic wiki to your application. The only dependency is RedCloth and the generator creates a migration for only two tables in your database. For more detailed information see the <a href="http://github.com/tompesman/mini_wiki">Github</a> page.</p>
<p>Try here: <a href="http://tnux.net/miniwiki/">http://tnux.net/miniwiki/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tnux.net/2010/01/17/ruby-on-rails-miniwiki-plugin-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tnux.net/2010/01/17/ruby-on-rails-miniwiki-plugin-released/</feedburner:origLink></item>
		<item>
		<title>SWFUpload direct to Amazon S3 in Ruby on Rails</title>
		<link>http://feedproxy.google.com/~r/tnuxnet/~3/Xs9C6zpkpL0/</link>
		<comments>http://tnux.net/2010/01/17/swfupload-direct-to-amazon-s3-in-ruby-on-rails/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 19:38:17 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Amazon S3]]></category>
		<category><![CDATA[SWFUpload]]></category>

		<guid isPermaLink="false">http://tnux.net/?p=34</guid>
		<description><![CDATA[I&#8217;m working on various projects and for one certain project this company wanted a file sharing website, like yousendit.com for example, but the site should be in-house. I proposed Amazon S3 for the storage of the files, otherwise the VPS &#8230; <a href="http://tnux.net/2010/01/17/swfupload-direct-to-amazon-s3-in-ruby-on-rails/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on various projects and for one certain project this company wanted a file sharing website, like yousendit.com for example, but the site should be in-house. I proposed Amazon S3 for the storage of the files, otherwise the VPS will become very expensive. This file sharing website should also handle large files, so a reliable upload method is desired. SWFUpload is a well known Flash upload application. So the requirements are now complete: Ruby on Rails, Amazon S3 and SWFUpload.</p>
<p>First I created a config file to enter my Amazon S3 credentials. The credentials are dependent on the Ruby on Rails environment. </p>
<p>config/amazon_s3.yml</p>
<pre class="brush: ruby">
development:
  bucket_name: BUCKET_NAME
  access_key_id: ACCESS_KEY_ID
  secret_access_key: SECRET_ACCESS_KEY

test:
  bucket_name: BUCKET_NAME
  access_key_id: ACCESS_KEY_ID
  secret_access_key: SECRET_ACCESS_KEY

production:
  bucket_name: BUCKET_NAME
  access_key_id: ACCESS_KEY_ID
  secret_access_key: SECRET_ACCESS_KEY
</pre>
<p>Created a controller and added the index method. The method reads the S3 settings from the config file and generates the fields required for SWFUpload and S3.</p>
<pre class="brush: ruby">
  def index
    filename = &quot;#{RAILS_ROOT}/config/amazon_s3.yml&quot;
    config = YAML.load_file(filename)

    bucket            = config[ENV[&#039;RAILS_ENV&#039;]][&#039;bucket_name&#039;]
    access_key_id     = config[ENV[&#039;RAILS_ENV&#039;]][&#039;access_key_id&#039;]
    secret_access_key = config[ENV[&#039;RAILS_ENV&#039;]][&#039;secret_access_key&#039;]

    key             = ENV[&#039;RAILS_ENV&#039;]
    acl             = &#039;public-read&#039;
    expiration_date = 10.hours.from_now.utc.strftime(&#039;%Y-%m-%dT%H:%M:%S.000Z&#039;)
    max_filesize    = 2.gigabyte

    policy = Base64.encode64(
      &quot;{&#039;expiration&#039;: &#039;#{expiration_date}&#039;,
        &#039;conditions&#039;: [
          {&#039;bucket&#039;: &#039;#{bucket}&#039;},
          [&#039;starts-with&#039;, &#039;$key&#039;, &#039;#{key}&#039;],
          {&#039;acl&#039;: &#039;#{acl}&#039;},
          {&#039;success_action_status&#039;: &#039;201&#039;},
          [&#039;starts-with&#039;, &#039;$Filename&#039;, &#039;&#039;],
          [&#039;content-length-range&#039;, 0, #{max_filesize}]
        ]
      }&quot;).gsub(/\n|\r/, &#039;&#039;)

    signature = Base64.encode64(
                  OpenSSL::HMAC.digest(
                    OpenSSL::Digest::Digest.new(&#039;sha1&#039;),
                    secret_access_key, policy)).gsub(&quot;\n&quot;,&quot;&quot;)

    @post = {
      &quot;key&quot; =&gt; &quot;#{key}/${filename}&quot;,
      &quot;AWSAccessKeyId&quot; =&gt; &quot;#{access_key_id}&quot;,
      &quot;acl&quot; =&gt; &quot;#{acl}&quot;,
      &quot;policy&quot; =&gt; &quot;#{policy}&quot;,
      &quot;signature&quot; =&gt; &quot;#{signature}&quot;,
      &quot;success_action_status&quot; =&gt; &quot;201&quot;
    }

    @upload_url = &quot;http://#{bucket}.s3.amazonaws.com/&quot;
  end
</pre>
<p>And the index.html.erb view.</p>
<pre class="brush: ruby">
&lt;% content_for :head do %&gt;
&lt;link href=&quot;/stylesheets/swfupload.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
&lt;% end%&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/swfupload/swfupload.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/swfupload/swfupload.queue.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/swfupload/fileprogress.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/swfupload/handlers.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
	var swfu;

	window.onload = function() {
		var settings = {
			flash_url : &quot;/assets/swfupload.swf&quot;,
			upload_url: &quot;&lt;%= @upload_url %&gt;&quot;,
			http_success : [ 200, 201, 204 ], 		// FOR AWS

			file_size_limit : &quot;2 GB&quot;,
			file_types : &quot;*.*&quot;,
			file_types_description : &quot;All Files&quot;,
			file_upload_limit : 100,
			file_queue_limit : 0,
			file_post_name : &quot;file&quot;, 				// FOR AWS

			custom_settings : {
				progressTarget : &quot;fsUploadProgress&quot;,
				cancelButtonId : &quot;btnCancel&quot;
			},
			debug: &lt;%= ENV[&#039;RAILS_ENV&#039;]==&#039;development&#039; ? &#039;true&#039; : &#039;false&#039; %&gt;,

			// Button settings
			button_image_url : &quot;/images/buttonUploadText.png&quot;,
			button_placeholder_id : &quot;spanButtonPlaceHolder&quot;,
			button_width: 61,
			button_height: 22,

			// The event handler functions are defined in handlers.js
			file_queued_handler : fileQueued,
			file_queue_error_handler : fileQueueError,
			file_dialog_complete_handler : fileDialogComplete,
			upload_start_handler : uploadStart,
			upload_progress_handler : uploadProgress,
			upload_error_handler : uploadError,
			upload_success_handler : uploadSuccess,
			upload_complete_handler : uploadComplete,
			queue_complete_handler : queueComplete,	// Queue plugin event

			post_params: &lt;%= @post.to_json %&gt;		// FOR AWS
		};

		swfu = new SWFUpload(settings);
     };
&lt;/script&gt;

&lt;div id=&quot;content&quot;&gt;
	&lt;form id=&quot;form&quot; action=&quot;/upload/upload&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt;
			&lt;div class=&quot;fieldset flash&quot; id=&quot;fsUploadProgress&quot;&gt;
			&lt;span class=&quot;legend&quot;&gt;Upload Queue&lt;/span&gt;
			&lt;/div&gt;
		&lt;div id=&quot;divStatus&quot;&gt;0 Files Uploaded&lt;/div&gt;
			&lt;div&gt;
				&lt;span id=&quot;spanButtonPlaceHolder&quot;&gt;&lt;/span&gt;
				&lt;input id=&quot;btnCancel&quot; type=&quot;button&quot; value=&quot;Cancel All Uploads&quot; onclick=&quot;swfu.cancelQueue();&quot; disabled=&quot;disabled&quot; style=&quot;margin-left: 2px; font-size: 8pt; height: 29px;&quot; /&gt;
			&lt;/div&gt;

	&lt;/form&gt;
&lt;/div&gt;
</pre>
<p>Upload the file crossdomain.xml to the root of your bucket. This is for Flash to upload to a different domain.</p>
<pre class="brush: xml">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;!DOCTYPE cross-domain-policy SYSTEM &quot;http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd&quot;&gt;
&lt;cross-domain-policy&gt;
  &lt;allow-access-from domain=&quot;*&quot; secure=&quot;false&quot; /&gt;
&lt;/cross-domain-policy&gt;
</pre>
<p>Finally took the files from the SWFUpload simpledemo and placed them in the following directories:</p>
<ul>
<li>swfupload.swf in public/assets/</li>
<li>fileprogress.js, handles.js, swfupload.js and swfupload.queue.js in public/javascripts/swfupload/</li>
<li>buttonUploadText.png in public/images/</li>
</ul>
<p>Now SWFUpload should be working in your Ruby on Rails application.</p>
<p><strong>Callback</strong><br />
For my application I needed a callback to let my application know there was a file successfully uploaded to the S3 bucket. To get this functionality I added a function to the controller and modified the handlers.js file.</p>
<pre class="brush: ruby">
  def upload_done
    file = ShareFile.new

    file.name = params[:name]
    file.filestatus = params[:filestatus]
    file.filetype = params[:type]
    file.size = params[:size]
    file.s3_available = true

    file.save
  end
</pre>
<pre class="brush: javascript">
function uploadSuccess(file, serverData) {
	// HERE: Send a notification upload has succeeded
	new Ajax.Request(&#039;/share/upload_done?&#039;+Object.toQueryString(file), {
		method:&#039;get&#039;,
		asynchronous: false,
		onSuccess: function(){
			var progress = new FileProgress(file, this.customSettings.progressTarget);
			progress.setStatus(&quot;Sending meta data.&quot;);
		}
	});
	// HERE: end

	try {
		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setComplete();
		progress.setStatus(&quot;Complete.&quot;);
		progress.toggleCancel(false);

	} catch (ex) {
		this.debug(ex);
	}
}
</pre>
<p>When SWFUpload is done uploading it uses the javascript callback to update the status of the form and to send a notification to the Ruby on Rails application.</p>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://tnux.net/2010/01/17/swfupload-direct-to-amazon-s3-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://tnux.net/2010/01/17/swfupload-direct-to-amazon-s3-in-ruby-on-rails/</feedburner:origLink></item>
		<item>
		<title>XEN, Ruby Enterprise Edition and 4gb seg fixup</title>
		<link>http://feedproxy.google.com/~r/tnuxnet/~3/2xCol20A8Oo/</link>
		<comments>http://tnux.net/2010/01/17/xen-ree-4gbsegfixup/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 17:35:39 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[VPS]]></category>
		<category><![CDATA[RubyEnterpriseEdition]]></category>
		<category><![CDATA[XEN]]></category>

		<guid isPermaLink="false">http://tnux.net/?p=32</guid>
		<description><![CDATA[My new CentOS XEN server has a virtual machine which serves as a dedicated web server. The on the console and in /var/log/messages the following message appeared: 4gb seg fixup, process ruby (pid 20252), cs:ip 73:00e0a636 printk: 151939 messages suppressed. &#8230; <a href="http://tnux.net/2010/01/17/xen-ree-4gbsegfixup/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My new CentOS XEN server has a virtual machine which serves as a dedicated web server. The on the console and in /var/log/messages the following message appeared:</p>
<pre class="brush: bash">
4gb seg fixup, process ruby (pid 20252), cs:ip 73:00e0a636
printk: 151939 messages suppressed.
</pre>
<p>The console is unusable, because every second a new message appears. The logfile is unusable as well, because it is very large and takes long to open in a text editor and interesting messages are difficult to find. After some google&#8217;ing I&#8217;ve found the following <a href="http://groups.google.com/group/emm-ruby/browse_thread/thread/1b9beffe8fa694a7/82fd6839307d9298">page</a> with some instructions to fix it. I&#8217;ve mixed up various methods, but this is the most robust one to use. It creates a wrapper around the gcc and g++ binaries with the correct parameters.</p>
<pre class="brush: bash">
mv /usr/bin/gcc /usr/bin/gcc.orig
mv /usr/bin/g++ /usr/bin/g++.orig
echo &#039;#!/bin/sh&#039; &gt; /usr/bin/gcc
echo &#039;#!/bin/sh&#039; &gt; /usr/bin/g++
echo &#039;exec gcc.orig -mno-tls-direct-seg-refs $@&#039; &gt;&gt; /usr/bin/gcc
echo &#039;exec g++.orig -mno-tls-direct-seg-refs $@&#039; &gt;&gt; /usr/bin/g++
chmod a+x /usr/bin/gcc
chmod a+x /usr/bin/g++
</pre>
<p>Extract the Ruby Enterprise Edition. Be careful to use a fresh extracted version to compile, because the files will not be recompiled. Compile and install Ruby Enterprise Edition as stated in the manual.</p>
<pre class="brush: bash">
tar zxvf ruby-enterprise-1.8.7-2009.10.tar.gz
./ruby-enterprise-1.8.7-2009.10/installer
</pre>
<p>Don&#8217;t forget to reinstall passenger, and off course reinstall all the gems from the old installation.</p>
<p>Now you can restore gcc and g++ as this will probably break yum updates of gcc and g++.</p>
<pre class="brush: bash">
rm -rf /usr/bin/gcc &amp;&amp; mv /usr/bin/gcc.orig /usr/bin/gcc
rm -rf /usr/bin/g++ &amp;&amp; mv /usr/bin/g++.orig /usr/bin/g++
</pre>
<p>Hopefully I&#8217;ve saved you guys some time <img src='http://tnux.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://tnux.net/2010/01/17/xen-ree-4gbsegfixup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tnux.net/2010/01/17/xen-ree-4gbsegfixup/</feedburner:origLink></item>
		<item>
		<title>Capistrano and Passenger part 2</title>
		<link>http://feedproxy.google.com/~r/tnuxnet/~3/KDEpkC0LUEw/</link>
		<comments>http://tnux.net/2009/12/12/capistrano-and-passenger-part-2/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 13:52:21 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tnux.net/?p=26</guid>
		<description><![CDATA[As Karl Varga pointed out in his comment on my previous post on Capistrano and Passenger (here) my apache rewrite rules did not send back the proper HTTP status codes. Now with the improved and tested rules the 503 status &#8230; <a href="http://tnux.net/2009/12/12/capistrano-and-passenger-part-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As Karl Varga pointed out in his comment on my previous post on Capistrano and Passenger (<a href="http://tnux.net/2008/06/23/capistrano-and-passenger/">here</a>) my apache rewrite rules did not send back the proper HTTP status codes. Now with the improved and tested rules the 503 status code is returned.</p>
<pre class="brush: bash">
ErrorDocument 503 /system/maintenance.html

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
# RewriteCond %{REQUEST_URI} !^/images/
# RewriteCond %{REQUEST_URI} !^/robots.txt
# RewriteCond %{REQUEST_URI} !^/sitemap
RewriteRule ^.*$ – [redirect=503,last]
</pre>
<p>If your maintenance page has images on it than you can enable line 6 by removing the &#8216;#&#8217;. </p>
<p>See also <a href="http://www.shiftcommathree.com/articles/make-your-rails-maintenance-page-respond-with-a-503">Chris K&#8217;s</a> article.</p>
]]></content:encoded>
			<wfw:commentRss>http://tnux.net/2009/12/12/capistrano-and-passenger-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tnux.net/2009/12/12/capistrano-and-passenger-part-2/</feedburner:origLink></item>
		<item>
		<title>Namespace route and form_for method</title>
		<link>http://feedproxy.google.com/~r/tnuxnet/~3/0AQ5qcJ4gog/</link>
		<comments>http://tnux.net/2008/06/29/namespace-route-and-form_for-method/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 08:16:43 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[form_for]]></category>
		<category><![CDATA[namespace]]></category>
		<category><![CDATA[routes]]></category>

		<guid isPermaLink="false">http://tnux.net/?p=14</guid>
		<description><![CDATA[When you have a namespace in your routes.rb like this: map.namespace :admin do &#124;admin&#124; admin.resources :users end And you like to have a form like this: &#60;% form_for(@user) do &#124;f&#124; %&#62; &#60;%= f.error_messages %&#62; Change the form_for in this and &#8230; <a href="http://tnux.net/2008/06/29/namespace-route-and-form_for-method/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When you have a namespace in your routes.rb like this:</p>
<pre class="brush: ruby">
  map.namespace :admin do |admin|
    admin.resources :users
  end
</pre>
<p>And you like to have a form like this: </p>
<pre class="brush: ruby">
&lt;% form_for(@user) do |f| %&gt;
  &lt;%= f.error_messages %&gt;
</pre>
<p>Change the form_for in this and you&#8217;re good to go!</p>
<pre class="brush: ruby">
&lt;% form_for([:admin, @user]) do |f| %&gt;
  &lt;%= f.error_messages %&gt;
</pre>
<p>This might save you some time. <img src='http://tnux.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://tnux.net/2008/06/29/namespace-route-and-form_for-method/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://tnux.net/2008/06/29/namespace-route-and-form_for-method/</feedburner:origLink></item>
		<item>
		<title>Gem 1.2.0 released</title>
		<link>http://feedproxy.google.com/~r/tnuxnet/~3/9XzymnOAuBA/</link>
		<comments>http://tnux.net/2008/06/24/gem-120-released/#comments</comments>
		<pubDate>Tue, 24 Jun 2008 10:20:49 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[VPS]]></category>
		<category><![CDATA[Gem]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://tnux.net/?p=10</guid>
		<description><![CDATA[Yesterday gem 1.2.0 was released. This is a release we&#8217;ve all been waiting for! This version doesn&#8217;t have the &#8216;bulkupdate&#8217; and doesn&#8217;t consume that much memory as before. So update your gem for the last time with the -B parameter. &#8230; <a href="http://tnux.net/2008/06/24/gem-120-released/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Yesterday gem 1.2.0 was released. This is a release we&#8217;ve all been waiting for! This version doesn&#8217;t have the &#8216;bulkupdate&#8217; and doesn&#8217;t consume that much memory as before. So update your gem for the last time with the -B parameter. Like this:</p>
<pre class="brush: bash">
gem update --system -B 1000000
</pre>
<p>Before version 1.2.0 I had to do on my VPS:</p>
<pre class="brush: bash">
gem install -B 1000000 --no-rdoc --no-ri rails
</pre>
<p>But now I can do:</p>
<pre class="brush: bash">
gem install --no-rdoc --no-ri rails
</pre>
<p>And it&#8217;s finished in a sec!</p>
]]></content:encoded>
			<wfw:commentRss>http://tnux.net/2008/06/24/gem-120-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tnux.net/2008/06/24/gem-120-released/</feedburner:origLink></item>
		<item>
		<title>Capistrano and Passenger</title>
		<link>http://feedproxy.google.com/~r/tnuxnet/~3/l0APr7fzOjA/</link>
		<comments>http://tnux.net/2008/06/23/capistrano-and-passenger/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 19:17:19 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Capistrano]]></category>
		<category><![CDATA[Passenger]]></category>

		<guid isPermaLink="false">http://tnux.net/?p=4</guid>
		<description><![CDATA[To use Capistrano on a Passenger enabled host, you need to add the following lines to your config/deploy.rb file. namespace :deploy do desc &#34;Restarting mod_rails with restart.txt&#34; task :restart, :roles =&#62; :app, :except =&#62; { :no_release =&#62; true } do &#8230; <a href="http://tnux.net/2008/06/23/capistrano-and-passenger/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>To use Capistrano on a Passenger enabled host, you need to add the following lines to your <code>config/deploy.rb</code> file.</p>
<pre class="brush: ruby">
namespace :deploy do
  desc &quot;Restarting mod_rails with restart.txt&quot;
  task :restart, :roles =&gt; :app, :except =&gt; { :no_release =&gt; true } do
    run &quot;touch #{current_path}/tmp/restart.txt&quot;
  end

  desc &quot;Stop task is a deploy.web.disable with mod_rails&quot;
  task :stop, :roles =&gt; :app do
    deploy.web.disable
  end

  desc &quot;Start task is a deploy.web.enable with mod_rails&quot;
  task :start, :roles =&gt; :app do
    deploy.web.enable
  end
end
</pre>
<p>Because in passenger there is no way of stopping or starting your Rails application, I&#8217;ve changed the <code>deploy:start</code> and <code>deploy:stop</code> to <code>deploy:web:enable</code> and <code>deploy:web:disable</code>. The <code>deploy:restart</code> is used by the deploy task, so now your deployment works as expected.</p>
<p><strong>Update:</strong><br />
Don&#8217;t forget to add the rewrite rules to your apache virtual host config, otherwise the enable disable tasks won&#8217;t work.</p>
<pre class="brush: bash">
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]
</pre>
]]></content:encoded>
			<wfw:commentRss>http://tnux.net/2008/06/23/capistrano-and-passenger/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://tnux.net/2008/06/23/capistrano-and-passenger/</feedburner:origLink></item>
	</channel>
</rss>
