Skip to content

Instantly share code, notes, and snippets.


Mark Holtzhausen mholtzhausen

View GitHub Profile
mholtzhausen /
Last active Oct 5, 2021
DateTime Formatting made very very simple


A very simple local-time only date formatting tool that lives in one file and does the minimum for mvp.

How to use

const {format} = require('./dateUtil.js')

let formatStr='www, DD mmmm, YYYY H:I:s.SS'
mholtzhausen /
Created Jun 22, 2021
Clear all Cookies on Primary domain and Subdomains

This function will remove all cookies that are:

  1. on the primary domain
  2. on the wildcard primary domain
  3. with the matching path (defaults to no-path or /)
  4. that is not an http cookie
mholtzhausen / demo.js
Created Apr 21, 2021
Simple timer function
View demo.js
const {start, measure, create} = require('./timer.js')
const MAX=1000
var seed = Math.random()*1000;
function random() {
var x = Math.sin(seed++) * 10000;
return x - Math.floor(x);
mholtzhausen / demo.js
Last active Apr 15, 2021
Compact pared down version of npm debug module
View demo.js
const debug=require('./qdebug.js')
const log1 = debug('log1')
const log2 = debug('log2')
const sublog = log1.ext('sublog')'hello world', {test:Math.random()})'hello world', {test:Math.random()})'hello world', {test:Math.random()})
mholtzhausen / .git_info_exclude
Last active Feb 23, 2021
Default Git Excludes
View .git_info_exclude
# VsCode Local Settings :: The team is too cool to standardise IDE
# Temp-Folder ::I am so dumb I need a persistent scratch-pad
# Dev Scripts :: The team is too advanced for this shit
# Unofficial Docs :: The team is too clever for this shit
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
mholtzhausen / ts2ms.js
Last active Feb 23, 2021
Timespan to Milliseconds
View ts2ms.js
const timespanToMs=(timeSpan)=>{
let lut={'':1, ms:1, s:1000, m:60000, h:3600000, d: 86400000, w:604800000, y:31556952000 }
let ms=(`${timeSpan}`.match(/\d+[ywdhms]{0,2}\s?/g)).reduce((a,s)=>{
let [,v,m] =s.match(/(\d+)([ywdhms]{0,2})/)
return a + (v * lut[m])
return ms
let passTests=[
mholtzhausen / Catch.js
Last active Sep 11, 2020
Catch -- try-catch wrapper for promises (with a bonus)
View Catch.js
const Catch = async (promise, errorHandler) => {
if (promise instanceof Promise) {
try {
let returnValue = await promise
return returnValue
} catch (e) {
if (typeof errorHandler === 'function') return errorHandler(e)
return errorHandler
mholtzhausen / HOME_FOLDER_.bashrc
Last active Aug 11, 2020
A script to make a function <name> that will autocomplete when finding a /<script> folder upstream
View HOME_FOLDER_.bashrc
# ...
source ~/scriptfinder ss scripts
mholtzhausen /
Created Jul 28, 2020
Simple Js validation - schemas for objects - extensible

Simple Js validation - schemas for objects - extensible

validation types work like this: [+]typename[(arg,[arg,...])]

The + in the beginning makes it required any arguments applied will be passed to that type's validation function