Skip to content

Instantly share code, notes, and snippets.

View pschichtel's full-sized avatar

Phillip Schichtel pschichtel

View GitHub Profile
@pschichtel
pschichtel / howto.md
Last active January 11, 2021 18:53
Batch script to enable IP forwarding on Windows. I use this to (ab)use Windows PCs as a Gateway into a site-to-site VPN.

Steps to setup external site

  1. Run setup_ip_forwarding.bat script to enable IP forwarding on Windows.
  2. Configure Windows firewall to accept traffic from all remote networks.
  3. Install wireguard and setup connection to central wireguard server with all remote networks as part of AllowedIPs and a unique IP within the wireguard network.
  4. Setup fritzbox to a custom local IP address range (e.g. 192.168.110.0/24) that is unique in all sites.
  5. Setup a static DHCP lease or a static IP for the local wireguard system.
  6. Setup static routes in fritzbox for each remote network using the local wireguard system's IP as the gateway/nexthop.
  7. For central wireguard server setup route for the network address range of the new external site.
@pschichtel
pschichtel / synthesize.sh
Created October 23, 2020 17:59
Small bash script that synthesizes text to speech using Google's services. The script expects the gcloud CLI tool, curl and jq installed in the path.
#!/usr/bin/env bash
voice="${1?no voice given!}"
gender="${2?no gender given!}"
text="${3?no text given!}"
file_name="${4:-"-"}"
access_token="$(gcloud auth application-default print-access-token)"
if echo "$text" | grep -q "<speak>"
then
@pschichtel
pschichtel / control_screen.sh
Last active January 1, 2021 19:33
Small script to control a screen using CEC
#!/usr/bin/env bash
device="${CEC_DEVICE:-0.0.0.0}"
command="${1?no command given}"
case "$command" in
on)
cec_command="on $device"
;;
@pschichtel
pschichtel / fourier.html
Created August 16, 2020 18:50
A simple FFT (fast fourier transform) implementation in browser JS
<!DOCTYPE html>
<html>
<head>
<title>Fourier</title>
<meta charset="UTF-8">
</head>
<body>
<textarea></textarea>
<table>
<thead>
@pschichtel
pschichtel / jsonpath.ts
Created July 14, 2020 21:53
A simple typescript script that parses json paths and composes a lense function
function extractorFor(selector: String): (x: any) => any {
function composeAccess(f: (x: any) => any, field: string): (x: any) => any {
return (x: any) => {
let r = f(x)
if (field in r) return r[field]
else return null
}
}
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
"RealTimeIsUniversal"=dword:00000001
@pschichtel
pschichtel / build-debug.sh
Created November 13, 2019 00:54
Arch Debug Build
#!/usr/bin/env bash
here="$(readlink -f "$(dirname "$0")")"
export PKGDEST="${here}/out"
makepkg --config "${here}/makepkg.conf" --sync --asdep -f
@pschichtel
pschichtel / play_video.sh
Created May 18, 2019 14:26
Simple script to play the video from a capture card
#!/bin/bash
device=/dev/video2
amixer -c stk1160mixer sset Line unmute cap
vlc -vvv --color --input-slave=alsa://pulse --live-caching=300 \
--v4l2-standard=PAL --deinterlace-mode=yadif \
--video-filter=deinterlace "v4l://${device}"
@pschichtel
pschichtel / eurit-4000-phonebook-migrate.py
Created December 2, 2018 21:22
The is a script to convert the phonebook CSV export from the EuriTel Pro software (used for old Ascom/Swissvoice analog phones together with the "PC-Dialer III" device) to the CSV schema supported by outlook and sipgate.de. It applies a bunch of assumptions to extract customer numbers and other contact details to the proper fields.
# coding=utf-8
import sys
import csv
import vobject
import re
whitespace = re.compile('\s+')
numberCleaner = re.compile('^.*?(\d+).*$')
customerIdFormat = re.compile('^\S*?\d+$')
extern crate multimap;
use std::hash::Hash;
use multimap::MultiMap;
fn main() {
let mut mmap = MultiMap::new();
mmap.insert(1, 'a');
mmap.insert(1, 'a');