Skip to content

Instantly share code, notes, and snippets.

@tkaemming
tkaemming / calls.sql
Created July 19, 2019 18:57
ClickHouse Table Schema for Tracking Call Timing and Similarity with Service Delegator
CREATE TABLE calls (
-- Kafka Message Details
timestamp DateTime,
partition UInt8,
offset UInt64,
-- Call Signature
service String,
method String,
Python 3.5.0 (default, Sep 23 2015, 04:42:00)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import six
>>> six.binary_type(10)
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
def foo():
bar()
def bar():
try:
baz()
except Exception as error:
import traceback
traceback.print_exc()
>>> t = int(time.time())
>>> (int(datetime.datetime.utcfromtimestamp(t).strftime('%s')) - t) / 3600
8
>>> (int(datetime.datetime.utcfromtimestamp(t).replace(tzinfo=pytz.utc).strftime('%s')) - t) / 3600
8
@tkaemming
tkaemming / deobfuscate.py
Last active May 2, 2021 13:50
parse proguard mapping files in python
import pprint
import itertools
import operator
import sys
from collections import namedtuple
Class = namedtuple('Class', [
'old',
'new',
click
redis
@tkaemming
tkaemming / read-payload.py
Created May 2, 2016 18:34
read a raw http payload (piped from from nc) for sentry and dump it as formatted json
import base64, json, sys, zlib
request = sys.stdin.read()
headers, payload = request.split('\r\n\r\n', 1)
result = json.loads(zlib.decompress(base64.b64decode(payload)))
sys.stdout.write(json.dumps(result, indent=2))
*.pyc
schemata/
*.pyc
"""
makes text read like it was written by a drunk person
er, makes txet rea dlike i twas rwitten by a durnk persob
"""
import random
import sys
drinks = float(sys.argv[1])