11 Sep 2007, 12:24pm
/dev/rails
by chris

Comments Off

Reloading dispatch.fcgi

Rails development is usually done using dispatch.cgi so changes are readily apparent. However dispatch.cgi is painfully slow for a production environment so it only makes sense to use dispatch.fcgi. You can check which you’re using by looking into your /public/.htaccess file. In this case I’m running dispatch.cgi and .fcgi is commented out:

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
#RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

Problem is dispatch.fcgi won’t immediately recognize changes made to content. In order to force a flush of all dispatch.fcgi instances we could kill all the processes but this seems better to me:

[chris@enki ticklist]$ touch public/dispatch.fcgi

17 Jul 2007, 8:47am
/dev/random
by chris

Comments Off

“You keep using that word. I do not think it means what you think it means.”

“It means impossible. Since no engineer is going to admit something is impossible, they use this word instead. When an engineer says something is “non-trivial,” it’s the equivalent of an airline pilot calmly telling you that you might encounter “just a bit of turbulence” as he flies you into a cat 5 hurricane.”

This quote shows both the difference between the engineer and non-engineer’s conception of non-triviality, and their different definitions of impossible (Flying through a hurricane isn’t necessarily impossible, you just really wouldn’t want to do it).

In Understanding Engineers: Feasibility Charles Miller does an excellent job of explaining what engineers (and by association software developers) really, truly mean when we say a problem is “hard” or “Very Hard” or “impossible”. An excellent read, well worth the time for anyone who has been on the receiving end of a bluntly-delivered “that problem is non-trivial” and been left annoyed and confused, wondering “wtf does that mean???”

Alas Charles doesn’t quite explain why engineers would use “trivial” instead of “already solved… in my head”, use “non-trivial” instead of “impossible”, and use “very hard” instead of “not a chance in hell”.

The answer is simple: we don’t want you to panic. Panic is bad.

To the engineer none of these terms actually mean impossible per se, not in the same sense that the entire rest of the world understands “impossible” anyhow.

Rather these terms are gradations of effort, and of work, and of thought and, oddly enough, the amount of practical engineering or development that will be involved in solving the problem.

(Note that if a developer actually says “no, impossible. Totally impossible, can’t be done” and then starts to walk around in small, worried circles that really does mean it can’t be done. In that case you probably ought to leave them alone for a bit to think about it, just in case.)

The rock climbers out there will instantly get this concept – think of this as the developer’s Yosemite Decimal System. The YDS is a scale by which rock climbers rate the difficulty of a climbing route (a “problem”). A 5.1 is a set of carpeted stairs with excellent hand-rails, 5.14 is restricted to baboons, orangutans and mutants. Most climbers would thus accuse a 5.15 of being “impossible, totally impossible”. A few would then up and send it, which of course does absolutely nothing to reduce the problem’s total impossibleness. It remains impossible.

A non-rock climber would look at that same rock wall, hear a climber moan “impossible” and assume that the climber actually means “nope, can’t be done, ever, no sense in even standing about gazing at it, might as well go have a beer” which of course is completely perpendicular to what the climber actually means. Except for the the beer bit. That’s probably still correct.

What the climber is really saying is:

“I’m going to stand here staring at this blank wall for a few hours, doing a strange little slow-motion dance, looking a bit like a mime trying to climb a ladder, while muttering under my breath. Then I’m going to go home and dream about this place. I’m going to wake up, re-christen it ‘my project’, sucker a friend into coming back here to suffer on belay, bash away at it for hours, swear a lot, call it ‘impossible’, curse its name, and come back and do the very same thing again next weekend. Let’s go have a beer.”

So, the next time you hear a developer use one of these terms know that they do so not to confuse but rather to mitigate worry. What they’re really saying is “Let me think about it”.

19 Apr 2007, 1:54am
/dev/ruby
by chris

2 comments

More Trivial Scripting with Ruby

Last Friday, in Trivial Scripting with Ruby on O'Reilly Ruby, Gregory Brown demonstrated a two-line example of the ease with which simple utility scripts can be created from Ruby. In his case a script that takes a filepath and returns the contents with all HTML entities escaped.

I like it, but I don't have any use for this operating on a per-file basis. More useful to me is being able to pass in the HTML text via command line args:

RUBY:
  1. #!/usr/bin/env ruby
  2.  
  3. require "cgi"
  4. ARGV.each { |x| puts CGI.escapeHTML( x ) }

I saved this as esc.rb. To use:

Sagarmatha:~/Documents/utilityscripts chris$ ./esc.rb "<em>Hello & World</em>"
&lt;em&gt;Hello &amp; World&lt;/em&gt;

19 Apr 2007, 12:00am
/dev/ruby
by chris

4 comments

Updating MySQL Gem to 2.7

While updating my installed gems this evening I ran into an issue with the mysql-2.7 gem:

ERROR: While executing gem ... (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

ruby extconf.rb update
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no

The solution was to explicitly tell gem where the local MySQL install is:

Sagarmatha:~ chris$ which mysql
/usr/local/mysql/bin/mysql

Sagarmatha:~ chris$ sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql

Caveat: Note the double -- between mysql and --with. That's not a typo (though it may look like a single dash in this page in some browsers).

20 Mar 2007, 2:40pm
/dev/random
by chris

Comments Off

RMagick Has NOT Defeated Me

Installing ImageMagick/GraphicsMagick and RMagick under OS X today has embodied almost everything I dislike about modern computing. After five hours of effort, following the various instructions on fourteen different web pages (thank god for browser tabs) and edit upon edit of arcane command line arguments, I give up. I conceed that they will not be installed, will not be operable.

Even though I'm absolutely comfortable in the command line, regularly have a number of terminal windows open, happily ssh into my various Linux boxes from my OS X laptop, it boggles my mind that I can install entire OS updates with a click of a button without interrupting my workflow yet stand-alone Linux-based apps seemingly cannot be installed without extracting a gallon of fresh blood.

After all this effort I'm left with no answers and a mash of:

/Users/chris/Documents/Downloads/RMagick-1.15.4/./lib/rvg/misc.rb:321: [BUG] Bus Error
ruby 1.8.4 (2005-12-24) [powerpc-darwin8.8.0]
...
post-setup.rb: InitialCoords.rb example returned error code 6
...
post-setup.rb: RotateScale.rb example returned error code 6
setup.rb: Too many examples failed. The RMagick documentation cannot be installed successfully. Consult the README.txt file and try again, or send email to rmagick@rubyforge.org.
make: *** [all] Error 1
...
---> ext/RMagick
no ruby extention exists: 'ruby setup.rb setup' first
Try 'ruby setup.rb --help' for detailed usage.

Thanks for the info, the bus error, the error code 6, the Error 1. That's all extremely fascinating and absolutely useless.

Yeah, I could keep googling, open another half dozen web pages, waste a couple more hours but I won't. I quit. Dealing with non-essential software at this level is simply just too massive a waste of time, and today is one of the rare days when the sun is shining.

Screw you *Magick, I don't really need you anyhow.

UPDATE: A pizza, a few pints and some distance later and *Magick is defeated instead. Solution: remove everything carefully. Forget every other link except this one: Really Truly Getting ImageMagick & RMagick Working on OSX from Source without Using MacPorts(DarwinPorts) or Fink. Download that shell script and run it. That oughta' do it.

Thank you LabRatz.

17 Feb 2007, 2:09pm
/dev/rails
by chris

Comments Off

The Singular of Data

I tend to use the noun "data" often in my database tables, often when a separate table stores the associated data to another object (ie: project.user and project.user_data). I also tend to think of the word "data" as being both the singular and plural of the same thing which tends to result in my typing

chris$ script/generate model user_data

when I want to create a new Rails model. However Rails then expects my database table to be called project.user_datas and thus my model fails.

The correct singular for "data" is "datum" and hence:

chris$ script/generate model user_datum