Skip to content

Instantly share code, notes, and snippets.

View chrisma's full-sized avatar

Christoph Matthies chrisma

View GitHub Profile
@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 / 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 / moderncv_left_aligned.tex
Last active January 1, 2022 14:15
LaTeX commands to add left aligned entries to moderncv template
\newcommand{\cvitemleft}[3][.25em]{%
\begin{tabular}{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}%
\hintstyle{#2} &{#3}%
\end{tabular}%
\par\addvspace{#1}
}
\newcommand{\cventryleft}[7][.25em]{%
\cvitemleft[#1]{#2}{%
{\bfseries#3}%
@chrisma
chrisma / hex_to_rgb.py
Created June 9, 2015 09:53
Django templatetag to convert hex to RGB colors.
# USAGE:
# {% load file_the_templatetag_is_in %}
# {{ my_hex_color| hex_to_rgb }}
# {{ my_hex_color| hex_to_rgb:'rgba({r},{g},{b}, 0.5)' }}
# {{ my_hex_color| hex_to_rgb:'Components: r:{r},g:{g},b:{b}' }}
# adapted from https://github.com/guillaumeesquevin/django-colors
@register.filter(name='hex_to_rgb')
def hex_to_rgb(hex, format_string='rgb({r},{g},{b})'):
"""Returns the RGB value of a hexadecimal color"""
@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 / fizzbuzz.py
Last active September 11, 2020 18:50
Fizzbuzz in too much detail
#! /usr/bin/env python3
# coding=utf-8
# Python version of
# http://www.tomdalling.com/blog/software-design/fizzbuzz-in-too-much-detail/
# Run it live at:
# https://www.pythonanywhere.com/gists/02d713164ca0f6882f50/fizzbuzz.py/ipython3/
### A Naïve Implementation
@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 / neo4j_cheatsheet.md
Last active October 1, 2019 16:18
Neo4J cheatsheet

Neo4J Cheatsheet

Refcard

http://neo4j.com/docs/2.1/cypher-refcard/

Database Exploration

List all labels of a node

labels(n)

List all node labels (and count them)

MATCH n

RETURN distinct labels(n), count(n) as count_n