Skip to content

Instantly share code, notes, and snippets.

@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 );
@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 / 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
@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 / gist:5693064
Last active December 17, 2015 23:59
{
"security": {
"name": "my security",
"type": "wss",
"username": "my user",
"password": "my password",
},
"outconns": {
"my external app": {
"type": "soap",
@dsuch
dsuch / get-exchange-rates-dream.py
Last active December 18, 2015 11:29
What should be needed to invoke any web services
request = {'from':'EUR', 'to':'HRK'}
response = get_exchange_rate(request)
print(response.rate)
# 1 EUR = 7.4680 HRK as of Jun 13, 2013, 5:00PM GMT
from django.template.response import TemplateResponse
def home(req):
# A dictionary of input data read from HTTP GET. If no input was given
# we translate from EUR to HRK.
to = req.GET.get('to', 'HRK')
request = {'from':'EUR', 'to':to}
# Pass the dictionary into the client's invoke method along with the name