Currently Browsing: Ruby on Rails

Sync a database with Capistrano

Here’s a quick capistrano task for synchronizing a remote database to your local development environment:   set :application, "appname" set :application_path, "/home/someurl/apps" set :user, "appuser" set :password, "***********" set :use_sudo, false   set :production_database,'mydb_production' set :production_dbhost, 'localhost' set :dbuser, 'dbadmin' set :dbpass, '************'   desc "Synchronizes remote database to local development database" task :sync_to_local, :roles => :web do sql_out =...

Painless db backups in Rails

Quite often in Rails projects, I need some way to backup the contents of database quickly. The script below is an easy way to backup the database of your current environment using the database.yml file already set up in your Rails project. Feel free to modify the below script to do your bidding. /script/backup_db: #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'erb' require 'yaml'   unless config = YAML::load(ERB.new(IO.read(RAILS_ROOT + "/config/database.yml")).result)[RAILS_ENV] abort "No database found...

Automated image sharpening

The Problem Working in an agency setting, where the crispness and clarity of your images is extremely important, writing web systems that automatically generate thumbnails can be problematic. When resizing images downwards, as is often the case in thumbnail generation, pixel values are approximated from their original size. These approximations can result in thumbnail images which are blurry and difficult to read. The bigger the change in pixel size, the more dramatic the effect. So if you resize a 900×900px image into 120×120, you will see a major difference in clarity. Photoshop has several...

5 Reasons to Use Rails

One axiom overheard constantly throughout the blogs and forums of the internet’s technorati, is “use the right tool for the job.” Generally this nugget is brought up in conversations questioning whether one should use framework A or framework B, language C or language D, etc… Invariably, people get pissed, comments get ridiculous, and “that guy”:http://www.geekitude.com/Pictures/Linucon2004/Ex45TronUpCloseRot.jpg eventually shows up to tell everyone that they’re retards for not using Lisp. This is not one of those articles. Having spent too much of my life...