Skip to content

Instantly share code, notes, and snippets.

View messa's full-sized avatar

Petr Messner messa

View GitHub Profile
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)

React

Petr Messner - petr.messner@gmail.com

Problémy s řešením webové aplikace pomocí jQuery:

  • callback hell
  • problematické generování HTML
@messa
messa / .pythonrc.py
Created September 16, 2009 14:33
My settings
"""
Startup script for Python interactive mode
Add these two lines to .bashrc:
PYTHONSTARTUP="$HOME/.pythonrc.py"
export PYTHONSTARTUP
"""
import sys, os, readline, atexit
@messa
messa / eight_queens_solver.py
Created September 18, 2009 13:58
AI examples. Not very fast/clever, no heuristic.
#!/usr/bin/env python
class EightQueens:
def __init__(self):
self.array = 64 * [-1]
def get(self, x, y):
return self.array[x + y * 8]
@messa
messa / .gitignore
Created November 18, 2009 16:26
SVN log with diffs
*.pyc
@messa
messa / data.xml
Created January 6, 2010 22:04
Python XML example (etree)
<doc>
<person no="1234">
<name>Tomáš</name>
<surname>Těžký</surname>
</person>
<person no="7">
<name>Standa</name>
<surname>Blábol</surname>
</person>
</doc>