Skip to content

Instantly share code, notes, and snippets.

View kalisjoshua's full-sized avatar

Joshua T Kalis kalisjoshua

View GitHub Profile
@kalisjoshua
kalisjoshua / domaddic.mjs
Created October 21, 2023 22:39
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 / dirToJSON.js
Created September 14, 2012 00:05
Directory as JSON object
var fs = require("fs");
var tree = function(dir, done) {
var results = {
"path": dir
,"children": []
};
fs.readdir(dir, function(err, list) {
if (err) { return done(err); }
var pending = list.length;
const debounce = (fn, delay) => {
let pending
return function postponed (...args) {
pending && clearTimeout(pending)
pending = setTimeout(fn.bind(this, ...args), delay || 200)
}
}
@kalisjoshua
kalisjoshua / ElevatorSaga.js
Last active December 10, 2021 21:07
Elevator Saga - Solution for challenges 1 through 12; still need to work on better efficiency.
{
init: function(elevators, floors) {
var TOP_LEVEL = floors.length - 1;
floors.requestQueue = [];
/**/
function _padd(len, str, char) {
str = '' + str;
while(str.length < len) {str = str + char;}
@kalisjoshua
kalisjoshua / jquery.pubsub.js
Created January 8, 2012 03:00 — forked from bentruyman/jquery-pubsub.js
Simple Pub/Sub Implementation for jQuery
/*
jQuery pub/sub plugin by Peter Higgins (dante@dojotoolkit.org)
Loosely based on Dojo publish/subscribe API, limited in scope. Rewritten blindly.
Original is (c) Dojo Foundation 2004-2010. Released under either AFL or new BSD, see:
http://dojofoundation.org/license for more information.
*/
(function($) {
var topics = {};
@kalisjoshua
kalisjoshua / pipe.js
Last active August 12, 2019 19:34
Simple utility function for "pipe-ing" values into functions because JavaScript doesn't have a Pipe (forward) operator... yet.
// Utility Function Definition
// A pipeline will call a series of functions pipe-ing output to input.
function pipe () {
return [].slice.call(arguments)
.reduce(function (acc, fn) {
return fn(acc)
})
}
// The above code compresses better then the ES2015 version.
@kalisjoshua
kalisjoshua / README.md
Last active May 29, 2018 13:47
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