Skip to content

Instantly share code, notes, and snippets.

View isocroft's full-sized avatar
😜
Seriously fooling around!

Ifeora Okechukwu Patrick isocroft

😜
Seriously fooling around!
View GitHub Profile
@isocroft
isocroft / react-router-dom-v.6.02.prompt.blocker.js
Created January 12, 2026 13:04 — forked from rmorse/react-router-dom-v.6.02.prompt.blocker.js
Adds back in `useBlocker` and `usePrompt` to `react-router-dom` version 6.0.2 (they removed after the 6.0.0 beta, temporarily)
/**
* These hooks re-implement the now removed useBlocker and usePrompt hooks in 'react-router-dom'.
* Thanks for the idea @piecyk https://github.com/remix-run/react-router/issues/8139#issuecomment-953816315
* Source: https://github.com/remix-run/react-router/commit/256cad70d3fd4500b1abcfea66f3ee622fb90874#diff-b60f1a2d4276b2a605c05e19816634111de2e8a4186fe9dd7de8e344b65ed4d3L344-L381
*/
import { useContext, useEffect, useCallback } from 'react';
import { UNSAFE_NavigationContext as NavigationContext } from 'react-router-dom';
/**
* Blocks all navigation attempts. This is useful for preventing the page from
* changing until some condition is met, like saving form data.
@isocroft
isocroft / inferal-workspace-architecture.md
Created December 24, 2025 21:50 — forked from yrashk/inferal-workspace-architecture.md
Inferal Workspace Architecture

Inferal Workspace Architecture

Your org's brain that AI can use

This document describes the conceptual architecture of the Inferal Workspace - a text-based, version-controlled knowledge and operations hub designed to replace tools like Notion and Webflow while being natively accessible to AI assistants.

Why We Built This

As an engineering-driven organization, we found ourselves fighting our tools instead of using them. Notion couldn't keep up with how we actually work - context scattered across pages, no version control, and AI that could read but not act. Webflow meant our website lived in a silo, disconnected from our codebase and deployment pipelines. Every tool was another tab, another context switch, another place where knowledge went to die.

@isocroft
isocroft / not_breaking_the_rules_of_hooks_react.js
Last active November 13, 2025 00:04
A simple use of a feature flag hook where the 1st rule of hooks in ReactJS is seemingly broken but not broken at all
function useXFeature (user, { xFeatureName = "", pageAndSection = "." } = {}) {
/* @NOTE:
This `useFeatureFlagConfig(...)` is static an immutable.
It can't change/be updated at runtime.
*/
const { isEnabledFor, loading } = useFeatureToggle(user);
if (isEnabledFor(xFeatureName, pageAndSection)) {
return useXFeature_Newer_Implementation_Stable();
@isocroft
isocroft / circuit_breaker_retry_protocol.md
Last active November 17, 2025 14:24
A protocol specification for how an arbitrary HTTP client can communicate with a reverse proxy (circuit breaker server) that forwards requests to a target service in such a way that does not require the HTTP client to blindly send retry requests.

Introduction

This is a specification that delineates how an arbitrary HTTP client should communicate with a circuit breaker so that it can know when to retry requests while the circuit breaker is in an OPEN (i.e. full-open & half-open) state and when the circuit breaker transitions to a CLOSED state. Remember, the circuit breaker is a reverse proxy that forwards requests to a target server/service in such a way that does not require the HTTP client to blindly send retry requests.

Screenshot 2025-11-17 at 2 52 20 PM Screenshot 2025-11-17 at 2 52 38 PM Screenshot 2025-11-17 at 2 52 56 PM

There are 2 ways in which the circu

@isocroft
isocroft / online_dating_app_design_database.sql
Created October 29, 2025 00:35
A database schema for a Tinder-clone dating app using either MySQL, SQLite or PostgreSQL as primary database
-- MySQL v8.0.16
-- PostgresSQL v16.9.2
CREATE DATABASE IF NOT EXISTS `test`
DEFAULT CHARACTER SET utf8 -- utf8mb4
DEFAULT COLLATE utf8_general_ci; -- utf8mb4_unicode_ci
SET default_storage_engine = INNODB;
CREATE TABLE ();
@isocroft
isocroft / project_management_app_design_database.sql
Last active October 23, 2025 11:23
A database schema for a Trello-clone project management app or managing and tracking tasks, timelines and deliverables using either MySQL, SQLite or PostgreSQL as primary database
-- MySQL v8.0.16
-- PostgresSQL v16.9.2
CREATE DATABASE IF NOT EXISTS `test`
DEFAULT CHARACTER SET utf8 -- utf8mb4
DEFAULT COLLATE utf8_general_ci; -- utf8mb4_unicode_ci
SET default_storage_engine = INNODB;
CREATE TABLE organizations (
@isocroft
isocroft / useObserveDOMMutations.js
Last active October 25, 2025 16:32
a ReactJS hook for observing DOM mutations as they occur upon DOM manipuation
import { useState, useEffect } from "react";
function useObserveDOMMutations (callback = (() => undefined), options = { childList: true, subtree: true, attributes: false, attributeFilter: [], attributeOldValue: false, characterData: false, characterOldValue: false }, rootElementId = '#root') {
const [observer] = useState(() => (typeof window !== "undefined" ? new MutationObserver(function (mutations, instance) {
const reactAppRootElem = window.document.querySelector(rootElementId);
if (!reactAppRootElem) {
instance.disconnect();
return;
}
@isocroft
isocroft / lyrics_display.py
Last active October 25, 2025 22:06
A python cli script to that prints the lyrics to a song character by character and line by line with timer delays using an idle wait on the main thread
from time import time
import sys
def display_lyrics():
song_lyrics_with_roll_timing = [
("They say, \"the holy waters' watered down\"", 0.020),
("and this towns' lost its' faith.", 0.030),
("Our colors will fade", 0.015),
("eventually", 0.001)
]
@isocroft
isocroft / processlist.sql
Created July 24, 2025 22:30 — forked from romuald/processlist.sql
Show PostgreSQL current (running) process list;
SELECT user, pid, client_addr, waiting, query, query_start, NOW() - query_start AS elapsed
FROM pg_stat_activity
WHERE query != '<IDLE>'
-- AND EXTRACT(EPOCH FROM (NOW() - query_start)) > 1
ORDER BY elapsed DESC;
@isocroft
isocroft / low_budget_ride_hailing_app_design_database.sql
Last active November 2, 2025 19:54
A database schema for an InDrive-clone ride hailing app that helps link riders to drivers on frequently-travelled transport routes (pricing based on a fair bargain) based on OpenStreet Maps info using either MySQL, SQLite or PostgreSQL as primary database
-- MySQL v8.0.16
-- PostgresSQL v16.9.2
CREATE DATABASE IF NOT EXISTS `test`
DEFAULT CHARACTER SET utf8 -- utf8mb4
DEFAULT COLLATE utf8_general_ci; -- utf8mb4_unicode_ci
SET default_storage_engine = INNODB;
CREATE TABLE rider_details (