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
Badgeville.ready(function(){ | |
Badgeville.Comet.bind( function( event, message ) { | |
console.log('site notification'); | |
console.log( message ); | |
event_handler(message); | |
}); | |
Badgeville.bind( 'siteMessage', function( event, message ) { | |
console.log( message ); |
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
# On a back-end side | |
Comet.trigger("some_event", user, {:text => 'hello'}) | |
#on a front-end side | |
Badgeville.bind('some_event', function(data) { | |
console.log("Event handler here"); | |
}); |
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
def notify(message) | |
msg = JSON.dump('channel' => "/notifications/channel", 'data' => {'text' => message}) | |
uri = URI.parse('http://127.0.0.1:3333/faye') | |
Net::HTTP.post_form(uri, :message => 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
//download the lib from http://faye.jcoglan.com/download.html | |
var http = require('http'), | |
faye = require('./faye/faye-node.js'); | |
var bayeux = new faye.NodeAdapter({ | |
mount: '/faye', | |
timeout: 45 | |
}); |
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
//have to include http://127.0.0.1:3333/faye.js in the html file | |
var client = new Faye.Client('http://127.0.0.1:3333/faye', { timeout: 120 }); | |
var subscription = client.subscribe('/notifications/channel', function(message) { | |
alert(message.text); | |
}); | |
//or with user_id as a channel |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
/* Given a list of numbers 0 to 10,000, return all those whose digits sum up to 20 | |
* Digits cannot repeat. Search space should be reduced. | |
*/ | |
def get20s(): Seq[Seq[Int]] = { | |
val ns = for { | |
i <- 0 to 6 | |
j <- 1 to 7 | |
k <- 2 to 8 | |
if i + j + k == 11 |
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
%matplotlib inline | |
import md5, struct | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
import mmh3 | |
def md5hash(i): | |
return md5.new(str(i)).digest()[12:16] | |
def mm(i): |
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
val poolConfiguration = new PoolConfiguration( | |
maxIdle = 1000, | |
maxObjects = 5, | |
maxQueueSize = 5, | |
validationInterval = 1000 | |
) | |
val factory = new PostgreSQLConnectionFactory(configuration) | |
val pool = new SingleThreadedAsyncObjectPool[PostgreSQLConnection](factory, poolConfiguration) |
NewerOlder