Skip to content

Instantly share code, notes, and snippets.

View ciis0's full-sized avatar

Christoph Schulz ciis0

View GitHub Profile
@ciis0
ciis0 / idea.sh
Created April 27, 2023 07:33
psi -- WSLg IntelliJ with pageant agent forwarding
#!/usr/bin/env bash
set -e
#tmux_sess="$( { pgrep -f "tmux attach" || pgrep -f "tmux new"; } | head -n1)"
#if ! [[ "$tmux_sess" ]]
#then read -p "confirm no tmux"
#fi
#eval export $(cat /proc/$tmux_sess/environ | grep -z SSH_AUTH_SOCK | tr "\0" "\n")
@ciis0
ciis0 / restart.sh
Last active February 21, 2023 19:35
jboss restart with server-log rotate and waiting for jboss to be ready again
#!/usr/bin/env bash
set -ex
cd $(dirname $BASH_SOURCE)
log=standalone/log/server.log
log_new=${log}.$(date +%Y-%m-%d)
log_num=$(ls -d "$log_new"* | wc -l)
mv $log $log_new-$log_num
@ciis0
ciis0 / psl.ps1
Last active January 17, 2023 16:59
start wsl ssh and connect using Windows OpenSSH running in pterm
wsl sudo service ssh start
reg add HKEY_CURRENT_USER\SOFTWARE\SimonTatham\PuTTY\Sessions\wsl /v HostName /t REG_SZ /d $(wsl hostname -I) /f
start pterm "-e", ssh, "-A", "-p", 2222, "-l", "cschulz", "-R", ":9000:127.0.0.1:9000", $(wsl hostname -I).trim()
@ciis0
ciis0 / tool.bash
Last active September 1, 2022 17:23
quite simple tool version selector (bash-based)
#!/usr/bin/env bash
SCRIPT_CALL=${BASH_SOURCE[0]}
SCRIPT_REAL=$(realpath $SCRIPT_CALL)
name=$(basename $SCRIPT_REAL)
ver_name=${name^^}_VER
ver_default_name=${ver_name}_DEFAULT
ver_default=${ver_default_name}
@Grab(group='org.yaml', module='snakeyaml', version='1.27')
import org.yaml.snakeyaml.Yaml;
@Grab(group = 'org.slf4j', module = 'slf4j-simple', version = '1.7.27')
import org.slf4j.LoggerFactory
/*
* Groovy script to update *scalar* YAML values without touching the file structure (comments, indent, ...)
*
* snakeyaml's Nodes returned by Yaml#compose inlude start and end "Marks" describing the location the input stream.
@ciis0
ciis0 / fou-about.md
Last active January 16, 2024 02:42
setup fou (foo-over-udp) ipip tunnel on ubuntu

Some networks, e.g. Azure VNets, are quite restrictive about the supported procotols. Azure for example only supports TCP and UDP. Fortunately there is the Foo-Over-UDP ("FOU"), tunneling over UDP and thus bypassing the Azure limitation.

  1. You need a Linux distribution that supports FOU, for example Ubuntu.
    RHEL for example does not support FOU (so Fedora and CentOS probably neither).
  2. the fou module must be configured to be loaded automatically. (modprobe fou, /etc/modules.conf)
  3. choose your "foo": e.g. IPIP.
    Check your OS docs what other protocols are supported, for example via man systemd.netdev.
  4. sending and receving FOU is separated, you will need to create on device for each:
    1. create one device for sending/encapsulation (fou-tx, fou-tx.netdev)
    2. create one device for receiving/decapsulation (fou-rx, fou-rx.netdev)
  5. attach networ
@ciis0
ciis0 / jinja-recursive-templates.py
Last active December 10, 2022 09:42
Recursive Jinja Templates (based on Ansible)
#!/usr/bin/env python3
# Stolen from Ansible, thus licensed under GPLv3+.
# https://github.com/ansible/ansible/blob/13c28664ae0817068386b893858f4f6daa702052/lib/ansible/template/__init__.py#L661
# https://github.com/ansible/ansible/blob/13c28664ae0817068386b893858f4f6daa702052/lib/ansible/template/vars.py#L33
from collections.abc import Mapping, Sequence
from hashlib import sha1
from jinja2.nativetypes import NativeEnvironment
from jinja2.runtime import Macro
@ciis0
ciis0 / handlers.json
Last active May 11, 2021 06:58
Set Firefox to always download PDF and XML files (e.g. for Selenium)
{
"defaultHandlersVersion": {},
"mimeTypes": {
"application/pdf": {
"action": 0,
"extensions": [
"pdf"
]
}
}
@ciis0
ciis0 / shuffle.sh
Last active February 1, 2021 14:07
Shuffle XSPF file by album using xsltproc for e.g. Clementine
#!/bin/bash
cd $(dirname $0)
playlist=shuffled.xspf
cat >$playlist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>
@ciis0
ciis0 / README.md
Last active January 28, 2021 20:33
Exporting timeline iterations from RTC/Jazz to Outlook via CSV

Exporting timeline iterations from RTC/Jazz

  1. locate timelines via RPT API (Script 1)
  2. store result to file, convert to csv with powershell (Script 2)
  3. Import CSV with LibreOffice Calc because Excel and Outlook are too stupid to parse the timestamps properly
  4. save as CSV again, will use display values Outlook understands
  5. in outlook
    1. FileOpen & ExportImport/Export
    2. Import from another program or fileComma Separated Values
    3. Browse for your CSV file and choose destination folder