Skip to content

Instantly share code, notes, and snippets.

Avatar

Christoph Matthies chrisma

View GitHub Profile
@chrisma
chrisma / pretty_man.sh
Created Feb 22, 2022
Show manpage in Preview
View pretty_man.sh
man -t bash | open -f -a Preview
@chrisma
chrisma / sum.py
Last active Jan 28, 2022
sum and count columns from stdin, because I'm no good at awk
View sum.py
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 Jun 4, 2021 — forked from drozzy/README.md
FMC (http://www.fmc-modeling.org/) compositional and dynamic elements draw.io libraries
View README.md

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 — forked from timpulver/GetNameAndTitleOfActiveWindow.scpt
[AppleScript] Get Name of active window | Returns the name / title of the active (frontmost) window
View GetNameAndTitleOfActiveWindow.scpt
# 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 Apr 20, 2020
Get BibTeX entry from doi.org
View bibtex_from_doi.sh
wget -qO- --header="Accept: application/x-bibtex" "https://doi.org/10.1109/5.771073"
@chrisma
chrisma / wizard_duel.py
Last active Mar 10, 2020
Coding exercise
View wizard_duel.py
#!/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 Mar 6, 2019
Minify .bib files to contain only references cited in a paper. Remove abstracts.
View minify_bib.sh
bibexport -o extracted.bib main.aux
echo "delete.field = { abstract }" > remove-abs.rsc && bibtool -r remove-abs.rsc extracted.bib -o minified.bib
View gist:437820ce15db30770975e47750c7dd0e
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 Jun 6, 2018
postactivate script to show current Python version in virtualenv
View postactivate.sh
#!/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 Jan 22, 2018
Python GUI for reMarkable sync script
View sync_gui.py
#!/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