Skip to content

Instantly share code, notes, and snippets.


Petr Messner messa

View GitHub Profile
#!/usr/bin/env python3
Inspired by pytest fixtures :)
import argparse
from inspect import signature
import logging
from reprlib import repr as smart_repr
View gist:371afb36fb2527353c398649911c989b
export default class PageLayout extends React.Component {
render() {
const {
children, siteTitleH1, mobileView, userAgent,
currentLanguage, enVersionUrl, csVersionUrl,
} = this.props;
let appBar = null;
import flask
app = flask.Flask(__name__)
def index():
return 'ahoj <img src="/graf">'
def graf():
either = lambda a, b: lambda i: a(i) or b(i)
plus = lambda a, b: lambda i: a(i) + b(i)
div = lambda n: lambda i: i % n == 0
iff = lambda c, a, b: lambda i: a(i) if c(i) else b(i)
nothing = lambda x: ''
itself = lambda x: x
const = lambda x: lambda i: x
# some hints how it works :)
messa /
Last active Apr 21, 2017
Check whether Binary Tree is a Binary Search Tree
# from
""" Node is defined as
class node:
def __init__(self, data): = data
self.left = None
self.right = None
def check_binary_search_tree_(root, lower_bound=None, upper_bound=None):
if not root:
View PyWorking_SQL_demo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env python3
ciphertext = '''
ymjwj fwj ybt ydujx tk jshwduynts: tsj ymfy bnqq
uwjajsy dtzw xnxyjw kwtr wjfinsl dtzw infwd fsi tsj ymfy bnqq
uwjajsy dtzw ltajwsrjsy. ymnx nx f ajwd nrutwyfsy qjxxts yt
wjrjgjwjxujhnfqqd ktw fyyfhpx zxnsl kwjvzjshd fsfqdxnx bmnhm
wjvznwj qtsljw ufxxflj tk yjcy ns twijw yt fhmnjaj gjyyjw wjxzqyx.
messa / Dockerfile
Last active Aug 2, 2021
Building graph-tool in Docker
View Dockerfile
FROM debian:stretch
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y apt-utils wget bzip2
messa / Makefile
Created Jan 7, 2017
Python project Makefile example
View Makefile
default: check
check: $(venv_dir)/packages-installed
$(venv_dir)/bin/py.test tests
run: $(venv_dir)/packages-installed
messa /
Last active Feb 1, 2021
MongoDB pymongo bulk update all documents in a collection
#!/usr/bin/env python3
from bson import MinKey
import pymongo
from pymongo import ASCENDING
client = pymongo.MongoClient()
db = client['test']
collection = db['dataset']