Skip to content

Instantly share code, notes, and snippets.

@JSquar
JSquar / remove_whitespaces.sh
Created March 25, 2026 10:07
Remove whitespaces from all files and directories in the current location
# created with the support of ChatGPT
remove_whitespaces() {
echo "Dry-run"
for f in *; do
new="${f// /_}"
if [[ "$f" == "${new}" ]]; then
continue
fi
if [[ -e "${new}" ]]; then
@JSquar
JSquar / rename_workspace.sh
Last active March 19, 2026 13:26
Rename sway workspace during runtime
# Created with the help of chatgpt
mvsway() {
if [ $# -lt 1 ]; then
echo "Usage: rename_workspace <new_label>"
echo "Example: rename_workspace 'web'"
return 1
fi
label="$1"

Script can be used to automatically setup a jupyter server on an (HPC) cluster using SLURM. The script assumes that the server shall be executed on a compute node, which can only be accessed via the login node.

The script performs the following actions:

  1. Login to login node
  2. Check if conda environment $ENV_NAME already exists. If it does it will be used (so make sure that jupyterlab is installed!), otherwise it will create a new environment and install jupyterlab. On my system conda was only available if loaded via module load python3. This will be different on other systems and needs to be adjusted accordingly.
  3. A SLURM job script (start_jupyter_server.sh) will be created within the home directory, which can be submitted via SLURM to start jupyter lab. If the file already exists, this step will be skipped. You can also use this script directly to submit the job yourself. The script is taken from here.
  4. The job script is submit
@JSquar
JSquar / gist:d8c82f11c852d3c61188e4c98096565c
Created February 8, 2022 14:14
Alias to echo environmental variables with linebreaks
splitter='sed '\''s/:/\n/g'\'' <<<'