This file contains hidden or 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
<script type='text/javascript' src='http://cdn.sockjs.org/sockjs-0.1.min.js'></script> | |
<script type='text/javascript' src='vertxbus.js'></script> | |
<script type="text/javascript"> | |
var eb = null; | |
window.onload = function() { | |
eb = new vertx.EventBus("http://localhost:8080/eventbus"); |
This file contains hidden or 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
# do gem install web-socket-ruby first | |
require 'web_socket' | |
require 'json' | |
client = WebSocket.new("ws://localhost:8080/eventbus/websocket") | |
message = {:name => "tim", :age => 29} | |
envelope = {:type => "send", | |
:address => "some-address", |
This file contains hidden or 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
var future = function(d) { | |
var obj = {}; | |
obj.val = 0; | |
setTimeout(function(){ obj.val=d;}, 5000); | |
return obj; | |
} | |
var result = future(4); |
This file contains hidden or 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 'em-synchrony' | |
require 'redis' | |
require 'redis/distributed' | |
require 'digest' | |
require 'redis/connection/synchrony' | |
EM.synchrony do | |
# this one fast | |
redis_hosts = ["redis://localhost:6379/1", "redis://localhost:6378/1"] |
This file contains hidden or 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
# is there a good pattern for this routine? | |
EM.synchrony do | |
size = keys.count | |
counter = 0 | |
# check if each iteration was completed | |
EM::add_periodic_timer( 2 ) do | |
next unless counter == size |
This file contains hidden or 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
# refactored version from http://redis.io/topics/mass-insert | |
def gen_redis_proto(*cmd) | |
cmd.inject("*#{cmd.length}\r\n") {|acc, arg| | |
acc << "$#{arg.length}\r\n#{arg}\r\n" | |
} | |
end |
This file contains hidden or 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
function A(name) { | |
this.name = name; | |
} | |
A.prototype.b = function(lastName) { | |
this.lastName = lastName; | |
console.log(this.name + " " + this.lastName); | |
} | |
a1 = new A("Howard"); |
This file contains hidden or 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
a = new A(); | |
b = new a.B(); | |
// how in 'b' have a refference to 'a'? |
This file contains hidden or 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
mkdir project1 | |
cd project1 | |
sbt | |
set name := "project1" | |
set version := "1.0" | |
set scalaVersion := "2.9.3" | |
session save | |
exit |
This file contains hidden or 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
package week7 | |
class Pouring(capacity: Vector[Int]) { | |
// States | |
type State = Vector[Int] | |
val initialState = capacity map (x => 0) | |
// Moves |