Extending RedCloth with remote pygments for syntax highlighting

If you ever used pygments for syntax highlighting, you know it’s a marvelous thing. What happens when you can’t have Python installed on you server (like e.g. Heroku ) and yet still want to use it?

I tried serving pygments’ highlight method using simple HTTP requests on a remote Google Apps instance for use with Textile and the RedCloth gem. Here’s what I ended up with:

Serving pygments via HTTP requests.

In order to have a remote app serving Python exclusive functionality, I needed something cheap, reliable and persistent. Didn’t take me a long time before I chose the Google App Engine. The Google Apps Python SDK allows for simple HTTP requests processing using just a few lines of code. This, combined with using the pygments lexers and HtmlFormatter, lets easily return highlighted code inside the HTTP response:

Continue reading >

Setting up carrierwave file uploads using GridFS on Rails 3 and mongoid

I recently needed to set up a prototype on Heroku using MongoDB. After digging into the topic for some time I finally got it working. Hence this guide.

Since Heroku offer an Add-On for configuring your app with MongoHQ database, I immediately went for that and decided to use Mongoid. However, once you want to use file uploads with e.g. carrierwave, you realize that Heroku’s file system is read-only. You can go for Amazon S3 storage, but that’ll cost you extra. But wait - if you are using MongoDB, why not settle for GridFS? I found a tutorial written by Matsimitsu on jkreeftmeijer's blog, but employing MongoMapper and Rails 2.3.x made it obsolete and incompatible with my needs.

Continue reading >

Ever seen a blog without a first post?

I'll try to share things related to my work, which would be web development, especially Ruby, Rails and JavaScript.

Why is this here?

Being hugely inspired by my buddy @jkreeftmeijer from the Netherlands and his blog I realized I could use a place to put my thoughts down and maybe share stuff that could prove useful to someone else.