Skip to content

Instantly share code, notes, and snippets.

View messa's full-sized avatar

Petr Messner messa

View GitHub Profile
@messa
messa / dependency_container.py
Last active September 30, 2017 02:19
Processing engine
#!/usr/bin/env python3
'''
Inspired by pytest fixtures :)
'''
import argparse
from inspect import signature
import logging
from reprlib import repr as smart_repr
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__)
@app.route('/')
def index():
return 'ahoj <img src="/graf">'
@app.route('/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
messa / bst_check.py
Last active April 21, 2017 20:33
Check whether Binary Tree is a Binary Search Tree
# from HackerRank.com
""" Node is defined as
class node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
"""
def check_binary_search_tree_(root, lower_bound=None, upper_bound=None):
if not root:
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
messa / Dockerfile
Last active May 25, 2023 00:32
Building graph-tool in Docker
FROM debian:stretch
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y apt-utils wget bzip2
WORKDIR /src
@messa
messa / Makefile
Created January 7, 2017 10:42
Python project Makefile example
venv_dir=local/venv
pyvenv=pyvenv-3.5
default: check
check: $(venv_dir)/packages-installed
$(venv_dir)/bin/py.test tests
run: $(venv_dir)/packages-installed
$(venv_dir)/bin/my-awesome-app
@messa
messa / demo.py
Last active September 19, 2022 03:32
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']