Skip to content

Instantly share code, notes, and snippets.

@daixque
daixque / client.rb
Created February 25, 2012 14:55
RPC over AMQP (RabbitMQ)
require 'amqp'
class Client
def initialize
@config = {
:host => 'localhost'
}
end
def request(api, msg, reply_to)
@daixque
daixque / consumer.rb
Created February 20, 2012 09:32
Sample AMQP consumer/producer for RabbitMQ with direct exchange
require 'amqp'
def run
config = {
:host => 'localhost'
}
AMQP.start(config) do |connection|
channel = AMQP::Channel.new(connection)
queue = channel.queue('', :auto_delete => true)
exchange = channel.direct 'ex.direct'
@daixque
daixque / ArithmeticParser.scala
Created January 14, 2012 09:00
Arithmetic parser/evaluator written in scala using parser combinator
import scala.util.parsing.combinator._
abstract class Value {
def eval():Double
}
case class Number(n:Double) extends Value {
def eval():Double = n
}
case class Binomial(op: String, v1:Value, v2:Value) extends Value {
def eval():Double = op match {