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
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 / 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
const debounce = (fn, delay) => {
let pending
return function postponed (...args) {
pending && clearTimeout(pending)
pending = setTimeout(fn.bind(this, ...args), delay || 200)
}
}
@kalisjoshua
kalisjoshua / interesting.js
Created April 6, 2017 12:36
Collection of interesting JavaScript syntax.
// 1.
// replace instances with different replacement strings
const qwerty = 'qw#rt#'.replace(/#/g, [].shift.bind(['e', 'y']));
// 2.
// make Array.slice available as a function instead of a method
const slice = Function.prototype.call.bind(Array.prototype.slice);
// 3.
// ASI (failure) working in conjunction with the comma operator
function pubsubFactory() {
let subscribers = [];
const pub = publish;
const sub = subscribe;
const remove = unsubscribe;
function publish(message) {
if (!message) {
throw new Error('Not going to publish an empty message to subscribers.', 'pubsub.js');
}
@kalisjoshua
kalisjoshua / README.md
Last active July 1, 2016 15:45
Exploration of Curry-ing function in JavaScript

Curry-ing Functions In JavaScript

I don't know why, but this morning I felt like exploring function curry-ing and writing a little bit about it. First I watched a video on curry-ing from the JS Weekly newletter. Then I wanted to write my own implementation. After that I thought I would share what I did with my team at work and then this.

Brain-dump over.

The only reason I created two different implementations is becuase semantically I think that a function is only curried once; as I understand it - to curry - is a process by which you convert a single function which takes multiple arguments into a series of multiple functions each taking exactly one argument.

So, while the implementations work identically from the point of view of the user the differ in their implementation; basically only semantically.