unix & Ruby 23 Apr 2008 10:54 am

Specifying path for tidy rubygem

HTML Tidy is a library used to fix invalid HTML and give the source code a reasonable layout. It was developed by Dave Raggett of W3C, and is now maintained as a Sourceforge project. These are several versions of tidy available for various operating system. But the quickest way(not always easiest) to install on various unix systems are given below.

On debian based OS such as ubuntu, use apt-get to install

1
apt-get install tidy

On RPM based OS like fedora centOS, use yum to install

1
yum install tidy

On mac os x, use macports to install

1
port install tidy

For tidy to be used in ruby, a rubygem is available here. Just fire up gem install tidy to get it installed on your development machine. A nice documentation is provided here for reference.

1
gem install tidy

Usage:

1
2
3
4
5
6
7
8
9
10
11
12
  require 'tidy'
  Tidy.path = '/usr/lib/tidylib.so'
  html = 'Body'
  xml = Tidy.open(:show_warnings=>true) do |tidy|
    tidy.options.output_xml = true
    puts tidy.options.show_warnings
    xml = tidy.clean(html)
    puts tidy.errors
    puts tidy.diagnostics
    xml
  end
  puts xml

While I was working on tidy on my mac, I noticed the Tidy.path variable explained above did not work for me. I figured out an equivalent path to be used on mac,

1
  Tidy.path = '/usr/lib/libtidy.A.dylib'

Similar was the case with my production servers hosted on fedora/CentOS, I had to modify my path as

1
  Tidy.path = '/usr/lib/libtidy-0.99.so.0'

To use both paths on my development and production environment, I modified the line 2 in the example above as

1
2
3
4
5
  begin
    Tidy.path = '/usr/lib/libtidy-0.99.so.0'
  rescue LoadError
    Tidy.path = '/usr/lib/libtidy.A.dylib'
  end

Update:
If you’re getting the error:

1
/opt/ruby/ruby-1.8.6/lib/ruby/gems/1.8/gems/tidy-1.1.2/lib/tidy/tidybuf.rb:40: [BUG] Segmentation fault

Apply the following patch to fix it.

java & presentations & server & barcamp & Ruby on Rails 22 Feb 2008 01:09 am

JMeter - Presentation at Barcamp Delhi 3

The following is the presentation which I gave at BarCamp 3. You can download the pdf version here. Apache JMeter is a 100% pure Java desktop application designed to load test functional behavior and measure performance.

vinsol & presentations & server & mongrel & Ruby on Rails 22 Feb 2008 12:02 am

Monit - A tool for unix system management

Monit is another tool for monitoring you unix processes. A comprehensive documentation about monit can be found here. A brief introduction to monit, its usage and configuration with apache, mysql, mongrel & mongrel cluster, solr, capistrano has been discussed in the presentation below which I presented at vinsol. The pdf version of the following presentation can be downloaded from here.

 

delhi & barcamp 08 Dec 2007 12:07 pm

Yo !!! BarCamp Delhi 3

Barcamp Delhi 3 has just started.barCamp Logo

Visit the wiki page to get details about the event, sessions being held.

This is my very first barcamp. So, just feeling a bit excited. I have a presentation too on “Jmeter - Performance testing your webapp”.

Stay tuned to get update about the barcamp from the barcamp wiki.

No need to get discouraged if you are unable to make it to this barcamp. Links to the presentations/podcast/screencast will be made available on the wiki. once we are finished with the barcamp.

Ruby 22 Jul 2007 01:12 am

The Ni Dilli Ruby Meetup

Hello everyone !

Few days back I attended the Ni Dilli Ruby meetup held at VINSOL, New Delhi. It was the second meetup of the group held on 19th July with the first one being held on 22nd June. I really enjoyed the meetup. Manik’s presentation on search engine Solr and acts_as_solr plugin was really new to me. Sur’s presentation on “Advanced Ruby Skills” really helped to know ruby in deep.


Click here to check out
The Ni Dilli Ruby Meetup Group!
It was overall a nice experience to share. Thanks MJ. Thanks Sur.
Don’t forget to checkout the flickr photo gallery of the event.

Next Page »