Skip to content

Instantly share code, notes, and snippets.

@james1236
james1236 / keynum.md
Last active May 23, 2025 01:35
Introducting "keynum" - a concise alternative to enum

Introducting "keynum" - a concise alternative to enum

The problem with regular enums

Standard enums in JavaScript require verbose syntax for checking their value:

const STATE = {
  WAIT  = 1,
  READY = 2,
  IDLE  = 3
};
@james1236
james1236 / p10k-tmux-status.md
Last active July 18, 2025 00:33
Powerline10k tmux status window list

p10k tmux window list

Display your tmux window list directly in your terminal prompt, eliminating the tmux status bar.

image

Adds an additional powerline10k right prompt containing the window list from your tmux status

Note

Terminal prompts only update when you press enter, so you may see an out of date window list

@FabulousCupcake
FabulousCupcake / windows-bluetooth-autoconnect.md
Created August 27, 2021 18:49
Actually Disabling Bluetooth Autoconnect on Startup in Windows

Actually Disabling Bluetooth Autoconnect on Startup in Windows

Situation

I use multiple devices with my bluetooth earphone connected to my mac machine, phone, or tablet.
When I boot my windows machine, it automatically connects to and snatches my bluetooth earphone. This is very annoying.

Results from google on ways to disable this are unhelpful:

  • Unpair the device (???)
  • Disable bluetooth support system service via services.msc
  • Disable the device via Device Manager

Electron is tricky to get set up on Windows Subsystem for Linux, but it can work!

Four things needed overall:

  1. you need WSL2, not WSL1
  2. you need node, of course, and that part isn't so bad
  3. you need to apt install several dependencies
  4. you need an X Server so it can display the electron GUI over in Windows-land

Setup instructions, in order:

@YuxiUx
YuxiUx / midi-note-to-freq.md
Last active August 10, 2025 15:25
How to convert midi note to frequency in C, C++, Python, JS and PHP

JS

function noteToFreq(note) {
    let a = 440; //frequency of A (coomon value is 440Hz)
    return (a / 32) * (2 ** ((note - 9) / 12));
}

PHP

function noteToFreq($note) {
@geoffb
geoffb / simple-canvas-rotation.html
Last active February 23, 2023 20:56
A simple example of rotating a rectangle using HTML5 canvas.
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Canvas Transformation</title>
</head>
<body>
<script>
// Create our canvas and append it to the document body
var stage = document.createElement("canvas");