Skip to content

Instantly share code, notes, and snippets.

View sthesing's full-sized avatar

Stefan Thesing sthesing

View GitHub Profile
@sthesing
sthesing / .gitignore
Last active January 5, 2016 08:20
Mr Q - Geschichte für den Writing Jam vom 24.-26.05.2013
*.pdf
*~
function detect( fn, err){
var flag = true;
setTimeout(function(){
if(flag) err();
},0);
fn();
flag = false;
}
// example with error
@sthesing
sthesing / nhk_replace.sh
Last active January 4, 2016 02:59
Replace script for app.net's @nhk using sed.
#!/bin/bash
#Cut extension off
FILENAME=`echo $1 | cut -d'.' -f1`
#Put [$FILENAME][S. ] before everything in double quotes
sed -i 's|\(\".*\"\)|['$FILENAME'][S. ]\1|g' $1
@sthesing
sthesing / snippets.conf
Last active January 4, 2016 16:09
My snippets file for Geany, mostly convenience stuff for LaTex
# Geany's snippets configuration file
#
# use \n or %newline% for a new line (it will be replaced by the used EOL char(s) - LF, CR/LF, CR).
# use \t or %ws% for an indentation step, it will be replaced according to the current document's indent mode.
# use \s to force whitespace at beginning or end of a value ('key= value' won't work, use 'key=\svalue').
# use %key% for all keys defined in the [Special] section.
# use %cursor% to define where the cursor should be placed after completion. You can define multiple
# %cursor% wildcards and use the "Move cursor in snippet" to jump to the next defined cursor
# position in the completed snippet.
# You can define a section for each supported filetype to overwrite default settings, the section
@sthesing
sthesing / rechner.py
Created May 17, 2017 09:26
Rechner Beispiel aus dem KBQ-Kurs Programmieren für Anfänger
def plus(zahl1, zahl2):
""""
Addiert zwei Zahlen.
"""
ergebnis = int(zahl1) + int(zahl2)
return ergebnis
def minus(zahl1, zahl2):
""""
Substrahiert die zweite Zahl von der ersten Zahl.
@sthesing
sthesing / zahlenraten.py
Created May 17, 2017 10:43
Zahlenraten Beispiel aus dem KBQ-Kurs "Programmieren für Anfänger"
import random
print("Willkommen beim Zahlenraten!")
untergrenze = input("Gib die Untergrenze ein: ")
obergrenze = input("Gib die Obergrenze ein: ")
# input liefert strings. Wir brauchen integers. Also umwandeln
untergrenze = int(untergrenze)
obergrenze = int(obergrenze)
@sthesing
sthesing / restart-network.5s.py
Created November 9, 2017 19:32
Argos script to restart networking with a click
#!/usr/bin/env python3
# License: WTFPL
import subprocess
status = subprocess.check_output(["nmcli", "networking", "connectivity"]).decode()
# replace "vollständig" with whatever nmcli outputs for "full" in your language setting
if status == "vollständig\n":
icon = "<span color='green'><tt>✓</tt></span>"
else: