Skip to content

Instantly share code, notes, and snippets.

@james1236
james1236 / storage.ino
Created April 28, 2025 05:02
Arduino nRF52833 flash storage example (FQBN: sandeepmistry:nRF5:BBCmicrobitV2)
#include "nrf.h"
static void flash_page_erase(uint32_t * page_address) { // Address of the first word in the page to be erased.
// Turn on flash erase enable and wait until the NVMC is ready:
NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Een << NVMC_CONFIG_WEN_Pos);
while (NRF_NVMC->READY == NVMC_READY_READY_Busy);
NRF_NVMC->ERASEPAGE = (uint32_t)page_address;
@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

@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 / count-items-alias.md
Last active July 18, 2025 00:00
Bash alias for counting files in path (or current directory) - colorful nerd fonts icons
image

Bash alias for counting files in path (or current directory), with colorful nerd fonts icons

countitems() {
  dir="${1:-.}"
  total=$(find "$dir" -mindepth 1 -maxdepth 1 | wc -l)
  files=$(find "$dir" -mindepth 1 -maxdepth 1 -type f ! -name ".*" | wc -l)
  hidden_files=$(find "$dir" -mindepth 1 -maxdepth 1 -type f -name ".*" | wc -l)