Skip to content

Instantly share code, notes, and snippets.

View brad-jones's full-sized avatar

Brad Jones brad-jones

View GitHub Profile
@brad-jones
brad-jones / Dockerfile
Created January 16, 2023 03:03
WSL Home Disk Auto Mount
ARG USERNAME
ARG WSL_DISTRO_NAME
RUN mv /home /home-tpl
COPY ./mount-home.ts /usr/bin/mount-home.ts
RUN deno cache /usr/bin/mount-home.ts
RUN chmod +x /usr/bin/mount-home.ts
RUN sed -i "s/%USERNAME%/$(printf '%s\n' "$USERNAME" | sed -e 's/[\/&]/\\&/g')/g" /usr/bin/mount-home.ts
RUN sed -i "s/%WSL_DISTRO_NAME%/$(printf '%s\n' "$WSL_DISTRO_NAME" | sed -e 's/[\/&]/\\&/g')/g" /usr/bin/mount-home.ts
COPY ./mount-home.service /usr/lib/systemd/system/mount-home.service
RUN systemctl enable mount-home.service
@brad-jones
brad-jones / xdg-open
Created January 16, 2023 02:56
xdg-open (WSL)
#!/bin/bash
exec deno run --cached-only -qA /usr/bin/xdg-open.ts "$@"
@brad-jones
brad-jones / README.md
Created January 9, 2023 09:03
Notes on Evakool Fridge WiFi Protocol

evakool

My evakool fridge comes with an app that connects over WiFi to a proprietary TCP service. ie: not HTTP.

The Android app that talks to this TCP service is shit.

I'm going to attempt to make a less shit app.

The Network

@brad-jones
brad-jones / libc.js
Created August 18, 2021 08:23 — forked from hinzundcode/libc.js
call execve from nodejs!
const { syscall, getAddress } = require("libsys");
const os = require("os");
if (os.endianess() != "LE")
throw "only little endian supported";
let dontGC = [];
function ref(buffer) {
dontGC.push(buffer);
return getAddress(buffer);
@brad-jones
brad-jones / ETLFrameworkThingo.md
Created August 11, 2021 11:44
Ideas about a new ETL Framework / SDK / Service

ETL Framework Thingo

Ok so my issue is essentially the same one that the steampipe tool has set out to solve.

Everyone that has worked with cloud service providers understands how hours can be wasted bouncing back and forth between tools to answer simple questions about your environment.

@brad-jones
brad-jones / Elevate when needed in Go.md
Created March 19, 2021 02:29 — forked from jerblack/Elevate when needed in Go.md
Relaunch Windows Golang program with UAC elevation when admin rights needed.

I'm buiding a command line tool in Go that has an option to install itself as a service on Windows, which it needs admin rights for. I wanted to be able to have it reliably detect if it was running as admin already and if not, relaunch itself as admin. When the user runs the tool with the specific switch to trigger this functionality (-install or -uninstall in my case) they are prompted by UAC (User Account Control) to run the program as admin, which allows the tool to relaunch itself with the necessary rights.

To detect if I was admin, I tried the method described here first:
https://coolaj86.com/articles/golang-and-windows-and-admins-oh-my/
This wasn't accurately detecting that I was elevated, and was reporting that I was not elevated even when running the tool in CMD prompt started with "Run as Administrator" so I needed a more reliable method.

I didn't want to try writing to an Admin protected area of the filesystem or registry because Windows has the ability to transparently virtualize those writes

@brad-jones
brad-jones / Dockerfile
Created May 11, 2020 23:37
apt virtual deps, like apk virtual
RUN export BUILD_PACKAGES="gnupg curl ca-certificates apt-transport-https" \
&& export EXISTING_PACKAGES="$(mktemp)" && apt-mark showauto | sort > $EXISTING_PACKAGES \
&& apt-get update && apt-get install -y --no-install-recommends $BUILD_PACKAGES \
&& export NEW_PACKAGES="$(mktemp)" && apt-mark showauto | sort > $NEW_PACKAGES \
&& export PACKAGES_TO_REMOVE="$(comm -23 $NEW_PACKAGES $EXISTING_PACKAGES)" \
\
&& mkdir -p /usr/share/man/man1 \
&& curl -s https://apt.corretto.aws/corretto.key | apt-key add - \
&& echo 'deb https://apt.corretto.aws stable main' > /etc/apt/sources.list.d/corretto.list \
&& apt-get update && apt-get install -y --no-install-recommends java-1.8.0-amazon-corretto-jdk \
@brad-jones
brad-jones / login.ps1
Created April 23, 2020 02:04
RDP CLI
cmdkey /generic:"TERMSRV/{{IP_OR_HOSTNAME}}" /user:"{{USERNAME}}" /pass:"{{PASSWORD}}"; mstsc.exe /v:"{{IP_OR_HOSTNAME}}"; cmdkey /delete:"TERMSRV/{{IP_OR_HOSTNAME}}";

Keybase proof

I hereby claim:

  • I am brad-jones on github.
  • I am bradjones (https://keybase.io/bradjones) on keybase.
  • I have a public key ASCTchBbxm2cbiSY41DxpQVSFARWzcWGFRZ2FGfuj4_TzQo

To claim this, I am signing this object:

@brad-jones
brad-jones / Dockerfile
Last active September 10, 2020 04:35
buildkit cache reproducer - see: https://github.com/moby/buildkit/issues/723
FROM alpine:latest AS devel
RUN apk --no-cache add git
RUN mkdir /app
RUN touch /app/foo
FROM scratch AS runtime
COPY --from=devel /app/. /app