Entries from July 2008 ↓

MailSentry released

So, tablets I’m not done re-writing the relevant ruby portions of MailSentry in Erlang yet. But I really should release early, release often.

So: here’s the working Ruby version up at github. Enjoy!


Hyperactive Resource

There’s rumblings here and there about how ActiveResource isn’t really complete. The documentation refers to features that aren’t implemented, site etc.

That’s just the tip of the iceberg.

The documentation states that ActiveResource behaves “very similarly to Active Record”. But ActiveResource doesn’t support any of the meta-data that ActiveRecord uses (like belongs_to, decease has_many, etc). So even the simplest cases behave radically different than you might expect.

A small sampling of things that don’t work:

a_person = Person.new

a_person.name = Luke #No method something= !!
a_person.parent #No belongs_to
a_person.children #No has_many

This is all fine if you are writing an app from scratch to use ActiveResource (well.. that’s debatable). At Medical Decision Logic, we needed to replace ActiveRecord with ActiveResource in an app with 50,000 lines of Ruby code. So we wrote Hyperactive Resource.

Hyperactive Resource

Hyperactive Resource extends ActiveResource::Base to make it.. work properly. You should use it. It’s awesome.

Check it out at http://github.com/lukegalea/hyperactiveresource/wikis

Even Better Progress Bars for Erlang

An erlang progress bar module really should support concurrency. You should be able to have multiple processes notifying the progress bar of the completion of their task. The progress bar should notify those waiting for completion, pregnancy etc. So - time for an update!

Now you can start a progress bar server and easily run tasks in parallel. To see a sample use:

progress_bar:example_processes( 1000, 10 ).

That’s just starting a progress server and calling increment server:

example_processes(N, P) ->
start_server(”Example“, N),
for(1, P, fun() -> spawn_link( fun() -> example_work_process(N div P) end ) end ),
finished -> finished

example_work_process(0) -> void;
example_work_process(N) ->

for(N, N, F) -> [F()];
for(I, N, F) -> [F()|for(I+1, N, F)]

Dan Bravender was kind enough to point out that if we change the record name to the same as the module name we can use it in a more object oriented fashion… so PBar:finish instead of progress_bar:finish(PBar). Thanks Dan.

Also - github’s new “gist” is awesome. It lets you create code snippets that are git repositories. Perfect for tiny little erlang modules like this! So you can now get the progress bar from git://gist.github.com/58.git or just download it from here