Skip to content

Instantly share code, notes, and snippets.

View WomB0ComB0's full-sized avatar
πŸ˜΅β€πŸ’«
I need an Advil

Mike Odnis WomB0ComB0

πŸ˜΅β€πŸ’«
I need an Advil
View GitHub Profile
@WomB0ComB0
WomB0ComB0 / variations.ts
Created August 2, 2024 21:17
Generate all possible alpha characters , on the point of casing (capital lowercase)
import fs from 'fs';
import { fileURLToPath } from 'url';
import path from 'path';
import { Worker, isMainThread, parentPort, workerData } from 'worker_threads';
const __filename: string = fileURLToPath(import.meta.url);
const __dirname: string = path.dirname(__filename);
const filePath = path.join(__dirname, 'server', 'data', 'nsfw-names.txt');
const fileContent = fs.readFileSync(filePath, 'utf8');
@WomB0ComB0
WomB0ComB0 / kv-generator.ts
Created August 10, 2024 11:44
Generate kv pairs for O(1) lookup time from text files
import { fileURLToPath } from "node:url"
import { readFileSync, writeFileSync } from "node:fs"
import { dirname } from "node:path"
(() => {
const __dirname = dirname(fileURLToPath(import.meta.url))
console.log(`${__dirname}<path><file_name>.<extension>`)
const robots = readFileSync(`${__dirname}<path><file_name>.<extension>`, "utf-8")
const kv: Map<string, string> = new Map<string, string>()
@WomB0ComB0
WomB0ComB0 / count_fles_pattern.py
Created August 11, 2024 01:49
Get the file names within a directory which match specified pattern
import os
import re
import sys
from typing import List
class FileSystem:
def __init__(self, path='.') -> None:
self.path = path
def filter_files(self, files, pattern) -> List[str]:
@WomB0ComB0
WomB0ComB0 / node-package-dependencies-checker.ts
Created August 15, 2024 20:50
Check the difference between n dev/dependencies
import { readFileSync } from 'fs';
import { join } from 'path';
import { z } from 'zod';
const packages = readFileSync(join(__dirname, 'package.json'), 'utf8');
const schema = z.object({
devDependencies: z.record(z.string()),
dependencies: z.record(z.string()),
});
@WomB0ComB0
WomB0ComB0 / match-env-vars.ts
Created August 16, 2024 01:34
This TypeScript script compares environment variables from .env files with a predefined set, performing set operations (union, intersection, or difference) specified via command-line arguments. It parses the variables, executes the chosen operation, and outputs the results to a file, providing a flexible tool for analyzing and managing environme…
import { readFileSync, writeFileSync, readdirSync } from "node:fs";
import { join } from "path";
const paste: string = `
<key>=<value>
...
`
const envFiles: string[] = readdirSync(process.cwd()).filter((file) => file.startsWith(".env"));
@WomB0ComB0
WomB0ComB0 / speech-to-text.tsx
Created August 22, 2024 12:50
Typescript, Typesafe Speech to Text
import { Button } from '@/components/ui/button';
/* eslint-disable @typescript-eslint/no-explicit-any */
/// <reference lib="dom" />
import React from 'react';
import { FaMicrophone } from 'react-icons/fa';
import { useIsomorphicLayoutEffect } from 'usehooks-ts';
/*
* Intakes a state setter where the component
* will store the result of speech to text into
@WomB0ComB0
WomB0ComB0 / use-persisted-id.ts
Created September 3, 2024 23:11
Query param state management
import { useQueryState } from 'nuqs';
import { useCallback } from 'react';
import { useIsomorphicLayoutEffect } from 'usehooks-ts';
import { v4 as uuidv4 } from 'uuid';
export const usePersistedId = (
key: string,
): {
id: string | null;
clearId: () => void;
@WomB0ComB0
WomB0ComB0 / sort-package-json.ts
Created October 16, 2024 17:21
Sort your package.json dependencies
import { readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
const packageJsonPath: string = join(process.cwd(), "package.json");
const packageJson: { dependencies: Record<string, string>, devDependencies: Record<string, string> } = JSON.parse(readFileSync(packageJsonPath, "utf8"));
const dependencies: Map<string, string> = new Map(Object.entries(packageJson.dependencies));
const devDependencies: Map<string, string> = new Map(Object.entries(packageJson.devDependencies));
const dependencies_: Record<string, string> = Object.fromEntries(dependencies);
@WomB0ComB0
WomB0ComB0 / full-stack.sh
Last active May 5, 2025 22:15
full-stack language install
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# Treat unset variables as an error.
set -u
# --- Colors ---
RED='\033[0;31m'
GREEN='\033[0;32m'
@WomB0ComB0
WomB0ComB0 / merge-package-json.ts
Created November 1, 2024 19:32
Merge package.json files
import { readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
interface PackageJson {
dependencies: Record<string, string>;
devDependencies: Record<string, string>;
[key: string]: any;
}
function mergePackageJsons(current: PackageJson, toMerge: PackageJson): PackageJson {