Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View martinth's full-sized avatar

Martin Thurau martinth

View GitHub Profile
function test() {
}
@martinth
martinth / Dota 2 winrates.ipynb
Created August 31, 2015 09:55
Dota 2 winrates 6.84 pro and pub
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from pympler import summary, muppy
import psutil
# source: http://www.mobify.com/blog/sqlalchemy-memory-magic/
def get_virtual_memory_usage_kb(): # pragma: no cover
"""
The process's current virtual memory size in Kb, as a float.
"""
@martinth
martinth / argparse_fileinput_demo.py
Created August 6, 2015 11:04
Read from stdin or files in Python (combining argparse and fileinput)
import argpase
import fileinput
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument('--dummy', help='dummy argument')
parser.add_argument('files', metavar='FILE', nargs='*', help='files to read, if empty, stdin is used')
args = parser.parse_args()
# If you would call fileinput.input() without files it would try to process all arguments.
class Range(object):
"""Represents an integer range"""
regex = re.compile(r'(?P<low>\d+|-\d+)?\.\.(?P<high>\d+|-\d+)')
def __init__(self, low, high):
self.low = low
self.high = high
@martinth
martinth / userscript.js
Created February 4, 2015 11:07
SCP Foundation reading helper
// ==UserScript==
// @name SCP Foundation reading helper
// @namespace http://hrnz.net/
// @version 0.1
// @description Adds simple buttons to SCP page to allow easy paging.
// @author Martin Thurau <martin.thurau@gmail.com>
// @match http://www.scp-wiki.net/scp-*
// @grant unsafeWindow
// @grant GM_addStyle
// @grant GM_setValue
@martinth
martinth / sign-and-align.sh
Created April 10, 2014 07:30
A simple script to automate signing and aligning of APK files for upload to the Playstore
#!/bin/sh
FOLDER=android/bin
IN_APK_NAME=App-release-unsigned.apk
OUT_APK_NAME=App-release-signed-aligned.apk
KEYSTORE=release-key.keystore
KEYSTORE_ALIAS=app_release
echo ">>> Signing $OUT_APK_NAME..."
@martinth
martinth / decorators.py
Last active January 21, 2018 01:09
A sample decorator the can be used on plain old functions and also on instance methods
class func_and_method_decorator(object):
'''A clased based decorator that takes parameters and works on plain functions
and instance methods'''
def __init__(self, *args, **kwargs):
'''The init function is called when a module where the decorator is used
is imported. It gets passed all parameters that are given to decorator
definition. I.e.
@func_and_method_decorator(foo='bar')
@martinth
martinth / googleio13.py
Created March 20, 2013 10:34
Generates valid click codes for Google I/O 2013
forbidden_starts = filter(bool,
'''
000
00100
0010100
00101011
001011
00110
00111000
0011101
@martinth
martinth / simple_server.py
Created January 25, 2012 12:50
simple HTTP server that dumps header
import SimpleHTTPServer
import SocketServer
class H(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
print self.headers
httpd = SocketServer.TCPServer(("", 8090), H)
httpd.server_forever()