View gist:8df34f46cd73fbdeb2e8
val poolConfiguration = new PoolConfiguration( | |
maxIdle = 1000, | |
maxObjects = 5, | |
maxQueueSize = 5, | |
validationInterval = 1000 | |
) | |
val factory = new PostgreSQLConnectionFactory(configuration) | |
val pool = new SingleThreadedAsyncObjectPool[PostgreSQLConnection](factory, poolConfiguration) |
View gist:f81dabdf6f4098100078
%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): |
View gist:f196236fe5691873901e
/* 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 |
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
View gist:1123860
//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 |
View gist:1123843
//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 | |
}); |
View gist:1123852
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 |
View gist:1147979
# 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"); | |
}); |
View gist:1166306
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 ); |
View gist:1166304
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 ); |
OlderNewer