Mike Grafton's blog



Mike GraftonMike Grafton
Standup 3/13/2009
edit Posted by Mike Grafton on Friday March 13, 2009 at 05:16PM

Help

What is better for optimizing the load time of pages on the iPhone: minifying or packing your javascript?

Mike GraftonMike Grafton
Standup 3/12/2009
edit Posted by Mike Grafton on Thursday March 12, 2009 at 04:48PM

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.

Mike GraftonMike Grafton
Standup 03/11/2009
edit Posted by Mike Grafton on Wednesday March 11, 2009 at 04:17PM

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!()

Mike GraftonMike Grafton
Standup 03/09/2009
edit Posted by Mike Grafton on Monday March 09, 2009 at 05:24PM

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.

Mike GraftonMike Grafton
New York Standup 11/24/2008
edit Posted by Mike Grafton on Monday November 24, 2008 at 03:05PM

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.

Mike GraftonMike Grafton
New York Standup 10/29/2008
edit Posted by Mike Grafton on Wednesday October 29, 2008 at 01:59PM

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' deprecate method 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 call will_change! on the model object. It was floated that a force_save method might be helpful.

  • It is often claimed that Symbol#to_proc is 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_param must 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.

Mike GraftonMike Grafton
Standup - 1/31/2008
edit Posted by Mike Grafton on Thursday January 31, 2008 at 05:56PM

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.

Mike GraftonMike Grafton
Standup - 1/30/2008
edit Posted by Mike Grafton on Wednesday January 30, 2008 at 05:21PM

Help!

  • Does anybody know anything about Lucene scoring using a document boost?

    We see an exponential relationship between document boost and the fieldNorm component of the score for each term. Can anybody explain this?

Mike GraftonMike Grafton
Standup 01/29/2008
edit Posted by Mike Grafton on Tuesday January 29, 2008 at 05:30PM

Help!

  • How do I turn off coloring in the RSpec runner?

    The answer: don't put

    --color
    in your spec/spec.opts file.

Interesting

  • There's an easy way to merge hashes in Javascript, using either JQuery or Prototype.

    For JQuery:

    $.extend(target, hash1, hash2, ...)

    For Prototype:

    Object.extend(target, hash)

    JQuery's syntax is a bit nicer since you can merge any number of hashes into the target hash.

    This is handy for grabbing JSON off the wire and merging it into an existing or "default" object.

    You can use this to merge prototypes, achieving a type of "inheritance" (or what passes for such in Javascript). But be careful, since the rightmost hash wins - IE, its properties overide properties by the same name in the target.