Skip to content

Instantly share code, notes, and snippets.

@AbeEstrada
AbeEstrada / capslock_esc.reg
Last active January 20, 2026 14:57
Windows 10/11 registry modification to replace Caps Lock by Escape
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,01,00,3a,00,00,00,00,00
; Data = 00000000 00000000 0200000000 01003A00 00000000
; 0x00000000 Header: Version. Set to all zeroes.
; 0x00000000 Header: Flags. Set to all zeroes.
; 0x00000002 Two entries in the map (including null entry).
@AbeEstrada
AbeEstrada / main.lua
Last active January 20, 2026 00:07
Yazi preview macOS sips
local M = {}
function M:peek(job)
local start, cache = os.clock(), ya.file_cache(job)
if not cache then return end
local ok, err = self:preload(job)
if not ok or err then
return ya.preview_widget(job, err)
end
@AbeEstrada
AbeEstrada / tog.sh
Last active January 15, 2026 02:42
Toggle booleans
#!/usr/bin/env bash
if [[ $# -gt 0 ]]; then
input="$1"
else
read -r input _ <<< "$(cat)"
fi
if [[ -z "$input" ]]; then
exit 0
@AbeEstrada
AbeEstrada / longestWord.ts
Created September 17, 2025 00:18
Exercise: find the longest word in a sentence
const longestWord = (str: string): void => {
if (str?.length === 0) return;
const words: string[] = str.split(" ");
const longest: string = words.reduce(
(a, b) => (b.length > a.length ? b : a),
"",
);
console.log(longest.length, longest);
};
@AbeEstrada
AbeEstrada / commits.md
Created September 13, 2025 20:38
Conventional Commits
build(build system or external dependencies changes)
ci(CI configurations and scripts changes)
docs(documentation)
feat(feature)
fix(bug fix)
perf(improves performance)
refactor(restructuring existing code, but not bug or feature)
revert(reverts a previous commit)
style(formatting, missing semi colons, etc.)
@AbeEstrada
AbeEstrada / whatFlavors.js
Created September 3, 2025 03:26
Exercise: Hash Tables Ice Cream Parlor
function whatFlavors(cost, targetAmount) {
const priceToIndexMap = new Map();
for (const [currentIndex, currentPrice] of cost.entries()) {
const neededPrice = targetAmount - currentPrice;
const displayIndex = currentIndex + 1;
if (priceToIndexMap.has(neededPrice)) {
const firstFlavorIndex = priceToIndexMap.get(neededPrice);
console.log(`${firstFlavorIndex} ${displayIndex}`);
return;
}
@AbeEstrada
AbeEstrada / checkMagazine.js
Created September 3, 2025 03:18
Exercise: Hash Tables Ransom Note
function checkMagazine(magazine, note) {
// Create a frequency map of words available in the magazine
const availableWords = new Map();
for (const word of magazine) {
const currentCount = availableWords.get(word) ?? 0;
availableWords.set(word, currentCount + 1);
}
// Check if we can form the note using available words
for (const requiredWord of note) {
const remainingCount = availableWords.get(requiredWord) ?? 0;
@AbeEstrada
AbeEstrada / quickSort.js
Created September 3, 2025 00:55
Exercise: Quicksort (Partition)
function quickSort(arr) {
if (arr.length === 0) return [];
const pivot = arr[0];
const left = arr.filter((num, i) => i !== 0 && num < pivot);
const equal = arr.filter(num => num === pivot);
const right = arr.filter((num, i) => i !== 0 && num > pivot);
return [...left, ...equal, ...right];
}
@AbeEstrada
AbeEstrada / bigSorting.js
Created September 3, 2025 00:45
Exercise: Big Sorting
function bigSorting(unsorted) {
return unsorted.sort((a,b) => {
const bigA = BigInt(a);
const bigB = BigInt(b);
if (bigA < bigB) return -1;
if (bigA > bigB) return 1;
return 0;
});
}
@AbeEstrada
AbeEstrada / checkLevelOrderBST.js
Created September 3, 2025 00:27
Exercise: Is This a Binary Search Tree?
function checkLevelOrderBST(levelOrder) {
if (levelOrder.length === 0) return true;
let i = 0;
const n = levelOrder.length;
// Stack to store nodes with their min and max constraints
const stack = [];
stack.push({
data: levelOrder[0],
min: -Infinity,
max: Infinity,