Skip to content

Instantly share code, notes, and snippets.

View boilemmashem's full-sized avatar

Mike Hart boilemmashem

  • 02:18 (UTC +01:00)
View GitHub Profile

Stuff I use

Hey there! Seems like you found me. Perhaps you came from uses? This is my stuff.

Hardware

  • Macbook Pro 2021
  • Windows PC
    • Core: AMD
  • GPU: NVIDIA 3600ti
@boilemmashem
boilemmashem / timed.ts
Last active January 12, 2024 11:50
Time a function decorator
/**
* Decorates a function so that it console logs how long it takes to run.
* @example
* // import {timed}
* let functionToTime = () => {...does something}
* functionToTime = timed(functionToTime)
* functionToTime() // use as normal
* @param func
* @returns
*/
@boilemmashem
boilemmashem / addDaysToDate.ts
Last active December 22, 2023 11:10
Add days to date
/**
* Add days to given Date
* @param {Date}
* @param {number}
* @returns {Date}
*
* @example
* addDaysToDate(new Date(), 7) // date for 7 days from now
*/
export const addDaysToDate = (date: Date, days: number): Date => {
@boilemmashem
boilemmashem / getMaxContrast.js
Last active December 22, 2023 11:11
Black/White maximum contrast detection
/**
* Return black or white, whichever has higher contrast given the input color.
*
* @param {string} n - Input hexcolor without #
* @return {string} – white or black hex value with #
*
* @example
*
* getMaxContrast('FFFFFF') // #000000
*/