Skip to content

Instantly share code, notes, and snippets.

View SupermanScott's full-sized avatar

Scott Reynolds SupermanScott

View GitHub Profile
reduce_function = bson.Code(
"function (key, values) {"
" var result = { tf: 0, df: 0};"
" values.forEach(function(value) {"
" result.tf += value.tf;"
" result.df = value.df;"
" });"
" return result;"
"}")
map_function = bson.Code(
"function () {"
" for (var i=0; i < this.matches.length; i++) {"
" var match = this.matches[i];"
" var data = {tf: match.term_fq, df: this.document_fq};"
" emit(this.matches[i].doc_id, data);"
" }}")
term_document = dict(
term=token,
matches=[dict(
doc_id=document_id,
field_name=field_name,
original_word=original_word,
term_fq=frequency)],
document_fq=1)
for token in self.tokenizer(doc.get(field_name, '')):
original_word = token
for analyzer in self.analyzers:
token = analyzer(token)
processed_tokens[token] = processed_tokens.get(token, 0) + 1
import redis
import logging
import redislog
import redislog.logger
logging.setLoggerClass(redislog.logger.RedisLogger)
LOGGING = {
'version': 1,
'formatters': {
'default': {
@SupermanScott
SupermanScott / gist:1658422
Created January 22, 2012 19:40
Python Redis Logger
>>> from redislog import handlers, logger
>>> l = logger.RedisLogger('my.logger')
>>> l.addHandler(handlers.RedisHandler.to("my:channel", host='localhost', port=6379, password='foobie'))
>>> l.info("I like pie")
>>> l.error("Trousers!", exc_info=True)
@SupermanScott
SupermanScott / gist:1658416
Created January 22, 2012 19:37
Very simple Javascript Server Side Event Example
var source = new EventSource('/events');
// Where on_message is some Javascript function to handle the message
source.addEventListener('message', on_message);
@SupermanScott
SupermanScott / gist:1658409
Created January 22, 2012 19:35
Tornado Server-Sent Event handler
class SSEHandler(tornado.web.RequestHandler):
def initialize(self):
self.set_header('Content-Type', 'text/event-stream')
self.set_header('Cache-Control', 'no-cache')
def emit(self, data, event=None):
"""
Actually emits the data to the waiting JS
"""
response = u''
@SupermanScott
SupermanScott / gist:1658402
Created January 22, 2012 19:33
Tornado Redis PubSub handler
class TornadoPubSub(redis.client.PubSub):
"""
PubSub handler that uses the IOLoop from tornado to read published messages
"""
_stream = None
def listen(self):
"""
Listen for messages by telling IOLoop what to call when data is there.
"""
if not self._stream:
diff --git a/html/sites/all/modules/contrib/notifications/notifications_content/notifications_content.module b/html/sites/all/modules/contrib/notifications/notifications_content
index 3628cff..38232c8 100644
--- a/html/sites/all/modules/contrib/notifications/notifications_content/notifications_content.module
+++ b/html/sites/all/modules/contrib/notifications/notifications_content/notifications_content.module
@@ -726,9 +726,13 @@ function notifications_content_nodeapi(&$node, $op, $arg = 0) {
function notifications_content_comment($comment, $op) {
// $comment can be an object or an array.
$comment = (object)$comment;
+ static $update_published_before = FALSE;
+ if ($op == 'update') {