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 / 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 / auto-configure-desktop.sh
Created March 25, 2015 02:57
Automating Linux Desktop with wmctrl
#!/bin/sh
# WMCTRL Desktop Automation script
# ================================
# Author: Brad Jones <brad@bjc.id.au>
#
# I assume you know what wmctrl is, if not not see:
# https://sites.google.com/site/tstyblo/wmctrl/
#
# I also assume you actually read the documentation.
# I have tested this on Fedora 21 running cinnamon and it works great.
@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 / 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 / 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 / get-passwords.php
Created February 24, 2014 05:48
IMAP/POP3 Password Recovery
<?php
// Read in the users to find passwords for.
$users = array();
foreach (file('users-to-find.txt') as $line)
{
$users[] = trim($line);
}
// Create the tcpdump command to search for all pop3 and imap login traffic
@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 / DbDiff.php
Last active December 31, 2020 03:06
DbDiff
<?php
/**
* Class: DbDiff
* =============================================================================
* This class will output the SQL needed to transform db_1 into db_2 including
* DATA changes, not just schema changes!!! And it pretty fast, when run locally
* at least. I developed this to help me detect changes in CMS type databases
* like wordpress so I could create SQL migration and seeding scripts easily.
*