Ruby

Getting subtitles in sync

As an early new years resolution I'll start with sharing more of the snippets I code up to make my life easier. Here's one : the SRT subtitle scaler. It's a little ruby script to sync subtitles with a movie. I don't know how often one needs this, but I got some English subtitles on-line for a Chinese movie and I just couldn't get them to properly line up with the movie.

Scratching my Flickr itch with Nitro

I have somewhat neglected my English speaking audience, I must apologise. I've recently moved to Taiwan to study Mandarin, and my travellers journal will mostly be published on the Dutch side of this blog.

Before I left to Taiwan my grandmother gave me a beautiful little camera, and I've been taking pictures like a madman and posting them to my Flickr account. I would like to include these pictures into my blogposts, but I would like to use a specific HTML template, so I can easily style them with CSS, like so :

Converting FOAF to OPML

Soon my first professional contract comes to an end, and I will have time again to develop my newsfeed addiction.

Previously I used Bloglines, which is certainly one of the better on-line feed readers. I'm switching to a desktop feed reader however, I'm trying out Liferea.

Pinyin for Ruby 0.0.1 has been released

Today I released my very first public Ruby project!

Pinyin is a pure Ruby library with a specific focus : converting between various transliteration systems for Mandarin Chinese.

Over time various systems have been devised to capture the phonetics of the Chinese language, often as a teaching aid.

This is the first public release. Pinyin for Ruby can currently convert between five different systems, with more to come.

The daily Nitro

Important 2007-12-01 : This article is deprecated. The location of the repository changed and I haven't had the time to update my scripts to reflect this. With version 0.50 approaching an easier way of trying out Nitro is on the horizon. I'll write a new article soon that will supersede this one. If you need help getting Nitro up and running please ask advice on the Nitro mailing list.

Nitro update

Nitro is seeing some action again recently, which is mighty good, obviously. Nitro is a free software framework (under the liberal BSD licence) for building wep applications quickly, utilizing the lightweight Ruby language.

The 0.42 release is very outdated compared to the repo version, so we're all preparing for a dazzling 0.50.

Announcing Pinyin for Ruby

This is a little library I wrote to convert between various romanization systems for Chinese. It currently supports Hanyu pinyin, Wade Giles, Zhuyin Fuhao (BoPoMoFo) and IPA (international phonetic alphabet).

A number of different systems to represent tones are supported : numbers, stand alone tone marks, accents or no tones. Take note that not all combinations make sense. E.g. ipa + accents will not yield useful results. However, numbers and standalone marks can be used with any system.

To get it do this

The Nitro documentation buzz

I'm finding myself slowly emerged in the Nitro community. Nitro is a ruby framework for the rapid development of web applications. Another such framework, Ruby on Rails, has gotten a lot of press. The alternatives are less known :

  • Camping
  • IOWA
  • Ramaze
  • Nitro

Equality in Ruby

Just so you know:

  • == a.k.a. value equality
  • eql? a.k.a. value and type equality
  • equal? a.k.a. object identity
  • === a.k.a. case equality

Object identity should never be overridden. It compares object ids, always.

When overriding, start with value equality. If you're not doing type conversions then you can simply add "alias :eql? :==". I was surprised to learn that eql? doesn't call == or vice versa (by default).

Boyer-Moore string search algorithm in ruby

Update: I cleaned the code up a bit and added more comments.

I was looking for a fast algorithms to search for matching strings. Boyer-Moore seems to be a good choice. It has the peculiar property that it gets faster once you're looking for longer strings. Wikipedia: Boyer–Moore string search algorithm. This site also has a good explanation with graphical examples: Boyer-Moore algorithm

Syndicate content