Skip to content

Instantly share code, notes, and snippets.

View tomschr's full-sized avatar

Tom Schraitle tomschr

View GitHub Profile
@tomschr
tomschr / subprocess_run.py
Last active June 21, 2019 08:43
Use subprocess.run for Python < 3.5
# Source: https://github.com/mitsuhiko/pipsi/blob/master/pipsi/__init__.py
from collections import namedtuple
import subprocess
def proc_output(s):
s = s.strip()
if not isinstance(s, str):
s = s.decode('utf-8', 'replace')
return s
@powersj
powersj / template.sh
Created September 6, 2017 20:47
Bash Shell Script Template
#!/bin/bash
# Bash script template
#
# Copyright 2017 Canonical Ltd.
# Joshua Powers <josh.powers@canonical.com>
VERBOSITY=0
TEMP_D=""
error() { echo "$@" 1>&2; }
@tomschr
tomschr / example-cli-argparse.py
Last active April 21, 2024 08:13
Template for an example CLI program with argparse, docopts and logging
#!/usr/bin/env python3
import argparse
import logging
from logging.config import dictConfig
import sys
__version__ = "0.2.0"
__author__ = "Tux Penguin <tux@example.net>"
@dmpop
dmpop / neonasms.txt
Last active May 18, 2017 12:26
THe doc team bEINg Crateive agiaN
abschnecken
nirgendwas
dement sprechend, dement schweigend
Nussschnecke - Frollein, das zwar nicht clever, aber dafür schön ist
bemitneiden
writearound
Schnexitus
Schnexit
Schneckopocalypse -> Schnec(k)olypse!
clusterfake - Sven's Raspberry Pi 3 Ceph cluster
@mivade
mivade / cli.py
Last active January 18, 2024 07:51
Using a decorator to simplify subcommand creation with argparse
"""This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@pylover
pylover / a2dp.py
Last active May 27, 2024 21:51
Fixing bluetooth stereo headphone/headset problem in ubuntu 16.04, 16.10 and also debian jessie, with bluez5.
#! /usr/bin/env python3
"""Fixing bluetooth stereo headphone/headset problem in debian distros.
Workaround for bug: https://bugs.launchpad.net/ubuntu/+source/indicator-sound/+bug/1577197
Run it with python3.5 or higher after pairing/connecting the bluetooth stereo headphone.
This will be only fixes the bluez5 problem mentioned above .
Licence: Freeware
@ericclemmons
ericclemmons / example.md
Last active April 24, 2024 18:09
HTML5 <details> in GitHub

Using <details> in GitHub

Suppose you're opening an issue and there's a lot noisey logs that may be useful.

Rather than wrecking readability, wrap it in a <details> tag!

<details>
 Summary Goes Here
@chrismccoy
chrismccoy / gitcheats.txt
Last active June 18, 2024 13:42
git cheats
# alias to edit commit messages without using rebase interactive
# example: git reword commithash message
reword = "!f() {\n GIT_SEQUENCE_EDITOR=\"sed -i 1s/^pick/reword/\" GIT_EDITOR=\"printf \\\"%s\\n\\\" \\\"$2\\\" >\" git rebase -i \"$1^\";\n git push -f;\n}; f"
# count total commits in a repo
git rev-list --all --count
# edit all commit messages
git rebase -i --root
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active June 16, 2024 13:44
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@dbast
dbast / uniform_exposure.py
Created December 11, 2013 21:13
uniform_exposure.py multiprocessing version
# Develop a bunch of raw pics so they look pretty much equally exposed.
# Copyright (2013) a1ex. License: GPL.
# Requires python, ufraw, enfuse, ImageMagick and exiftool.
# Usage:
# 1) Place your raw photos under a "raw" subdirectory; for example:
#
# $ ls -R
# .: