Skip to content

Instantly share code, notes, and snippets.

View kalisjoshua's full-sized avatar

Joshua T Kalis kalisjoshua

View GitHub Profile
// SOURCE: https://gist.github.com/ssippe/1f92625532eef28be6974f898efb23ef?permalink_comment_id=4612830#gistcomment-4612830
export function cartesian<T>(...all: T[][]): T[][] {
return all.reduce<T[][]>(
(results, entries) =>
results
.map((result) => entries.map((entry) => result.concat([entry])))
.reduce((sub, res) => sub.concat(res), []),
[[]],
);
}
@kalisjoshua
kalisjoshua / domaddic.mjs
Last active August 27, 2024 19:26
A helper function for adding content to the DOM.
/**
* A helper function for adding content to the DOM. Using pretty standard DOM
* functionality domaddic enables the creation of modules that are capable of
* re-rendering themselves when they decide it to be necessary. Modules enable
* information hiding through scope and function calls so that everything is
* out of the global scope.
*
* Is this at all a good idea? Will it potentially be found to be a horrible
* memory hog/leak? Who can tell. Let's see if this bird has wings!
*
@kalisjoshua
kalisjoshua / tinyTest.mjs
Created August 16, 2023 13:20
A tiny test "runner".
class TestResult {
value: any
constructor (value: any) {
this.value = value
}
}
function assert (a: any, b?: any) {
throw new TestResult(b ? a === b : a)
@kalisjoshua
kalisjoshua / counter-intelligence.js
Created June 12, 2022 10:53
Job Posting Keywords
(function () {
console.clear()
let body = window.getSelection().toString()
const ignored = "able about across and for company more public team the that their they where with work world"
.split(" ")
if (!body) {
alert("You forgot to select the text to search.")
} else {
package main
import (
"fmt"
"math/rand"
"os"
"strconv"
"time"
)
@kalisjoshua
kalisjoshua / README.md
Last active August 12, 2024 14:17
Hypermedia Adventure

Hypermedia Adventure

This will be an adventure in navigating a Hypermedia API. This API will illustrate API standards that should be followed in all APIs.

  1. Where to begin?
    • GET /
    • (non-authenticated)
    • Perform a simple GET request to get a list of available API resources.
  • This resource will always be available - authenticated or not - and will
@kalisjoshua
kalisjoshua / audit.js
Created May 10, 2018 17:52
npm audit added functionality - summary
const fs = require('fs')
const file = './audit.log'
const start = (q) => /^┌[─]+┬[─]+┐$/.test(q)
const split = (q) => /^├[─]+┼[─]+┤$/.test(q)
const close = (q) => /^└[─]+┴[─]+┘$/.test(q)
const audit = fs.readFileSync(file, 'utf-8')
.split(/\n/g)

Keybase proof

I hereby claim:

  • I am kalisjoshua on github.
  • I am kalisjoshua (https://keybase.io/kalisjoshua) on keybase.
  • I have a public key ASB0fmsuRsLx_spNBDE-j91MEdsUorgmX0BtdT20cWEybgo

To claim this, I am signing this object:

const debounce = (fn, delay) => {
let pending
return function postponed (...args) {
pending && clearTimeout(pending)
pending = setTimeout(fn.bind(this, ...args), delay || 200)
}
}
@kalisjoshua
kalisjoshua / compose.js
Created April 13, 2017 13:19
JavaScript function composition.
const compose = (...fns) =>
fns.reduceRight((g, f) => (...args) => f(g(...args)))