things to keep

diverting content of a developers life

Python - Basic - print variables inline of a string

2023-01-29 1 min read dev ckroeger
I’m new to python and asked me how to print variables in a string without concatination. Here it is: # first we need data karl = { 'who': 'karl', 'days': { 29: 4, 28: 4, 27: 6, 26: 4, 25: 4 } } print(f"{karl['who']}: {karl['days'][26]}") Output: karl: 4 The var-name between the curly braces will be printed. varData = "world" print(f"Hello {varData}") Output: Hello world

gc - another shell alias

2022-12-24 1 min read dev ckroeger
Wouldn’t it be nice to have a alias for cloning a git repo and change to cloned directory? Here it is: # clones git and change to new dir alias gc='_gc(){ git clone $1 && cd `echo "$1" \ | sed -E "s|.*/([a-zA-Z0-9\\-]+)\.git|\1|"`; }; _gc' Usage: $ gc <CLONE-URL>