Skip to content

Instantly share code, notes, and snippets.

View arne-cl's full-sized avatar

Arne Neumann arne-cl

  • Potsdam
View GitHub Profile
@arne-cl
arne-cl / restore_packages.R
Created September 16, 2014 08:46
save/load/install a list of your currently installed R packages
# restore_packages.R
#
# installs each package from the stored list of packages
# source: http://hlplab.wordpress.com/2012/06/01/transferring-installed-packages-between-different-installations-of-r/
load("~/installed_packages.rda")
for (count in 1:length(installedpackages)) {
install.packages(installedpackages[count])
}
@arne-cl
arne-cl / gist:d777fafcdf650f73da364d9f879b296b
Created June 23, 2021 13:41
Show Zoom video as pop-out / picture-in-picture in Google Chrome.
let canvas = document.getElementsByClassName('sharee-container__canvas')[0];
let videoWrapper = document.createElement('video');
videoWrapper.muted = true;
videoWrapper.srcObject = canvas.captureStream(60);
videoWrapper.play();
videoWrapper.requestPictureInPicture();
@arne-cl
arne-cl / epydoc_to_sphinx.sh
Last active June 11, 2021 14:04 — forked from Kami/migrate_docstrings.sh
converts epydoc docstrings to sphinx docstrings (restructuredText)
#!/usr/bin/env bash
#
# Script for migrating from epydoc to Sphinx style docstrings.
#
# WARNING: THIS SCRIPT MODIFIES FILES IN PLACE. BE SURE TO BACKUP THEM BEFORE
# RUNNING IT.
#
# Forked from: https://gist.github.com/Kami/6734885
DIRECTORY=$1
@arne-cl
arne-cl / write_to_file_or_stdout.py
Created January 3, 2021 21:13
Python3: write to file if filename is given as argument, else write to stdout.
import argparse
import datetime
import sys
"""
This script writes the current timestamp to the file given a cli argument.
If no filename is given, the timestamp is written to stdout.
"""
if __name__ == "__main__":
@arne-cl
arne-cl / setup.py
Created May 4, 2014 13:02
minimal example setup.py for a single-module package
#!/usr/bin/env python
import sys
import os
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
here = os.path.abspath(os.path.dirname(__file__))
@arne-cl
arne-cl / find-unpushed-repos.sh
Created December 11, 2018 19:49
List all git repositories with uncommitted code / unpushed commits in the current dir
#!/bin/bash
# This script lists all git repositories in the current directory
# that contain uncommited code or have unpushed commits.
# recursively list all directories (three levels deep) that don't have
# '.git' in their path.
#
# 'while read LINE' and 'cd "$LINE"' are used to handle paths that
# would need escaping.
@arne-cl
arne-cl / Dockerfile
Created December 2, 2018 20:51
alpine-python-imagehash-docker
FROM alpine:3.8
RUN apk update && \
apk add git build-base py2-pip python-dev zlib-dev jpeg-dev lapack-dev gfortran && \
pip2 install Cython numpy
WORKDIR /opt
RUN git clone https://github.com/PyWavelets/pywt.git PyWavelets
WORKDIR /opt/PyWavelets
@arne-cl
arne-cl / html2csv.py
Created January 21, 2015 13:18
extract all tables from an HTML file and write them into one CSV file
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
# Hello, this program is written in Python - http://python.org
programname = 'html2csv - version 2002-09-20 - http://sebsauvage.net'
import sys, getopt, os.path, glob, HTMLParser, re
try: import psyco ; psyco.jit() # If present, use psyco to accelerate the program
except: pass
@arne-cl
arne-cl / git-selective-merge.md
Last active November 14, 2017 15:23 — forked from katylava/git-selective-merge.md
git selective merge

Example: You have a branch refactor that is quite different from master. You can't merge all of the commits, or even every hunk in any single commit or master will break, but you have made a lot of improvements there that you would like to bring over to master.

Note: This will not preserve the original change authors. Only use if necessary, or if you don't mind losing that information, or if you are only merging your own work.

On master:

> git checkout -b temp
@arne-cl
arne-cl / tigerxml2txt.py
Created December 11, 2013 16:15
converts TigerXML files into tokenized plain text (one word per line with an empty line between sentences).
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Arne Neumann
#
# Purpose: extracts sentences from a Tiger XML input file and writes
# them to an output file (one word per line with an empty line
# between sentences).
import sys
import codecs