July 2007 Archives

Autotest meets Doom

Autotest with SFX

http://fozworks.com/static/autotest-sound10.html

I really like this last one. It uses well engineered audio to bypass the need for visual interruptions. Hopefully it'll help you keep flow better.

From an email:

just a quick announcement: ruby user group berlin has decided to organize the obligatory reject conf for rails conf europe in september.

when? tuesday, 2007-09-18, 21:00
where? secret place (i.e. we have not found the perfect location yet)

slightly different rules this time. anybody can talk about anything, but we ask you to present your talk as a micropresentation - that is: 15 slides, 20 seconds each, with a countdown which automatically brings up the next slide.

sounds weird, but i have seen it at reboot in copenhagen and it works really really well:

http://www.reboot.dk/artefact-466-en.html

I give them full permission to use my glorious artwork. :P

at icanhasruby tonight

| | Comments (0)

Eric and I will be at icanhasruby tonight... join us if you can!

them: this brick wall keeps hurting my head every time I bash into it over and over!
them: it never changes! help! why doesn't it work?
me  : what are you actually trying to do?
them: bash my head through this brick wall!
me  : what are you actually trying to do?
them: I'm trying to bash my head through this brick wall!
them: why do you keep asking me that?!?!
me  : do you perhaps mean, get to the other side of the wall?
me  : why don't you just use that door?

There is a certificate course at the UW starting this fall. It is 3 quarters long starting at rubynewb, then rails/web development, then rubyjedi. no, not the real titles. You are not required to take all three courses. do what feels right. To take just one:

http://www.extension.washington.edu/ext/certificates/rby/rby_sce.asp

There is space available. apparently, plenty of space... so take make this a success, if you are interested or suspect someone you know is interested, PLEASE, help make it happen.

ZenTest provides 4 different tools and 1 library: zentest, unit_diff, autotest, multiruby, and Test::Rails.

ZenTest scans your target and unit-test code and writes your missing code based on simple naming rules, enabling XP at a much quicker pace. ZenTest only works with Ruby and Test::Unit.

unit_diff is a command-line filter to diff expected results from actual results and allow you to quickly see exactly what is wrong.

autotest is a continous testing facility meant to be used during development. As soon as you save a file, autotest will run the corresponding dependent tests.

multiruby runs anything you want on multiple versions of ruby. Great for compatibility checking!

Test::Rails helps you build industrial-strength Rails code.

Changes:

3.6.1 / 2007-07-23

DESCRIPTION:

Hoe is a simple rake/rubygems helper for project Rakefiles. It generates all the usual tasks for projects including rdoc generation, testing, packaging, and deployment.

Tasks Provided:

  • announce - Generate email announcement file and post to rubyforge.
  • audit - Run ZenTest against the package
  • check_manifest - Verify the manifest
  • clean - Clean up all the extras
  • config_hoe - Create a fresh ~/.hoerc file
  • debug_gem - Show information about the gem.
  • default - Run the default tasks
  • docs - Build the docs HTML Files
  • email - Generate email announcement file.
  • gem - Build the gem file only.
  • install - Install the package. Uses PREFIX and RUBYLIB
  • install_gem - Install the package as a gem
  • multi - Run the test suite using multiruby
  • package - Build all the packages
  • post_blog - Post announcement to blog.
  • post_news - Post announcement to rubyforge.
  • publish_docs - Publish RDoc to RubyForge
  • release - Package and upload the release to rubyforge.
  • ridocs - Generate ri locally for testing
  • test - Run the test suite. Use FILTER to add to the command line.
  • test_deps - Show which test files fail when run alone.
  • uninstall - Uninstall the package.

Changes:

1.2.2 / 2007-07-23

A script which automates a limited set of rubyforge operations.

  • Run 'rubyforge help' for complete usage.
  • Setup: For first time users AND upgrades to 0.4.0:
    • rubyforge setup
    • edit ~/.rubyforge/user-config.yml
    • rubyforge config
  • Don't forget to login! logging in will store a cookie in your .rubyforge directory which expires after a time. always run the login command before any operation that requires authentication, such as uploading a package.

Changes:

0.4.3 / 2007-07-23:

NOTE: This is for keynote 2, which is bundled with iWork '07. I've posted an updated script for keynote 3.

on run
  display dialog "Drag keynote documents on me to convert to PDF."
end run

on open draggeditems
  repeat with thisFile in draggeditems as list
    tell application "Finder" to reveal item thisFile
    set thisFile to thisFile as alias

    tell application "Keynote" to open thisFile

    tell application "System Events"
      tell application process "Keynote"
        set frontmost to true

        if menu item "Hide Inspector" of menu 1 of menu bar item "View" of menu bar 1 exists then
          keystroke "i" using {command down, option down}
        end if

        click menu item "Export…" of menu 1 of menu bar item "File" of menu bar 1

        repeat until sheet 1 of window 1 exists
        end repeat

        tell sheet 1 of window 1
          click radio button "PDF" of radio group 1
          click button "Next…"
        end tell

        repeat until button "Export" of sheet 1 of window 1 exists
        end repeat

        tell sheet 1 of window 1
          click button "Export"
        end tell

        delay 3
        keystroke "w" using command down
      end tell
    end tell

  end repeat
end open

My theme for this year is shaping up to be "don't be clever, it doesn't suit you". Here is some real code we found and how it can quickly and easily be cleaned up to be much more readable, more correct, and more efficient all at the same time. (indeed, it took more time to benchmark and write this post than it did to fix the code)

The original code in all its clever glory:

if MODELS.keys.inject(true) {|b, klass| b and klass.constantize.columns.map(&:name).include? association.options[:foreign_key]}

pull out the foreign key, since there is no reason to do that in a loop:

fk = association.options[:foreign_key]
if MODELS.keys.inject(true) {|b, klass| b and klass.constantize.columns.map(&:name).include? fk}

pull out columns to improve readability:

fk = association.options[:foreign_key]
columns = MODELS.keys.map { |key| key.constantize.columns.map(&:name) }
if columns.inject(true) {|b, column| b and column.include? fk}

Oh look, now that we can read it, inject is totally wrong and slow:

fk = association.options[:foreign_key]
columns = MODELS.keys.map { |key| key.constantize.columns.map(&:name) }
if columns.all? {|column| column.include? fk}

Finally, while that map symbol to_proc hack sure looks cute, it sucks:

fk = association.options[:foreign_key]
columns = MODELS.keys.map { |key| key.constantize.columns.map { |c| c.name } }
if columns.all? {|column| column.include? fk}

Measure the change (slightly wrong after minor edits):

  1. 1 line, 132 chars, 131 avg len
  2. 2 line, 140 chars, 69 avg len
  3. 3 lines, 180 chars, 59 avg len
  4. 3 lines, 163 chars, 53.3 avg len
  5. 3 lines, 163 chars, 54.3 avg len

And finally, (rough) benchmarks:

\# of iterations = 100000
iter                      user     system      total        real
null_time             0.020000   0.000000   0.020000 (  0.012905)
benchmark-1          11.350000   0.030000  11.380000 ( 11.564039)
benchmark-2          10.900000   0.020000  10.920000 ( 10.975134)
benchmark-3          10.720000   0.010000  10.730000 ( 10.928107)
benchmark-4          10.520000   0.030000  10.550000 ( 11.300934)
benchmark-5           3.260000   0.010000   3.270000 (  3.275238)

(nevermind: don't look at the times, that wasn't the point... those that focused on the times missed the point.)

Sure does pay to not be clever...

<deep sigh>

Hi, my name is Ryan and... and I am an info-junkie.

Hi Ryan!

I use NetNewsWire (pro) to read my newsfeeds. Too many newsfeeds. I've got 178 feeds currently tho that fluctuates. I've got them grouped into prioritized groups so I can focus on certain ones more than others, like "ruby" vs "ruby-bored". I know that's not good... but... That works pretty well, actually.

Why I'm really here... my real problem... From these feeds, I queue up even more. Like, I read wiki update feeds and queue up whole pages to read for later. Loads of them. 132 of them right now. I'm weak. I know it. I gotta know! But since I can't group them the way I can the feeds, I'd like SOME way to bring some order out of chaos...

We've not had anything reasonably challenging (at our perm job) since March, when I made the app 20x faster and massively cleaner/happier.

We'll (most likely) be going indie after this.

I'm hoping to finish up with some clients that I've currently got (I've been moonlighting) and take most or all of August off (or September if it gets pushed off too much). After that we'll come back to the consulting arena full force. rawr

In the fall I'm going to be teaching the ruby course I hinted at in my last blog post. I've pretty much finalized the curriculum's syllabus, and am starting in on each day's slides now. I plan on releasing the slides under creative commons or some-such, but can't do so until afterwards. However, I would like to get a small (5ish?) private group of people who would be interested in reviewing the slides ahead of time. They'll be in PDF form to make life easier. I'm guessing you'll spend roughly 5 minutes to my 60.

Anybody interested? If so, leave a comment here. If I know you and your background, great. If not, please drop a 3-5 sentence description telling me who you are and your background.