Kinetic Spine and Tire Centre

Posted by Colin A. Bartlett Thu, 29 Nov 2007 15:05:00 GMT

Steve came up with “Kinetic Spine and Tire Centre” many months ago as a test account on a chiropractic-related website we did. It always give me a chuckle to think of a chiropractor that also did auto repair.

I very often click on the “who made this site” link at the bottom of sites while I browse. I recently came across a site designed by a firm whose “our services” page looked like this:

I’m not sure that I’d ever get a spinal adjustment at a place that worked on tires and I don’t know if I’d ever get a website made by a company that lists real estate investment and property management above web design on their site.

Generating Ruby 1.9 RDocs Tip 1

Posted by Justin Reagor Wed, 28 Nov 2007 16:39:00 GMT

Like many hardcore Ruby hackers, I am completely psyched for this December… Ruby 1.9 will depot to the world, and give us a much needed refresher in the community.

Last night, following RubyInside’s How to Start Playing with Ruby 1.9 Right Now! I was able to have it compiled in no time (after upgrading GNU Bison on Tiger).

So with a brand new programming language refresh your going to need the API docs right? Well, some people are finding problems when generating these new rdoc’s, so I figured I’d have the same problem…. but not quite…

Allison Is Sexy

Using Evan Weaver’s “Allison” RDoc template gem I was able to do a simple generation of the new RDoc’s with his gorgeous template.

First you’ll need the template…

# sudo gem install allison

Then, from within the root level of the Ruby 1.9 trunk source directory (where you built Ruby 1.9) use the allison command like so.

# allison --title 'Ruby 1.9beta' --line-numbers -o new-rdoc

This will place all the new docs into “new-rdoc” directory. You can copy them out to where ever you like afterwards. I stored mine within my /usr/local/ruby1.9b/doc/.

Remember, when compiling 1.9 to configure with prefix=/usr/local/ruby1.9 otherwise you may overwrite your 1.8 installation… and that would make for a bad workday.

Small Issue

I have experienced some error messages coming from Safari 3, that the Allison template’s Javascripts are loading too slowly. Just hitting the “Continue” button will keep them going. I have not tried this in Firefox or any other browser yet… but that would probably fix this small issue.

44 Questions

Posted by Colin A. Bartlett Tue, 27 Nov 2007 01:40:00 GMT

My Dad asked me to help him buy a new (Windows) computer for work today and I agreed to walk him through it on the phone. “Just get the best you can afford.” is usually my mantra to folks who ask for help speccing a PC.

Little did I know the gauntlet that lay before us.

Dell’s website demanded we choose options for each one of 44 different questions as a part of “building” a new laptop.

The process was truly laughable. While there’s something to be said for having a variety of options to get just what you want, this was just ridiculous. It’s no wonder the Mac is considered the non-technologists computer (and hell, now it’s the computer of geeks too)—Apple’s website has just 13 simple options all on one screen.

Most of the “options” were just upsells for all manner of add-ons from PDF writing capability (free with OS X, or an open source download but that’s another story…) all the way to “Would you like Dell to plant a tree for you when you buy this computer?” ($4).

Many of the options were nonsensical and difficult choices even for a seasoned veteran like myself. Here’s one of my favorite selections:

When will people learn that simple is often better? I’m reminded of the old “less software” approach of a well known company…

Starlight TextMate Theme v1.1

Posted by Justin Reagor Thu, 22 Nov 2007 22:53:00 GMT

UPDATED – I added my personal information as well as a few minor updates, repacked and posted to the download link below…

Download: The latest iteration of my TextMate theme Starlight is here!

“Starlight” is based off of one of the pre-installed TextMate themes called “Twilight”.

There are several “Twilight”-based themes out there. Mine is probably the furthest from the original. I pretty much…

  1. Moved all of the original color scheming to the CSS style sheet scopes (which I may or may not change at some point)
  2. Re-worked it to better fit Ruby development
  3. Added HTML/Erb coloring
  4. and just recently, Javascript coloring (sub-theme I call Invasion, coming seperately soon)

HTML/ERB

—Ruby/Rails

—Javascript

Most of the original scope selectors are used for the syntax highlighting, though the Javascript ones are all new.

The font I am using is a “programmers font” called Inconsolata. It is mostly used for printing code, but I’ve found it to be great for on-screen use as well (at middle ranged sizes).

Time Machine is Awesome 1

Posted by Colin A. Bartlett Sun, 18 Nov 2007 20:51:00 GMT

Nothing more to say.

It just rocks. So easy to setup. So easy to use.

Once again, Apple, I bow before thee.

Kinetic's Intro to Ruby-Debugging 1

Posted by Justin Reagor Fri, 16 Nov 2007 03:35:00 GMT

Galvanize your debugging skills, Rails 2.0 cometh. With its optimized breakpointing we will all soon find ourselves wanting to be thrown into the console. If your up to it that is, and consoles don’t scare you. This quickie guidebook demonstrates some current features of the ‘ruby-debug’ gem and how you can start getting into the mindset of live debugging your Rails code.

At the conclusion of this article I will provide several useful links for other resources into Ruby-debug.

Warning: This stuff tends to be only for real Ruby hackers that like to follow live execution of their applications and frameworks, demystifying the magical and generally understanding exactly whats going on during execution.

Get the Goods

Start-up your terminal of choice and do the old…

# sudo gem install ruby-debug -y

You’ll of course want to choose either Win32 or the more fashionable Ruby version, depending on your platform.

You may also want to install Wirble. Wirble gives you helpful IRB syntax highlighting which can come into so much handiness that you might just pee your pants.

# sudo gem install wirble
...for wet pants.

Next, visit our old friend ‘development.rb’ and add the following line at the bottom of this file…

# require 'ruby-debug'

If your using the current Edge Rails, 2.0 RC1, you should not need to do any of this as the new version of Rails will be using this by default. This is from my own hear-say, so I’ve installed it anyway, and using it in Rails 1.2.5 as well.

The Pay Dirt

Fire up your Rails application in your terminal, head over to a controller and add the following line as the first call in any action. Preferrably one with some instance variable assignments like a POST/UPDATE…

debugger

You can place this where ever you like when debugging this way, but for the article you might find my controller placement idea good for your first use (where the ACTION is).

Your going to now navigate to this action from within your web browser. Your browser should stall (what looks to be a stall), and your browser may be still be trying to load the page. Apple-Tab over to your Terminal, where you ran script/server, and you should see…

./script/..config/../app/controllers/pirates_controller.rb:8 @pirate = Pirate.find(params[:id]) if params[:treasure]
(rdb:1)

Take notice to the first line will be the last line executed before hitting your ‘debugger’ line. As well as your new friend, the ruby-debug prompt.

Help

(rdb:1) help
ruby-debug help v0.9.3
Type 'help <command-name>' for help on a specific command

Available commands:
backtrace break catch cont delete display down eval exit finish frame 
help irb list method next p pp quit reload restart save script set 
step thread tmate trace undisplay up var where 

(rdb:1) help var
ruby-debug help v0.9.3
v[ar] c[onst] <object>          show constants of object
v[ar] g[lobal]                  show global variables
v[ar] i[nstance] <object>       show instance variables of object
v[ar] l[ocal]                   show local variables

List and Where

Now try “list”ing out your source, and finding out “where” you are in a stack trace (if this was an error we’d see a nice long trace).

(rdb:1) list =
    5            def ensure_booty
    6                debugger
=>    8                @pirate = Pirate.find(params[:id]) if params[:treasure]
    9                if @pirate.update_attributes(:booty => params[:treasure])
    10                    redirect_to :action => :set_sail
    11                else
    12                    redirect_back_or_default(raid_island_path)
    13                end
    14            end
(rdb:1) where
--> #0 /Users/padiomonk/rails/piratr/app/controllers/pirates_controller.rb:8 in 'ensure_booty'

You can list as many times as you want to follow down your source. Using the ”=” symbol will always return you to where you are in the current source.

Next and Step

You can use the “step” command to make a single step, while the “next” command will move you to the next line of execution without descending inside methods (I haven’t gotten the full hang of this yet).

(rdb:1) next
Processing PiratesController#ensure_booty (for 127.0.0.1 at 1505-11-15 23:38:35) [GET]
  Session ID: 03411cca0de2164ecb751116ae19d948
  Parameters: {"action"=>"ensure_booty", "controller"=>"pirate", "id" => "23", "treasure" => "women's panties"}
  SQL (0.000214)   SET SQL_AUTO_IS_NULL=0
  Pirate Columns (0.004699)   SHOW FIELDS FROM pirates
  Pirate Load (0.001597)   SELECT * FROM pirate WHERE (pirates.`id` = 23) LIMIT 1
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/base.rb:1102 render unless performed?

Break and Continue

Breakpoints are instances where you are thrown back into your debugger when a certain method is called, a certain line is reached or a certain condition occurs. Mostly a fine-art of development, good breakpointing skills can definitely take a while to grow into your personal development cycle.

(rdb:1) b 9
Set breakpoint 1 at ./script/.../controllers/pirates_controller.rb:9
(rdb:1) b Booty.find
Set breakpoint 2 at Booty.find
(rdb:1) b 12 if params[:treasure].nil?
Set breakpoint 3 at 12
(rdb:1) b
Breakpoints:
    1 pirates_controller.rb:9
    2 Booty.find
    3 pirates_controller.rb:12 if params[:treasure].nil?
(rdb:1) cont

You will now be thrown back into the debugger when any of these breakpoints are “met”. Taking a look up above, this should throw us right at the redirect_back_or_default if I’m correct.

RDebug

Now that you know some about breakpoints, you might find the time where you just want to load up the debugger before running Rails… set some breakpoints in places you already know of, or need to investigate… then run your script/server. Without placing a “debugger” call anywhere.

# rdebug script/server

Open With Your Mate

Something that I caught onto very quickly, was the ability to open up the current file into TextMate at any time. This comes in handy when exploring the Rails source, being swung into one file after another.

Simply use the “tmate” command!

IRB

The great thing about ruby-debug is that it gives you the current state of your app loaded into an irb session to mess around with. Sometimes I tend to use this more, to checkout my constants and instance variables…

(rdb:73) irb
>> self.class
=> PirateController
>> instance_variables
=> ["@response", "@assigns", "@template", "@_session", "@params", "@_request", "@pirate", "@before_filter_chain_aborted", "@headers", "@flash", "@cookies", "@_response", "@request_origin", "@variables_added", "@_flash", "@action_name", "@session", "@_cookies", "@performed_redirect", "@sailboat", "@_headers", "@current_user", "@url", "@request", "@_params", "@performed_render"]
>> @pirate.is_a?(Person)
=> true
>> quit
(rdb:73)

Outro

This tool might not be for you, but I’ve been learning more and more as I use this. I also don’t feel there is a better development utility if you intend to truly understand the under pinnings of the Rails source and wield its magical Ruby wisdom (pppfffffttt).

Anyway, here’s are a couple links for more information…

Datanoise: Ruby-debug homepage

Datanoise: Debugging in Rails

Datanoise: Tutorial on Ruby-debug

Misc Praise with Link to Railscast video

Older posts: 1 2