Skip to content

Instantly share code, notes, and snippets.

View miketromba's full-sized avatar
🎯
Focusing

Michael Tromba miketromba

🎯
Focusing
View GitHub Profile
@miketromba
miketromba / qa.md
Last active December 20, 2025 07:36
/QA Cursor Command

Please give me a clear and concise QA checklist for the changes we made so that I can manually test to verify the integrity of our functionality.

Do not include features or functionality that are unrelated to the changes we made. Only include relevant features and functionality that may have been impacted by the changes.

Make it as concise and minimal as possible to effectively test the changes - do not include additional unnecessary steps.

Structure the checklist like this:

# QA Checklist for [come up with a name for the update]
@miketromba
miketromba / FifoOperationQueueCache.js
Created February 7, 2022 17:10
FifoOperationQueueCache.js
// @ts-nocheck
function createDeferredPromise(){
let res, rej
const promise = new Promise((resolve, reject) => { [res, rej] = [resolve, reject] })
promise.resolve = res
promise.reject = rej
return promise
}
class FifoOperationQueue {
@miketromba
miketromba / ItemCache.js
Last active January 10, 2022 16:51
ItemCache.js
// Very simple item cache (easily add .flush/dump and/or .delete functions if needed)
class ItemCache {
constructor({ get, init }){
this._items = {}
this.getItem = get
// use init to initialize the cache: init(set){ getItems, then set(key,
// item) for each }
this._init = init
this._initialized = false
@miketromba
miketromba / PaginationTraverser.js
Last active January 10, 2022 16:43
PaginationTraverser.js
// Get all records from { page, limit } style pagination
// NOTE: this class assumes that the first page value is 1 (NOT 0)
// Tweak the class if your system begins pagination with page 0.
class PaginationTraverser {
constructor({ limit, getPage }){
// Limit must not exceed server's clamp range or this breaks
// very badly (infinite while loop)
this.limit = limit
this.getPage = getPage
@miketromba
miketromba / ApiClient.js
Created September 29, 2021 21:36
ApiClient.js
import axios from 'axios'
// Extend me!
export default class ApiClient {
constructor(endpoint, token){
this.endpoint = endpoint
this.token = token
}
async post(path, data){
@miketromba
miketromba / install_node_and_docker.sh
Last active May 10, 2021 18:21
install node and docker
# (use docker droplet)
# Install node and npm:
sudo apt update
sudo apt install nodejs
sudo apt install npm
# Now, docker + node + npm should be ready.
# Yarn, optional:
@miketromba
miketromba / sleep.js
Created March 31, 2021 20:16
sleep.js
// Returns promise that resolves in ms milliseconds
export async function sleep(ms) {
return new Promise(resolve => {
setTimeout(resolve, ms)
})
}
@miketromba
miketromba / RecurringTask.js
Created March 31, 2021 20:15
RecurringTask.js
// Utility for running recurring tasks
// Uses setInterval and setTimeout
// Has ability to schedule the first run instantly or wait for a fixed MS
export default class RecurringTask {
constructor({
task, // can be async
intervalMs = 1000, // interval in milliseconds
lastRun = 0, // 0 == run immediately
@miketromba
miketromba / chunkArray.js
Last active March 12, 2021 13:22
chunkArray.js
export function chunkArray(array, size) {
const chunked_arr = [];
let index = 0;
while (index < array.length) {
chunked_arr.push(array.slice(index, size + index));
index += size;
}
return chunked_arr;
}
@miketromba
miketromba / Pipe.js
Created January 26, 2021 21:27
Pipe data from one fn call to another with delivery guarentee
class Pipe {
constructor(){
this.onChangeHandler = null
this.cache = []
}
onChange(fn){
this.onChangeHandler = fn
this.flush()
}