Skip to content

Instantly share code, notes, and snippets.

View christian-korneck's full-sized avatar
💭
I may be slow to respond.

Christian Korneck christian-korneck

💭
I may be slow to respond.
View GitHub Profile
@christian-korneck
christian-korneck / commit-message-toolbox.md
Created April 10, 2023 18:32
commit message building blocks
  • Why?
    • describe issue (motivation of the change)
      • describe error scenario ("as-is it throws unhandled exception on special characters").
      • introduce issue report (i.e. cite linter warnings)
      • describe shortcomings ("I'm unhappy with [...]: No timeouts, features like x are clumsy.")
    • illustrate requirement
      • usage need ("x is only works on pre-Python 3.7, but we want to support all Python 3 versions")
      • out of date ("remove outdated property. x is no longer defined, but was still referenced in the docs")
      • runtime or dev env change ("API has changed, fixing the example")
  • describe objective
@christian-korneck
christian-korneck / repeat.bat
Created April 2, 2023 15:19
batch file - execute the shell command received from stdin
@echo off
setlocal
REM batch script that executes the command that it received via STDIN
REM (whitespaces should be working)
for /f "tokens=*" %%i in ('find /v ""') do set MYCMD=%%i
cmd.exe /c %MYCMD%
set myerrorlevel=%errorlevel%
@christian-korneck
christian-korneck / appsmith_webify_powershell.md
Created March 26, 2023 15:15
powershell query with appsmith

quick & dirty powershell query with appsmith

(WARNING - very insecure)

on windows worker (here on docker host):

webify powershell -c "Get-WmiObject -Class win32_processor | Select-Object -Property Caption, DeviceID, Manufacturer, MaxClockSpeed, Name, SocketDesignation | ConvertTo-Json -Compress"
2023/03/26 16:31:11 listening on :8080, proxying to powershell -c Get-WmiObject -Class win32_processor | Select-Object -Property Caption, DeviceID, Manufacturer, MaxClockSpeed, Name, SocketDesignation | ConvertTo-Json -Compress
@christian-korneck
christian-korneck / inverse-cidr.py
Created December 18, 2022 22:06 — forked from nacx/inverse-cidr.py
Compute the inverse list of CIDR blocks
"""Use it like this: main('192.168.1.0/24')"""
IPV4_MIN = 0
IPV4_MAX = 0xFFFFFFFF
def not_network(ipv4_address, ipv4_netmask):
assert IPV4_MIN <= ipv4_address <= IPV4_MAX
assert IPV4_MIN <= ipv4_netmask <= IPV4_MAX
def hostmask_netmask(m):
@christian-korneck
christian-korneck / gist:c4d5d9c5f180cbad3be595f80ea2fe47
Created November 20, 2022 17:38
windows: use Internet over specific gateway, everything else according to other routes (i.e. another default gateway on another interface)
@echo off
setlocal
set inetgw=192.168.0.1
route delete 0.0.0.0 mask 0.0.0.0 "%inetgw%"
route delete 0.0.0.0 mask 248.0.0.0 "%inetgw%"
route delete 8.0.0.0 mask 254.0.0.0 "%inetgw%"
route delete 11.0.0.0 mask 255.0.0.0 "%inetgw%"

overwrite a function (or just anything). Target doesn't need to be exported. Go doesn't support overloading. Can't be done multiple times (i.e. trying to overwrite time.Sleep() fails as it's actually the unexported runtime.timeSleep()).

package main

import (
	"fmt"
	_ "unsafe" // required to enable go:linkname

	"log"
@christian-korneck
christian-korneck / dmidecode.md
Created July 22, 2022 16:58
dmidecode get win key
sudo grep -Eao '(-?[A-Z0-9]{5}){5}' /sys/firmware/acpi/tables/MSDM
@christian-korneck
christian-korneck / wsl2-unc.md
Created June 24, 2022 18:39
wsl2 unc linux filesystem access
\\wsl$\<distro>
\\wsl$\fedoraremix
\\wsl$\AlmaLinux-8
\\wsl$\Debian
\\wsl$\Ubuntu
\\wsl$\Ubuntu-22.04

on W11 also: \\wsl.localhost\, i.e. \\wsl.localhost\fedoraremix

@christian-korneck
christian-korneck / install_python37_on_fedora36.md
Last active June 14, 2022 13:45
install Python 3.7 on Fedora 36

build and install Python 3.7.13 from source on Fedora 36

dnf -y install gcc openssl-devel bzip2-devel libffi-devel zlib-devel xz-devel wget pkg-config
# optional:
# dnf -y groupinstall development-tools
cd /usr/src/
wget https://www.python.org/ftp/python/3.7.13/Python-3.7.13.tgz
tar xzf Python-3.7.13.tgz
cd Python-3.7.13/
@christian-korneck
christian-korneck / postman_variables_chaining.md
Created June 11, 2022 03:10
Postman - use output from request in another request (i.e. JWT token)

Postman - use request output as input for another request

Let's assume we request a JWT token from one endpoint and want to use it as Bearer Token in another request to a different endpoint.

We can:

  • 1. store the output (or part of it) in an environment variable
    • in the JWT request create a test and add some javascript. This selects the value of the JSON token {root}.token and stores it in a Postman env var token:
      token = pm.response.json().token;
      

pm.environment.set("token", token);