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 / 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);

@christian-korneck
christian-korneck / README.md
Created February 14, 2022 19:42
R-Go Split Break - MacOS fixes

a config for Karabiner Elements, a MacOS keyboard mapper, that solves the following problem with the R-Go Split Keyboard (US/QWERTY) on MacOS:

  • Problem: key combinations only work on one half of the keyboard (i.e. [LEFT SHIFT]+ [A] works, but [RIGHT SHIFT] + [A] doesn't).
    • Solution: [Right Shift] <-> [Left Shift] swapped
  • Problem: Function (i.e. volume, etc) are mapped to the function keys
    • Solution: Function keys mapped to Function keys

More notes:

  • How to turn off blinking logo LED (top left) on the R-Go Split keyboard: press FN + A
@christian-korneck
christian-korneck / main.go
Created February 5, 2022 13:30
golang errors.As()
package main
import (
"errors"
"fmt"
"io/fs"
"os"
)
// output: Failed at path: non-existing