Skip to content

Instantly share code, notes, and snippets.

View herczy's full-sized avatar

Hercinger Viktor herczy

  • Balabit Europe Kft.
  • Veszprém
View GitHub Profile
@herczy
herczy / mitm.py
Last active June 29, 2022 07:38
Small man in the middle script
#!/usr/bin/env python3
import argparse
import socket
import select
def main():
parser = argparse.ArgumentParser(description="MITM proxy")
parser.add_argument(
@herczy
herczy / pycore.py
Created February 17, 2015 13:55
Tracefile in Python
import collections
import traceback
import json
import pickle
import sys
import inspect
import yaml
from pprint import pprint
#!/usr/bin/env python
import os
import sys
import random
import hashlib
import tempfile
import subprocess
import atexit
@herczy
herczy / gist:3859615
Created October 9, 2012 15:41
Online average counter
import math
class Calculator(object):
def __init__(self):
self.__count = 0
self.__sum = 0.0
self.__sqsum = 0.0
@property
def average(self):
@herczy
herczy / cree.py
Created July 18, 2012 10:31
Creepy gtk message dialog
import pygtk
pygtk.require('2.0')
import gtk
import random
full = '''To invoke the hive-mind representing chaos.
Invoking the feeling of chaos.
With out order.
The Nezperdian hive-mind of chaos. Zalgo.for
@herczy
herczy / python.prez
Created May 2, 2012 12:14 — forked from rsdy/python.prez
A prezentation about what is wrong with Python
{{{
╻ ┏━╸┏━┓┏━┓┏┓ ┏┓ ┏━╸╺┳┓ ╺┳╸╻ ╻┏━╸ ┏━┓╻ ╻╺┳╸╻ ╻┏━┓┏┓╻
┃ ┃╺┓┣┳┛┣━┫┣┻┓┣┻┓┣╸ ┃┃ ┃ ┣━┫┣╸ ┣━┛┗┳┛ ┃ ┣━┫┃ ┃┃┗┫
╹ ┗━┛╹┗╸╹ ╹┗━┛┗━┛┗━╸╺┻┛ ╹ ╹ ╹┗━╸ ╹ ╹ ╹ ╹ ╹┗━┛╹ ╹
}}}
{{{
>>> from __future__ import braces
SyntaxError: not a chance (<input>, line 2)
}}}
print '#include <stdio.h>\n#include <string.h>\n\nint main() {\nunsigned char mem[30000];\nunsigned char *ptr = mem;\nmemset(mem, 0, sizeof(mem));\n\n/* BF code */\n%s\nreturn 0;\n}\n' % __import__('re').sub(r'[^\+\-\[\],\.><]', '', __import__('sys').stdin.read()).replace('+', '++*ptr;').replace('-', '--*ptr;').replace('[', 'while (*ptr) {').replace(']', '}').replace('>', '++ptr;').replace('<', '--ptr;').replace(',', '*ptr = getchar();').replace('.', 'putchar(*ptr);')
@herczy
herczy / specialize.hh
Created September 7, 2011 21:24
Template specialization problem (outline)
// This is the original template
template < typename _Type >
class SomeClass
{
public:
// Some functions
void foo()
{
}
@herczy
herczy / access.py
Created September 3, 2011 16:54
Want to have protected and private? :-)
import sys
import types
class AccessError(Exception):
'''Object access violation'''
def get_caller_instance(skip = 2):
try:
raise RuntimeError
@herczy
herczy / containment.py
Created July 10, 2011 20:10
Create a self-compressed Python script
'''Python self-contained module maker
Creates a small Python script containing the neccessary complete
modules in a tar.bz2 archive. The generated script unpacks this
and it can be used as a stand-alone script without explicitly
installing the whole module.'''
import os
import sys
import os.path