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
# -*- coding: utf-8 -*- | |
""" | |
Runs a simple pubsub listener which pushes to clients via sockjs | |
Based on https://gist.github.com/mrjoes/3284402 | |
Eventually I'd like to have one redis connection listening on user_* channel | |
and pushing messages ONLY to that user's client. | |
Setup: | |
virtualenv testenv |
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
def waiter(tasks): | |
""" async tasks to sync | |
tasks -> yield + tasks_wo_result | |
1 2 3 4 | |
[0,0,0,0] -> [ ] + [0,0,0,0] 1, 3 solved | |
[1,0,3,0] -> [1,3 ] + [ 0, 0] 2 solved | |
[ 2, 0] -> [1,3,2 ] + [ 0] 4 solved | |
[ 4] -> [1,3,2,4] + [ ] | |
""" | |
while tasks: |
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 itertools import zip_longest | |
from pprint import pprint | |
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] | |
def chunks(iterable, n, fill_value=None): | |
args = [iter(iterable)] * n | |
return zip_longest(*args, fillvalue=fill_value) | |
c1 = list(chunks(a, 3)) |
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
('Platform:', 'Linux', '3.13.0-77-generic') | |
('Python version:', sys.version_info(major=2, minor=7, micro=6, releaselevel='final', serial=0)) | |
('SAP NW RFC:', (7200, 0, 33)) | |
('PyRFC:', '1.9.4\r\n') | |
000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFE | |
0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9 |
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 typing import Iterator | |
from functools import wraps, singledispatch | |
def wrap(begin: bytes=None, end: bytes=b'e'): | |
def outer_wrapper(func): | |
@wraps(func) | |
def inner_wrapper(*args, **kwargs): | |
yield begin | |
yield from func(*args, **kwargs) |
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 | |
BASE_URL='http://0.0.0.0:8000' | |
USERNAME='testtest' | |
PASSWORD='testtest' | |
ENV_NAME='env_dev' | |
PROJ_NAME='proj_demo' | |
APP_NAME='app_demo' | |
HHDEMO_2TABLES='hhdemo_2tables' |
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
curl \ | |
-s \ | |
-X POST \ | |
-H "Content-Type: application/json" \ | |
-b "api_sessionid=$SESSION_ID" \ | |
-d '{"scalar_bigint": 105, "scalar_numeric": 888.1, "scalar_smallint": 123, "scalar_real": 999.256, "scalar_double": 66.1256, "scalar_boolean": true, "scalar_bytea": "QQ==", "scalar_character": "k", "scalar_varchar": "hhh", "scalar_text": "fghfhh fhjfhjkl", "scalar_date": "2016-10-25", "scalar_timestamptz": "2016-12-12T12:12:12.12+0300", "scalar_integer": 55}' \ | |
"$BASE_URL/api/v0.6/table/$HHDEMO_BASESCALARS/" |
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 argparse import ArgumentParser | |
from getpass import getpass | |
from json import dumps | |
from os.path import expanduser, join, exists | |
from sys import exit, stdout | |
from yaml import load, dump | |
from requests import Session, codes | |
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 pyrfc import Connection | |
from pprint import pprint | |
connection_info = { | |
'ashost': '...', | |
'client': '...', | |
'lang': '...', | |
'user': '...', | |
'passwd': '...', |
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
class Cmp: | |
def __init__(self, value): | |
self._value = value | |
def __eq__(self, other: 'Cmp'): | |
return self._value == other._value | |
def __ne__(self, other: 'Cmp'): | |
return self._value != other._value |
OlderNewer