codemonkey like you

Month: November, 2010

Pidgin2Adium and the next step

Pidgin2Adium is getting old. It’s certainly useful, and it’s by far the most-used piece of software I’ve created (and the only one people have emailed me about). But it has a couple of problems:

  • It’s based on a PHP script, and it shows. I’ve managed to move it to a more Rubyish, object-oriented program, but parts of the original PHP are still there, particularly the LogFile class.
  • Needs more tests. While it does have tests, they’re not as comprehensive as they could be, and when testing, the C extension needs to be recompiled for each Ruby version I test against (1.8.7, 1.9.1, 1.9.2, etc.), which is annoying. The next version should be written using TDD.
  • Two ways to use it. It’s (1) a library that parses Pidgin log files, and (2) a script that uses that parser to parse files, then writes them out in Adium format. This double functionality means that Pidgin2Adium should be split into 2 projects.

Therefore, I am happy to announce that I am working on a new project: a parser for chat log files (Pidgin, Adium, etc), called Chat Stew. Instead of just parsing Pidgin files, it will parse many programs’ log files, and will have a robust plugin system for 3rd party parsers, which will allow anyone to contribute a parser. This means that Pidgin2Adium 4.0.0 will no longer include a parser; instead, by using Chat Stew, it will become a much simpler, cleaner script with a smaller focus.

Sounds awesome! When will it be ready?

Chat Stew is currently under development, and probably won’t be released until January 2011 (alas, school…). In the meantime, I will continue to improve Pidgin2Adium.

Upcoming post on status of Pidgin2Adium

I’m going to be posting more about the current state of Pidgin2Adium and my plans for its next generation sometime this week or early next week. Stay tuned!

Pidgin2Adium 3.2.1 Released [UPDATED for 3.2.3]

UPDATE: 3.2.1 didn’t fix all of the problems. People should not use 3.2.1 or 3.2.2, since they were minor releases to fix the bug that 3.2.3 finally fixed. All of the information in this post applies to 3.2.3, not 3.2.1 or 3.2.2.

Pidgin2Adium 3.2.1 has been released. Get it now: gem install pidgin2adium.

This release parses more date/time formats than previous versions by using the built-in DateTime.parse command. It falls back to Date._strptime if DateTime.parse fails. This means that it should be faster than previous versions and more liberal in the date formats it parses.

Stupid Ruby Trick: Using a Hash to generate the Fibonacci Sequence

Via, which is in turn via Nick Quaranto.

The gist pointed out that, with its default values, is good for implementing Fibonacci sequences. So I decided to check:

fib = do |hash,key|
  k = key.to_i
  hash[key] = case k
    when 0 then 0
    when 1 then 1
    else hash[k-1] + hash[k-2]

This recursive (and memoized!) definition means that you can do fib[18] and get back 2584, plus you get the Fibonacci numbers from F0 (fib[0]) to F17 (fib[17]). Recursively defined Hashes are useful auto-memoized structures.