Mike Grafton's blog
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.
Help
What is better for optimizing the load time of pages on the iPhone: minifying or packing your javascript?
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.
Interesting
Rails 2.2.2 is released!
Even Rails 2.2.2 isn't always threadsafe. I found this out by running a script with JRuby from the command line. The script loaded the Rails environment and then launched two threads that simply tried to resolve an ActiveRecord class constant. Fireworks (in the form of LoadError) ensued deep inside of const_missing. I'll post the full example later today.
Tsearch2 is now built into Postgres (as of 8.3). This means you must remove the metadata from your tables, since Postgres now stores it in a separate place.
Interesting
Until a recent commit, Polonium defined a method on Module named
deprecate, which (at least in our case) overrode the method of the same name defined in Rails. This caused some code in Rails to blow up at class loading time when trying to call Rails'deprecatemethod with the wrong number of arguments.We changed the name of Polonium's method so it wouldn't clash with Rails, and checked this into the master branch of Polonium on GitHub.
As of Rails 2.1, ActiveRecord support partial updates, which means that it's smarter about what fields get updated in the SQL UPDATE statement issued by
save. If you haven't updated any fields in the object, no update will happen at all, no AR callbacks will fire, etc. If you depend on these things to happen even when not updating any fields, you can callwill_change!on the model object. It was floated that aforce_savemethod might be helpful.It is often claimed that
Symbol#to_procis to slow to use in production code. But a clever Rubyist out there found a way to speed it up by 4x.The test run for one of our projects here runs in 223 seconds on OSX, but in in 157s on Ubuntu. We'd like to figure out why (we're pretty sure we're using the MySQL Gem rather than the built-in MySQL driver that comes with Rails)
Git4Idea is now available through the IntelliJ Plugin manager. No more hand installation!
ActiveRecord::Base#to_parammust return a String if you override it. If you return an Integer you will get a weird "Can't convert Fixnum to String" exception somewhere deep in the routing code. You can't even tell where the exception is coming from due to the routing code's bizarreness.
Help!
- Has anybody successfully used the drag-and-drop functionality included in the newer versions of Selenium? It doesn't appear to work - the mouse events never seem to get fired.
Interesting
If you're messing with the solr.war inside of the solr_runner plugin, beware that the webapps directory (in which it sits) is scanned by Jetty for .war files, and that when your use 'rake solr_runner:start', you might not be running off the .war file you think you are. When we started SOLR this way, we saw some output from Jetty that indicated that it was unpacking and using the wrong .war file from that directory (in our case, it apparently used solr.war.new!).
The moral of the story is, if you want to swap in a new version of solr.war, just move it on top of the existing one, and don't put any other files in there.







