Skip to content

Instantly share code, notes, and snippets.

@koehlma
koehlma / forward.py
Created September 30, 2012 15:06
MTS - Forward Proxy
# -*- coding:utf-8 -*-
#
# Copyright (C) 2012, Maximilian Köhl <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@koehlma
koehlma / config.py
Created October 4, 2012 17:01
Qtile - Configuration
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import locale
import subprocess
locale.setlocale(locale.LC_ALL, '')
from libqtile import bar, hook, layout, widget
from libqtile.command import lazy
@koehlma
koehlma / pdef.py
Last active December 16, 2015 11:18
PDEF (=Portable Data Exchange Format) is a JSON like format that encodes into binary data.
# -*- coding:utf-8 -*-
#
# Copyright (C) 2013, Maximilian Köhl <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# -*- coding:utf-8 -*-
#
# Copyright (C) 2013, Maximilian Köhl <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@koehlma
koehlma / moneymgr.py
Last active August 29, 2015 14:05
MoneyManager
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import collections
import csv
import datetime
import os
import os.path
import subprocess
def insertionsort(liste):
counter = 0
for i in range(1, len(liste)):
x, j = liste[i], i
while j > 0:
counter += 1
if not liste[j - 1] > x: break
liste[j] = liste[j - 1]
j -= 1
liste[j] = x
def partition(liste, links, rechts, pivot):
b = links - 1
counter = 0
for k in range(links, rechts + 1):
liste[k], liste[b + 1] = liste[b + 1], liste[k]
counter += 1
if liste[b + 1] <= pivot:
b += 1
return b, counter
Quicksort:
A=[23, 11, 8, 4, 15], pivot=15
Partition:
Vertausche 23(0) mit 23(0)
[23, 11, 8, 4, 15] -> [23, 11, 8, 4, 15]
Vergleiche 23(0) mit 15(pivot)
Vertausche 11(1) mit 23(0)
[23, 11, 8, 4, 15] -> [11, 23, 8, 4, 15]
Vergleiche 11(0) mit 15(pivot)
b++
@koehlma
koehlma / g19.py
Last active August 29, 2015 14:15
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015, Maximilian Köhl <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@koehlma
koehlma / gc.log
Last active January 24, 2016 10:59
gc: collecting generation 2...
gc: objects in each generation: 13 0 5824
gc: collectable <B 0x7f8c86b4ec50>
gc: collectable <dict 0x7f8c86b57248>
finalize b <__main__.A object at 0x7f8c86b4ec18>
gc: done, 3 unreachable, 0 uncollectable, 0.0005s elapsed
gc: collecting generation 2...
gc: objects in each generation: 1 0 5831
gc: done, 0.0005s elapsed
gc: collecting generation 2...