Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am tomdottom on github.
  • I am tomom (https://keybase.io/tomom) on keybase.
  • I have a public key whose fingerprint is 2BDA CE1A 6261 8449 C914 9DE1 CDEA 6CC1 F0FE 2829

To claim this, I am signing this object:

@tomdottom
tomdottom / gist:536e0daba7b0acf6a9f3
Created July 23, 2014 17:55
Install OpenSSH6.6. on Saucy Salamander
wget https://launchpad.net/openssh/main/6.6p1/+download/openssh-6.6p1.tar.gz
tar -xvf openssh-6.6p1.tar.gz
cd openssh-6.6p1
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-privsep-path=/var/run/sshd --with-default-path=/usr/local/bin:/usr/bin:/bin --with-superuser-path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin --includedir=${prefix}/include --mandir=${prefix}/share/man --infodir=${prefix}/share/info
make install
@tomdottom
tomdottom / pre-reveive
Last active March 13, 2016 22:29
Git Hook Pre Receive StdIn
#!/bin/bash
while read oldrev newrev refname; do
echo "$oldrev $newrev $refname"
# your code
done
@tomdottom
tomdottom / tox.ini
Last active March 3, 2020 11:01
Testing bdist_wheel with tox
[tox]
envlist = py27
[testenv]
skipdist=True
skip_install=True
deps=
nose
wheel
commands=
@tomdottom
tomdottom / jmeterxmltocsv.py
Last active April 12, 2021 23:03
A quick script to convert JMeter log XML files to CSV file. Tries to create csv in same column order as jmeter.
#!/usr/bin/env python
# Python version of https://gist.github.com/tonycoco/661615
import csv
import sys
import untangle
usage = '''
import mock
import sys
# Create a mock `uwsgi` module so that
# import uwsgi does not throw an ImportError
uwsgi = mock.MagicMock()
sys.modules.setdefault('uwsgi', uwsgi)
uwsgidecorators = mock.MagicMock()
@tomdottom
tomdottom / Recompile uwsgi with --json option on alpine linux
Last active March 9, 2017 03:57
Steps needed to compile a uwsgi binary with --json option support on alpine linux
# As root prepare build user
apk update
apk add sudo
adduser -D build
addgroup build abuild
addgroup abuild root
echo 'build ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
# Switch to build user
su build
@tomdottom
tomdottom / version.py
Created April 3, 2017 19:03 — forked from dcreager/version.py
Extract a setuptools version from the git repository
# -*- coding: utf-8 -*-
# Author: Douglas Creager <dcreager@dcreager.net>
# This file is placed into the public domain.
# Calculates the current version number. If possible, this is the
# output of “git describe”, modified to conform to the versioning
# scheme that setuptools uses. If “git describe” returns an error
# (most likely because we're in an unpacked copy of a release tarball,
# rather than in a git working copy), then we fall back on reading the
# contents of the RELEASE-VERSION file.
@tomdottom
tomdottom / decode_flask_session.py
Created June 10, 2019 18:30
How to decode flask session cookies as retrieved from the browser
from types import SimpleNamespace
from io import StringIO
from flask.sessions import SecureCookieSessionInterface
session_cookie = "... get me from your browser ..."
secret_key = "... get me from your app settings ..."
app = SimpleNamespace(secret_key=secret)
session = SecureCookieSessionInterface()
@tomdottom
tomdottom / demo.py
Created August 1, 2019 15:40
Distributed rate limited task queues.
"""demo.py
Distributed rate limited task queues.
Uses a leaky-bucket token-queue to ensure multiple workers don't exceed global rate limit.
# Setup & Dependencies
docker run -d --hostname my-rabbit --name some-rabbit -p 5672:5672 rabbitmq:3
pip install kombu
# Term 1 & 2