CSS Priming For Fun Part 2: CSSPrimer 0.1

A while back I did a small post on parsing HTML/XML files and extracting the ids and classes into a generated CSS file. I finally got around to refactoring and packaging it into a ruby gem. This can help you rapidly prototype your markup without having to write the CSS at the same time. Use the gem to generate a scaffold CSS file that you can then fill out. The generated CSS file can also be used as a template for generating multiple “themes” for your html/xml markup :-).

You can install the CSSPrimer gem  as usual with ruby gems.

–> gem install css_primer

For full documentation and examples check out the source code on github.

Next plans:

  • get a working Redcar plugin!
  • generating a CSS file from multiple html source files

CommunityEngine: The Play-Doh for a Rich, Functional and Decoupled Social Extension to any Rails application

Lately we have been working diligently on getting the Ripple Community website up and running. A daunting task in itself, not to mention alongside launching our flagship product The Ripple Emulator into Beta!

Our ideal goal was to find a solid and easy way to integrate a solution that could help save a lot of time researching and writing the social extensions of the site that we needed.

Eventually, we came upon CommunityEngine and promptly opted to integrate it.  A featured- packed, open source Rails plug-in that seemed to have what we needed including; forums, blogs; and much more. Currently it provides a very powerful, decoupled and extensible integration into your existing application. The end result:  we were able to deploy a full blown social media site for Ripple in about three weeks.

So far, we have been enjoying working with it. Models, views and controllers can be easily overridden or extended while keeping the plugin files unchanged and easy to update. A bonus for us was the use of Authlogic as the user authentication mechanism. Sweet, now all our previous User (model) code is just plug-and- play with the fused in User model from community engine’s implementation. Or  just override the User model to match your own needs.

Sending email with Gmail and Rails, while supporting multiple Ruby versions

Recently I have been working on a Rails app hosted on our deployment server (Heroku) and trying to get ActionMailer and Ruby working with Gmail’s SMTP service. The one catch is you need to use the TLS protocol and prior to Ruby 1.8.7 (Rails 2.3+) you need to write your own wrapper.

Heroku (still using 1.8.6 on some servers) had a nifty addon (now just a blog post and a Rails plugin) that has a TLS wrapper and configuration for ActionMailer’s  SMTP server settings. Awesome!

But… the plugin still fails to work on a platform with Ruby 1.8.7! Most notably my local development environment. Fortunately the internet is great and solutions can be found.

But… something inside of me still wanted to take advantage of the built in support. So I quickly went ahead and did just that and posted my changes to the Heroku google group (a working alternative to the plugin is mentioned here as well).

Hopefully this helps anyone looking for the same answers as me.

* Update *
Heroku just updated their platform (with a complimentary blog post) to support painless migration to updated deployment stacks (including 1.8.7 and 1.9.1).

Proxying HTTP Requests in Ruby

So building upon my other jaunts into Ruby I decided to post some code to make http requests to external urls. It could use come polish and there there is most definitely better mechanisms out there (probably a gem or two… or three) but tis fun to write well… code.

First, here is an example of using it.

require 'Proxy'
class HttpCaller
  include Proxy

caller = HttpCaller.new

response = caller.call "http://www.somewebsite.com"

if response[:error]
  puts response[:object].message
  response[:object].each_header do |key, value|
    puts "#{key}: #{value}"
  puts response[:object].code.to_s
  puts response[:object].body 

And I have posted the full code sample here.


Get every new post delivered to your Inbox.