Blog Posts tagged with: open-source

Aug 24 2010

Comments

Introducing Errbit

Here at Relevance, we use Hoptoad for tracking exceptions in our Rails apps. It's great because it gives us a heads up when something goes wrong but it doesn't bury us with tons of email. So, when we found out we couldn't use it on one of our client's apps due to firewall and data confidentiality requirements, we were naturally upset, but we worked around it.

We ended up using a mix of Chatterbox and CapGun to track exceptions and deployments. While this works great, it requires a bit more configuration and doesn't have some of the features that we're used to with Hoptoad. What's a developer to do?

Needing a new project to work on for my Open Source Fridays, I decided to try to tackle this problem. As a result, I'm excited to announce Errbit, the open source, self-hosted error catcher.

Errbit is API-compatible with Hoptoad. This means you can just configure your Hoptoad notifier to send errors to your Errbit server.

It is a pretty standard Rails 3 app that uses MongoDB+Mongoid for the persistence layer. If you have experience with MongoDB and deploying Rails apps, it shouldn't be too much of a learning curve to get up and running.

Take it for a spin and let us know what you think. In the spirit of open source, feel free to fork it, contribute features, or white label it for a more personalized look that your clients will recognize.

Big thanks to Michael Parenteau for his awesome design work on the UI and of course to Relevance for giving me Fridays to make cool stuff.

Note: After developing Errbit, we discovered that Hoptoad does offer a "Hoptoad behind your firewall" solution. Definitely check it out if you want a fully supported exception notifier that has to sit behind a firewall.

Screenshots

  • Apps Index
  • Setup
  • App Show
  • Errs Index
  • Backtrace

Aug 23 2010

Comments

The Relevant Bits - 08/23/2010 Edition

What have we been doing with our "20%" time the past couple weeks? Read on to find out. It's been a busy couple of weeks in the Clojure and Ruby world for us.

  • The (first clojure-conj) was announced. This event is being organized by Clojure/core and Relevance, Inc. Make sure to sign up if you are interested in attending this fantastic opportunity.
  • Clojure/core released Clojure 1.2. If you've been waiting for the official version to be released, the time is now!
  • Alan has been organizing several successful Triangle Hackerspace meetups. Come on by on a Tuesday night if you are in the Triangle area!
  • Rob released a very early version of Nachos, a tool to help you keep all the git repos you care about in sync. Currently it just handles your GitHub watched repos, but feature requests are requested.
  • Shay organized an awesome DevNation in San Francisco, and even delivered a talk about "Getting to Minimum Viable Product."
  • Chris spent a week hanging out at EngineYard hacking on open source software with Carlhuda.
  • Aaron & Stuart S modularized Clojure contrib. Especially if you are a Clojure lib author, read this message.
  • Jason, Jess & Michael released the Venture Dojo website.
  • Stuart S has continued development on Lazytest, his BDD testing framework for Clojure. It is still in an alpha state, but worth checking out to see where he is going with it.
  • Michael released dribbble_desktop, a project for scraping rss feeds of shots from Dribbble.
  • Chad updated his Vimlander 2 config. In addition to other tweaks, he has brought the best Vim config up to MacVim 7.3 compatibility.
  • Aaron, Jon & Stuart H brought labrepl up to Clojure 1.2 goodness. If you are new to Clojure, this is a great way to learn!
  • Jared released version 0.4.4 of PDFKit. If you need to create PDFs, definitely take a look at this library.
  • Alan created a new project reconfig for Reloading configuration files in Clojure daemons.

Aug 02 2010

Comments

The Relevant Bits - 08/02/2010 Edition

Presenting this week's edition of "What We Did With our 20% Time." Lots of stuff to talk about from more awesome gem releases to getting closer to the official release of Clojure 1.2.

Jul 26 2010

Comments

The Relevant Bits

As Justin mentioned last week, here at Relevance we spend 20% of our time on non-billable activities. Here's a peek into some of the activities that went on at Relevance HQ this past week.

Jun 15 2010

Comments

Rethinking PDF Creation in Ruby

Every now and then, a requirement will come up in a project, that will make me second guess my career choice as a programmer. It usually involves making me go through tedious exercises, never knowing if I'll end up where I want to be along the way.

This happened a couple of weeks ago when one of our projects called for generating PDF reports. The reports needed many stylized elements, layouts, and dynamic graphs. If you've ever generated PDFs in Ruby before, you know that it can be both tedious and difficult using the standard go-to PDF libraries out there. Let's face it, we're web developers. Coming from HTML+CSS-based layouts, writing Ruby code for that stuff is a major pain.

To give you an idea of how heavy it can get, here's an example taken from Prawn. The example was ironically called simple_table.rb.

  Prawn::Document.generate("simple_table.pdf") do 

  table([["foo", "bar " * 15, "baz"], 
         ["baz", "bar", "foo " * 15]], :cell_style => {:padding => 12}) do
    cells.borders = []

    # Use the row() and style() methods to select and style a row.
    style row(0), :border_width => 2, :borders => [:bottom]

    # The style method can take a block, allowing you to customize 
    # properties per-cell.
    style(columns(0..1)) { |cell| cell.borders |= [:right] }
  end

  move_down 12

  table([%w[foo bar bazbaz], %w[baz bar foofoo]], 
        :cell_style => { :padding => 12 }, :width => bounds.width)

end

If you're scratching your head at this point, the code above generates a PDF with two simply styled tables. That's it. If you asked me to implement this in an app, I might have something half-way presentable in an hour. But, I could get a monkey, who just drank a whole bottle of scotch—don't ask about his drinking problem—to write two tables using HTML in less than 5 minutes.

A New Hope

Now some of you may be familiar with PrinceXML, which is a command line utility that will take HTML+CSS and give you back a beautiful PDF. It's even CSS2 compatible and passes the ACID2 test. Awesome. The only problem is that a single server license will set you back $3,800—which is prohibitively not awesome.

Being the open source zealots we are here at Relevance, we set out to find another solution. Tucked away in the internets, we stumbled across wkhtmltopdf. I know what you're thinking; awesome name, huh? wkhtmltopdf uses a WebKit rendering engine to make pretty PDFs out of HTML+CSS. Since it's leveraging WebKit, you get all the tasty CSS3 properties it supports. Ugly PDFs are suddenly a thing of the past.

Goodbye Prawn, Hello PDFKit

We were surprised that none of us had ever heard of wkhtmltopdf, considering how useful it is. When we looked for a Ruby library that leveraged it, we realized it didn't exist. Apparently not a whole lot of other people had heard of it either. That couldn't stand. A couple of open-source Fridays and several gallons of Mountain Dew later, we're excited to announce PDFKit, an open source library that makes working with wkhtmltopdf a snap.

Usage

Inline HTML+CSS => PDF

  kit = PDFKit.new("<h1>Oh Hai!</h1>")
  kit.stylesheets << '/path/to/pdf.css'
  kit.to_pdf # inline PDF
  kit.to_file('/path/to/save/pdf')

HTML file => PDF

  html_file = File.new('/path/to/html')
  kit = PDFKit.new(html_file)
  kit.to_pdf # inline PDF

Remote HTML => PDF

  kit = PDFKit.new("http://google.com")
  kit.to_pdf # inline PDF

What's the big deal?

If this hasn't sunk in yet, let's go over a quick list of wins this buys us:

  1. HTML+CSS - Assuming you're a web developer, there's a good chance that you already know HTML and can work with it efficiently.
  2. CSS3 - We get WebKit's CSS3 support for free. This means effects like drop shadows, rounded borders, transformations and others are super-easy. (Note: effects requiring blur radius do not work.)
  3. Testing - We have tools built into our normal workflow for testing HTML. You can even use Cucumber to drive the development of a PDF with PDFKit.

To give you an idea of how well this fits into our normal workflow here at Relevance, this is how we built out our PDF reports:

  1. Our designer mocked up a sample PDF and converted it to HTML+CSS.
  2. Using Cucumber to drive development, we created a controller action to generate this HTML view of the PDF. (It was just another URL in our app.)
  3. We added a screen-only stylesheet to the HTML that mimics the look of a PDF reader. This allowed us to get a feel of how it would look as a PDF.
  4. Using a bit of Rack Middleware that ships with PDFKit, we can get the PDF version of that web page by simply appending '.pdf' to the url.
  5. We're done. No crazy extra class to handle PDF rendering. No need to spend all day reading through docs to learn the obscure code and magic incantations required to generate your PDF.

Samples

  • PDF of google.com - PDF rendered from http://google.com
  • CSS3 Examples - Sample rendering of common CSS3 effects including border-radius, text-shadow, box-shadow, and border-image. Notice the lack of a blur radius on text-shadow and box-shadow.
  • Sample HTML page with PDF viewer CSS - Example of using a single HTML source to render both a screen version and a PDF version. Uses a media="screen" and media="all" to mark relevant CSS.
  • PDF generated from PDF viewer HTML - PDF generated from sample HTML above. You must tell PDFKit to only use print stylesheets in order to achieve this effect (PDFKit.new(html, :print_media_type => true)).

Go Forth and PDF

I encourage you to take PDFKit for a spin, let us know what you think, and even submit some patches.

If you are pumped about the possibility of using PDFKit on a future project, then I've achieved my goal. If not, I'd ask you to think about what is missing, find out if it's already out there, and let us know how to make PDFKit even better.

May 10 2010

Comments

Relevance Open-door Bug Mash Friday May 14

This Friday, May 14, Relevance Inc. is hosting a local bug mash in preparation for the Rails 3 BugMash May 15 & 16 organized by RailsBridge. We tip our hats to this worthy cause and hope to set a modest bar for the participants over the weekend.

Dan Pickett, who is coordinating the Rails 3 BugMash, recently challenged users to give back to the platform that has provided so much win for so many. At Relevance we certainly hear that message. Rails supports a significant portion of our work. It has been and continues to be one of the most progressive and dynamic platforms for programmers today. On top of that, it is fundamentally open source and thrives in a community of mutual collaboration.

In this spirit, we at Relevance pledge to donate our entire Friday to kick-starting the mashing festivities. Those bugs we target will be crushed not for prizes or glory, but out of gratitude to the platform and community. We are eager to see the magic that Rails 3 will produce and we hope to do our part to make that release the best it can be. If you will be in the area this Friday please feel free to stop by our office where there will be food, fun, and lots and lots of coffee.

You can find us at:
200 North Mangum St., Suite 204
Durham, NC, 27701

For more information, please contact us via email at info@thinkrelevance.com or by phone at 919-442-3030.

Aug 25 2009

Comments

Tarantula Supports Ruby 1.9

We're excited about Ruby 1.9. It's fast and stable, and brings nice improvements for programmers. But there are obstacles to adoption---mostly gems, plugins, and tools that don't support 1.9 yet.

So we're working on the things Relevance maintains, to get them on board. We're doing it by dog-fooding: We've got one customer project that we're actively testing on both 1.8 and 1.9 (although deployment is still on 1.8 for the moment). That's helping us see where the holes are, so we can fix them. We're already working on Ruby 1.9 support for RunCodeRun, and investigating the best way to interface rcov with 1.9.

Now one more piece of the puzzle is in place: on our last open-source Friday, Chad upgraded Tarantula to support Ruby 1.9. If you're trying out Rails on 1.9 (or even if you aren't), get the latest version (0.2.1) of tarantula from github:

gem install --source http://gems.github.com relevance-tarantula

Then add the plugin to your app and add some fuzz-testing goodness to it!

Popular Tags