Tips 'n Tricks

Rails tip - run FCGI if you can't do Mongrel

Tags: 

A small tip, but one I just encountered. If your web hosting provider can't allow you to set up a nice proxied Mongrel cluster, your best bet is to use the FastCGI (aka "FCGI") interface to Apache as the plain-Jane CGI interface is just slow as a dog. I ran into this little issue when using RedMine for my project management, and let me tell you it was slow. Well, it finally dawned on me to take a look see if it was using CGI or FCGI - low and behold by default it is set to use CGi, no wonder it was so slow! All it took to give it a 3x speed boost, i.e. make it run like a regular app, was to edit the public/.htaccess file and change the line that said

RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

to say

RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

et voila, RedMine instantly turns into a much more usable application.

Rails on OSX tip: MySQL access

Tags: 

After wasting lots of time trying to get a database connecting to Rails on my MacPro at work I finally found the magic combination for MySQL.

  • Install MySQL.
  • Install the MySQL GUI Tools set.
  • Using the MySQL Administrator from the GUI Tools add a new user.
  • When adding permissions for the use set the hostname to be "(computername).local", e.g. "mymac.local".

It is that last part that had me pulling my hair out - using just "%" didn't work for me, it had to be "(computername).local". Silly thing.

MySQL + Rails on Cygwin tip

Tags: 

Here's a really quick tip for anyone using Rails on Cygwin. If you want to connect to a MySQL database the understood practice is to compile MySQL and go through the hassle of getting it all working within Cygwin itself. After what I've gone through with it all, the best way of getting this combination to work is to:

  • Install MySQL under Windows itself rather than Cygwin.
  • Make sure that the MySQL binaries are in your system path under Windows and, if installing via SSH, restart the Cygwin SSH service so that your login will be able to see the new path.
  • When installing the MySQL gem (gem install mysql) select the mswin32 option rather than the pure Ruby option.
  • Now, when you define your database connections just give the machine's IP address instead of saying "localhost" and it'll work great!

After wasting several days getting it all to work the "proper" way, the above is a much cleaner solution.

IE bug - background images, floating blocks

Tags: 

There's a bug in all versions of Internet Explorer, including the latest IE7, whereby if you have a floating block in a block inside another block which has a background image (possibly also background colors), text will disappear. I was hitting this at work where we had two columns created using floating blocks, inside two separate blocks that each had a background image, and just above the columns was a heading - the text within the columns showed up but the heading always disappeared after the images finished loading. While there are some detailed explanations of why this bug happens, nothing quite explained my scenario or had a fix for it. Well, after poking around with it for a while I came up with a nifty fix: I put the heading inside a DIV that was set to 100% and floating to the left, which worked wonderfully!

Most important thing for ColdFusion development

Tags: 

After working with Adobe's ColdFusion for several years I've come to the conclusion that the single most important thing that a developer can do is use the CFQUERYPARAM tag. This single tag can help prevent many security problems as it will automatically work out how to pass the variable into the database based on the type of data you say it is, e.g. strings will get the proper quotation marks around it, dates will have pound signs added if needed, etc, etc. Wonderful stuff and one of ColdFusion's best features.

Pages

Subscribe to Tips 'n Tricks