Skip to content

Instantly share code, notes, and snippets.

View ralphm's full-sized avatar

Ralph Meijer ralphm

View GitHub Profile
@ralphm
ralphm / web_comment.tac
Created January 29, 2013 23:14
Twisted/Wokkel web comment bot that sends messages over XMPP.
"""
Web comment bot that sends messages over XMPP.
Run this with: twistd -ny web_comment.tac
"""
from twisted.application import service, strports
from twisted.words.protocols.jabber.jid import JID
from twisted.web import http, server, resource
from wokkel import client, xmppim
@ralphm
ralphm / result.json
Last active August 29, 2015 14:09
Boolean ES term filter
{
"bool": {
"must": [
{
"bool": {
"should": [
{
"term": {
"event": "delivered"
}
@ralphm
ralphm / udplog.json
Created February 11, 2015 20:33
Elasticsearch index template for UDPLog events
{
"template": "udplog-*",
"settings": {
"index.refresh_interval" : "5s",
"number_of_shards": 5,
"analysis" : {
"filter": {
"compound_word": {
"type": "word_delimiter",
"preserve_original": true
from twisted.internet import defer, reactor
from twisted.python import log
from twisted.trial.unittest import TestCase
class Tests(TestCase):
timeout = 5
def tearDown(self):
log.msg("hi")
@ralphm
ralphm / timeout.py
Created April 6, 2015 22:26
Cancel on timeout
from twisted.internet import defer, reactor
from twisted.python import log
from twisted.trial.unittest import TestCase
def foo(timeout):
"""
Actual code returning deferred than cancels its DelayedCalls.
"""
def canceller(d):
dc.cancel()
2015-05-29 17:47:05
Full thread dump OpenJDK 64-Bit Server VM (24.79-b02 mixed mode):
"ConsumerFetcherThread-logstash-reputation4_logs16.example.com-1432895708747-3a1151d3-0-3" prio=10 tid=0x00007fa56c008800 nid=0x9522 waiting on condition [0x00007fa53faec000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000e2807c10> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.LinkedBlockingQueue.put(LinkedBlockingQueue.java:349)

Keybase proof

I hereby claim:

  • I am ralphm on github.
  • I am ralphm (https://keybase.io/ralphm) on keybase.
  • I have a public key whose fingerprint is D5BF 034A D323 56B5 FCB1 A476 D91A D42A 4AB7 1678

To claim this, I am signing this object: