This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'connamara_api' | |
require 'serializer/protobuf/protobuf' | |
require 'pub/activemq/publisher' | |
include Connamara | |
## start | |
config = {'connect_string'=>"tcp://localhost:61616"} | |
api = ConnamaraAPI.run( config, Connamara::ProtoBuf, Connamara::AMQPublisher ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conf = {:host=>"127.0.0.1", :port=>2345, :api_info=>{:name=>:ruby_client, :vers=>"ruby-api.0.1"}, :user=>"user", :password=>"password"} | |
require 'connamara_api' | |
require 'pub/champ/publisher' | |
require 'serializer/erlbin/erlang_binary_term' | |
include Connamara | |
cp = ConnamaraAPI.run( conf, ErlangBinaryTerm, ChampPub ) | |
cp.subscribe(:Position) {|pos| puts 'pos ' + pos.inspect } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require "test/unit" | |
require 'mongoid' | |
class DT | |
include Mongoid::Document | |
field :birthday, :type => DateTime | |
end | |
class TestDT < Test::Unit::TestCase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra/base' | |
require 'eventmachine' | |
require 'thin' | |
EventMachine.run do | |
class Dude < Sinatra::Base | |
get '/' do | |
'oh hai' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api_event(start_comet, _, [ComentID]) -> | |
wf:comet(fun() -> up_loop() end, CometID); | |
api_event(send_msg, _, [CometID, Msg]) -> | |
wf:send(CometID, {msg, Msg}). | |
up_loop() -> | |
receive | |
{msg, Msg} -> error_logger:info_msg("OHAI JAVASCRIPT MSG ~p",[Msg]) | |
end, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{sys, [ | |
{lib_dirs, ["../deps","../../"]}, | |
{rel, "risk_scope", "1", | |
[ | |
kernel, stdlib, sasl, syntax_tools, compiler, xmerl,ssl,inets,crypto, | |
jsx, | |
rabbit_common, | |
amqp_client, | |
conn_domain, | |
champ_domain_server, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'data_mapper' | |
class Post | |
include DataMapper::Resource | |
property :id, Serial | |
before :save, :categorize | |
before :update, :categorize | |
before :create, :categorize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foldR: function(str, acc, fun) { | |
var i, | |
len = str.length, | |
for(i = 0; i < len; i++) { | |
acc = fun(acc, str.substring(len-i-1,len-i)); | |
} | |
} | |
isCreditCard( CC ) { | |
if (CC.length > 19) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(currentCard in CreditCard.CARDS) | |
var localCard = currentCard; | |
CreditCard['is'+currentCard] = function(number){ | |
return localCard.test(CreditCard.strip(number)); | |
}; | |
})(CreditCard.CARDS[currentCard]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(var currentCard in CreditCard.CARDS) | |
var card = currentCard; | |
CreditCard['is'+currentCard] = function(number){ | |
return card.test(CreditCard.strip(number)); | |
}; | |
})(CreditCard.CARDS[currentCard]); |
OlderNewer