Skip to content

Instantly share code, notes, and snippets.

View benjamingwynn's full-sized avatar
💡

Benjamin Gwynn benjamingwynn

💡
  • United Kingdom
  • 11:27 (UTC +01:00)
View GitHub Profile
# note to self: packages for building on fedora(ish) are
# autoconf automake libtool glib2-devel json-glib-devel systemd-devel libus1-devel libX11-devel libXrandr-devel jansson-devel
# read. worth noting that no registers ever changed between input swapping HDMI1 and DP. also maybe worth noting that i dont think --i1 x50 would do anything here, but im no expect i literally discovered ddc existed today
$ ddcutil getvcp scan --i1 x50
VCP code 0x02 (New control value ): One or more new control values have been saved (0x02)
VCP code 0x0b (Color temperature increment ): Invalid value: 0
VCP code 0x0c (Color temperature request ): 3000 + 35 * (feature 0B color temp increment) degree(s) Kelvin
VCP code 0x0e (Clock ): current value = 50, max value = 100
@benjamingwynn
benjamingwynn / index.js
Last active October 19, 2022 13:54
Generate a random hexadecimal colour in Javascript
function generateRandomColour () {
return '#'+(Math.random() * 0xffffff | 0).toString(16).padStart(6, '0')
}
@benjamingwynn
benjamingwynn / location-calc.js
Created October 11, 2020 19:14
Calculate how often Google Location data is recorded/sent to Google using Location History.json from Google Takeout
// use nodejs to load location history.json from your google takeout folder -b
var data=require('./Location History')
var times=data.locations.map(d=>parseInt(d.timestampMs))
var between=times.map((t,i) => times[i-1] ? t-times[i-1] : 0 )
var mean=between.reduce((a,v)=>a+v)/between.length
var meanInMinutes=mean/1000/60
console.log("Google location data reported every " + meanInMinutes + " minutes.")
@benjamingwynn
benjamingwynn / open
Last active March 20, 2023 05:59
macOS open command for WSL (Windows Subsystem for Linux)
#!/bin/bash
# open
# macOS open command for WSL (Windows Subsystem for Linux)
# written by benjamin gwynn (https://benjamingwynn.com)
# get latest version here: https://gist.github.com/benjamingwynn/a778aa6cf2dd461dc18978f245bd90c1
#
# You can run this on WSL wuth no prior setup or changes to host Windows.
#
# See: * https://docs.microsoft.com/en-us/windows/wsl/interop#run-windows-tools-from-linux
# * https://stackoverflow.com/a/501295
@benjamingwynn
benjamingwynn / google-home-bluetooth-windows-10-repair.py
Created May 31, 2020 23:31
Actually gets Google Home's bluetooth to connect reliably on Windows 10. Fixes pairing issues, stuck paired issue and just makes the whole process a lot less awful.
# Actually gets Google Home's bluetooth to connect reliably on Windows 10.
# Unpairs Windows AND Google Home using MAC address, then sets everything up for a one-click connection.
# * Prevents Google Home from getting stuck paried using bttool, which is apparently the only way to fix that?
# * Uses some code from Stack Overflow to get the IP from the MAC address so you don't have to dick around with static IP's
# * Connects reliably by repairing bluetooth on Google Home using the "secret" REST API (https://rithvikvibhu.github.io/GHLocalApi)
# * Opens control legacy panel after setting up Google for pairing
#
# Needs btpair installed first, get it from http://bluetoothinstaller.com/bluetooth-command-line-tools/
/** Image object for WebAppManifest */
declare interface WebAppManifestIcon {
/** A string containing space-separated image dimensions. */
sizes: string,
/** The path to the image file. If src is a relative URL, the base URL will be the URL of the manifest. */
src: string,
/** A hint as to the media type of the image. The purpose of this member is to allow a user agent to quickly ignore images of media types it does not support. */
type: string,
}
@benjamingwynn
benjamingwynn / theme.css
Last active December 5, 2017 14:16
ProtonMail Modern Theme
/**
White modern theme for ProtonMail
Work-in-progress (v2) - Copyright Benjamin Gwynn, 2017 (http://benj.pw)
*/
body {
--font: "Roboto", "Cantarell", "Segoe UI", "Ubuntu", sans-serif;
font-family: var(--font);
}
// copy current children except a certain child while keeping all refs - a pain in the ass.
let i = oldParent.childNodes.length - 1
for (; i >= 0; i -= 1) {
const c = oldParent.childNodes[i]
// whatever, your condition here
if (c.nodeName.toLowerCase() !== "slot") {
newParent.appendChild(c)
const TeamspeakQuery = require('teamspeak-query')
, query = new TeamspeakQuery('127.0.0.1', 10011)
, TARGET_CLIENT = 1
, TARGET_CHANNEL = 2
, TARGET_SERVER = 3
, Steam = require("steam-webapi")
, console = require("better-console")
, jsonfile = require("jsonfile")
, SQ_PASSWD = "oh boy this sure is a secret password"
/* TeamSteam - written by Benjamin Gwynn for ts3.xenxier.com */
const TeamspeakQuery = require('teamspeak-query')
, query = new TeamspeakQuery('127.0.0.1', 10011)
, TARGET_CLIENT = 1
, TARGET_CHANNEL = 2
, TARGET_SERVER = 3
, Steam = require("steam-webapi")
, console = require("better-console")
, jsonfile = require("jsonfile")