Skip to content

Instantly share code, notes, and snippets.

View jotafeldmann's full-sized avatar
🐙
Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn

Jota Feldmann jotafeldmann

🐙
Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn
  • São Paulo, SP, Brazil
View GitHub Profile
@jotafeldmann
jotafeldmann / j-slack-switch-theme.js
Created October 15, 2026 14:29
Flips app.slack.com between light and dark without touching the menus yourself.
/**
Flips app.slack.com between light and dark without touching the menus yourself. It reads the current mode from the page, opens your avatar menu → Preferences → Appearance, selects the opposite color mode, waits until the page actually changes, then closes the dialog and returns Slack theme switched to dark (or light).
Paste it in the DevTools console on app.slack.com, or run it from anything that injects a script into the tab. It only drives the DOM and needs nothing from Slack’s own JavaScript. It depends on Slack’s data-qa attributes and menu labels in English, so a Slack redesign or another interface language is what breaks it. Each step says which element it could not find.
*/
(async () => {
const sleep = ms => new Promise(r => setTimeout(r, ms));
const waitFor = async (fn, t = 8000) => {
const s = Date.now();
@jotafeldmann
jotafeldmann / ai-status.sh
Last active September 3, 2026 15:26
ai-status.sh: Quick diagnostic for the four major AI providers plus the shared layers underneath. Generated by Qwen3.8-27B Locally on an NVIDIA RTX 5090
#!/usr/bin/env bash
# ai-status.sh
# Quick diagnostic for the four major AI providers plus the shared layers underneath.
# Separates an edge failure (CDN/DNS) from an inference failure (provider status page).
#
# Usage:
# ./ai-status.sh # run once, everything
# ./ai-status.sh edge # run once, edge only
# ./ai-status.sh --watch # loop every 300s (default)
# ./ai-status.sh --watch 60 # loop every 60s
@jotafeldmann
jotafeldmann / fix-bluetooth-quality.sh
Created August 21, 2026 01:20
Recover the high-quality Bluetooth A2DP audio profile when Ubuntu reconnects
#!/usr/bin/env bash
# fix-bluetooth-quality.sh
#
# Purpose
# -------
# Recover the high-quality Bluetooth A2DP audio profile when Ubuntu reconnects
# a headset/earbuds using only the low-quality HSP/HFP "Handsfree" profile.
#
# This is intended for Ubuntu 24.04 systems using BlueZ + PipeWire +
@jotafeldmann
jotafeldmann / bst-binary-search-tree.md
Last active May 25, 2026 19:52
Binary Tree Cheat Sheet

BST: Binary Search Tree - Cheat Sheet

When to think “tree”

Use a tree when the problem has:

  • hierarchy
  • parent/child relationships
  • root, leaf, depth, height
  • nested data
@jotafeldmann
jotafeldmann / wsl-mirrored-network-mode-setup.md
Created May 6, 2026 01:08
Enable WSL2 mirrored networking on Windows 11 for localhost access to Windows services (then you can access http://localhost from WSL)

Enable WSL2 Mirrored Networking on Windows 11

This guide configures WSL2 to use mirrored networking mode, so Linux inside WSL can access Windows-hosted services through localhost.

Example use case: curl from WSL2 Ubuntu to reach Ollama running on Windows:

curl http://localhost:11434/api/tags
@jotafeldmann
jotafeldmann / save-path.sh
Created January 23, 2025 23:33
save-path.sh
# . save-path.sh
# . save-path.sh save
SAVE_PATH_FILE=$1
OPTION=$2
if [ "$OPTION" = "save" ]; then
echo $PWD > $SAVE_PATH_FILE
elif [ "$OPTION" = "create" ]; then
touch $SAVE_PATH_FILE
@jotafeldmann
jotafeldmann / ubuntu_simple_bash_git_prompt.sh
Last active August 26, 2024 18:27
ubuntu_simple_bash_git_prompt.sh
# Source: https://code.mendhak.com/simple-bash-prompt-for-developers-ps1-git/
function parse_git_dirty {
[[ $(git status --porcelain 2> /dev/null) ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ (\1$(parse_git_dirty))/"
}
export PS1="\n\t \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
@jotafeldmann
jotafeldmann / console.utils.js
Created August 16, 2024 01:38
console.utils.js
// map for list-like things
// mmap(document.querySelectorAll('a'),console.log)
function mmap (listLike, lambda){ for(let i of listLike){lambda(i)} }
@jotafeldmann
jotafeldmann / typescript-method-decorator.ts
Last active April 29, 2024 22:35
typescript-method-decorator.ts
// Edit on https://gist.github.com/jotafeldmann/c3129225ba5d0c26b5fb32273752e8fc
// Test on https://replit.com/@jotafeldmann/typescript-method-decorator#index.ts
// "experimentalDecorators": true
function log(target: any, propertyName: string, descriptor: PropertyDescriptor) {
const originalMethod = descriptor.value;
descriptor.value = function (...args: any[]) {
const result = originalMethod.apply(this, args);
console.log(`${propertyName}(${args}) = ${result}`);
@jotafeldmann
jotafeldmann / generate_query_to_sort_cols.sql
Created March 9, 2022 23:45
Generate query to sort cols (PostgreSQL)
-- Generate query to sort cols (PostgreSQL)
-- https://gist.github.com/jotafeldmann/5eeca544c8e86afe546c794636d27ebf
drop function if exists get_sorted_cols_from_table;
CREATE OR REPLACE FUNCTION get_sorted_cols_from_table(_tbl regclass, OUT result text)
LANGUAGE plpgsql AS
$func$
BEGIN
EXECUTE format('
select