Skip to content

Instantly share code, notes, and snippets.

Avatar

Petr Messner messa

View GitHub Profile
View gist:47e58593113f52d24604
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 Aug 29, 2015
MAS report LP
View mas_report_lp.py
#!/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 Aug 29, 2015
HTML footer always at the bottom
View stickyFooter.js
/// 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 / fib.py
Last active Aug 29, 2015
Testing only Python code that has changed using trace
View fib.py
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 Aug 29, 2015
Sample OpenSSL configuration for local CA; see my CA guide: https://github.com/messa/tips/blob/master/OpenSSL.md
View openssl.conf
[ 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
View react-talk.md

React

Petr Messner - petr.messner@gmail.com

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

  • callback hell
  • problematické generování HTML
View .pythonrc.py
"""
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 Sep 18, 2009
AI examples. Not very fast/clever, no heuristic.
View eight_queens_solver.py
#!/usr/bin/env python
class EightQueens:
def __init__(self):
self.array = 64 * [-1]
def get(self, x, y):
return self.array[x + y * 8]