Skip to content

Instantly share code, notes, and snippets.

@rferraz
rferraz / cometd_client.clj
Created February 5, 2012 06:12
Clojure CometD client example
(ns test.cometd-client
(:import (org.cometd.bayeux.client ClientSessionChannel$MessageListener)
(org.cometd.client BayeuxClient BayeuxClient$State)
(org.cometd.client.transport ClientTransport LongPollingTransport)
(org.eclipse.jetty.client HttpClient)))
(def channel-name "/my-channel")
(def client-url "http://localhost:8080/cometd")
@rferraz
rferraz / gist:1055255
Created June 29, 2011 23:20
Poker Hands
class Card
attr_reader :value, :suit
def self.parse(str)
if str =~ /^([2-9AJQK])([CDHS])$/
self.new($1, $2)
end
end
def initialize(value, suit)
ronaldo@minerva:~/Projects/rubinius$ [master] ./configure
Configuring LLVM...
Checking for existing LLVM tree: found!
Checking sizeof(long): 8 bytes
Checking platform endianness: little endian
Checking tr1/hash definition: found
Checking for function 'backtrace': found!
Checking for function 'readline': found!
Checking curses library: curses
; ModuleID = 'test'
@jumper = internal global [256 x i8] zeroinitializer
declare i32 @setjmp(i8*)
declare void @longjmp(i8*, i32) noreturn nounwind
define i64 @b() {
entry:
@rferraz
rferraz / 999_program.spell
Created January 22, 2011 21:17
A demo spell program
account (balance) = { balance: balance }
account#deposit (account amount) = { balance: account.balance + amount }
account#withdraw (account amount) =
? account.balance < amount -> error#signal "Insufficient funds!"
? _ -> { balance: account.balance - amount }
main () =
do