Skip to content

Instantly share code, notes, and snippets.

@kofigumbs
kofigumbs / proxy.js
Last active February 26, 2024 01:04
Zero-downtime Node deploys using parent process proxy, early exploration for https://kofi.sexy/blog/zero-downtime-render-disk
import { spawn } from 'child_process'
import { createServer, request } from 'http'
import pidtree from 'pidtree'
const deployCommand = ['npm', ['start']]
const deployWait = 30 * 1000
const deploySecretPath = '/~deploy-01HPZ2ACGJSJJ0NGX9MT1RYRDB'
let server = startServer(8001)
struct CompilerCache: soul::patch::RefCountHelper<soul::patch::CompilerCache, CompilerCache> {
std::mutex mutex;
std::filesystem::path path;
CompilerCache(std::filesystem::path path): path(path) {
std::filesystem::create_directory(path);
}
void storeItemInCache(const char* key, const void* source, uint64_t sourceSize) override {
std::scoped_lock lock(mutex);
std::ofstream file(this->path / key, std::ifstream::out | std::ifstream::binary);
file.write((char*) source, sourceSize);
@kofigumbs
kofigumbs / slack.js
Created December 21, 2020 20:31
Muti, reload Slack on disconnect
setInterval(() => {
if (document.body.innerText.includes('Load new messages.'))
window.location.reload();
}, 90000)
@kofigumbs
kofigumbs / links.css
Created December 21, 2020 20:29
Multi, display link targets
@kofigumbs
kofigumbs / dnd.js
Created December 21, 2020 20:27
Multi, url drag & drop
document.addEventListener("dragover", e => e.preventDefault())
@kofigumbs
kofigumbs / links.js
Created December 21, 2020 20:25
Multi, fix GSuite links
@kofigumbs
kofigumbs / find.js
Created December 21, 2020 20:19
Multi find, Cmd-F
(() => {
const highlightResults = (text, color) => {
document.designMode = "on"; // https://stackoverflow.com/a/5887719
var selection = window.getSelection();
selection.collapse(document.body, 0);
while (window.find(text)) {
document.execCommand("HiliteColor", false, color);
selection.collapseToEnd();
}
document.designMode = "off";
@kofigumbs
kofigumbs / config.json
Last active December 19, 2020 22:42
Multi internal links
{
"tabs": [
{
"title": "Substack Reader",
"url": "https://reader.substack.com",
"customJs": ["https://gist.githubusercontent.com/kofigumbs/4a9708a35807dd16f2541dc3204d6a25/raw/1579800b262aee48a3c731e0f00e3ce2d20cca01/link.js"]
}
]
}
@kofigumbs
kofigumbs / url.js
Created December 17, 2020 03:58
Multi URL bar, Cmd-K
document.addEventListener("keydown", event => {
if (event.metaKey && event.key === "k") {
event.preventDefault();
const input = document.createElement("input");
input.required = true;
input.type = "url";
input.placeholder = "URL";
input.style.position = "absolute";
input.style.top = "0";
#version 150
uniform float time;
uniform vec2 resolution;
uniform sampler2D bitmoji;
in VertexData
{
vec4 v_position;
vec3 v_normal;