Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

Monthly Archives: February 2008

David Goudreau

Standup 02/29/08

David Goudreau
Friday, February 29, 2008

Ask for Help

  • “Help! We’ve been Rick Rolled!“
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
David Goudreau

Standup 02/28/2008

David Goudreau
Thursday, February 28, 2008

Interesting Things

  • If you want to run your Selenium tests in parallel, it looks like ThoughtWorks has released Selenium Grid.
  • When testing Live Query, you don’t always want the event queue to be processed asynchronously, so we’ve submitted a patch that will allow a triggered event to return synchronously instead. The patch has not been integrated into Live Query yet.
  • Git – lets investigate where or when we can spike on this using a small internal project.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
David Goudreau

Standup 02/27/2008

David Goudreau
Wednesday, February 27, 2008

Interesting Things

  • Rails is gradually moving to git. Should we? There’s a brown bag today about git from a guest speaker. We’ll talk about it then.
  • port install bash-completion
  • plus your custom completion configuration
  • plus your alias
  • equals

    work proj[TAB]

  • mod_proxy_html – if you’re hoping to get this to work, you may have to worry about INFLATEing the html response coming from the server you’re proxying to before being able to parse the html and change its urls. We ended up using SetOutputFilter INFLATE;proxy-html;DEFLATE to pass the html through the Apache2 proxy instance correctly.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

jQuery & greasemonkey while being considerate to John's bandwidth

Pivotal Labs
Wednesday, February 27, 2008

Here is a slight modification to Joan Piedra’s jQuery greasemonkey script that loads the jQuery library on any page you visit. This gives you the power of jQuery when using Firebug or Greasemonkey. Here is an example of its usage.

var jQueryDefinition = (function() {/*jQuery library*/});
var GM_JQ = document.createElement('script');

GM_JQ.innerHTML = '(' + jQueryDefinition.toString() + ')();';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);

Here is the full script.
Here is the userscrips page.

Make sure that the jquery.user.js script is loaded before any other dependent Greasemonkey scripts.

The difference is you can put the jQuery library into the script itself. This causes the page to load faster and does not use up John Resig’s bandwidth. Unfortunately, this also means you will need to manually upgrade your greasemonkey script when the next version of jQuery comes out.

[Update] Edited the Greasemonkey script to make jQuery compatible with other js libraries.
[Update] Pointing to userscripts.org

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Can less leave the screen alone when it quits?

Alex Chaffee
Tuesday, February 26, 2008

From the less faq:

blah blah blah ti/te blah blah blah -X blah blah.

Also, -R makes it show ANSI color. So I put this in my .bash_profile:

export LESS=-RX
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Stupid Ruby Quoting Tricks

Pivotal Labs
Monday, February 25, 2008

Let’s start with something easy.

Here’s the mirepoix

bar = "chicken"

You know single quotes and double quotes, right? These are our salt and pepper.

'frickin #{bar}' # => "frickin #{bar}"
"frickin #{bar}" # => "frickin chicken"

Have you seen %%q and %%Q?

%%q(frickin #{bar}) # => "frickin #{bar}"
%%Q(frickin #{bar}) # => "frickin chicken"
%%q{frickin #{bar}} # => "frickin #{bar}"
%%Q{frickin #{bar}} # => "frickin chicken"

You’ve also seen “”" (triple-quotes) right?

"""frickin #{bar}""" # => "fricken chicken"
"""frickin '#{bar}'""" # => "fricken 'chicken'"
"""frickin "#{bar}"""" # => "fricken "

UPDATE: As John points out in the comments, in addition to triple quotes there are also quintuple quotes, septuple quotes, and so forth. In fact, you can invent your own quoting operator for any odd number of quotes. (Just kidding.)

The truth is, singly and doubly-quoted object concatenate simply by juxtaposition!

"frickin " "chicken" # => "fricken chicken"
'frickin ' 'chicken' # => "fricken chicken"
"frickin " bar # => kabooom!
%%q{frickin } %%q{chicken} # => kablooey!
"""" #=> ""
"""frickin chicken" # => "frickin chicken"

Hokay. So that is all child’s play. These are the quoting operators for the big boys.

This is why Ruby’s Grammar is not Context-Free:

def foo(x)
  x.reverse
end

foo(<<-EOS)
  Your mom
EOS
# => "mom ruoY"

foo(<<-EOS).reverse
  amanaplanacanalpanama
EOS
# => "amanaplanacanalpanama"

Even better:

puts(DATA.read.reverse)

__END__
Your mom
# => "mom ruoY"

You actually have to copy the above code into a ruby file and run it — it wont work in IRB.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

dri on openbsd/amd64

Pivotal Labs
Saturday, February 23, 2008

I’ve been helping out oga@ with the porting of dri onto OpenBSD, specifically in the !i386 sense. I’m also learning C, and kernel and X and ioctl at the same time. So needless to say, he’s done the heavy lifting ;).

Last night, I finally got my machine to start dri. I had to remove DEBUG from my kernel config (an absurd amount of debug messages from everything, and all sorts of excess checking slowed things down dramatically. kernel compiles took 15 minutes, vs the 2.5 minutes they do in normal mode.), and fix the Xorg libdri libraries. Bampf, glxgears runs at 660fps, vs 40fps. PrivSep has to be disabled, and you have to run X as root (eep!!!), so those need to be fixed before anything hits the OpenBSD source tree. Anyways, the OpenBSD tree is locked in preparation for the 4.3 release, so nothing can hit the tree anyways.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Chad Woolley

Removing Old Ruby Source Installation After a Leopard Upgrade

Chad Woolley
Friday, February 22, 2008


Removing Ruby

I just upgraded to Leopard on my Mac. Previously, on Tiger, I had installed Ruby from source, in the default /usr/local/lib prefix. After reading the discussion on the Apple-provided Ruby installation, I decided to try it – mainly to ensure that my apps, such as GemInstaller, play well with it (on Pivotal’s Mac pair workstations, we still install Ruby from source, so everything matches our demo/production environments as closely as possible, and things are in consistent locations).

So, I wanted to uninstall the old Ruby source installation, and only have the Apple-provided Ruby on disk. Googling for a few minutes did not provide exact instructions for this, so I’m writing up what I did, in hopes that it will help you!

I didn’t use the “–prefix” option when I originally installed Ruby from source, so it was in the default location of /usr/local/lib/ruby, with binaries in /usr/local/bin.

WARNING: Use ‘rm -rf’ at your own risk – a sleep-deprived encounter with ‘rm -rf’ and a stray file named ‘~’ is what “motivated” my Leopard upgrade in the first place…

First, I deleted the old ruby libraries/gems, which was easy enough, because they all lived under /usr/local/bin/ruby:

sudo rm -rf /usr/local/lib/ruby

However, this left all the old ruby/gems executables in /usr/local/bin. This resulted in errors when trying to run executable gems that I had not yet installed under the Apple Ruby installation:

$ cheat
/usr/local/bin/cheat:9:in `require': no such file to load -- rubygems (LoadError)
from /usr/local/bin/cheat:9

Instead of a cryptic rubygems error, I should get a ‘file not found error’:

$ sudo rm /usr/local/bin/cheat
$ cheat
-bash: /usr/local/bin/cheat: No such file or directory

So, I want to purge everything ruby-releated from my /usr/local/bin folder. I whipped up a quick ruby one-liner which just prints out (almost) all ruby-related files in /usr/local/bin:

ruby -e "old_ruby_execs = `egrep 'rubygems|bin/ruby|env ruby' /usr/local/bin/*`; require 'pp'; pp old_ruby_execs.split("n").collect{|line| line.split(':').first}.uniq"

Yeah, I know, ugly and obtuse, but one-liners are kind of fun, and help me remember that Ruby is great tool for sysadmin scripts. Feel free to put it in a class and test it if you are so inclined.

Even though I tried to make a fairly specific regexp for egrep, when inspecting that list, I did find a ‘jgem’ file, which was part of JRuby. I’m planning on reinstalling JRuby anyway, so I didn’t care if that got deleted along with the other ruby stuff.

Anyway, if the output of that looks like everything you want to delete, then run this one-liner to do the actual deed (the ‘sudo echo’ is to ‘prime’ the sudo auth, so you don’t get a noninteractive password prompt):

sudo echo; ruby -e "old_ruby_execs = `egrep 'rubygems|bin/ruby|env ruby' /usr/local/bin/*`; old_ruby_execs.split("n").collect{|line| line.split(':').first}.uniq.each { |exec| p 'removing ' + exec; `sudo rm #{exec}`}"

After that, the only thing that I saw left was the ‘ruby’ executable itself, which I whacked as well:

$ sudo rm /usr/local/bin/ruby

That seems to be about it, as least good enough to get all the old invalid executables off my path. I’m sure this could have been done cleaner if I had taken more care with the original source install. However, a good brute-force approach never hurt anyone. Much. Feel free to post links to relevant and helpful stuff.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Rails 2 on Windows with Oracle: notes about getting started

Pivotal Labs
Wednesday, February 13, 2008

I’m planning to make this the first in a series of random small notes
about working on a Rails project in an enterprise (by which I mean large-scale, mature-company, high-demand) setting. I’m aiming for small bite-sized dispatches, not for comprehensiveness. [Edited to say: I'm now working on a Java project, so I'm not sure when I will have more to add.] Please
chime on in with additions and comments. This post focuses on our installation process. If you’ve gotten here via google, you’re going to find much more systematic guides than this, so be of good cheer!

To get going on Windows XP (which really didn’t take long after we received admin permissions for our PC) we began by installing and
configuring Cygwin. There are many good Cygwin resources, so I’ll just note that being proxied inside a firewall, we needed to set our ‘http_proxy’ environment variable to a fully qualified proxy URL (http://proxy_host:port) in order for gem to be able to pull packages down.

Also (maybe unnecessary if we got all our paths right, but I’ve had this kind of path wonkiness in Cygwin before) we needed to
alias rake, rails and gem, as in "alias gem='/cygdrive/c/ruby/bin/ruby
c:rubybingem"

We froze to Edge rails. We installed mySql first, did some scaffolding out of resources (I do love script/generate Noun) so that we had some migrations to apply. Then we made the transition to Oracle 10g local install (free).

You’ll need oci8, the Oracle connection layer. In case you miss this the way I did, there’s a binary Windows installer there for you — download it and run ruby ruby-oci8-1.0.0-mswin32.rb.

Current Rails 2 also omits the oracle connection adapter: put it in with the other connection adapters in ${RUBY_HOME}/lib/ruby/gems/1.8/gems/lib/active_record/connection_adapters/

At the moment you’ll also need to make this patch to the adapter.

Our project has a requirement for different table names than the Rails-guessable default. (The requirement is that they differ even within an Oracle view.) For this case, any database will need you to set the table name (we had trouble with set_table_name, but we were able to use def self.table_name() "my_actual_table_name" end ). With Oracle, and I would imagine with Postgres, you also need to set the sequence name:

   set_sequence_name "my_actual_table_name_seq"

or you get a “sequence does not exist” error. We flipped back to MySql at one point and didn’t get any complaints about setting sequence names in each model object, so that’s good.

If you insert data in your migrations and you have explicitly set sequence names, don’t forget that you will have to make the ID one of the inserted columns, with the value being my_actual_table_name_seq.nextval. If you aren’t monkeying with table names, ignore all of this, because the adapter will take care of sequences behind the scenes.

We tried applying a global prefix to our table names, because the prefix is the non-guessable part, but didn’t manage to make that work, presumably because we hadn’t yet figured out the sequence naming issue.

We’ve done a quick experiment with creating an updatable view, to make sure we can make that work with Rails (since the database schema is already specified and is not very Rails-friendly, we’ll mask that with views), and it just worked. The sequence gets called appropriately by the adapter for the ID. (I initially had some doubt about this, but it was just because I messed up the first version of my view by leaving out the ID field.)

Dropping the database from rake doesn’t seem to work. More importantly, we have a still-unsolved issue with not being able to reliably run “rake test” — the migration process breaks sporadically. (Individual tests run outside of rake from the command line are fine.) Our current fix is that we put the following test suite in test/test_suite.rb

       require 'test/unit'

       Dir.chdir("test")
       @@test_files = Dir.glob("**/*_test.rb")
       Dir.chdir("..")
       @@test_files.each {|x| require "test/" + x unless x.include?("selenium")}

and we’re running it from IntelliJ.

That’s probably more than enough for today. I’m on vacation for a couple of weeks. So if you share your own Oracle/Rails tips while I’m gone, I won’t be able to thank you till March… but don’t let that discourage you!

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Standup 02/11/2008

Pivotal Labs
Monday, February 11, 2008

Interesting Things

  • Got Example?

    Don’t forget to make use of the reserved (top- and second-level) domain names set aside by RFC 2606… especially if you find yourself writing something like:

    result = @model.do_request('http://www.somebogusdomain.com')
    result.code.should == 1001
    
    
    # NOTE: www.somebogusdomain.com actually exists!
    
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Topics

  • agile (778)
  • rails (113)
  • testing (86)
  • ruby (83)
  • ruby on rails (70)
  • jobs (62)
  • javascript (53)
  • techtalk (44)
  • rspec (38)
  • activerecord (29)
  • productivity (29)
  • gogaruco (29)
  • ironblogger (29)
  • git (28)
  • nyc (27)
  • rubymine (25)
  • mobile (21)
  • cucumber (20)
  • bloggerdome (19)
  • process (19)
  • pivotal tracker (19)
  • design (18)
  • jasmine (18)
  • ios (18)
  • webos (17)
  • objective-c (17)
  • android (16)
  • palm (16)
  • "soft" ware (16)
  • fun (15)
  • tracker ecosystem (15)
  • ci (15)
  • cedar (15)
  • rails3 (14)
  • performance (14)
  • gem (13)
  • bdd (13)
  • selenium (12)
  • css (12)
  • goruco (12)
  • bundler (12)
  • tdd (12)
  • meetup (11)
  • railsconf (11)
  • nyc-standup (11)
  • capybara (10)
  • mac (10)
  • mojo (10)
  • chef (10)
  • rubygems (9)
Subscribe to Community Feed
  1. 1
  2. 2
  3. →
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >