Skip to content

Instantly share code, notes, and snippets.

Raymond Hettinger - Beyond PEP 8 -- Best practices for beautiful intelligible code - PyCon 2015

https://www.youtube.com/watch?v=wf-BqAjZb8M

Avoid unnecessary packages in favor of simpler imports

nettools.py

class NetworkError(Exception):
    pass
@schilli91
schilli91 / sample.service
Created January 17, 2021 23:25
Sample systemd service file.
[Unit]
Description=sample service
[Service]
User=johndoe
WorkingDirectory=/path/to/working_dir/
ExecStart=/path/to/working_dir/serve.sh
Restart=always
[Install]

TypeScript (TS)

TS is based on the JavaScript (JS) language and can be seen as a type checker for JS apps. During compilation, the TS code is evaluated for correct typing and subsequently compiled to plain JS code. It introduces the concept of types to JS.

Type System

@schilli91
schilli91 / clear_jenkins_build_history.groovy
Last active November 17, 2020 12:41
Delete Jenkins build history
# https://superuser.com/questions/1418885/clear-jenkins-build-history-clear-build-yesterday/1418896
def jobName = "JOB_NAME"
def job = Jenkins.instance.getItem(jobName)
job.getBuilds().each { it.delete() }
job.nextBuildNumber = 1
job.save()
# Credit:
# https://stackoverflow.com/a/34467298/6180150
# https://stackoverflow.com/a/9074343/6180150
[alias]
lg = lg1
lg1 = lg1-specific --all
lg2 = lg2-specific --all
lg3 = lg3-specific --all
lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
#!/bin/bash
git config --global alias.ll 'log --oneline --graph --all '
git config --global alias.st 'status '
git config --global remote.origin.prune true
git config --global rerere.enabled=true
git config --global core.editor=vim
git config --global core.pager=less -F -X
git config --global diff.wsErrorHighlight all
#!/bin/bash
alias ducks='du -cks * | sort -rn | head'
@schilli91
schilli91 / scheduler.py
Created May 4, 2020 13:55
Schedules a notification every second and runs it in background thread.
import threading
from time import sleep
import schedule
class Notifier(threading.Thread):
def __init__(self):
super(Notifier, self).__init__()
https://github.com/pyenv/pyenv/issues/94
On MacOS you may need to set some env. vars. in order for the pyenv installation to pick up the homebrew tcl-tk. Check your brew info tcl-tk's caveats section for the exact values you should use.
pyenv uninstall 3.8.1
export PATH="/usr/local/opt/tcl-tk/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/tcl-tk/lib"
export CPPFLAGS="-I/usr/local/opt/tcl-tk/include"
export PKG_CONFIG_PATH="/usr/local/opt/tcl-tk/lib/pkgconfig"
pyenv install 3.8.1
% standalone um Bild zu rendern
% Fuer standalone luatex85
% \RequirePackage{luatex85}
% \documentclass{standalone}
\documentclass{article}
\usepackage[dvipsnames,table]{xcolor}
\usepackage{tikz}
\usetikzlibrary{graphdrawing, graphs, backgrounds, fit, positioning, calc, arrows}
\usegdlibrary{layered}