Archives
Tags
- General (18)
- Food (1)
- Cooking (1)
- Ruby (6)
- Rails (2)
- Svn (2)
- Linux (9)
- Git (1)
- Firefox (8)
- Porn (1)
- Freyja (1)
- Witchhammer (6)
- Music (1)
- Merb (3)
- Poetry (0)
- Bolverk (3)
- Sinatra (1)
- Discogs (1)
- Centos (1)
- Python (1)
- Whinging (2)
- Travel (2)
- Scheme (7)
- Lisp (8)
- Sicp (1)
- Rot13 (1)
- Czech (2)
- Metal (3)
- Passenger (1)
- Fun (5)
- Fractals (2)
- Plt (2)
- Clojure (1)
- Continuations (1)
- Javascript (1)
- Presentation (1)
ImageMagick and RMagick on Centos 5.3
Installing ImageMagick + RMagick seems to be a common source of problems. Here is my eventual solution.
I must admit, I'm not a huge fan of yum. And this latest experience has not helped my disposition. There is an ImageMagick(-devel) package in the repository, but it's very old now requires an earlier version of RMagick. I also found that it didn't work with the FileColumn Rails plugin ("Invalid image" error).
I recommend, for CentOS 5.x atleast, that you build ImageMagick from source.
0) Install all the dependencies (yum should be fine for these):
1) Grab ImageMagick and unpack it
$ wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz $ tar xvzf ImageMagick.tar.gz $ cd ImageMagick-x.x.x
2) Compile and install ImageMagick. Note, these are the flags I used for my own server. Use --help to see a full list of the options.
$ ./configure --prefix=/usr --disable-static --with-modules --without-magick-plus-plus --with-quantum-depth=8 $ make $ sudo make install
3) Play the waiting game. Or you can have a sword fight with an employee. :)
4) Install the latest version of the RMagick gem
$ sudo gem install rmagick
5) For good measure, open up IRB and see if it's installed correctly.
$ irb > require 'RMagick' > true
Good luck in your adventures, people.
Loading your Rails App independently
Yesterday I found myself in a position where some horrendously ugly code just became too much for me to handle. To cut a long story short, I needed to decouple a custom library from ActiveRecord. How did it get there in the first place, you ask? Please don't. It's a tragic story...
I set up an experimentation environment (in seperation from my working app), but of course, I needed to temporarily have full access to my models, controllers, etc, etc. Now, I use version control (who doesn't?) and I could have simply branched off and started hacking. But for shits-and-giggles, I decided not to.
I played around for a while and, as it turns out, it's very easy to load your application into an otherwise independent Ruby script. All you need is:
ENV['RAILS_ENV'] = 'development' require '/path/to/your/rails/app/config/environment'
Easy!
As a final note, it's worth pointing out that this is something that you should basically never need to do. If you simply want to automate something or perform an application-specific task, I highly recommend you write a raketask instead.