Skip to content

Instantly share code, notes, and snippets.

View psenger's full-sized avatar
:octocat:
Makin Bacon

Philip A Senger psenger

:octocat:
Makin Bacon
View GitHub Profile
@psenger
psenger / README.md
Last active January 19, 2025 22:29
[Async Await Without Try catch / optional catch binding ] #JavaScript #AsyncAwait #Promise

Why Use the tryCatch Function Over Traditional Error Handling

The tryCatch utility function provides several significant advantages over traditional try-catch blocks and Promise chains. Here's why you might want to consider this pattern:

1. Unified Error Handling for Sync and Async Operations

Traditional error handling requires different approaches for synchronous and asynchronous code:

// Traditional approach - try catch
@psenger
psenger / README.md
Last active June 13, 2025 12:48
[Git Commit] #AI #git #macos

🤖 Git Commit Helper

Never write boring commit messages again! This AI-powered tool analyzes your staged changes and generates detailed, structured commit messages automatically.

🌟 Features

  • 🔍 Analyzes staged git changes
  • ✨ Generates structured, detailed commit messages
  • 📋 Automatically copies to clipboard
  • 🎯 Creates per-file descriptions
@psenger
psenger / prompt-options.js
Created January 3, 2025 02:17
[Prompt with NodeJS] #JavaScript #prompt
const readline = require('readline')
/**
* Prompts the user with a question and returns their answer.
*
* @param {readline.Interface} rl - The readline interface instance
* @param {string} query - The question to ask the user
* @returns {Promise<string>} A promise that resolves with the user's answer
*
* @example
@psenger
psenger / ADR.md
Last active November 11, 2024 20:43
[Obsidian Markdown Templates] #obsidian #templates #adr #bcp #meeting
creation-date <% tp.file.creation_date("YYYY-MM-DDTHH:mm:ssZZ") %>
modification-date <% tp.file.last_modified_date("YYYY-MM-DDTHH:mm:ssZZ") %>
version 0.0.1
tags
adr
aliases
type empty-note

Architecture Design Registry - <% tp.file.title %>

@psenger
psenger / README.md
Created November 3, 2024 22:41
[How to Separate changes to individual Branches] #git

Splitting Mixed Changes into Separate Feature Branches in Git

You have a git project, based on main. With mixed changes in your local copy of the project for two different features none of the changes are pushed to the origin git server. You want to create two branches and check the two branches to the origin git server, separating the two sets of changes.

This guide helps you separate mixed local changes into two different branches and push them individually to the origin Git server.

Steps

  1. Stash Your Changes Temporarily
@psenger
psenger / README.md
Last active October 30, 2024 03:30
[Markdown Frontmatter Schema Analyzer] #MarkDown #MDX #FrontMatter #JSONSchema #helper #JavaScript

Markdown Frontmatter Schema Analyzer

Purpose

The Markdown Frontmatter Schema Analyzer is a Node.js script that recursively scans Markdown (.md and .mdx) files in a specified directory, extracts their frontmatter, and analyzes the data types of attributes within the frontmatter. The script provides a summary of consistent and conflicting schema data across all analyzed files, making it easier to identify discrepancies in metadata. This ultimately will help you build a json schema.

How It Works

  1. Read Markdown Files: The script recursively traverses the specified directory and collects all Markdown files.
  2. Parse Front Matter: For each Markdown file, it reads the content and extracts the front matter using the front-matter library.
@psenger
psenger / README.md
Created October 15, 2024 04:23
[Docker Cheat Sheet] #Docker

Docker Cheat-sheet for Beginners 🐳

#webdev #docker #beginners #programming

🔧 Common Docker Commands

  • Start Docker:
systemctl start docker # Linux
@psenger
psenger / Readme.md
Created September 22, 2024 22:01
[How to programmatically get data in JavaScript directly into your buffer] #Browser #JavaScript #clipboard #copy-cut-paste

How to programmatically get data in JavaScript directly into your buffer

Important Notes:

  • This API requires a secure context (HTTPS).
  • Users must interact with the page (e.g., click a button) before clipboard access is allowed for security reasons.
const toClipboard = async (text) =&gt; {
@psenger
psenger / README.md
Last active August 14, 2024 00:52
[Design Pattern: Role-Based Access Control (RBAC)] #DesignPattern #JavaScript #Security

Role-Based Access Control (RBAC)

RBAC involves defining roles and permissions, then enforcing these permissions in your API endpoints.

Roles and Permissions

Roles: Examples include Admin, Editor, and User.

Permissions: Common actions like Create, Read, Update, and Delete.

@psenger
psenger / README.md
Last active May 25, 2025 02:05
[Design Pattern: "Error Handling Wrapper" or "Async Await Wrapper"] #Promise #JavaScript #DesignPattern

Design Pattern: "Error Handling Wrapper" or "Async Await Wrapper"

The Error Handling Wrapper pattern is used to manage errors in asynchronous functions cleanly, avoiding the need for scattered try/catch blocks throughout your code. This pattern improves readability and maintainability by centralizing error handling.

Advantages of the Pattern

  • Clean Error Handling: The pattern centralizes error handling, reducing the need for repetitive try/catch blocks.
  • Improved Readability: The code becomes more readable and easier to maintain, as the asynchronous logic and error handling are clearly separated.
  • Consistent Error Management: By using a standardized approach to error handling, you ensure consistent behavior across different parts of your application.