Skip to content

Instantly share code, notes, and snippets.

View chrisma's full-sized avatar

Christoph Matthies chrisma

View GitHub Profile
@chrisma
chrisma / pretty_man.sh
Created February 22, 2022 18:17
Show manpage in Preview
man -t bash | open -f -a Preview
@chrisma
chrisma / sum.py
Last active January 28, 2022 19:34
sum and count columns from stdin, because I'm no good at awk
import sys
d = {}
for line in sys.stdin:
adds, dels, path = line.rstrip().split('\t')
if path in d:
d[path]['adds'] += int(adds)
d[path]['dels'] += int(dels)
d[path]['count'] += 1
@chrisma
chrisma / README.md
Created June 4, 2021 09:44 — forked from drozzy/README.md
FMC (http://www.fmc-modeling.org/) compositional and dynamic elements draw.io libraries

ABOUT

This is just some stencils I created for myself to draw FMC (http://www.fmc-modeling.org/) diagrams with draw.io.

Here is how they look:

lib_fmc_compositional

lib_fmc_dynamic

@chrisma
chrisma / GetNameAndTitleOfActiveWindow.scpt
Created May 20, 2021 08:21 — forked from timpulver/GetNameAndTitleOfActiveWindow.scpt
[AppleScript] Get Name of active window | Returns the name / title of the active (frontmost) window
# taken from user Albert's answer on StackOverflow
# http://stackoverflow.com/questions/5292204/macosx-get-foremost-window-title
# tested on Mac OS X 10.7.5
global frontApp, frontAppName, windowTitle
set windowTitle to ""
tell application "System Events"
set frontApp to first application process whose frontmost is true
set frontAppName to name of frontApp
@chrisma
chrisma / bibtex_from_doi.sh
Last active April 20, 2020 15:29
Get BibTeX entry from doi.org
wget -qO- --header="Accept: application/x-bibtex" "https://doi.org/10.1109/5.771073"
@chrisma
chrisma / wizard_duel.py
Last active March 10, 2020 12:16
Coding exercise
#!/usr/bin/env python3
# In this bonus challenge, you'll need to check the winner of the battle but this time, a sorcerer wins if he succeeds in winning 3 spell clashes in a row.
#
# 1. Create variables POWER, gandalf and saruman as seen above.
#
# spells have names, dictionary that associates that name to a power.
POWER = {
'Fireball': 50,
@chrisma
chrisma / minify_bib.sh
Created March 6, 2019 15:05
Minify .bib files to contain only references cited in a paper. Remove abstracts.
bibexport -o extracted.bib main.aux
echo "delete.field = { abstract }" > remove-abs.rsc && bibtool -r remove-abs.rsc extracted.bib -o minified.bib
@chrisma
chrisma / gist:437820ce15db30770975e47750c7dd0e
Last active December 11, 2018 15:12 — forked from barentsen/gist:bacd4360fb31e7456d659d07b014e834
How to get clickshare working on Ubuntu
sudo apt install libresample1
http://mirrors.kernel.org/ubuntu/pool/universe/liba/libav/libavutil52_9.20-0ubuntu0.14.04.1_amd64.deb
sudo gdebi libavutil52_9.18-0ubuntu0.14.04.1_amd64.deb
http://security.ubuntu.com/ubuntu/pool/universe/liba/libav/libswscale2_9.20-0ubuntu0.14.04.1_amd64.deb
sudo gdebi libswscale2_9.18-0ubuntu0.14.04.1_amd64.deb
# Download clickshare deb
# https://drive.google.com/drive/folders/0B9IKZqXvLKM_Yno1UmpGLVRXNDg
# https://drive.google.com/file/d/0B9IKZqXvLKM_QzF4aTlRNVV5Wk0/view
sudo gdebi clickshare_01.07.01-79_amd64.deb
@chrisma
chrisma / postactivate.sh
Created June 6, 2018 12:33
postactivate script to show current Python version in virtualenv
#!/usr/bin/zsh
# This hook is sourced after this virtualenv is activated.
echo $fg_bold[green] $(python --version)
echo $fg_bold[green] $(which python)
@chrisma
chrisma / sync_gui.py
Created January 22, 2018 15:52
Python GUI for reMarkable sync script
#!/usr/bin/env python3
import os
import tkinter as tk
from tkinter import filedialog
from tkinter import ttk
from tkinter import scrolledtext
import time
import threading