Skip to content

Instantly share code, notes, and snippets.

@jkbjh
jkbjh / pdfstatistics.py
Created February 11, 2025 14:07
Download all pdfs from a page/ check pdf file statistics -- pages, word count, characters
#!/usr/bin/env python3
import os
import tempfile
import subprocess
import fitz # PyMuPDF for reading PDFs
import re
import statistics
import argparse
@jkbjh
jkbjh / load-mujoco-210.sh
Last active October 27, 2023 11:45
load-mujoco-210.sh
#!/bin/bash
set -e
# you can directly run this with: bash <(curl -Ls "https://gist.githubusercontent.com/jkbjh/c83e5bf6d708f590f77ccdd6b2ef0a40/raw/mujoco-210-user-install.sh?$(date +%s)")
# (the date query parameter is to to prevent caching when downloading through curl.)
export START_DIR=$(pwd)
export MJ_DIR=$HOME/.mujoco
# Check if the file exists
if [ -e "$MJ_DIR/mujoco210/bin/compile" ]; then
echo "mujoco already there, not downloading."
@jkbjh
jkbjh / git-copush
Last active February 8, 2023 19:47
push to a remote checked out repository (by pushing into a temporary branch and then ssh-ing to the repository and performing the merge)
#!/usr/bin/env python
import argparse
import re
import subprocess
import sys
import uuid
url_rex = re.compile(
"^(?P<user>.*?)@(?P<host>.*?):(?:(?P<port>[0-9]*?))?(?P<path>.*?/.*?)$"
)
@jkbjh
jkbjh / arxivit.py
Created November 10, 2022 16:08
helper util to package arxiv submissions
#!/usr/bin/env python
import argparse
import subprocess
import shlex
import shutil
import sys
def check_programs(*progs):
all_success = True
@jkbjh
jkbjh / at-covid19.py
Last active November 19, 2021 12:38
Plot covid incidence / death numbers for selected countries (austria+neighbors+uk)
#!/usr/bin/env python3
import pandas as pd
import matplotlib.pyplot as plt
import countryinfo # for populations
FUTURE = 28
POPULATION = {
"Czechia": countryinfo.CountryInfo("Czech Republic").population(),
}
#!/bin/bash
set -e
set -x
# you can directly run this with: bash <(curl -Ls "https://gist.githubusercontent.com/jkbjh/c83e5bf6d708f590f77ccdd6b2ef0a40/raw/mujoco-210-user-install.sh?$(date +%s)")
# (the date query parameter is to to prevent caching when downloading through curl.)
export START_DIR=$(pwd)
export MJ_DIR=$HOME/.mujoco
mkdir -p $MJ_DIR
pushd $MJ_DIR
curl -LJ 'https://github.com/deepmind/mujoco/releases/download/2.1.0/mujoco210-linux-x86_64.tar.gz' -o $MJ_DIR/mujoco210_linux.tgz
import collections
JointInfo = collections.namedtuple(
"JointInfo",
[
"index",
"name",
"type",
"q_index",
# a selection of small numpy helper functions
import joblib
def apply_along_axes(func, data, axes):
"""
apply function along axes and use joblib parallel to execute the function on the selections.
might result in a large allocation for reconstructing the result.
only makes sense if the sub-executions are sufficiently costly.
"""
;;; diction.el --- minor mode to interface the command diction
;;; Copyright Sven Utcke <[email protected]>
;; Emacs Lisp Archive Entry
;; Filename: diction.el
;; Version: $Id: diction.el,v 1.8 2005/09/29 12:55:52 utcke Exp $
;; Keywords: diction, style
;; Author: Sven Utcke <[email protected]>
;; Maintainer: Sven Utcke <[email protected]>
@jkbjh
jkbjh / pip_require_this.py
Last active August 18, 2020 08:15
Get PIP Requirements for current folder. Hacky.
import importlib
import subprocess
import re
import os
import joblib
from joblib import parallel_backend, Parallel, delayed
found_imports = sorted(list(set([x.lstrip().rstrip() for x in subprocess.check_output("findimports -p -l 1 |grep -v ':' |sort -u", shell=True).decode("utf-8").rstrip().lstrip().split("\n")])))
installed_packages = subprocess.check_output('pip list | tail -n +3 | cut -d" " -f1', shell=True).decode("utf-8").rstrip().lstrip()