Skip to content

Instantly share code, notes, and snippets.

View dejurin's full-sized avatar
💭
;-)

YURII D. dejurin

💭
;-)
View GitHub Profile
@dejurin
dejurin / path.ts
Created April 13, 2025 09:12
Monkey patch: Added non-passive event listener to a scroll-blocking 'wheel' event.
// This code patches addEventListener globally to force passive wheel events
if (typeof window !== 'undefined') {
const originalAddEventListener = window.EventTarget.prototype.addEventListener;
window.EventTarget.prototype.addEventListener = function(type, listener, options) {
if (type === 'wheel') {
// Transform options to object and force passive: true
if (options === undefined) {
options = { passive: true };
} else if (typeof options === 'boolean') {
@dejurin
dejurin / preact.ts
Last active April 13, 2025 08:48
Headless UI shadow DOM support for Preact
const containerRef = useRef<HTMLDivElement | null>(null);
useEffect(() => {
if (!containerRef.current) return;
const observer = new MutationObserver((records) => {
const record = records.filter((record) => {
const el = record.target as HTMLDivElement;
return el.id === 'headlessui-portal-root';
}).pop();
@dejurin
dejurin / gen-unicode-csv.py
Created April 10, 2025 20:15
List of all (non-control) Unicode characters with codepoint and Unicode descriptor (as given by python module "unicodedata").
#!/usr/bin/python
import unicodedata
import math
import csv
MIN_CHAR = 0x20
MAX_CHAR = 0x100000
PROGRESS = 0x8000
@dejurin
dejurin / my-badge.css
Last active April 7, 2025 08:41
Tailwind 4 Badge classes on based utility
@utility my-badge {
@apply inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset;
}
.my-badge-gray {
@apply my-badge bg-gray-50 text-gray-600 ring-gray-500/10 dark:bg-gray-400/10 dark:text-gray-400 dark:ring-gray-400/20;
}
.my-badge-red {
@apply my-badge bg-red-50 text-red-700 ring-red-600/10 dark:bg-red-400/10 dark:text-red-400 dark:ring-red-400/20;
@dejurin
dejurin / settings.json
Created March 24, 2025 13:31
Format on Save in Go with VS Code
{
"cSpell.words": [
"fexscrape"
],
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"eslint.alwaysShowStatus": true,
"eslint.validate": [
"javascript",
"javascriptreact"
@dejurin
dejurin / collect.py
Created February 22, 2025 10:02
This script recursively scans a specified directory, generates a tree-like structure of its directories and files, and collects the contents of all files.
#!/usr/bin/env python3
import os
import argparse
import fnmatch
# Directories and files to ignore by exact name
IGNORE_DIRS = ['.git', '.vscode', '__pycache__', 'node_modules', 'templates']
IGNORE_FILES = ['.gitignore', '.DS_Store', 'LICENSE', '.gitattributes', 'collect.py', 'output.txt', 'README.md', 'go.mod', 'go.sum']
# Patterns for directories and files to ignore
@dejurin
dejurin / currency_country.json
Last active December 25, 2024 21:36
ISO 3166-1 alpha-2 by ISO 4217
{
"ADP": "AD",
"AFA": "AF",
"ALK": "AL",
"AOK": "AO",
"AON": "AO",
"AOR": "AO",
"ARA": "AR",
"ARP": "AR",
"ARY": "AR",
@dejurin
dejurin / IANATimeZones.json
Last active December 25, 2024 21:36
IANATimeZones by country ISO2 code
{
"AF": "Asia/Kabul",
"AN": "America/Curacao",
"AL": "Europe/Tirane",
"DZ": "Africa/Algiers",
"AS": "Pacific/Pago_Pago",
"AD": "Europe/Andorra",
"AO": "Africa/Luanda",
"AI": "America/Anguilla",
"AQ": "Antarctica/Vostok",
@dejurin
dejurin / languageCodes.ts
Created June 9, 2024 12:25
Language codes
// https://qit.tools/developer/cheat-sheet/unicode/languages/
// https://www.alchemysoftware.com/livedocs/ezscript/Topics/Catalyst/Language.htm
// let languageNativeNames = new Intl.DisplayNames([lang], { type: "language" });
// let languageNames = new Intl.DisplayNames(['en'], { type: "language" });
[
{
"code": "aa",
"name": "Afar",
"native": "Afar",
@dejurin
dejurin / create_archive.sh
Created April 19, 2024 14:13
This script creates a zip archive of the current directory, excluding files starting with '.DS_', and names the archive after the current directory.
#!/bin/bash
# Script: create_archive.sh
# Description: This script creates a zip archive of the current directory, excluding files starting with '.DS_', and names the archive after the current directory.
# Assign the name of the current directory to the variable 'folder_name'
folder_name=$(basename "$PWD")
# Find files in the current directory and its subdirectories, excluding those whose names start with '.DS_', and zip them into an archive named after the current directory
find . -type f -not -name '.DS_*' -exec zip "$folder_name.zip" {} +