Skip to content

Instantly share code, notes, and snippets.

View leidegre's full-sized avatar

John Leidegren leidegre

View GitHub Profile
@leidegre
leidegre / uninstall.py
Last active November 4, 2023 08:36
Uninstall a bunch of apps by invoking the UninstallString for apps matching DisplayName (passed on command line)
# requires python 3.6 or later
# run as elevated user (requires admin permission for reg delete)
# python uninstall.py "<DisplayName>"
# you will get to confirm matching apps before any uninstall takes place
import sys
import winreg
import subprocess
def get_matching_apps(filter_string):
@leidegre
leidegre / common-error.hh
Created August 6, 2023 07:03
Tiff loader, very basic
#pragma once
namespace game {
enum ErrorCode {
// Prefix with GRR_
G_ERR_OK = 0,
G_ERR_ERROR,
G_ERR_WIN32,
G_ERR_FILE_NOT_FOUND,
G_ERR_QUIT,
@leidegre
leidegre / a.c
Last active February 17, 2023 12:16
Tundra nil Depends repo
int a()
{
return 3;
}
@leidegre
leidegre / seq.ts
Created April 8, 2021 11:24
Lazy sequence that does composition via transducers (can be extended to do chunked stuff for async support)
/** Sentinel value. Signal break. */
const BREAK = Symbol("break")
type Break = typeof BREAK
function isBreak<Result>(result: Result | Break): result is Break {
return result === BREAK
}
/** Sentinel value. Signal continue. */
@leidegre
leidegre / eq.js
Created August 26, 2020 06:42
Hashing and strict value equality for JavaScript primitives
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const xxh_1 = require("./xxh");
// Hash randomization
const SEED_ARRAY = (1000000000 * Math.random()) | 0;
const SEED_BIG = (1000000000 * Math.random()) | 0;
const SEED_NUM = (1000000000 * Math.random()) | 0;
const SEED_STR = (1000000000 * Math.random()) | 0;
const SEED_KEY = (1000000000 * Math.random()) | 0;
const SEED_DATE = (1000000000 * Math.random()) | 0;
@leidegre
leidegre / README.md
Last active March 1, 2021 15:30
The neverending story about autofill in Chrome

The autofill is overlaying my web component and atemptting to insert my home address into this field which is a database configurator, it has nothing to do with my home address. So why can't I get rid of it!?


Background

The issue here is with autofill. The feature in Chrome that fills in form data for you. It's great when it works but it doesn't always work and nobody thinks its reasonable to expect the browser to ever get it right, every time. There's simply not enough context. And for some reason the Chrome/Chromium dev team is stonewalling on this issue, despite the fact that they are making life really difficult for a lot of people. It is as if they have a religious stance on this issue. Every response from a Google or Chromium person fails to capture just how much they are pissing people of with this nonsense.

@leidegre
leidegre / tundra.lua
Created April 20, 2019 05:43
Implicit build units with Tundra
local msvc_common = {
{"/MDd", Config = "*-msvc-debug-*"},
--Unicode
"/DUNICODE",
"/D_UNICODE",
"/D_CRT_SECURE_NO_WARNINGS",
"/D_WINSOCK_DEPRECATED_NO_WARNINGS",
"/W4",
--treat as error
"/we4701", --Potentially uninitialized local variable 'name' used
@leidegre
leidegre / gen-base32-id.js
Created August 25, 2018 12:13
gen-base32-id.js
function genBase32Id() {
// Math.pow(2, 40): 1099511627776
const x = Math.floor(Math.random() * 1099511627776).toString(32) // 40 bits
// padding
switch (x.length) {
case 8:
return x
case 7:
return "0" + x
case 6:
@leidegre
leidegre / channel-test.js
Created August 21, 2018 18:59
Go channel abstraction for JavaScript
const { default: Channel } = require("./channel");
const timeout = 100;
async function unbuffered() {
const xs = [];
var ch = new Channel();
xs.push("start");
setTimeout(async () => {
xs.push("timeout");
@leidegre
leidegre / main.go
Created July 4, 2018 08:44
Heap issue
package main
func main() {
println([]int{})
}