Skip to content

Instantly share code, notes, and snippets.

View messa's full-sized avatar

Petr Messner messa

View GitHub Profile
@messa
messa / graf.dot
Last active December 26, 2015 10:39
TVS cv. 5
digraph cv5 {
// public int fnc() {
node [fontname="menlo-regular"];
edge [fontname="arial"];
// B999();
// int d999 = 808;
@messa
messa / tcpproxy.py
Created December 10, 2013 18:44
TCP proxy in Python - some IP-restricted programs requre a bit of TCP magic...
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from optparse import OptionParser
import os
from select import select
import socket
def main():
op = OptionParser()
is_even = lambda n: n % 2 == 0
even_numbers = filter(is_even, range(10**100))
with open('even_numbers.txt', 'w') as f:
for number in even_numbers:
f.write('{}\n'.format(number))
@messa
messa / mas_report_lp.py
Last active August 29, 2015 14:10
MAS report LP
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# PuLP is an LP modeler written in Python.
# PuLP can generate MPS or LP files and call GLPK, COIN CLP/CBC, CPLEX,
# and GUROBI to solve linear problems.
import pulp
from pulp import (
LpMaximize,
@messa
messa / stickyFooter.js
Last active August 29, 2015 14:15
HTML footer always at the bottom
/// Keep footer always at the bottom, even when the page is too short
stickyFooter = function() {
jQuery(document).ready(function() {
var footer = jQuery("footer");
var body = jQuery(document.body);
var win = jQuery(window);
var fixed = false;
var positionFooter = function() {
var footerHeight = fixed ? footer.outerHeight() : 0;
if ((body.outerHeight() + footerHeight) < win.outerHeight()) {
@messa
messa / capture_screenshot.png
Last active August 29, 2015 14:18
homography
capture_screenshot.png
@messa
messa / fib.py
Last active August 29, 2015 14:21
Testing only Python code that has changed using trace
def fib(n):
# just an example function
if n == 0:
return 0
if n == 1:
return 1
return fib(n-1) + fib(n-2)
@messa
messa / openssl.conf
Last active April 12, 2022 04:52
Sample OpenSSL configuration for local CA; see my CA guide: https://github.com/messa/tips/blob/master/OpenSSL.md
[ ca ]
default_ca = CA_default
[ CA_default ]
dir = /XXX/root-ca
certs = $dir/certs
crl_dir = $dir/crl
new_certs_dir = $dir/newcerts
database = $dir/index.txt
serial = $dir/serial
@messa
messa / asyncio_ssl_example.py
Created June 26, 2015 12:43
Python asyncio + SSL TCP client/server example
#!/usr/bin/env python3
import asyncio
import multiprocessing
import os
import ssl
from time import sleep
port = 9000
@messa
messa / potom.py
Last active May 27, 2016 14:30
funkce (Pyladies CZ 2015)
def ano_nebo_ne(otazka):
"Vrátí True nebo False, podle odpovědi uživatele"
while True:
odpoved = input(otazka)
if odpoved == 'ano':
return True
elif odpoved == 'ne':
return False
else:
print('Nerozumím! Odpověz "ano" nebo "ne".')