Skip to content

Instantly share code, notes, and snippets.

View Millsky's full-sized avatar
🌮
🌮

Kyle Mills Millsky

🌮
🌮
  • Vibrent Health
  • Fairfax VA
View GitHub Profile
I am attesting that this GitHub handle millsky is linked to the Tezos account tz1QnBdcdVBxrJXuAFXwnaZyHTijU7gjQF3E for tzprofiles
sig:edsigu2sR42XM151Go6pxcpG27DhKamy61r6M2KtrU8GHxt2jWYHTT489yvduoCDDut2Bp74dAbeCYMSALFge9v3utjdQsiu7mB
/* Context example 1: Using Prototype */
/* A functions context may be updated via the prototype */
/* Currently this.speak refers to the global this, window in the browser */
function animal() {
this.category = 'animal';
/* Ran w/o context on the global scope this will throw an error */
this.speak();
}
@Millsky
Millsky / mergesort.js
Created May 19, 2019 01:31
merge sort functional style
const merge = (a1,a2) => {
if (a1.length === 0) {
return a2;
}
if (a2.length === 0) {
return a1;
}
if (a1[0] <= a2[0]) {
return [
a1[0],
import * as L from 'partial.lenses';
import * as R from 'ramda';
const classA = {
p: 2,
d: 2,
c: true,
classB: null,
};
const classAOptic = ['classB'];
@Millsky
Millsky / functionalRenderPipeline.jsx
Last active April 17, 2019 20:38
A functional render pipeline for react
import React, { lazy, Suspense } from "react";
import ReactDOM from "react-dom";
import R from "ramda";
import { task, of } from "folktale/concurrency/task";
function processService(p) {
return p.data;
}
const getDataFailure = data => ({
import * as R from "ramda";
const log = R.tap(R.bind(console.log, console));
// F1 :: float -> float
const f1 = f => f * 1.23;
// F2 :: float -> float
const f2 = f => f * 1.345;
// F3 :: float -> float
const f3 = R.compose(
/* Build an adjacency matrix for a super simple tree a -> b,c */
const m = [
[0, 1, 0, 0, 0],
[0, 0, 1, 1, 0],
[0, 0, 0, 0, 1],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]
];
/* Data at each node */
@Millsky
Millsky / functionalDataPipeline.js
Last active January 11, 2019 15:13
Clean Functional Service -> Transform -> Dispatch, with handling for cancellation, failure and success
import R from 'ramda';
import { task, of } from 'folktale/concurrency/task';
import hash from 'object-hash';
function processService(p) {
return p.data;
}
const getDataFailure = data => ({
type: 'FAILURE_TYPE',
function observer() {
const data = {};
const callbacksObj = {};
const set = (property, value) => {
data[property] = value;
notify(property);
};
const notify = (property) => {
if(!property) {
throw new TypeError('Property "property" is not type string')
function sortTable(table,col){
if(table.nodeName != "TABLE"){
throw new Error("Node is not of type TABLE");
return;
}
/* DEEP CLONE WILL BREAK THE REF */
//table = table.cloneNode(true);
var rows = [].slice.call(table.tBodies[0].rows,1);
var tBody = table.tBodies[0];
/* SORT MAP AND REPLACE */