Bill Rowell is a Web Developer in Massachusetts, currently specializing in e-commerce development.

billrowell
  • Home
  • Work
  • About
  • Music
  • Books
  • Archives
  • Contact
 
RSS Feed via FeedBurner

Subscribe via RSS or via Email


Colleagues

  • Andrew Teman
  • Conor McNamara
  • Dan Pickett
  • Joe Riopel
  • Ken Bailey
  • Kyle Bradshaw
  • Peter Caputa
  • Scott Jangro

Of Interest

  • Rick Whittington
  • Steve Krug
  • Coding Horror
  • Blow Up Your Computer With A Single Email!

    May 12, 2008 in Random

    I found this scan of an article via Reddit in some newspaper where a crazy “computer expert” named Arnold Yobenson claims hackers can blow up computers with emails. Look out below!

    Needless to say, I think it will be rather difficult to “alter the electrical current and molecular structure of the central processor” to turn your computer into a bomb that will “blow your family to smithereens!”.<

    No Comments Yet

  • Red Sox Opening Day at Fenway Park!

    April 9, 2008 in Random

    The Boston Red Sox opened their 2008 season at Fenway Park yesterday with a bang! Being 2007 World Series Champions, it was only fitting that we had the 2007 World Series banner unfurled and the players received their rings (or bling as owner John Henry calls it). It was a great day from what I could tell from the highlights on T.V. I wasn’t able to attend the game or watch it on T.V. since I was at work.

    Daisuke Matsuzaka threw a gem and the Sox won the game over the (lifeless) Detroit Tigers. Manny provided the offense with a triple turned home run on an error from the Tigers, who had 2 on the day. Go Sox!


    I think the most touching part of the day though was the arrival of Bill Buckner to throw out the first pitch. This guy has been dogged by a dumb play in the 1986 World Series for over 20 years. Driven out of the Boston area by Boston media and fans, I wasn’t sure this guy would ever be able to come back. But, the Red Sox ownership shows time and time again that anything is possible and had him throw out the first pitch yesterday in a roar of cheers from Boston fans. Buckner deserves this and more. It wasn’t his fault the Sox lost the 1986 World Series. Heck, there was a whole other game to play that they could have won. Yeah, it was a sucky play that he should have had, but hey, shit happens. You play the game and move on to the next one.

    Anyway, great stuff that Buckner was able to bask in Boston Red Sox cheers in the sun one final time. Cheers to you Bill and I hope we’ll see you at Fenway park again in the future!

    1 Comment

  • Astronomers Find Newborn Planet Just Around The Block

    April 2, 2008 in Random

    According to an article I found via the BBC, Astronomer’s found what could be a baby planet, just outside of our solar system a mere 520 light-years away. This is basically “across the city” as far as space is concerned. I find stuff like this to be really really cool. Definitely puts things in perspective as far as how you fit into the universe.

    Baby Planet

    I guess the image above (via radio emissions from its nearby star), courtesy of the BBC article, shows the new planet in the top right. I’m no rocket scientist, so I can’t see much, but I’m sure its cool!

    Anyway, apparently this will be a Jupiter like planet and may have started forming in the last 2,000 years. Take a look at the article here!

    1 Comment

  • Updating Pagination When Deleting Items with AJAX In Ruby on Rails

    April 1, 2008 in Development, Ruby on Rails

    Ruby on Rails & AJAXRuby on Rails

    Lately, I seem to be on a tear here with my Ruby on Rails development related posts. I suppose its more for my own documentation, but if it helps someone else out with their own development struggles, even better.

    Today, I wanted to find a solution to updating pagination using AJAX. My issue was I use AJAX to update the DOM to remove an item when its deleted. However, the pagination doesn’t update and the listings don’t adjust as you delete them from the middle of the list. My solution, while not rocket science, I think is pretty cool. Basically, just keep using AJAX!

    The first thing I need is a div to encapsulate my list. Something like:

    
         <div id="my_list">
              <%= render :partial => “items”, :collection => items %>
              <%= will_paginate items, :renderer => ‘ItemLinkRenderer’ %>
         </div>
    

    Obviously, that’s my original list inside the my_list div. I’ll get to what ItemLinkRenderer is in a big.

    I delete my items from the list by updating the dom from within the delete action. So, something like this:

    
        @item = Item.find(params[:id])
        if !@item.nil?
            @item.destroy
            render(:update) { |page|
                page.remove dom_id(@item)
            }
        end
    

    This should look pretty straight forward. Delete the item from the database, then remove it from the current document.

    But what about updating the pagination and the list? We can remove an item, but how do we adjust the displayed list? Well, just fetch the list of items again.

    
        @items = Item.paginate :all, :page => params[:page], :per_page => 10
        if @items.length > 0
            page.replace_html “my_items”, :partial => “items”, :locals => {:items => @items}
        else
            page.replace_html “my_items”, “<p>You have no items.</p>”
        end
    

    Ok, so we can render the items. But, if you put this in, then start deleting items, you’ll notice your pagination links get messed up and you have your delete action in the URL. This isn’t good, but, like I mentioned earlier, this is where ItemLinkRenderer comes in. You can define a helper class called ItemLinkRenderer (in item_link_renderer.rb) to render your links properly.

    
        class ItemLinkRenderer < WillPaginate::LinkRenderer
            def page_link_or_span(page, span_class = 'current', text = nil)
                text ||= page.to_s
                if page and page != current_page
                    @template.link_to text, :controller => “items”, :action => “list”, :page => page
                else
                    @template.content_tag :span, text, :class => span_class
                end
            end
        end
    

    This will render your pagination links properly. Hopefully this works out well for anyone who stumbles upon this. Let me know if it does or if you find any errors with what I’ve presented.

    No Comments Yet

  • Accessing “Child” Associations in Ruby on Rails

    April 1, 2008 in Development, Ruby on Rails

    Ruby on Rails

    My good buddy Dan of SecondRotation.com helped me out with a Rails problem last night. I wanted to access the associations defined on an association of one of my model classes when calling find, in essence, accessing a “child” association. I looked high and low for this, but with no luck so Dan was able to come to my rescue. He said you can do this:

    
    @collection = MyClass.find(:all, :conditions => ["id = ?", params[:id]],
          :include => [:foo => [:bar]], :order => sort)
    

    I guess using :include like this is will tell Rails and ActiveRecord that you want to include the Bar class association in the JOIN you’re doing in SQL so you can enhance your query. Makes sense, but too bad it seems to be hardly documented!

    1 Comment


© Copyright 2007 Bill Rowell, Powered by WordPress 2.3.1