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
#!/bin/bash | |
_exit() { | |
echo "CTRL + C pressed, exiting." | |
exit 0 | |
} | |
trap _exit INT | |
read -p "Password: " -s PASSWORD |
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
from application.system import host | |
class Foo(object): | |
def __init__(self, host_ip=None): | |
self.host_ip = host_ip or host.default_ip | |
for host in range(10): | |
print host | |
f = Foo() | |
print f.host_ip |
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
# Derived from: http://paste.pocoo.org/show/407530/ | |
import sys | |
import imp | |
import urllib2 | |
import urlparse | |
class WebImporter(object): |
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
# Derived from: http://paste.pocoo.org/show/407530/ | |
import sys | |
import imp | |
import urllib2 | |
import urlparse | |
class WebImporter(object): |
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
# producer | |
import zmq | |
context = zmq.Context() | |
socket = context.socket(zmq.PUB) | |
socket.setsockopt(zmq.LINGER, 0) # discard unsent messages on close | |
socket.connect('tcp://127.0.0.1:5000') | |
while True: |
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
# consumer | |
import zmq | |
context = zmq.Context() | |
socket = context.socket(zmq.SUB) | |
socket.bind('tcp://127.0.0.1:5000') | |
socket.setsockopt(zmq.SUBSCRIBE, 'test') | |
socket.setsockopt(zmq.SUBSCRIBE, 'topic_1') |
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
# producer | |
import os | |
import random | |
import threading | |
import time | |
import zmq | |
context = zmq.Context() |
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
# producer | |
import zmq | |
context = zmq.Context() | |
socket = context.socket(zmq.PUB) | |
socket.setsockopt(zmq.LINGER, 0) # discard unsent messages on close | |
socket.connect('epgm://239.192.1.1:5000') | |
while True: |
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
# consumer | |
import zmq | |
context = zmq.Context() | |
socket = context.socket(zmq.SUB) | |
socket.connect('epgm://239.192.1.1:5000') | |
socket.setsockopt(zmq.SUBSCRIBE, 'test') | |
socket.setsockopt(zmq.SUBSCRIBE, 'topic_1') |
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
<html> | |
<head> | |
<title>ZWS Example</title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" ></script> | |
<script language='javascript'> | |
$(document).ready(function() { | |
var ws = new WebSocket("ws://localhost:9999/test"); | |
ws.onmessage = function(evt) { | |
$('#output').append(evt.data+'<br />'); |