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 / auto_commit.sh
Last active March 29, 2025 05:11
Utilizing an AI-powered CLI to incrementally create AI-generated commit messages based on you git changes.
#!/bin/bash
# Still want to catch undefined variables, but don't exit on errors
set -u
# Script configuration
DEFAULT_REPO_DIR="$HOME/github"
DEFAULT_AI_COMMAND="ask cm -m gemini-2.0-flash"
LOG_FILE="/tmp/git-auto-commit-$(date +%Y%m%d-%H%M%S).log"
MAX_RETRIES=3
@WomB0ComB0
WomB0ComB0 / create-ics.ts
Created January 24, 2025 20:20
Create ICS files based on input
/**
* @fileoverview Creates an ICS calendar file with recurring events based on provided configuration
*/
import ical, { ICalEventRepeatingFreq, ICalWeekday } from 'ical-generator';
import { writeFileSync } from 'fs';
import { DateTime } from 'luxon';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import type { ICalRepeatingOptions } from 'ical-generator/dist/index.d.ts';
@WomB0ComB0
WomB0ComB0 / ics-parser.ts
Created January 24, 2025 20:16
Advanced, CLI-based ICS parser
/**
* @fileoverview A utility for converting ICS (iCalendar) files to JSON format with customizable output options.
* Supports flattening nested structures, removing fields, renaming keys, and filtering by date range.
*/
import { lines2tree } from 'icalts';
import { $ } from 'bun';
import { Command } from 'commander';
/**
@WomB0ComB0
WomB0ComB0 / ics-parser-simple.ts
Created January 24, 2025 20:12
Simple ICS file parser
/**
* A script to parse ICS (iCalendar) files and convert them to JSON format.
* Supports processing either a single file or scanning a directory for multiple .ics files.
*
* @module ics-parser
*
* Usage:
* - Process single file: node ics-parser.ts path/to/file.ics
* - Process all .ics files in root: node ics-parser.ts --root
*
@WomB0ComB0
WomB0ComB0 / github-secrets.ts
Last active January 24, 2025 00:43
This script automates the process of adding secrets from a local .env file to a GitHub repository. It uses the GitHub API to encrypt and store secrets
/**
* This script automates the process of adding secrets from a local .env file to a GitHub repository.
* It uses the GitHub API to encrypt and store secrets securely using libsodium encryption.
*
* @module github-secrets
*
* How to run this script:
*
* For npm:
* 1. Install dependencies: npm install
@WomB0ComB0
WomB0ComB0 / database.get.ts
Created January 22, 2025 10:00
Prisma x Supabase script to execute on package.json scripts for easy db updates
'use server';
import { exec } from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import { promisify } from 'node:util';
import { logger } from '@/utils';
const execPromise = promisify(exec);
@WomB0ComB0
WomB0ComB0 / jotai-provider.tsx
Created January 20, 2025 21:44
A higher-order component that wraps a given component with Jotai's Provider. This enables state management using Jotai atoms throughout the component tree
import { Provider } from 'jotai/react';
import type { ReactNode } from 'react';
/**
* Type definition for a React component that can accept children
* @template P - The props type for the component
*/
type ComponentWithChildren<P = {}> = React.ComponentType<P & { children?: ReactNode }>;
/**
@WomB0ComB0
WomB0ComB0 / zustand-provider.tsx
Created January 19, 2025 16:19
GlobalStoreProvider component that provides the global store to the React component tree. This component initializes the store on first render and maintains a consistent reference to it using useRef to prevent unnecessary re-renders.
'use client';
import { type StoreState, createGlobalStore } from '@/core/store';
import type React from 'react';
import { createContext, useContext, useRef } from 'react';
import { useStore } from 'zustand';
/**
* React context to provide the global store throughout the application. The context
* holds a reference to the store created by createGlobalStore or null if not yet initialized.
@WomB0ComB0
WomB0ComB0 / package-cost.ts
Created January 11, 2025 16:18
Calculate dependency cost, returns array of objects which have the name and size (in bytes) of their respective package
import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';
import type { PackageJson } from 'type-fest';
const packageJsonPath = path.join(process.cwd(), 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')) as PackageJson;
const dependencies = Object.keys(packageJson.dependencies || {});
const devDependencies = Object.keys(packageJson.devDependencies || {});
const allDependencies = [...dependencies, ...devDependencies];
@WomB0ComB0
WomB0ComB0 / check-unused.ts
Created January 11, 2025 16:05
Check unused dependencies within your project by match casing your package.json and node_module deps
import fs from 'fs';
import path from 'path';
import depcheck from 'depcheck';
import { $ } from 'bun';
import type { PackageJson } from 'type-fest';
// If you're coming from GitHub Gist, you can remove or change this
const rootDir = path.join(__dirname, '..'); // Go up one level to project root
const packageJsonPath = path.join(rootDir, 'package.json');
console.log('Checking:', packageJsonPath);