Skip to content

Instantly share code, notes, and snippets.

@dsuch
dsuch / zato_pymqi.py
Created April 21, 2015 11:02
PyMQI directly under Zato
from zato.server.service import Service
class MyService(Service):
def handle(self):
import pymqi
queue_manager = 'IDM'
@dsuch
dsuch / client.py
Created May 22, 2015 11:19
Obtaining self.broker_client without self
# stdlib
import gc
# Zato
from zato.common.broker_message import SERVICE
from zato.common.util import new_cid
from zato.server.base.parallel import ParallelServer
from zato.server.service import Integer, Service
@dsuch
dsuch / gist:1961505
Created March 2, 2012 21:22
SimpleBunch vs. Bunch vs. dict
# -*- coding: utf-8 -*-
# stdlib
from timeit import Timer
# Bunch
import bunch
d = {1:11, 2:22, 3:33}
b = bunch.Bunch(d)
@dsuch
dsuch / gist:2828049
Created May 29, 2012 11:58
Decompress any archive in Python
# pip
from pip.download import unpack_file_url
class _DummyLink(object):
""" A dummy class for staying consistent with pip's API in certain places
below.
"""
def __init__(self, url):
self.url = url
@dsuch
dsuch / q209225.c
Created September 21, 2012 15:39
MQCMD_SET_AUTH_REC in C
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <cmqc.h> /* MQI */
#include <cmqcfc.h> /* PCF */
#include <cmqbc.h> /* MQAI */
void check_call_result(MQCHAR *, MQLONG , MQLONG );
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
# gevent
from gevent import sleep
# Zato
from zato.common.broker_message import SERVICE
from zato.common.util import new_cid
@dsuch
dsuch / uncamelify.py
Created February 11, 2013 14:08
A Python function to uncamelify CamelCaseNames
# Use it under the Python license
import re
_uncamelify_re = re.compile(r'((?<=[a-z])[A-Z]|(?<!\A)[A-Z](?=[a-z]))')
# Inspired by http://stackoverflow.com/a/9283563
def uncamelify(s, separator='-', elem_func=unicode.lower):
""" Converts a CamelCaseName into a more readable one, e.g.
will turn ILikeToReadWSDLDocsNotReallyNOPENotMeQ into
@dsuch
dsuch / install.sh
Last active December 17, 2015 18:29
Zato 1.0 install.sh for Mac OS X
#!/bin/bash
#
# Taken from https://gist.github.com/josephwecker/2884332
#
CURDIR="${BASH_SOURCE[0]}";RL="readlink";([[ `uname -s`=='Darwin' ]] || RL="$RL -f")
while([ -h "${CURDIR}" ]) do CURDIR=`$RL "${CURDIR}"`; done
N="/dev/null";pushd .>$N;cd `dirname ${CURDIR}`>$N;CURDIR=`pwd`;popd>$N
function symlink_py {
@dsuch
dsuch / buildout.cfg
Created May 26, 2013 17:37
Zato 1.0 buildout.cfg for Mac OS X
[buildout]
extends=versions.cfg
unzip = true
parts =
cython-src
cython-install
gevent_zeromq_patched-src
gevent_zeromq_patched-install
pyyaml-src
@dsuch
dsuch / versions.cfg
Created May 26, 2013 17:39
Zato 1.0 versions.cfg for Mac OS X
[buildout]
versions=versions
[versions]
anyjson = 0.3.3
apscheduler = 2.0.3
argparse = 1.2.1
boto = 2.6.0
bunch = 1.0.1
bzr = 2.5