Open Source Development Workshop
Thursday, October 28 at 6:30PM
Pivotal Labs is hosting and our own Sarah Mei is leading an open source workshop for developers interested in learning about contributing to open source projects. Sarah will be using the Diaspora project as an example, and the Diaspora team will be on hand to assist. Email Sarah at sarahmei at pivotallabs dot com for more info, or view the meetup page here
Standup 2010-10-26 and 2010-10-27
“How do I use RVM on the server?”
RVM on the server can be fraught with peril. Be sure that your (or your process’s) shell is being invoked in a way which plays nice with RVM, for instance bash -lc or bash -ic in cron.
“Why does Google Street View give me a grey dead area instead of a picture of some dude’s house?”
Most likely this is due to having requested a view for an area where none is available. The Google docs have been found to be a bit misleading on this, however there is an api call to see if there is an available street view for a given radius — try increasing this radius near your lat & long until you get success in order to avoid a useless response.
- Running MySql in ramdisk does not yield any discernable performance boost for small to medium-sized rails projects, for test suites or the app itself. This is probably due to the fact that most projects’ code and data are already small enough to fit in cache.
- Looking for a real perf boost? Try REE with the Twitter GC tweaks
I’m updating Erector to RSpec 2 and came across two problems for which solutions were surprisingly difficult to Google. Here are my (finally successful) results.
no such file to load -- spec/rake/spectask
require "spec/rake/spectask" # RSpec 1.3
require "rspec/core/rake_task" # RSpec 2.0
undefined method `spec_files=' for #<RSpec::Core::RakeTask:0x00000101550aa8>
# RSpec 1.3
Spec::Rake::SpecTask.new(:core) do |spec|
spec.spec_files = FileList['spec/erector/*_spec.rb']
spec.spec_opts = ['--backtrace']
# RSpec 2.0
RSpec::Core::RakeTask.new(:core) do |spec|
spec.pattern = 'spec/erector/*_spec.rb'
spec.rspec_opts = ['--backtrace']
See also http://github.com/rspec/rspec-core/blob/master/Upgrade.markdown (curiously cloaked from Google searches for the above problem strings).
Here are a few notes on how to get individual CruiseControl.rb project Builders running with RVM.
[Note: I’m making an assumption here that you know and understand Bundler and RVM.]
[Also: Cruise may or may not be running on RVM]
Create and check in a .rvmrc file in your rails root directory. Here’s an example.
Then, add a project build command to your cruise_config.rb file.
Project.configure do |project|
project.build_command = './cruise_build.sh'
Finally, create a cruise_build.sh file. The bash script setups rvm and just calls your cruise control build task.
[Note: Your cruise rake task should probably call Bundler’s “bundle install”.]
source $HOME/.rvm/scripts/rvm && source .rvmrc
…and your cruise project builder is now using RVM!
- Edit: followup to delayed_job job logging failures
Switching to resque might help, but not without first rewriting the jobs.
More research yielded the fact that delayed_job reopens all files (including the log files) when it spins up. Under Ruby 1.8, File#reopen defaults file mode to last set, while 1.9 defaults to read only. This could easily cause logging failures. (with a nod to Davis W. Frank for the followup info)
“Anybody have any experience using the oath gem without net/http? There are some things we want to do that it’s not good at”
Like posting large files? Shell out to curl. There are a couple things nobody seems to have done right, yet, and that you just have to use curl for.
“What is the right gem to use for AWS? The official one seems newer than this right_aws that hasn’t had a commit in a couple years”
You are probably looking at the wrong version. Another project was using right_aws and they swear it’s newer than that. It sounds like the gem forked and you probably want the RightScale one. Either way it definitely works better than Amazons ec2 gem, which will get the job done sometimes, but is less than optimal.
Testing right_aws with webmock
A team was seeing webmock continuing to feed a bad result to all of their tests (within a timeout for the shared connection) when one failed, instead of trying again. They switched to using connection=dedicated instead of shared.
If you are looking for a ruby gem to interact with S3, you may want to choose the S3 gem over the AWS::S3 gem.
The S3 gem seems to be under active development while the AWS::S3 gem gem seems to have gotten a little stale.
I mistakenly chose the AWS::S3 gem gem based on the number of downloads on rubygems.org but it was missing the ability to copy from one S3 bucket to another without having to move the files through my local machine. That will teach me for not reading the source code…
“We’re using Rails 2.3.x built-in Digest Auth to hide the production/demo env of a site that doesn’t have a user model yet. It seems like every few requests we have to reauth – possible worse when multiple computers request concurrently”
Make sure there aren’t any failing requests (such as an ajax firing off an illegal route) that might be causing the browser to think it is no longer authed? Maybe just stick with using Basic Auth via an .htaccess? A number of other comments and guessed were thrown around, but nothing conclusive.
The team asking about charting yesterday said Flot was the answer. Highchart has licensing/pricing they didn’t like, Graphael might be getting stale, as it hadn’t been touched in a while, and they needed more data than the GET limit, which prevents the use of Google Charts.
Some Jasmine tests were failing on CI in Selenium, but not locally.
It turned out to be some tests that fail when the window size is to small. The team bringing this up added a helper for Jasmine to resize the window if it was too small. Another team mentioned new Selenium runs fullscreen by default. Another team gave the Jasmine test block a static style and large size in css.
“Anybody have a favorite for charting on the client-side?”
Google charts works well for getting something simple going quickly, use Flot for anything beyond that. Some people mentioned the existence of Raphael.js, but nobody had much experience with it.
“We had to make sure we were using rvm as a function instead of a binary and-“
You installed it wrong – the install checks that rvm is a function.
“We are seeing a lot of errors (more than the hoptoad limits) going to hoptoad and newrelic for error types that are handled by rails built-in rescues, like 404s for ActiveRecord::RecordNotFound. The app is serving up the correct error page, but still sending an error to the services.”
These services hook in lower than that so they can get all error info. Make sure nothing happened to their config of which errors to ignore, because they have their own way of skipping them.
Also consider turning off the default route to cut back on crawlers. This would likely just trade 405s for 404s, though.
Inspired by Aaron Patterson at the Mountain.rb Conference, I thought I’d share my favorite programming/software engineering books.
- C Programming Language (2nd Edition) by Brian W. Kernighan and Dennis M. Ritchie (1988)
- Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (1994)
- Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development by Craig Larman (1995)
- Refactoring: Improving the Design of Existing Code by Martin Fowler, Kent Beck, John Brant, and William Opdyke (1999)
- Peopleware: Productive Projects and Teams (Second Edition) by Tom DeMarco and Timothy Lister (1999)
- Extreme Programming Explained: Embrace Change by Kent Beck (1999)
- Effective Java by Joshua Bloch (2001)
- Test Driven Development: By Example by Kent Beck (2002)
- Refactoring to Patterns by Joshua Kerievsky (2004)
- Java Concurrency in Practice by Brian Goetz, Tim Peierls, Joshua Bloch, and Joseph Bowbeer (2006)
- Restful Web Services by Leonard Richardson, Sam Ruby, and David Heinemeier Hansson (2007)
- Getting Real: The smarter, faster, easier way to build a successful web application by Jason Fried, Heinemeier David Hansson, and Matthew Linderman (2009)
“Yesterday we agreed to always check in the Gemfile.lock, but 1.8 and 1.9 versions differ slightly so…?”
It wouldn’t quite make sense to maintain a whole separate branch, but someone cleverly suggested making the file a symlink and having your .rvmrc manage which file the symlink points to.
Ask for Help
“Does everybody check their Gemfile.lock into source control?”
Yes! Yehuda said so and if you don’t the earth might fall into the sun.
“Anybody have any experience using chef client-server?”
A number of people said they had seen it go down in flames and get ripped out of projects in favor of chef solo.
*”Is there a way to get IE7 to render in quirks mode, but IE8 and everything else in standards?”
Not that anybody knows of. IE6 can be triggered by an xml prolog before the doctype, but they fixed that for IE7. So your choices are IE6 and earlier in quirks and IE7+ in standard, or all IEs in quirks.
A pivot had trouble with rspec being not be installed in development mode and getting rake spec to run right, but others had had no trouble with it in test env only.
You can do layouts in pure css that used to be a lot of work, like 100% height with fixed px headers/footers, using the display:table|table-row|table-cell styles.
This will work in the standards based browsers and IE8+. This means you need to use an alternative for IE7, either js, expressions in an IE only stylesheet, or a quirks-mode based layout using fixed padding. I experimented with this over the week-end and blogged about it: The new css 100% width and height with header and sidebar