Skip to content

Instantly share code, notes, and snippets.

@dsuch
dsuch / html-service-usage.py
Created October 27, 2013 17:33
Sample usage of HTMLService
# -*- coding: utf-8 -*-
from html_service import HTMLService
TEMPLATE = """<!doctype html>
<html>
<head>
<title>Sample HTML template</title>
</head>
<body>
@dsuch
dsuch / py-client.py
Created September 29, 2013 21:16
Using Python client
from zato.client import JSONClient
address = 'http://localhost:11223'
path = '/rates/get-rate'
client = JSONClient(address, path)
payload = {'code_from':'USD', 'code_to':'EUR'}
response = client.invoke(payload)
@dsuch
dsuch / session.bash
Last active December 24, 2015 06:19
Sample exchange rates session
$ curl localhost:11223/rates/create-exchange-pair -d '{"code_from":"USD", "code_to":"EUR"}'
$
(and after a couple of minutes once the cache has been populated)
$ curl localhost:11223/rates/get-rate -d '{"code_from":"USD", "code_to":"EUR"}'
{"response": {"rate": "0.7395"}}
$
@dsuch
dsuch / zato-mq-put.py
Created September 12, 2013 15:26
MQ put - Zato
from zato.server.service import Service
class MyService(Service):
def handle(self):
self.outgoing.jms_wmq.send('my-message', 'outgoing-connection-name', 'QUEUE.1')
@dsuch
dsuch / sp-put.py
Last active December 22, 2015 22:19
MQ put - Spring Python
from springpython.jms.core import JmsTemplate
from springpython.jms.factory import WebSphereMQConnectionFactory
qm_name = 'QM.1'
channel = 'SVRCONN1.1'
host = '192.168.1.121'
listener_port = '1434'
queue1 = 'TEST.1'
factory = WebSphereMQConnectionFactory(qm_name, channel, host, listener_port)
@dsuch
dsuch / linuxjournal.py
Created September 4, 2013 17:52
Services accompanying an LJ article
# -*- coding: utf-8 -*-
# stdlib
from datetime import datetime
# dateutil
from dateutil.parser import parse
# lxml
from lxml import etree
@dsuch
dsuch / server.conf
Last active December 22, 2015 02:48
server.conf w/ request profiler
..
[profiler]
enabled=True
..
@dsuch
dsuch / multi-ns-result.txt
Created August 28, 2013 18:54
Multi NS result
John Brown
Dixie Black
@dsuch
dsuch / lxml-objectify-multi-ns.py
Created August 28, 2013 18:52
lxml.objectify - multilple namespaces
s = """<ns:request
xmlns:ns="http://example.com/ns"
xmlns:ns2="http://example.com/ns2">
<ns:customer>
<ns:id>123</ns:id>
<ns:name type="NCHZ">John Brown</ns:name>
<ns2:name type="NCHZ">Dixie Black</ns2:name>
</ns:customer>
</ns:request>
"""
@dsuch
dsuch / soap-logging.txt
Created August 28, 2013 18:05
SOAP logging
INFO - <type 'lxml.objectify.ObjectifiedElement'>
INFO - 123
INFO - John Brown
INFO - NCHZ