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 / 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 / xfce4-hm.sh
Last active July 26, 2023 19:30
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 / 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 / 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 / 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)

@mkg20001
mkg20001 / ignore-warnings-pytest.md
Last active November 3, 2021 04:34
Ignore pytest failure because of warnings

If you're trying to get pytest running for old packages you may encounter failures due to ResourceWarning or DeperactionWarning errors

Those can be easily resolved by executing pytest as follows:

pytest -v tests -W ignore::ResourceWarning -W ignore::DeprecationWarning

In your nixpkgs package that would be

@mkg20001
mkg20001 / cjs-to-esm-helpers.js
Last active August 31, 2021 21:56
Common things from CJS brought to ESM
/*
NOTE:
- The metadata of the current module "module" in ESM is under "import.meta"
- Dynamic import is always async, meaning you need to await it
- Also if you export default it's under .default, no longer returned directly
*/
@mkg20001
mkg20001 / export-chrome-domains.js
Last active July 6, 2021 06:43
Export all Domains from Chrome Browser History
'use strict'
// go to https://takeout.google.com/settings/takeout
// Create new export
// Select chrome
// Download the export
// Extract it and run this script in the folder (you can directly run from node REPL)
const history = require('./Takeout/Chrome/BrowserHistory.json')