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 / 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 / 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 / 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 / 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 / nested_dict_print.py
Created September 19, 2015 20:31
prettyprint a nested dictionary
def nprint(d, tab=0, tab_width=2):
'''print nested key-value datastructures (e.g. dicts)'''
for k, v in d.iteritems():
if not hasattr(v, 'iteritems'):
print u'{}{} {}'.format(' '*tab, k, v)
else:
print u'{}{}:'.format(' '*tab, k)
nprint(v, tab=tab+tab_width)
@arne-cl
arne-cl / tmux.conf
Created September 15, 2015 17:33
tmux config file with better key bindings
# use Ctrl-a instead of Ctrl-b as the default key
unbind-key C-b
set -g prefix C-a
# use | to split windows horizontally
# use - to split windows vertically
unbind %
bind | split-window -h
bind - split-window -v
@arne-cl
arne-cl / fefe_scraper.py
Created March 31, 2015 12:22
simple scraper for blog.fefe.de
import os
import datetime
from datetime import timedelta
import requests
def create_dir(path):
"""
Creates a directory. Warns, if the directory can't be accessed. Passes,
@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 / 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])
}