geek!daily

... it is by will alone i set my mind in motion ...

Got the "can't activate" Gem::Exception Blues? gem cleanup!

What to do when rubygems can't activate a version of a gem because it's already activated a different version of the same gem? My Google magic wasn't good enough to find this one quickly, so I'll happily point out Jesse Hu's nearly one-year-old post about the same problem, descended from a Ruby on Rails thread on ruby-forum.com where, unsurprisingly, it's Jeremy McAnally who knows that `gem cleanup` is the way to go.

Took nearly 45 minutes. Freed untold amounts of disk. Much happiness.

2009.06.14 in Ruby/Rails | Permalink | Comments (0) | TrackBack (0)

Technorati Tags: ruby, rubygems

Cucumber, Webrat ... Who Names These Things?

I'm tinkering a bit with Cucumber and Webrat for my day job and am very excited by some of the prospects for our QA group's automation efforts. Along the way I'm finding that I have to explain how all the moving parts relate to each other, so I made this diagram:

Cucumber Diagram

Cucumber, based on RSpec, uses Webrat to drive Selenium. Seems to make it all make sense to the folks with the questions.

(and thanks, brynary + all the webrat contributors, aslakhellesoy + all the cucumber contributors, and dchelimsky + all the rspec contributors, and the whole selenium crew ... this is very, very cool stuff).

2009.06.10 in Ruby/Rails, Testing | Permalink | Comments (0) | TrackBack (0)

Generating with Ruby OFF Rails

I'm spending a fair amount of my time working on non-Rails Ruby projects lately and I've been missing the fine code generation toys in Rails. So tonight, for the fun of it and because I was hankering to play with cucumber, I hacked up the minimal set of bits that gets you script/generate in your non-Rails project.

This is how we do it:


> mkdir my_non_rails_proj
> cd my_non_rails_proj
> mkdir script config
> touch config/environment.rb
> cat > config/boot.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
RAILS_ENV = nil
require 'rubygems'
require 'initializer'

Rails.configuration = Rails::Configuration.new
^D
> cp -p /path/to/gems/rails-2.3.2/bin/generate script/.
> ./script/generate
Usage: ./script/generate generator [options] [args]
Rails Info:
-v, --version Show the Rails version number and quit.
-h, --help Show this help message and quit.
[...]
> ./script/generate cucumber
create features/step_definitions
create features/step_definitions/webrat_steps.rb
create features/support
create features/support/env.rb
create features/support/paths.rb
create lib/tasks
create lib/tasks/cucumber.rake
create script/cucumber
> touch Rakefile
> rake features
[... large lack of FAIL ...]
>

Voila! Not guaranteed to work for all Rails generators, but it bootstrapped rspec and cucumber just fine, which was the point of my exercise. Someday I'll make a generator:bootstrap rake task or gem something if I need to do it again.

2009.06.03 in Hacking, Ruby/Rails | Permalink | Comments (0) | TrackBack (0)

Technorati Tags: rails, ruby

Re-finding my rubyligion ...

Life's been busy. Good, but busy. My gig at LinkedIn, two hours of commuting each day, plus our four person plus dog family certainly keeps me awash in things I should be doing. Thing is, ever since I stepped away from managing LinkedIn's rubyists, I haven't had much to keep me practicing my Ruby skills or tied to the Ruby community. That's made me a bit sad.

So, for the last few months, I've been finding spare-time, non-urgent Ruby projects on github to play with, forking them when I'm ready to make contributions. The one I'm currently twiddling most is a fork of Jon Maddox's IMDB library. He got the very basics in to deal with movies; I'm expanding it to handle TV series and episodes as well. In the process, I've added testing and some heavy refactoring, mostly to arrange the libraries in a more idiomatic fashion but also to swap out Hpricot for Nokogiri (sorry, why, but Nokogiri has better support for complex XPath and XSLT fun that simplifies some of the code dramatically).

I'm also digging into the guts of the Confluence4R and Jira4R libraries (and I am gratefully indebted to Ben Walding for setting up a github mirror of the Jira4R main git repo at Codehaus); for them, I'm mostly adding spec code to demonstrate what I think is true as I'm learning. Jira4R is driving me a bit nuts -- I'm having a love/hate relationship with its wsdl2ruby underpinnings. Slowly I learn.

But, then, that's the point, isn't it?


2009.05.03 in Hacking, Ruby/Rails | Permalink | Comments (0) | TrackBack (0)

Old & Rusty to Shiny & New, Part 1

I'm feeling particularly masochistic today, so I'm going to tackle a project I've been putting off for a while: moving a Rails 1.2.6 app in our subversion repository into github, then updating it to Rails 2.1.

The first part, getting from svn to github, should be relatively painless according to github's "Importing From SVN" guide. It is, as long as you have already created your github repo (I hadn't) and already have git-svn installed (I didn't). So here's the expanded tutorial

1. Create your github repo

2. Be sure you have git-svn installed. I didn't, so here's what I had to do:

sudo port uninstall git-core
sudo port install git-core +svn

I had a bit of trouble with the serf port breaking during build time:

--->  Building serf with target all
Error: Target org.macports.build returned: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_www_serf/work/serf-0.2.0" && make all " returned error 2
Command output: /opt/local/share/apr-1/build/libtool --silent --mode=compile /usr/bin/gcc-4.0 -O2 -I/opt/local/include -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp -I. -I/opt/local/include/apr-1 -I/opt/local/include/apr-1  -c -o buckets/aggregate_buckets.lo buckets/aggregate_buckets.c && touch buckets/aggregate_buckets.lo
libtool: compile: unable to infer tagged configuration
libtool: compile: specify a tag with `--tag'
make: *** [buckets/aggregate_buckets.lo] Error 1

Error: The following dependencies failed to build: p5-svn-simple subversion-perlbindings serf p5-term-readkey
Error: Status 1 encountered during processing.

... so I got all medieval on it, building it manually, then finishing the port install:

> cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_www_serf/work/serf-0.2.0"
> head config.status
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by configure, which was
generated by GNU Autoconf 2.61.  Invocation command line was

  $ ./configure --prefix=/opt/local --with-apr=/opt/local --with-apr-util=/opt/local

## --------- ##
## Platform. ##
> sudo ./configure --prefix=/opt/local --with-apr=/opt/local --with-apr-util=/opt/local
[...generally successful configuration noises...]
> sudo make all
> [...generally successful build noises...]
> cd -
> sudo port install serf
[...generally successful install noises...]
> sudo port install git-core +svn
[...more generally successful install noises...]

3. Create an authors file

I made mine as authors.txt; it looks kinda like:

jim = Jim Meyer <jim@...>
joe = Joe DiMaggio<joe@...>

4. Run the commands from the github guide. My pseudo-values included below:

$ git-svn --authors-file authors.txt clone http://events-svn.example.com/ events_tmp
$ cd events_tmp
$ git remote add origin git@github.com:my_github_username/events.git
$ git push origin master

...é voila! It's done! It even (quite cleverly) recognized other authors and properly linked them. Very nice!

2008.08.07 in Hacking, Ruby/Rails | Permalink | Comments (0) | TrackBack (0)

Technorati Tags: git-svn, github

LinkedIn Mobile is Live!

It's been a busy few months since I joined LinkedIn, but some of that work is finally out there for the world to see: LinkedIn Mobile is now in public beta. You can get more details from the LinkedIn Blog.

Today's going to be an exciting day. =]

2008.02.25 in Ruby/Rails, Social Networks | Permalink | Comments (1) | TrackBack (0)

Textile, RedCloth, and MonkeyPatching

Okay, I need to go through ~2700 articles, some large, some very large, and programmatically decide which of them use an interesting amount of Textile formatting. Don't ask why; it's not polite to stare at the unfortunate. Just smile and nod and think about how you'd puzzle this one out.

So I've got a bunch of content, some of which may be in Textile format; how can I tell without looking at every piece and making a judgement call? First, I decided to try comparing the text before and after RedCloth processing, but that didn't work since RedCloth does some whitespace cleanup (among other things) which mean that feeding it a string devoid of Textile markup doesn't guarantee you'll get the same string back. A small part of me is offended by this -- it breaks the principle of least astonishment -- but I'm enough of a situational ethicist to value the good in what it's doing for me and move on.

I started poking around in RedCloth 3.0.4, found the bits which were perpetually going to alter some of my strings (for the better!) and discovered something wonderful -- you can pass an ordered list of rules into RedCloth#to_html, allowing you to tweak it just the way you like it. Do you like using -- gasp! -- long dashes? The :glyphs_textile rule converts them to an HTML entity (&#8212; to be precise) along with a bunch of other conversions. And there are even handy shortcuts to specify all of the textile markup rules (:textile) and all of Markdown (:markdown). Yay! Flexibilty rewards to those who read the code closely!

But why, then, if I do something like:


RedCloth.new('foo -- bar -- baz').to_html(:glyphs_textile, :textile)

Do I get this:

foo - bar - baz

It turns out that the glyph and inline rules are run in the same method, inline, which looks like this:


    def inline( text ) 
        [/^inline_/, /^glyphs_/].each do |meth_re|
            @rules.each do |rule_name|
                method( rule_name ).call( text ) if rule_name.to_s.match( meth_re )
            end
        end
    end

See the problem? Because inline comes first in the ordered list of regular expressions, all inline rules come straight to the head of the line. It should look more like this:


    def inline( text ) 
        @rules.each do |rule_name|
            method( rule_name ).call( text ) if rule_name.to_s.match(/^(inline|glyphs)_/)
        end
    end

... and that's exactly what I monkey-patched into my app.

Meanwhile, judging from the Textile demo, Textile should handle my double-dash example above; this is also a bug in the Ruby implementation -- and all this time I blamed Textile ... sorry! I think I'll send in a patch as penance.

Things I've Learned

  • Making your code flexible is good for other developers.
  • Being good to other developers means they might send you patches when they find problems.
  • There's a hidden feature in Textile which allows you to disable Textile for a chunk of text: <notextile>-not struck-</notextile> -or- ==-also not struck-==
  • Monkey-patching is a nice way to get something fixed in your app quickly.
  • It's handy to be able to silence constant setting warnings when you have to monkey-patch a constant.
  • Even smart people make bugs (so what hope is there for me?)

2007.12.19 in Ruby/Rails | Permalink | Comments (1) | TrackBack (0)

Ruby Benchmark Shootout, Round 2

Back in February, Antonio Cangiano did a fairly impressive run at benchmarking the various Ruby interpreter implementations and comparing the results. He's just done it again and, just nine months later, the improvements are fairly dramatic.

I'd summarize here but frankly I hate trying to reduce the complexity of a benchmark suite to a pithy conclusion. Instead, I'll inline one of the several results tables here; this one presents the benchmark execution times in seconds:

Befor you draw any conclusions, go read the rest for yourself.

I hope he'll provide the raw numbers in some format I can pull into a spreadsheet and play with myself.

2007.12.05 in Ruby/Rails | Permalink | Comments (1) | TrackBack (0)

Me @ LinkedIn.com

Today is my first day as the manager of light engineering development at LinkedIn and I'm incredibly excited about it. Why's that, you might ask? Because LED is the group that's bringing agile development and Ruby on Rails to LinkedIn.

Who says Rails isn't ready for the enterprise? ;p

2007.11.26 in Business, Leadership, Management, Ruby/Rails, Social Networks | Permalink | Comments (1) | TrackBack (0)

Post-Leopard Checklist

I'm resettling into my laptop post-Leopard upgrade as a background task today and thought it might be useful (mostly to future-me) to note all the bits I'm twiddling:

  • Uninstalled and reinstalled SpanningSync to get iCal and GoogleCal talking again
  • Installed MacPorts 1.5 for 10.5; `sudo port selfupdate` yielded no changes.
  • Started installing Ruby gems: rcov uuidtools ... I'm sure there are more coming.
  • Installed QuickSilver for the first time. I've been watching folks like Evan speed along using it, so I thought I'd give it a try. I'll probably take time to watch the 10 minute tutorial on YouTube. Happily just discovered that this eliminates the need for  SizzlingKeys to control iTunes. Excellent. Installed a metric buttload of plugins for it. If I can achieve a graceful way of adding tasks and appointments, I'll be a happy camper.
  • Kept Twitteriffic 2.1 rather than upgrading to 3.0. I keep hearing grief about 3.0 and ads, which is uninteresting to experience firsthand.
  • Installed RMagick according to the usual instructions; however, rather than port install all the supporting libs, then compile the sources I just did `sudo port install imagemagick` which seems to have worked, so the sum of the instructions amounts to:
    1. Install X11, Xcode, and X11 SDK (there are people who don't? ;)
    2. install MacPorts
    3. `sudo port selfupdate && sudo port install imagemagick`
    4. `sudo gem install rmagick`

That's about it for now.

Update: Round 2 ... fight!

  • Resubscribe to US Holidays and Movie release calendars. (I don't usually track the DVD releases, but you can if you like)
  • Partitioned my drive with BootCamp Assistant and upgraded to latests Parallels in preparation for tonight's Vista installfest. Found it interesting/amusing that Bootcamp suggested that I could install Vista Home although this is against the MS Vista EULA.
  • Try installing mysql5 from MacPorts and get it to start. Fail miserably. Oh well.
  • Install the MySQL 5/Intel DMG from MySQL.com
  • Install /Library/LaunchDaemons/com.mysql.mysqld as root, courtesy of Joannou Ng
  • sudo launchctl load /Library/LaunchDaemons/com.mysql.mysqld
  • Install the mysql gem. This was tricky (or I don't know how it's supposed to be done); the usual method failed while building the Makefile. In the end I had to read code to discover that I should install like so: sudo gem install -- --with-mysql-config ... and even so, it wanted to build a Universal bundle and kept failing due to '-arch ppc' compiler and linker flags. Ripped those out of the Makefile and did a make install ... and voila.
  • More gems: parsetree capistrano feedtools fastercsv ferret flexmock mongrel piston rails_analyzer_tool rspec rubygrowl rubyprof sake tzinfo

Still need to work out the Address Book missing thing.

2007.11.12 in Computing, Ruby/Rails | Permalink | Comments (2) | TrackBack (0)

Next »
My Photo

About

 Subscribe in a reader

AddThis Social Bookmark Button

Categories

  • Administrivia
  • Blogs
  • Books
  • Business
  • Computing
  • Data Portability
  • Economics
  • Electronics
  • Engineering
  • Environment
  • Facebook
  • Food and Drink
  • Fun!
  • Graphing.Social
  • Hacking
  • History
  • Identity
  • Leadership
  • Linux
  • MacOS X
  • Management
  • Metadata
  • Open Source
  • Organization
  • Parenting
  • People
  • Photography
  • Privacy
  • PublicSquare
  • RailsRumble
  • Reputation
  • Ruby/Rails
  • RubyConf 2007
  • Science
  • Social Networks
  • TagEverything
  • Technology
  • Testing
  • Thinking
  • Trust
  • UI
  • Web 2.0
  • Weblogs
  • Writing

Archives

  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • January 2009
  • September 2008
  • August 2008
  • July 2008

Words on a Page

  • Carol Tavris: Mistakes Were Made (But Not by Me): Why We Justify Foolish Beliefs, Bad Decisions, and Hurtful Acts

    Carol Tavris: Mistakes Were Made (But Not by Me): Why We Justify Foolish Beliefs, Bad Decisions, and Hurtful Acts

  • Steven Gary Blank: The Four Steps to the Epiphany

    Steven Gary Blank: The Four Steps to the Epiphany

  • Chip Heath: Made to Stick: Why Some Ideas Survive and Others Die

    Chip Heath: Made to Stick: Why Some Ideas Survive and Others Die

  • Patrick M. Lencioni: Silos, Politics and Turf Wars : A Leadership Fable About Destroying the Barriers That Turn Colleagues Into Competitors

    Patrick M. Lencioni: Silos, Politics and Turf Wars : A Leadership Fable About Destroying the Barriers That Turn Colleagues Into Competitors

  • Marc Ian Barasch: Field Notes on the Compassionate Life : A Search for the Soul of Kindness

    Marc Ian Barasch: Field Notes on the Compassionate Life : A Search for the Soul of Kindness

Pages

  • If
  • The Tagline Graveyard