Skip to content

Instantly share code, notes, and snippets.

import pypm
import time
def listdev(options):
for i in xrange(pypm.CountDevices()):
inf = pypm.GetDeviceInfo(i)
print '{0}.{default} api: {1}, name: {2}, input: {3}, output: {4}'\
.format(i, *inf, default='*' if options.device == i else ' ')
def serve(options):
@tailhook
tailhook / test2.py
Created December 12, 2010 18:15
test.py
import sys
import zmq
import time
import subprocess
import atexit
ctx = zmq.Context(1)
sock = ctx.socket(zmq.XREQ)
sock.bind('tcp://127.0.0.1:12345')
Route:
limits: &limits
method: !Array
element: !String ""
max-body-size: !Int
min: 0
default: 65536 # 64k
responses: &responses
Route:
# Common part
limits: &limits
method: !Array
element: !String ""
max-body-size: !Int
min: 0
default: 65536 # 64k
headers: !Mapping
from __future__ import print_function
import unittest
"""
Proof of concept of versionning database with minimum memory leaked.
Backend, which keeps data on disk should be still just transactional key-value
storage.
We use numbers as uids and fixed strings as value. In each
subsequent transaction we modify first character and character with number of
import sys
from PyQt4 import QtCore, QtGui, QtWebKit
def main():
app = QtGui.QApplication(sys.argv)
win = QtGui.QWidget()
vert = QtGui.QVBoxLayout(win)
tab = QtGui.QTabWidget(win)
view = QtWebKit.QWebView(win)
settings = view.settings() # self.webView is the QWebView
-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.4.10 (GNU/Linux)
hQEMAwJlKOG3XZX4AQf/TpjNhvCHjesNc364oAU6eQXU00EaoRkCkb1GUVN2Y1q4
hJlzbnvwjq1qjOzLORnmBR6risphrDvVRW6P++xpk8F+xYX8yZwhxJOBNT8Zb87s
uNPv6BWZDjlSs+t1s13Tyyc9LMeV8i9TFsQsfP6eRdRk2O10NBXBNrwKWC8XvdK/
L07V5comKFwW03UndBQUPWz2Vol8mq4a2/RQjlBDgXxvtsQr06MBR6M5ocQDPEiF
sLRL6YP+VUNTl0xmxv0cI3Y6mvrGujfuDZVttBhC6HIbt9403v5auu3eQVfF9tpk
AT7nFzDWxqxKNYrx7lVQ7IE5aQcX2KzjvJF6LmuAKtLAtwFjdgvimEglhqoh4V40
yugy3DwI6KSeGH5KUs3jYpFmIgHj1zawGoQZVy79FT6cwXTPFOy4oXjlopr+M9ls
#include <assert.h>
#include <zmq.h>
int main(int argc, char *argv[]) {
void *ctx = zmq_init(1);
assert(ctx);
void *sock = zmq_socket(ctx, ZMQ_PULL);
assert(sock);
int rc = zmq_connect(sock, "tcp://127.0.0.1:5555");
@tailhook
tailhook / onedc_to_twodc_upgrade.diff
Last active December 23, 2015 10:39
Diffs showing how complex (i.e. easy) it's to add a another cluster to the topology managed by rulens
diff -u examples/onedc/topology.yaml examples/twodc/topology.yaml
--- examples/onedc/topology.yaml 2013-09-19 15:17:42.546613699 +0300
+++ examples/twodc/topology.yaml 2013-09-19 14:49:10.519955115 +0300
@@ -81,6 +81,20 @@
# If worker p isi not in the list above, choose random balancer for it
default: random
+ cluster2:
+ layout: cluster
+ rule:
@tailhook
tailhook / estp_by_default
Created September 24, 2013 09:15
ESTP-formatted data from experimental branch of nanomsg
ESTP:mac:nanomsg.3045:socket.1:established_connections: 2013-09-24T09:10:44Z 10 0:c
ESTP:mac:nanomsg.3045:socket.1:accepted_connections: 2013-09-24T09:10:44Z 10 2:c
ESTP:mac:nanomsg.3045:socket.1:dropped_connections: 2013-09-24T09:10:44Z 10 0:c
ESTP:mac:nanomsg.3045:socket.1:broken_connections: 2013-09-24T09:10:44Z 10 1:c
ESTP:mac:nanomsg.3045:socket.1:connect_errors: 2013-09-24T09:10:44Z 10 0:c
ESTP:mac:nanomsg.3045:socket.1:bind_errors: 2013-09-24T09:10:44Z 10 0:c
ESTP:mac:nanomsg.3045:socket.1:accept_errors: 2013-09-24T09:10:44Z 10 0:c
ESTP:mac:nanomsg.3045:socket.1:messages_sent: 2013-09-24T09:10:44Z 10 0:c
ESTP:mac:nanomsg.3045:socket.1:messages_received: 2013-09-24T09:10:44Z 10 291:c