Skip to content

Instantly share code, notes, and snippets.

View NeuronButter's full-sized avatar
:octocat:
yes

Neeron Bhatta NeuronButter

:octocat:
yes
View GitHub Profile
@NeuronButter
NeuronButter / size.sql
Created July 23, 2025 11:16
PostgreSQL Physical Size
--- Get total WAL sizes / file count
SELECT
pg_size_pretty(SUM(size)) AS total_wal_size,
COUNT(*) AS wal_file_count
FROM pg_ls_dir('pg_wal') f(name)
JOIN LATERAL pg_stat_file('pg_wal/' || name) s ON true
WHERE name ~ '^[0-9A-F]{24}$';
--- Get sizes per db
SELECT
@NeuronButter
NeuronButter / editorconfigFix.sh
Created July 16, 2025 13:28
Fix .editorconfig violations
# This script is old, archived, and has deprecated dependencies (including security vulnerabilities)
# But I don't care this still works so oh well
pnpx eclint fix
@NeuronButter
NeuronButter / longhornmount.md
Last active August 6, 2025 06:26
Mounting Longhorn volumes

Usually Longhorn devices attached to a node are usually:

/dev/longhorn/{volumename}

So just mount it to a temporary folder and unmount it when finished:

sudo mount /dev/longhorn/{volumename} tempmount
@NeuronButter
NeuronButter / uno.config.ts
Last active July 3, 2025 01:58
Reasonable UnoCSS Starter
import { defineConfig } from 'unocss'
import presetIcons from '@unocss/preset-icons'
import presetWebFonts from '@unocss/preset-web-fonts'
import presetWind4 from '@unocss/preset-wind4'
import presetTypography from '@unocss/preset-typography'
export default defineConfig({
presets: [
presetWind4({
dark: 'media'
@NeuronButter
NeuronButter / constrastedColour.ts
Last active July 3, 2025 01:54
Get Contrasting Black or White Colour (TS/JS)
// modified version of https://hackmd.io/@Markdown-It/HJeV6339X
export function getContrastYIQ(hexcolor: string): string {
const hex = hexcolor.replace('#', '')
const r = parseInt(hex.slice(0, 2), 16)
const g = parseInt(hex.slice(2, 4), 16)
const b = parseInt(hex.slice(4, 6), 16)
const yiq = (r * 299 + g * 587 + b * 114) / 1000
return yiq >= 120 ? 'black' : 'white'
}
@NeuronButter
NeuronButter / cloudflaredtunnels.js
Last active January 22, 2025 10:51
Programmatically use cloudflared Quick Tunnels
// Original answer here https://community.cloudflare.com/t/quick-tunnel-from-nodejs/336868/3
const express = require('express');
const { spawn } = require('child_process');
let port = 8080;
// Express
let app = express();
app.get('/', (req, res) => res.send('Hi'));
app.listen(port);