Archive for June, 2009

Rounding off floating point numbers in Ruby

Problem: If you want to round a floating point number off to two decimals, there is no standard method in Ruby that does it for you. Solution: The general solution is (f * 10**d).round.to_f / 10**d where f is the floating number and d is the number of decimals. See my code sample for adding […]

Turn On ArcSDE Logging

Problem: You want to log the traffic between the client (i.e. ArcMap) and an ArcSDE database. Solution: In the Command Window, write: >set SDEINTERCEPTLOC = c:\tempclient >c:\program files\arcgis\bin\arcmap.exe It’s important to start the client (ArcMap in the above example) from the command prompt. ArcMap will intercept the traffic and log it to temp files, named […]

Migrations and Environments in Ruby on Rails

Problem: You want to migrate a target environment other than development. Solution: For production: >rake environment RAILS_ENV=production migrate For test: >rake environment RAILS_ENV=test migrate

Redirect Pages in WordPress

Problem I want to move a page in a WordPress site to a different location, but I still want the old address to be active and instead redirect to the new address. Solution Unfortunatelly as per WordPress 2.7 there isn’t any standard functionallity to accomplish this, so the easiest way to go is to use […]

Capistrano: Subversion asks for password

Problem: When deploying a Ruby on Rails application using Capistrano and the command rake deploy, you get an error message similar to this: ** [out :: 192.168.0.200] Authentication realm: dev ** [out :: 192.168.0.200] Password for ‘hasse’: ** [out :: 192.168.0.200] subversion is asking for a password ** [out :: 192.168.0.200] Authentication realm: dev ** […]

Force a www Prefix

Problem: You want to force the World Wide Web prefix of your domain name, even though a page was requested without it. For example, if you would like all requests to http://hans-eric.com be redirected to http://www.hans-eric.com Solution: Solution from Alister Cameron. It works for Linux/Unix and requires .htaccess file access. In the web root directory […]