Skip to content

Instantly share code, notes, and snippets.

Joshua T Kalis kalisjoshua

Block or report user

Report or block kalisjoshua

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kalisjoshua
kalisjoshua / README.md
Last active May 29, 2018
Hypermedia Adventure
View README.md

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
npm audit added functionality - summary
View audit.js
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)
View keybase.md

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:

View debounce.js
function debounce(fn, delay) {
let pending
function postponed(...args) {
pending && clearTimeout(pending)
pending = setTimeout(fn.bind(this, ...args), delay || 200)
}
return postponed
@kalisjoshua
kalisjoshua / compose.js
Created Apr 13, 2017
JavaScript function composition.
View compose.js
const compose = (...fns) =>
fns.reduceRight((g, f) => (...args) => f(g(...args)))
@kalisjoshua
kalisjoshua / curry.js
Created Apr 7, 2017
Simple - recursive - ES6/2015 curry function.
View curry.js
const curry = (fn, ...args) => args.length < fn.length
? (...add) => curry(fn, ...args.concat(add))
: fn(...args)
@kalisjoshua
kalisjoshua / pipe.js
Last active Aug 12, 2019
Simple utility function for "pipe-ing" values into functions because JavaScript doesn't have a Pipe (forward) operator... yet.
View pipe.js
// 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 / interesting.js
Created Apr 6, 2017
Collection of interesting JavaScript syntax.
View interesting.js
// 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
View admin-factorio.sh
#! /bin/bash
ROOT=/opt/fact
FACTORIO="$ROOT/factorio/bin/x64/factorio"
VERSION=$($FACTORIO --version | xargs echo | cut -d ' ' -f 2)
if [ "$1" = "start" ]; then
echo 'starting server'
# echo $$ > $ROOT/factorio.pid
View pubsub.js
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');
}
You can’t perform that action at this time.