37signals Getting Real Book

Posted by Frederic Jean Fri, 03 Mar 2006 18:22:14 GMT

David announced that the Getting Real book was now available as a PDF file.

I bought a copy, downloaded it and read it from end to end. It is mostly a compilation of the 37signals blog with supporting quotes and evidence. It is a good read overall, although it did make me envious of how developers at 37signals and other startups are able to work without the overhead that I have to face here at Sun. I'm not really the target audience though since the book is better targetted to small teams and startups working on products.

I certainly recommend it.

Update: The 37signals team released a refreshed version of the PDF in response to comments from people who bought the book. It is certainly a great example of a company walking the talk.

Ruby on Rails Tutorial on apple.com

Posted by Frederic Jean Mon, 27 Feb 2006 22:52:51 GMT

Apple has posted a tutorial about Ruby on Rails on their web site. It does highlight Textmate and explains why Mac OS X is such a great platform to develop RoR applications.

Of course, you knew that already if you played with RoR on a Mac...

Better-than-Google activity indicators with Rails

Posted by Frederic Jean Mon, 20 Feb 2006 02:46:37 GMT

The next time that you use your GMail account, look on the upper-right corner of the screen when you go from email to email. You'll notice that a red box shows up containing the word "Loading...". This is a very helpful indicator that GMail is in the process of doing something.

Mir.aculo.us has a great article on how to achieve a similar effect using an animated GIF image. You can achieve an even nicer effect by adding partials and Script.aculo.us effects.

First, make sure that the javascripts files are loaded by adding this to the head of your page:

              1
              
<%= javascript_include_tag :defaults %>

This will force the default sets of javascripts files to load. These do include effects.js and application.js.

Next, create a file called application.js under public/javascripts if it doesn't already exists. Add this code:

              1
              2
              3
              4
              5
              6
              7
              8
              9
              10
              11
              
Ajax.Responders.register({
                  onCreate: function() {
                      if($('loading') &#38;& Ajax.activeRequestCount>0) {
                          Effect.Appear('loading',{duration:0.5});
                      }  
                  },
                  onComplete: function() {
                      if($('loading') && Ajax.activeRequestCount==0)
                          Effect.Fade('loading', {duration:1.0});
                  }
              });

Then create a partial called _loading.rhtml:

              1
              2
              3
              
<div id="loading" style="display: none;" class="loading">
                  <h2><img src="http://typo.fredjean.net/typo/images/load.gif">&nbsp;Loading...&nbsp;</h2>
              </div>

I also added the following CSS to my application's stylesheet:

              1
              2
              3
              4
              5
              6
              7
              8
              
.loading {
                  background: rgb(250,250,250); 
                  border: solid 2px; 
                  vertical-align: middle; 
                  text-align: center; 
                  padding-left: 20px; 
                  padding-right: 20px;
              }

I finally included the partial at the bottom of my layout:

              1
              
<%= render :partial => 'loading' %>

From that point on, I got a "loading" indicator each time I clicked on a link created through the link_to_remote helper method. No need to go ahead and add the effects to each invocations.

-- Fred

Technorati Tags: ,

First Boulder-Denver Ruby Enthusiasts Meeting

Posted by Frederic Jean Mon, 20 Feb 2006 02:44:24 GMT

The Boulder-Denver Ruby Group had its first meet and greet last night at the Southern Sun Pub and Grill in South Boulder. The attendance was much higher than was expected, and the crowd quite noisy.

The group is going to start meeting in a more regular venue next month (see this message in archives). It's certainly going to be an interesting group to interact with. I am glad that such a group is forming in the Denver area. I read many blog entries from people in Seattle and Portland boasting about their meetings.

A big theme was the Waterfall 2006 conference being planned for Niagara falls. Looks like I might have to skip that one though ;).

-- Fred

Geocoding, REXML and the Missing Method

Posted by Frederic Jean Mon, 20 Feb 2006 02:35:48 GMT

Scott Davis introduces the audience of his Real World Mapping presentation to the geocoder.us web site, which allows anyone to transform US based addresses to longitude and latitude coordinates. There are many options beyond the web based UI, including SOAP, XML-RPC, and RESTful web services. We will be using the RESTful RDF service for this demonstration.

The first step is to find (and URL encode) an address. For this demonstration, we will be using "Mission & Valencia Sts, San Francisco CA" as the address. You will see the following XML document if you point a browser at http://rpc.geocoder.us/service/rest?address=Mission+%26+Valencia+Sts%2C+San+Francisco+CA:

              1
              2
              3
              4
              5
              6
              7
              
<rdf:RDF>
                <geo:Point rdf:nodeID="aid06646235">
                  <dc:description>Mission St and Valencia St, San Francisco CA 94110</dc:description>
                  <geo:long>-122.420082</geo:long>
                  <geo:lat>37.74533</geo:lat>
                </geo:Point>
              </rdf:RDF>

This is technically an RDF document. It can still be parsed as a regular XML document though. Let's define a Location class:

              1
              2
              3
              4
              5
              6
              7
              8
              9
              10
              11
              12
              13
              14
              15
              16
              17
              18
              19
              20
              21
              22
              23
              24
              25
              
require 'rexml/document'
              require 'net/http'
              
              class Location
                require REXML
              
                def initialize(address)
                  geocoder = Net::HTTP.new("rpc.geocode.us", 80)
                  query = "/service/rest?address=#{address}"
                  query.gsub!(/ /, "+")
                  @entry = Document.new geocoder.get(query).body
                end
                
                def long
                  @entry.elements["//geo:long"].text
                end
                
                def lat
                  @entry.elements["//geo:lat"].text
                end
                
                def desc
                  @entry.elements["//dc:description"].text
                end
              end

From there, you can create a Location object and get the coordinates:

              1
              2
              3
              
location = Location.new "Mission St and Valencia St, San Francisco CA 94110"
              location.lat
              location.long

From there, you can use the location in a mapping application (such as a Google Maps mashup for example...)