Skip to content

Instantly share code, notes, and snippets.

@yankov
yankov / gist:1123843
Created August 3, 2011 21:38
Faye node.js server
//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
});
@yankov
yankov / gist:1123852
Created August 3, 2011 21:41
Sending message to faye server from ruby
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
//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
# 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");
});
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 );
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 );
{
'contents': [
{'content_id' : 1, 'content_url' : 'url'},
{'content_id' : 2, 'content_url' : 'url2'},
],
'result' : [existing_array] //something that we return right now
}
[
-{
-data: {
-result: {
points: 1
}
+activity: { … }
rewards: [ ]
+user: { … }
}
[
-{
-data:
{
+result: { … }
+activity: { … }
rewards: [ ]
+user: { … }
}
}
11/10/18 23:28:46 INFO mapred.JobClient: map 0% reduce 0%
11/10/18 23:29:10 INFO mapred.JobClient: Task Id : attempt_201110180937_0045_m_000000_0, Status : FAILED
Error: java.lang.InstantiationError: org.bson.BSONDecoder
at com.mongodb.hadoop.io.BSONWritable.readFields(BSONWritable.java:167)
at org.apache.hadoop.io.WritableComparator.compare(WritableComparator.java:97)
at com.mongodb.hadoop.io.BSONComparator.compare(BSONComparator.java:41)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.compare(MapTask.java:1110)
at org.apache.hadoop.util.QuickSort.fix(QuickSort.java:30)
at org.apache.hadoop.util.QuickSort.sortInternal(QuickSort.java:83)
at org.apache.hadoop.util.QuickSort.sort(QuickSort.java:59)