Mike Grafton's blog
Interesting Things
- A certain Pivotal project runs 'bundle update' often, since they have a shared gem that gets updated a lot. They were wondering why it was so slow, and supposed it was due to slowness at rubygems.org, and thought a local mirror would help. They were wrong. Turns out the slowness is in the implementation of rubygems, whereby a 110K list of gems is marshalled and unmarshalled.
Interesting Things
- jQuery mobile: awesome!
- jQuery 1.6 is out and will break you. Read the change notes and upgrade with care. [Ed.: you do have JS tests, don't you?]
Interesting Things
- Josh and Alexander are pairing at a new iteration of the tête-à-tête pairing desk, where they've hacked (with a bandsaw) a traditional Ikea desk to allow for better ergonomics and pairing dynamics. Expect a blog post with pictures soon.
Help
How do I migrate paperclip attachments from one model to another?
A Pivot wants to do his civic duty of embracing change. This means refactoring his domain model to suit the emerging requirements of his product team. Unfortunately, this also means he has to move a paperclip attachment from one model to another. Paperclip does not appear to have a built in way to do this.
The opinion of the group was to use the brute-force solution: write some code to do the migration yourself. If you are using Amazon S3 for storage (which this project is), you can do an S3 'cp' command to move the assets from one path to another. At the end, you can use the rake command 'paperclip:refresh:thumbnails' to re-generate the thumbnails.
If you want to do this by hand, cyberduck has a nice interface for batch re-naming of files on S3.
Interesting
Amazon CloudFront now supports HTTPS
They also dropped their prices.
IE has a limit of 31 CSS files.
This has bitten many Pivots over the years. Your 32nd (and up) CSS file will be silently ignored.
Interesting
String#to_xs behavior can change if you happen to have the fast_xs gem installed.
Rails tries to require the 'fast_xs' c-extension to implement String#to_xs (it falls back to a pure Ruby XML escaping algorithm if it can't find it). Unfortunately, fast_xs is not API compatible with the built-in version provided by Rails (it escapes double quotes, for no apparent reason).
This is all well and good if that's what you decide go with. But unfortunately, fast_xs is a c-extension, which means that if it's been installed on your system for whatever reason (say, installing Hpricot), then Rails will start using it, and there's no good way to turn it off (unless you consider hacking your ActiveSupport gem "good"). So the behavior of your app could change without any explicit intention on your part.
fast_xs also exists as a gem that wraps the c-extension, and if you use to_xs (i.e. your app emits XML), it might behoove you to depend on the gem explicitly. It was noted that for apps that emit a lot of XML to be performant, you will need fast_xs, anyway.
Help
Why is upgrading to Ruby 1.8.7 so painful?
More specifically, a Pivot was wondering why there seem to be so many ways to install Ruby and Rubygems on a Mac. There are a lot of different places where gems end up being installed depending on which version of Ruby you have installed, and the specifics of how you installed it. The conversation turned into one about RVM and Yehuda Katz' Bundler, two technologies that appear destined to make it much easier to easily combine a version of Ruby with a set of gems under a particular project.
What is that technology that allows for more complex condition hashes in ActiveRecord?
This must be ActiveRecord::Extensions, which allows for an expanded syntax in the conditions hash of AR finders. A debate was had as to whether hashes and arrays could possibly comprise a reasonable DSL for complex query logic, but surprisingly, the final word on the subject was not reached during standup.
We are using
curlto talk to a Mongrel/Rack server that is running some specs. That server is emitting dots (just as any Rspec process would), but we cannot get those dots to show up in real-time on the client. The only way we've been able to force a flush is with a newline character, but that gives us an ugly vertical column of dots. Any suggested hacks for this?
The Bay Area Chef Meetup Group is meeting on 10/14 in Mountain View. If you're into Chef (and here at Pivotal we use it extensively), you might want to check it out.
Help
Has anybody seen memcache clients suddenly stop being able to talk to the memcached server and mark it as dead?
In fact many people have seen this. The Pivot with the question is using the memcached gem, while others noted that the memcache-client gem had special retry logic within it to deal with such a situation. In the latter case, some have still seen connections to memcache timeout despite the retry logic and despite the fact that memcache appears to be up and operational by all other checks.
That being said, nobody had any notion of what the root cause was - anybody out on the interwebs have insight on this?
Anybody seen random segmentation faults and bus errors happening in Ruby?
One of our projects is seeing intermittent crashing of the Ruby interpreter (MRI) while running the app. It seems to happen in a random place inside of Rails, but never the exact same place. We can't find anything suspicious about the code where it is crashing.
It was noted that the project in question is using libxml (to support Nokogiri) and that various combinations of libxml and MRI are known to be incompatible; in fact a few previous Blabs posts exist on this subject. However, in this case the crashes do not happen deterministically, which is unlike the cases described previously.
Interesting
Selenium removes the If-Modified-Since header. This gets in your way if you are testing ETags.
Speaking of ETags - they are awesome. See Ryan Daigle's article for code.
Help
Just how slow is Mongrel when serving static images?
The answer is - pretty slow. The reason for the question was that Google's crawler tends to keep a single connection open and fire lots and lots of http requests over a period of several hours. With a standard Nginx/Mongrel setup, this would tie up a mongrel for this entire period.
A proposed solution to this problem is to use HAProxy between Nginx and Mongrel.
Interesting
- With RMagick 2.9.1 and ImageMagick 6.4.6.9 (or so), you get a 1x1 pixel image if you crop and then resize an image to be bigger:
image.crop!().resize!()
- Pivotal Tracker is a finalist for a Jolt award in project management. Good luck Tracker!
Help
How do you make a Mac not sleep?
Use the Energy Saver section of the System Preferences.
Interesting
RubyMine 749 is out. Many of the existing bugs have been fixed, but a few new ones have been found. Notably, running specs with a "#" character in the describe string has problems.
The USPS has a nifty web service for addresses. The zip code lookup (which gives you zip+4) and the address standardization services were found to be useful.
