Skip to content

Instantly share code, notes, and snippets.

#! /bin/bash
# needs qpdf and docker installed
set -x
decrypt_command="qpdf --replace-input --decrypt"
find . -name "*.pdf" -type f -exec echo DECRYPTING {} \; -exec $decrypt_command {} \;
ocr_command="docker run --rm --user $(id -u):$(id -g) --workdir /data -v $PWD:/data -i jbarlow83/ocrmypdf -l deu --rotate-pages --clean-final --jobs 4"
@puhoy
puhoy / 1_flask-restplus_sqlalchemy-wrapper.md
Last active July 1, 2019 18:53
flask-restplus sqlalchemy wrapper

setup

pip install flask flask-migrate flask-restplus flask-sqlalchemy

flask db init
flask db upgrade
flask db migrate

flask run

@puhoy
puhoy / boost + libtorrent in a virtualenv
Created May 22, 2016 20:25 — forked from jcsaaddupuy/boost + libtorrent in a virtualenv
Install boost + libtorrent in a virtualenv
#!/bin/bash
get_boost(){
wget -c "http://downloads.sourceforge.net/project/boost/boost/1.57.0/boost_1_57_0.tar.gz"
[ $? -ne 0 ] && exit 1
tar xf boost_1_57_0.tar.gz
[ $? -ne 0 ] && exit 1
pushd ./boost_1_57_0
[ $? -ne 0 ] && exit 1
./bootstrap.sh --with-python=$(which python) --prefix=$VIRTUAL_ENV
@puhoy
puhoy / pubsub.py
Created April 2, 2016 09:49
pubsub-like messaging in python
from queue import Queue, Empty
from threading import Lock
import logging
logger = logging.getLogger(__name__)
topics = {}
lock = Lock()
@puhoy
puhoy / storedDict.py
Created October 18, 2015 21:41
wrapper for python dict to store as json
import json
class StoredDict(dict):
def __init__(self, filename, **kwargs):
self.filename = filename
file = open(filename, 'w+')
try:
super(StoredDict,self).__init__(json.load(file))
except ValueError:
super(StoredDict,self).__init__({})