As part of the Ruby Summer of Code, Tim Felgentreff has been building out C extension support for JRuby. He's already made great progress, with simple libraries like Thin and Mongrel working now and larger libraries like RMagick and Yajl starting to function. And we haven't even reached the mid-term evaluation yet. I'd say he gets an "A" so far.
I figured it was time I talked a bit about C extensions, what they mean (or don't mean) for JRuby, and how you can help.
…presentation which also got a lot of traffic, and Jason posted about Compiling RMagick on OSX.
This led up to one ORUG meeting ( Orlando Ruby Users Group) in April 2006, when Jason and I started to wonder what it would be like if we took the format of the Apple commercials and instead of Mac vs Pc, it was Rails vs Everyone else. I wrote up most of the scripts, Jason helped with the comedy relief, and we paid one of Jason's friends (who had a film degree) to film …
…libraries: server side ones, flash and javascript. Since I don't want to depend on having neither RMagick nor Flash installed on the developer machine, I chose the javascript kind.
After some research I ended up with three libraries: g.raphael , flot and jqplot .
For RailsMetrics , I chose to use g.raphael since I can easily manipulate the objects it creates and it is the one which looks better (at least imho ). However it has poor documentation …
It seemed for a while that I had one of two options when it came to graphing with Rails: use gruff or use flash. Neither seemed very appealing to me. For starters, gruff requires the installation of Rmagick & Imagemagick, the former of which has garbage collection issues that can result in major memory leaks (though there are workarounds).
Furthermore, it does all the processing on the server, which can take about a second or more per request. The other option is a proprietary …
The RMagick project is looking for someone to take over maintenance. The project requires a moderately good C programmer who understands the Ruby C extension API and who is familiar with or is interested in becoming familiar with the ImageMagick MagickCore API. If you're interested email rmagick@rubyforge.org.
The block_helpers gem generates helpers similar to the form-builders, but for the general case.
Now Snow Leopard…
I just created a new server running a rails app using the wonderful Passenger plugin .
After I'd install all the gems needed, I still got errors like :
"no such file to load — RMagick ( MissingSourceFile)"
I tried doing a:
require ‘ RMagick'
in both IRB and the console and here it loaded fine. Then I suddenly remembered the last time I installed a server (I quickly forget silly errors since it's so easy to just google them), so I thought I'd …
…self-improvement and useful software blog .
I'll experiment more with shadows and other little customizations when required.
RMagick tutorials
I found the following links helpful while looking for information to do that:
Render great looking collages with ruby and rmagick
…because I didn't need the interactive features of flot and I didn't want to worry about RMagick needed for gruff , scruffy , or sparklines .
Google Charts API
The Google Charts API is an interesting tool that lets you dynamically generate charts using a "simple" URL scheme. The usage policy is very generous too: "There's no limit to the number of calls per day you can make to the Google Chart API."
This would allow me to offload …
Bad Idea. Ever heard anything about RMagick being a memory hog? Well, it's never a good idea to feed RMagick's addiction to hogged resources. And, having RMagick resize an image five time that could possibly be up to 5 megabytes in size is not a good idea. Duh, Phil.
So, what was the solution to the problem. After thinking about it for a bit, I arrived on the solution I moved forward with, and it appears to be working quite well. Here's a run-through of the plan I formulated …
We'll use linear interpolation again to compute a gradient of color and use RMagick to fill the discs representing the stations: def draw_station(image,x,y,available,total) gc = Draw.new availability_rate = 100.0*available/total red = interpolate(190,0,0,100,availability_rate) green = interpolate(230,0,100,0,availability_rate) gc.fill = "rgb(#{red},#{green},0)" gc.circle(x,y,x-Math.sqrt(total),y) gc.draw(image) end
Putting it all together
We use the following …