Skip to content

Instantly share code, notes, and snippets.

View jrobinsonc's full-sized avatar
😁
coding for fun

Jose Robinson jrobinsonc

😁
coding for fun
View GitHub Profile
@jrobinsonc
jrobinsonc / README.md
Created May 12, 2026 07:13
Pre-Push Hook: Run checks for PRs

Pre-Push Hook — Draft PR Guard

This Husky pre-push hook skips CI checks when the current branch is linked to a GitHub draft pull request, allowing work-in-progress branches to be pushed freely. For all other branches (no PR or an open/ready PR), it enforces a full quality gate.

Flow:

  1. Resolves the current branch name via git rev-parse.
  2. Queries the GitHub API (via gh) for the branch's associated PR draft status.
  3. If draft → prints an informational message with the PR number and exits cleanly (exit 0), bypassing all checks.
  4. Otherwise → runs the full check suite via Turbo: check-types, lint, and test.
@jrobinsonc
jrobinsonc / Prompt.md
Last active May 11, 2026 03:38
Turn AI conversation context into a clean PRD. #PRD #ProductRequirements #SpecWriting #ProductDesign #RequirementsDoc

You are to turn the current conversation context into a single Product Requirements Document (PRD).

Do not interview the user. Do not ask follow-up questions. Do not inspect any repo or codebase. Do not reference issue trackers, labels, publishing workflows, or triage vocabulary. Do not produce anything except the PRD.

Your job is to synthesize only what is already present in the conversation and output a PRD in the format below.

Process

  1. Review the full conversation context and identify:
  • The user’s problem
@jrobinsonc
jrobinsonc / pre-push.sh
Last active December 18, 2025 00:15
Run pre-push checks only when the branch is not associated with a draft pull request.
# Skip pre-push checks only if the branch is linked to a draft pull request.
# This script requires the GitHub CLI (gh), and the package Husky v9+.
# Get the current branch name
BRANCH=$(git rev-parse --abbrev-ref HEAD)
# Check if there's a PR for this branch and get its draft status
PR_IS_DRAFT=$(gh pr view "$BRANCH" --json isDraft -q '.isDraft' 2>/dev/null || echo "false")
# Check if PR is in draft status
@jrobinsonc
jrobinsonc / cn.ts
Last active July 13, 2025 19:41
Merge Tailwind CSS classes efficiently.
import { clsx, type ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';
/**
* Merge Tailwind CSS classes efficiently.
*
* @param inputs - Class values to merge.
* @returns Merged class names.
*/
export function cn(...inputs: ClassValue[]): string {
@jrobinsonc
jrobinsonc / DeviceInfoDisplay.tsx
Last active July 10, 2025 14:12
Show details about the device
import Constants from 'expo-constants';
import * as Device from 'expo-device';
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import {
getDeviceInfo,
getEnvironmentDescription,
isExpoGoRunning,
isIOSSimulatorRunning,
} from './deviceDetection';
/**
* Constructs a URL by appending query parameters to a given path.
*
* @template TVariables - The shape of the params.
*
* @param path - Path.
* @param params - Optional. Params to be added as query parameters to the URL.
*
* @returns The constructed URL.
*/
/**
* @param time - The time in 24 hours format
* @returns The time in 12 hours format
*/
export function convertTime24to12(time: string): string {
const [hours, minutes]: number[] = time.split(':').map(Number);
const meridiem: 'PM' | 'AM' = hours >= 12 ? 'PM' : 'AM';
return `${hours % 12 || 12}:${minutes
.toString()
.padStart(2, '0')} ${meridiem}`;
@jrobinsonc
jrobinsonc / parseMarkdownLinks.js
Last active November 18, 2023 21:44
Markdown Link Parser
@jrobinsonc
jrobinsonc / PromiseResolution.ts
Last active November 23, 2023 18:53
Promise Resolution with Resolver and Rejector
/**
* Function that returns a promise along with resolver and rejector functions
*
* @template T The type of the resolved value
* @returns {{ promise: Promise<T>, resolver: (arg: T) => void, rejector: (error: Error) => void }}
*/
const PromiseResolution = <T>() => {
let resolver!: (arg: T) => void;
let rejector!: (error: Error) => void;
@jrobinsonc
jrobinsonc / isDefined.ts
Last active July 10, 2025 16:57
Type Guard Functions for Various Data Types
export function isDefined<T>(arg: T | undefined | null): arg is T {
return arg !== undefined && arg !== null;
}