Posts filed under 'Our Software'

Diff for Javascript, revisited

Last weekend I finally revisited the diff-in-javascript code I’d written a couple of years back, adding (very simple) patch-like and diff3-like functionality.

On the way, not only did I discover Khanna, Kunal and Pierce’s excellent paper “A Formal Investigation of Diff3“, but I found revctrl.org, the revision-control wiki, which I’m just starting to get my teeth into. I’m looking forward to learning more about merge algorithms.

The code I wrote last weekend is available: just download diff.js. The tools included:

  • Diff.diff_comm - works like a simple Unix comm(1)
  • Diff.diff_patch - works like a simple Unix diff(1)
  • Diff.patch - works like a (very) simple Unix patch(1) (it’s not a patch on Wall’s patch)
  • Diff.diff3_merge - works like a couple of the variations on GNU’s diff3(1)

Read on for some examples showing the library in action.

Continue Reading Add comment May 9th, 2008 tonyg

STOMP adapter updated for RabbitMQ 1.3.0

I’ve updated our STOMP adapter for RabbitMQ to fix a bug reported by Carl Bourne. In the process, I updated the code to work with the latest snapshots of RabbitMQ, including the currently-released version, v1.3.0.

You can get the code by checking it out from our repository with

hg clone http://hg.opensource.lshift.net/rabbitmq-stomp/

or you can instead download a snapshot of the current state of the adapter[1], currently at revision 392d8cc8449c.

Here’s a summary of how to build and run a STOMP-enabled RabbitMQ broker - for more details, see the original post on the topic:

  1. First, retrieve the RabbitMQ server 1.3.0 source code, and unpack it:
    curl http://www.rabbitmq.com/releases/source/rabbitmq-1.3.0.tar.gz | tar -zxvf -

  2. Next, grab the latest STOMP adapter:
    curl http://hg.opensource.lshift.net/rabbitmq-stomp/archive/rabbitmq_v1_3_0_branch.tar.gz | tar -zxvf -

  3. Compile the server itself:
    make -C rabbitmq-1.3.0/erlang/rabbit

  4. Finally, compile the adapter, and start the server with extra options that cause the adapter to start too:
    make -C rabbitmq-stomp-rabbitmq_v1_3_0_branch run

If this is successful, you should end up with “starting STOMP-listeners …done” and “broker running” in your terminal. At this point you can try out the service - for instance, you can run Carl’s test cases if you have ruby and rubygems handy:

sudo apt-get install ruby
sudo apt-get install rubygems
sudo gem install stomp
ruby rabbitmq-stomp-rabbitmq_v1_3_0_branch/priv/tests-ruby/cb-receiver.rb

and in another window

ruby rabbitmq-stomp-rabbitmq_v1_3_0_branch/priv/tests-ruby/cb-sender.rb

It will transfer 10,000 short messages, and end up displaying

...
Test Message number 9998
Test Message number 9999
All Done!

in the receiver-side terminal.

If you’re interested in the gory details of the bug-fix itself, you can see the relevant patch here. The problem was that the code that handled abrupt socket closure wasn’t handshaking with enough of the internals of the server to ensure that the last few work items were being processed successfully. Trapping socket closure in the STOMP adapter code, and politely handshaking, turned out to be all that was required. An alternative workaround would be to use STOMP’s DISCONNECT method before closing the socket on the client side.


Footnote 1: Note that despite the misleading URL, the snapshot download really is of the STOMP adapter, and not of the broker itself! I’m making use of hgwebdir’s archive-download feature here.

Add comment April 30th, 2008 tonyg

Rabbit Facts

Apropos of RabbitMQ

  • In Native American Ojibwe mythology, Nanabozho, or Great Rabbit, is an important deity related to the creation of the world
  • The term kit or kitten has been used to refer to a young rabbit. A group of young rabbits is referred to as a kindle
  • Varron (116 to 27 BC) suggested that rabbits be kept in leporaria, stone-walled pens or parks
  • The physiology of the rabbit digestive system is such that they are not able to vomit
  • The Greek for rabbit is Lago, while the Latin is cuniculus
  • In Central Africa Kalulu the rabbit is widely known as a tricky character, getting the better of bargains
  • Rabbits are small mammals in the family Leporidae, of the order Lagomorpha. There are many species of rabbit, and these, along with cottontails, pikas, and hares, make up the order Lagomorpha
  • The smallest rabbit is the pygmy rabbit (Brachylagus idahoensis)
  • The only auditory signal known for most species is a loud foot thump made to indicate alarm or aggression. Notable exceptions are the Amami rabbit and the Volcano rabbit of Mexico, which both utter a variety of calls
  • A male rabbit is a buck
  • Newborn rabbits are naked, blind, and helpless at birth (altricial)
  • Breeding rabbits for meat is called cuniculture
  • In Aztec mythology, a pantheon of four hundred rabbit gods known as Centzon Totochtin, led by Ometotchtli or Two Rabbit, represented fertility, parties, and drunkenness
  • Their urine, being high in nitrogen, makes lemon trees very productive
  • The Romans ate newborn rabbits, which they called laurices

5 comments March 4th, 2008 andy

Using AMQP to do cron-like scheduling

Barry Pederson’s excellent py-amqplib Python AMQP client comes with a very cute little demo, demonstrating how easy it is to do sophisticated cron-like things with AMQP and RabbitMQ.

As Barry writes in the example, the trick is to “[fire] off simple messages at one-minute intervals to a topic exchange named ‘clock’, with the topic of the message being the local time as ‘year.month.date.dow.hour.minute‘, for example: ‘2007.11.26.1.12.33′, where the dow (day of week) is 0 for Sunday, 1 for Monday, and so on (similar to Unix crontab). A consumer could then bind a queue to the routing key ‘#.0′ for example to get a message at the beginning of each hour.”

Lovely!

1 comment February 8th, 2008 tonyg

How to run RabbitMQ’s experimental STOMP adapter

The code for the experimental STOMP adapter for RabbitMQ is distributed separately from the main server, at the moment. This post walks through the steps needed to try the adapter out, running it against a recent snapshot release of RabbitMQ. The perl Net::Stomp STOMP client is used to demonstrate the adapter in action, subscribing to a queue and sending a couple of messages to it.

Continue Reading 6 comments February 2nd, 2008 tonyg

New .NET/C# client library for RabbitMQ

We’ve just finished and released our .NET/C# client library for AMQP. We developed it on Mono, and made sure it ran on the Microsoft .NET stacks as well - versions 1.1 and 2.0. There’s also a WCF binding, for exposing WCF-based services over AMQP. (The WCF binding only compiles and runs on the Microsoft CLR implementations, until Mono’s Olive WCF implementation matures a little, anyway.)

One interesting thing about the library is its support for more than just one protocol variant: it speaks AMQP 0-8 as standardised, AMQP 0-8 as extended by QPid, and AMQP 0-9 as standardised (sans the bits of the spec marked “work in progress”, ie. the Message class). You can switch protocol variants at runtime, and there’s a common interface that abstracts away from the incompatibilities in the protocol variants. We’ve run the library against RabbitMQ (of course), as well as QPid-java and OpenAMQ 1.2c4.

The library is documented in a PDF user guide, which actually contains quite a bit of useful general AMQP information and guidelines, and could form the core of a language-neutral RabbitMQ manual. The detailed API guide is also available - you can download the code, the binaries, and all the different reformattings of the documentation on the interim page for the .NET/C# client library.

Our RabbitMQ website is starting to look a bit messy, so we’re working on a revised layout that should be a bit tidier; then, the .NET stuff will be presented alongside all the other client libraries and bindings we have available, rather than being presented as a separate-looking piece.

4 comments January 30th, 2008 tonyg

NDocProc bug fix for empty namespaces

Thanks to a comment from Claus, I’ve discovered the wonderful fact that null is not permitted as a key in an IDictionary in .NET. As it happens, the main problem was that I’d not covered namespaceless classes in NDocProc at all gracefully, but nonetheless, forbidding nulls as dictionary keys is a strange design decision.

I’ve fixed the bug, and now NDocProc handles types with no namespace much more gracefully. I’ve updated the darcs repository:

darcs get http://www.lshift.net/~tonyg/ndocproc/

and there’s a snapshot (source and binary) available, as well: ndocproc-200801211208.zip

Add comment January 21st, 2008 tonyg

Erlang SMTP code updated

A couple of months ago, I improved our erlang SMTP server code.

  • Mon Oct 15: Support callbacks and more of the spec.

    Support multiple forward paths. Support callbacks for verification and delivery. Pass domain as well as mailbox for reverse and forward paths. Cope with improper line termination. Log failures in delivery/verification callbacks.

  • Wed Oct 17: Split out smtp_util:strip_crlf; be RFC2821-strict about CRLF

The code is available by browsing or through darcs:

darcs get http://www.lshift.net/~tonyg/erlang-smtp/

1 comment December 28th, 2007 tonyg

Astral Plane characters in Erlang JSON/RFC4627 implementation

Sam Ruby examines support for astral-plane characters in various JSON implementations. His post prompted me to check my Erlang implementation of rfc4627. I found that for astral plane characters in utf-8, utf-16, or utf-32, everything worked properly, but the RFC4627-mandated surrogate-pair “\uXXXX” encodings broke. A few minutes hacking later, and:

Eshell V5.5.5  (abort with ^G)
1> {ok, Utf8Encoded, []} =
        rfc4627:decode("\"\\u007a\\u6c34\\ud834\\udd1e\"").
{ok,<<122,230,176,180,240,157,132,158>>,[]}
2> xmerl_ucs:from_utf8(Utf8Encoded).
[122,27700,119070]
3> rfc4627:encode(Utf8Encoded).
[34,122,230,176,180,240,157,132,158,34]
4> 

Much better.

You can get the updated code using darcs:

darcs get http://www.lshift.net/~tonyg/erlang-rfc4627/

Add comment November 16th, 2007 tonyg

NDocProc updated for C# 2.0 with Generics

NDocProc, our small and simple .NET javadoc-like documentation generator, has been updated for C# 2.0 and Generics.

Changes since the previous announcement include:

  • Support for generics, nested types, arrays, delegates, events, and the intersection of them all.
  • Now requires .NET 2.0 or Mono 2.0 to build.
  • Support for slightly more of the XML documentation language used in .NET documentation comments.
  • Better formatting of namespace pages, and summaries on the main index page.

The project homepage is here. You can download a zip of the latest version, or use darcs to check out the repository:

darcs get http://www.lshift.net/~tonyg/ndocproc/

5 comments November 7th, 2007 tonyg

Previous Posts

Calendar

May 2008
M T W T F S S
« Apr    
 1234
567891011
12131415161718
19202122232425
262728293031  

Posts by Month

Posts by Category