Skip to content

Instantly share code, notes, and snippets.

View kalisjoshua's full-sized avatar

Joshua T Kalis kalisjoshua

View GitHub Profile
@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:

@kalisjoshua
kalisjoshua / standardTraits.yaml
Created May 29, 2015 20:25
Standard Traits for RAML
standardDELETE:
responses:
200:
description: <<200description>>
body:
application/json:
example: <<200jsonExample>>
schema: <<200jsonSchema>>
202:
description: <<202description>>
@kalisjoshua
kalisjoshua / compose.js
Created April 13, 2017 13:19
JavaScript function composition.
const compose = (...fns) =>
fns.reduceRight((g, f) => (...args) => f(g(...args)))
@kalisjoshua
kalisjoshua / curry.js
Created April 7, 2017 00:17
Simple - recursive - ES6/2015 curry function.
const curry = (fn, ...args) => args.length < fn.length
? (...add) => curry(fn, ...args.concat(add))
: fn(...args)
@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
#! /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
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.

@kalisjoshua
kalisjoshua / angularjs_directive_hack.js
Created January 26, 2014 03:15
AngularJS linking form constructor with dynamic field name
angular.module('app')
.directive('dynamicFields', function () {
return {
link: function ($scope) {
// this hack brought to you by kalisjoshua; plenty of searching
// and one big guess that this might work, only time will tell
$scope.validation[$scope.name] = $scope.validation['{{name}}'];
},
scope: {
name: '@',