Skip to content

Instantly share code, notes, and snippets.

View mkg20001's full-sized avatar
🌟
rinse and repeat, rise and shine

Maciej Krüger mkg20001

🌟
rinse and repeat, rise and shine
View GitHub Profile
@mkg20001
mkg20001 / generate-nginx-cloudflare-allow.sh
Last active December 8, 2024 13:47
A script to generate a config to allow or additionally allow cloudflare addresses for a specific domain
#!/bin/bash
set -e
cf_ips() {
echo "# https://www.cloudflare.com/ips"
for type in v4 v6; do
echo "# IP$type"
curl -sL "https://www.cloudflare.com/ips-$type/" | sed "s|^|allow |g" | sed "s|\$|;|g"
@mkg20001
mkg20001 / waydroid.sh
Last active October 13, 2024 14:40
Waydroid in non-wayland desktop (requires cage)
#!/usr/bin/env bash
set -euxo pipefail
if [ -v INSIDE ]; then
sleep 10s
waydroid show-full-ui
exit 0
fi
@mkg20001
mkg20001 / fritzdump.sh
Created September 28, 2024 23:41
Dump Fritzbox PCAP into wireshark
#!/bin/bash
# This is the address of the router
FRITZIP=http://192.168.178.1
# This is the WAN interface
IFACE="2-0" # view from inside
#IFACE="2-1" # view from outside
# Lan Interface
@mkg20001
mkg20001 / xfce4-hm.sh
Last active May 26, 2024 19:11
Get XFCE4 xfconf settings as home-manager configuration
#!/usr/bin/env bash
# Note: unsupported elements such as arrays with non-strings will be returned as "<<UNSUPPORTED>>"
echo "xfconf.settings = {"
for m in $(xfconf-query -l); do
echo " $m = {"
for p in $(xfconf-query -l -c $m); do
v=$(xfconf-query -l -c $m -p $p -v | sed "s|.* ||g")
echo " \"$(echo "$p" | sed "s|^/||g")\" = \"$v\";"
@mkg20001
mkg20001 / inject-dirname.mjs
Created March 1, 2023 23:05
Babel Transformer that addds __dirname, __filename
import {template} from '@babel/core'
import path from 'path'
import fs from 'fs'
const header = `
import { dirname as _INJECT_d } from 'path';
import { fileURLToPath as _INJECT_f } from 'url';
const __filename = _INJECT_f(import.meta.url)
const __dirname = _INJECT_d(__filename)
`
@mkg20001
mkg20001 / nixpkgs-openwrt-update.sh
Created August 27, 2023 23:28
Nixpkgs OpenWRT update script
#!/usr/bin/env bash
# This script assums it is being run in a nixpkgs checkout
# This script will try to update all packages with sources from git.openwrt.org
# to their latest unstable version automatically
set -e
for p in $(grep -rn git.openwrt pkgs/ | sed "s|:.*$||g" | sort | uniq); do
@mkg20001
mkg20001 / opkg-deps.js
Last active May 2, 2023 23:18
OpenWRT package dependency debugging script
#!/usr/bin/env node
'use strict'
/*
Usage:
- first dump package dependencies with "opkg status > /tmp/status" and copy the file "scp -O root@your-router:/tmp/status ./dependencies"
- then use the script:
$ node opkg-deps.js ./dependencies why luci
$ node opkg-deps.js ./dependencies search iptables
@mkg20001
mkg20001 / index.html
Created February 27, 2023 21:42
Simple Cookie Switcher
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
@mkg20001
mkg20001 / binary_decode_encode.js
Created December 18, 2022 12:45
Node functions to decode and encode strings into literal binary format
// Decode binary
function decodeBinary(arr) {
let out = ''
for (let i = 0; i < arr.length; i += 8) {
out += String(Buffer.from(parseInt(arr.slice(i, i + 8), 2).toString(16), 'hex'))
}
return out
}
@mkg20001
mkg20001 / README.md
Last active March 4, 2022 01:58
Download Chrome OS Flex on Linux

chrome-os-flex-downloader

You're on linux, the Chrome OS Recovery Utility isn't supported, but you'd still want to try Chrome OS Flex? Worry no more!

(NOTE: I'm aware of Googles offical Linux script, but that one is "in maintaince mode" and also doesn't have flex)

usage

Install the following packages: jq, curl, wget, unzip (most, if not all, should be preinstalled)