<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom">
 
  <title>para9's blog</title>
  <subtitle>Musings on life with technology</subtitle>
  
  <link href="http://para9.com/blog/" />
  <updated>2009-11-10T15:02:14-05:00</updated>
  <author>
    <name>para9</name>
    <email>hello@para9.com</email>
  </author>
  <id>http://para9.com/</id>
  
  <link rel="self" href="http://feeds.feedburner.com/para9" type="application/atom+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry>
    <title>Make jrails_auto_complete work with Safari</title>
    <link href="http://para9.com/blog/2009/10/12/make-jrails-auto-complete-work-with-safari.html" />
    <id>tag:para9.com,2009-10-14:1255535383</id>
    <updated>2009-10-14T11:49:43-04:00</updated>
    <content type="html">&lt;p&gt;In the process of migrating an application from Prototype to jQuery, we used &lt;a href="http://code.google.com/p/ennerchi/"&gt;jRails&lt;/a&gt; as an intermediary step for our rjs templates. As a replacement to Rails&amp;#8217; &lt;a href="http://github.com/rails/auto_complete"&gt;autocomplete plugin&lt;/a&gt; we tried Marty Zalega&amp;#8217;s &lt;a href="http://github.com/evilmarty/jrails_auto_complete"&gt;jrails_auto_complete plugin&lt;/a&gt;. Unfortunately, there was a problem when using it with Safari: we were not able to move up and down the suggestion list using the up and down keys.&lt;/p&gt;
&lt;p&gt;The plugin listens to &lt;em&gt;keypress&lt;/em&gt; events instead of &lt;em&gt;keydown&lt;/em&gt; events to decide when the up and down keys are pressed. Since Safari 3.1 a &lt;em&gt;keypress&lt;/em&gt; event is no longer fired when a non-character key is pressed. We found the explanation in this &lt;a href="http://stackoverflow.com/questions/1496635/keyboard-select-not-working-in-safari"&gt;Stack Overflow thread&lt;/a&gt;. The solution is not explicitly shown over there, so here it is&amp;#8230;&lt;/p&gt;
&lt;p&gt;In the jrails.autocomplete.js file, replace the call to &lt;em&gt;keypress&lt;/em&gt; near line 61 with a call to &lt;em&gt;keydown&lt;/em&gt;:&lt;/p&gt;
&lt;div class="CodeRay"&gt;
&lt;pre&gt;&lt;span class="no"&gt;1&lt;/span&gt;     &lt;span class="pd"&gt;$&lt;/span&gt;(&lt;span class="lv"&gt;this&lt;/span&gt;.update).hide();
&lt;span class="no"&gt;2&lt;/span&gt;     &lt;span class="pd"&gt;$&lt;/span&gt;(&lt;span class="lv"&gt;this&lt;/span&gt;.element).attr(&lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;autocomplete&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;off&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;)
&lt;span class="no"&gt;3&lt;/span&gt;     .blur(&lt;span class="kw"&gt;function&lt;/span&gt;(e) { autocomplete.onBlur(e); })
&lt;span class="no"&gt;4&lt;/span&gt;     &lt;span class="c"&gt;// .keypress(function(e) { autocomplete.onKeyPress(e); });&lt;/span&gt;
&lt;span class="no"&gt;5&lt;/span&gt;     &lt;span class="c"&gt;// Use keydown here. Safari &amp;gt;= 3.1 does fire keypress for&lt;/span&gt;
&lt;span class="no"&gt;6&lt;/span&gt;     &lt;span class="c"&gt;// non-character keypresses&lt;/span&gt;
&lt;span class="no"&gt;7&lt;/span&gt;     .keydown(&lt;span class="kw"&gt;function&lt;/span&gt;(e) { autocomplete.onKeyPress(e); });
&lt;span class="no"&gt;8&lt;/span&gt; }
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;We tested the fix in Safari 4, Firefox 3, Internet Explorer 7 and 8.&lt;/p&gt;
&lt;p&gt;For some background info, see &lt;a href="http://ejohn.org/blog/keypress-in-safari-31/"&gt;John Resig&amp;#8217;s post&lt;/a&gt; on that subject. There is also a &lt;a href="http://www.quirksmode.org/dom/events/keys.html"&gt;nice writeup&lt;/a&gt; on Quirksmode describing the uses of both events.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Front Row Plugin 2.0.5</title>
    <link href="http://para9.com/blog/2009/09/07/front-row-plugin-205.html" />
    <id>tag:para9.com,2009-09-07:1252374622</id>
    <updated>2009-09-07T21:50:22-04:00</updated>
    <content type="html">&lt;p&gt;Mathieu took some time during the long weekend to update the DVDpedia &lt;a href="/en/front_row_plugin.html"&gt;Front Row Plugin&lt;/a&gt;. The new release brings the much requested support to Snow Leopard and Apple TV 2.4.&lt;/p&gt;
&lt;p&gt;Thanks to everyone who sent emails and made a &lt;a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;amp;hosted_button_id=8056278"&gt;donation&lt;/a&gt;. Your feedback and support is truly appreciated.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>para9's New Look</title>
    <link href="http://para9.com/blog/2009/03/15/para9_new_look.html" />
    <id>tag:para9.com,2009-03-15:1237137464</id>
    <updated>2009-03-15T13:17:44-04:00</updated>
    <content type="html">&lt;p&gt;With spring quickly approaching, we thought it was time to give para9 a new look. Please say hello to para9&amp;#8217;s new logo and website.&lt;/p&gt;
&lt;p&gt;We are also introducing our &lt;a href="http://para9.com/blog"&gt;blog&lt;/a&gt;, so subscribe to the &lt;a href="http://feeds2.feedburner.com/para9"&gt;feed&lt;/a&gt; if you&amp;#8217;d like to keep up with our latest musings. Heartfelt thanks to our friends at &lt;a href="http://www.ottoblix.com/"&gt;Ottoblix&lt;/a&gt; for the design of para9&amp;#8217;s new visual identity.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>printf and Octal Values</title>
    <link href="http://para9.com/blog/2009/08/13/printf-and-octal-values.html" />
    <id>tag:para9.com,2009-08-13:1250194108</id>
    <updated>2009-08-13T16:08:28-04:00</updated>
    <content type="html">&lt;p&gt;We came across a strange issue while using &lt;a href="http://www.activemerchant.org/"&gt;ActiveMerchant&lt;/a&gt; to connect Moneris&amp;#8217; &lt;a href="http://www.eselectplus.ca/"&gt;eSelect Plus&lt;/a&gt; payment gateway in one of our projects. ActiveMerchant raised an exception every time an order had &amp;#8216;08&amp;#8217; or &amp;#8216;09&amp;#8217; as the credit card expiry month.&lt;/p&gt;
&lt;p&gt;The culprit was the way ActiveMerchant uses sprintf to format the month value before sending it to the payment gateway. In the file &lt;a href="http://github.com/Shopify/active_merchant/blob/aa6eba5ea27c88bd27c16592ef7016fe110b1667/lib/active_merchant/billing/gateways/moneris.rb"&gt;lib/active_merchant/billing/gateways/moneris.rb&lt;/a&gt; (around line 80):&lt;/p&gt;
&lt;div class="CodeRay"&gt;
&lt;pre&gt;&lt;span class="no"&gt;1&lt;/span&gt; &lt;span class="r"&gt;def&lt;/span&gt; &lt;span class="fu"&gt;expdate&lt;/span&gt;(creditcard)
&lt;span class="no"&gt;2&lt;/span&gt;   sprintf(&lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;%.4i&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, creditcard.year)[&lt;span class="i"&gt;-2&lt;/span&gt;..&lt;span class="i"&gt;-1&lt;/span&gt;] + 
&lt;span class="no"&gt;3&lt;/span&gt;                 sprintf(&lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;%.2i&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, creditcard.month)
&lt;span class="no"&gt;4&lt;/span&gt; &lt;span class="r"&gt;end&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Let&amp;#8217;s test that in irb.&lt;/p&gt;
&lt;div class="console"&gt;
&lt;pre&gt;&lt;code&gt;
&amp;gt;&amp;gt; sprintf("%.2i", '06')
=&amp;gt; "06"	
	
&amp;gt;&amp;gt; sprintf("%.2i", '07')
=&amp;gt; "07"

&amp;gt;&amp;gt; sprintf("%.2i", '10')
=&amp;gt; "10"
	
&amp;gt;&amp;gt; sprintf("%.2i", '08')
ArgumentError: invalid value for Integer: "08"
	from (irb):1:in `sprintf'
	from (irb):1
	from :0

&amp;gt;&amp;gt; sprintf("%.2i", '09')
ArgumentError: invalid value for Integer: "09"
	from (irb):2:in `sprintf'
	from (irb):2
	from :0
&lt;/pre&gt;&lt;p&gt;&lt;/code&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Weird, isn&amp;#8217;t it?&lt;/p&gt;
&lt;p&gt;It seems like sprintf won&amp;#8217;t accept values &amp;#8216;08&amp;#8217; and &amp;#8216;09&amp;#8217;. &lt;a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/145510"&gt;This ruby-talk  message&lt;/a&gt; explains why. The leading zero tell Ruby to interpret 8 and 9 as octal numbers. Anything above 7 is obviously not a valid octal number.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;div class="console"&gt;
&lt;pre&gt;&lt;code&gt;
irb(main):005:0&amp;gt; 07
=&amp;gt; 7

irb(main):006:0&amp;gt; 08
SyntaxError: compile error
(irb):6: Illegal octal digit
	from (irb):6
	from :0
&lt;/pre&gt;&lt;p&gt;&lt;/code&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The solution is quite simple: just make sure you cast the expiry month as an integer (using to_i) before creating an ActiveMerchant credit card object.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Announcing the Guichetier</title>
    <link href="http://para9.com/blog/2009/03/16/announcing-the-guichetier.html" />
    <id>tag:para9.com,2009-03-16:1237249335</id>
    <updated>2009-03-16T20:22:15-04:00</updated>
    <content type="html">&lt;p&gt;&lt;img src="http://para9.com/images/front_page/guichetier_1.png" class="left_image" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;We&amp;#8217;re pleased to announce that our iPhone/iPod touch app, the Guichetier, is now available on the App Store. The Guichetier is an ATM locator for Montreal, Laval and the urban agglomeration of Longueuil. By finding your bank&amp;#8217;s ATMs, the app helps you avoid additional transaction fees.&lt;/p&gt;
&lt;p&gt;The Guichetier is available for $1.99. Avoid transaction fees once and the application easily pays for itself! For more details, visit the &lt;a href="http://para9.com/en/guichetier.html"&gt;product page&lt;/a&gt; or go directly to the &lt;a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=306113112&amp;amp;mt=8" onClick="javascript: pageTracker._trackPageview('/app_store/guichetier');"&gt;App Store&lt;/a&gt;.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>A QuickTime logo instead of a video</title>
    <link href="http://para9.com/blog/2009/05/17/a_quicktime_logo_instead_of_a_video.html" />
    <id>tag:para9.com,2009-05-17:1242595488</id>
    <updated>2009-05-17T17:24:48-04:00</updated>
    <content type="html">&lt;p&gt;A couple of weeks ago, I replaced the video showing what our &lt;a href="/en/front_row_plugin.html"&gt;Front Row DVDPedia plugin&lt;/a&gt; looks like. The original video was too big to be watched on a mobile device and loaded right away, wasting precious bandwidth.&lt;/p&gt;
&lt;p&gt;While playing around with QuickTime pro, I found the solution I was looking for. QuickTime can export various versions of a movie and create a script that serves the most appropriate one depending on the bandwidth available and the device used to request the media. Plus, it gives you a &amp;#8220;click to play&amp;#8221; link for free !&lt;/p&gt;
&lt;p&gt;A couple of minutes later, everything was working correctly on my laptop. Unfortunately, once the website was deployed on our web server, it did not work as I expected. A big QuickTime logo was displayed where I was expecting the video. The funny thing is that it worked on our staging server, but not on the production server. It obviously had something to do with the web server&amp;#8217;s configuration but a quick look at Apache&amp;#8217;s logs showed nothing conclusive.&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/blog/quicktime_logo_instead_video.jpg" class="center_image" title="A QuickTime logo appears instead of the expected video" alt="A QuickTime logo appears instead of the expected video" /&gt;&lt;/p&gt;
&lt;p&gt;If this happens to you, make sure you have the right mime types activated in Apache. Our web server sent the correct mime types for the .mov file we originally had but it did not know what to do with the .m4v and .3gp files generated by QuickTime.&lt;/p&gt;
&lt;p&gt;If you don&amp;#8217;t have access to Apache&amp;#8217;s configuration file, you can use a &lt;a href="http://en.wikipedia.org/wiki/Htaccess"&gt;htaccess file&lt;/a&gt;. The syntax looks like this:&lt;/p&gt;
&lt;div class="CodeRay"&gt;
&lt;pre&gt;&lt;span class="no"&gt;1&lt;/span&gt; &lt;span class="c"&gt;# Correct Mime Types for delivery of QuickTime movies&lt;/span&gt;
&lt;span class="no"&gt;2&lt;/span&gt; &lt;span class="co"&gt;AddType&lt;/span&gt; video/x-m4v m4v
&lt;span class="no"&gt;3&lt;/span&gt; &lt;span class="co"&gt;AddType&lt;/span&gt; video/&lt;span class="i"&gt;3&lt;/span&gt;gpp &lt;span class="i"&gt;3&lt;/span&gt;gp
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Put the htaccess file at the root of your website and you should be good to go !&lt;/p&gt;
&lt;p&gt;Of course, this is &lt;a href="http://developer.apple.com/webapps/designingcontent.php"&gt;explained in detail&lt;/a&gt; on Apple&amp;#8217;s website but it&amp;#8217;s not easy to find.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Front Row Plugin 2.0.4</title>
    <link href="http://para9.com/blog/2009/03/27/plugin_front_row_204.html" />
    <id>tag:para9.com,2009-03-27:1238199735</id>
    <updated>2009-03-27T20:22:15-04:00</updated>
    <content type="html">&lt;p&gt;We&amp;#8217;ve just released an update to the DVDpedia &lt;a href="http://para9.com/en/front_row_plugin.html"&gt;Front Row Plugin&lt;/a&gt;. Apple TV users will be glad to learn that the most recent version of Apple TV (2.3.1) is now supported. As always, the Front Row Plugin is offered as a free download.&lt;/p&gt;</content>
  </entry>
  
</feed>
