Skip to content

Instantly share code, notes, and snippets.

View kurtmilam's full-sized avatar
💯
❌ 🤠 coder

Kurt Milam kurtmilam

💯
❌ 🤠 coder
View GitHub Profile
@kurtmilam
kurtmilam / aoc2016-1.js
Last active December 11, 2016 23:15
Advent of Code 2016, Puzzle #1: Using Ramda, doubly linked cyclical list and lenses
// Paste into the Ramda REPL at http://ramdajs.com/repl/
// NESW - doubly linked list, cyclical
const compass = [[1, 1], [[0, 1], [[1, -1], [[0, -1]]]]]
compass[1][1][1][1] = compass
compass[1][2] = compass
compass[1][1][2] = compass[1]
compass[1][1][1][2] = compass[1][1]
compass[2] = compass[1][1][1]
@kurtmilam
kurtmilam / partial.lenses-query-array-by-sub-array-object-property
Last active April 26, 2017 07:34
partial.lenses: query array by sub array object property
// REPL: https://calmm-js.github.io/partial.lenses/playground.html
// discussion: https://gitter.im/calmm-js/chat?at=58ecf9c6bdf4acc1124c504f
const list =
{
tasks: [ { id: 2
, state: 'todo'
, users: [ { id: 1 } ]
}
, { id: 2
, state: 'todo'
@kurtmilam
kurtmilam / partial.lenses-get-set-object-in-list-by-uuid.js
Last active April 26, 2017 07:31
partial.lenses - get/set object in list by uuid
// REPL: https://calmm-js.github.io/partial.lenses/playground.html
// setup
const list = [ { uuid: 1, v: 1 }, { uuid: 2, v: 2 } ]
// lenses
const byPropNameL = R.curry( propName => R.compose( L.find, R.propEq( propName ) ) )
const byUuidL = byPropNameL( 'uuid' )
// getters & setters
const getByUuid = R.curry( ( uuid, o ) => L.get( byUuidL( uuid ), o ) )
@kurtmilam
kurtmilam / nvm-windows-upgrade-npm-and-uninstall-node-version-instructions.md
Last active July 5, 2021 13:13
how to upgrade npm and uninstall a specific node version when using windows-nvm

Do these from powershell or bash running as admin.

Upgrade npm

Node usually ships with an older version of npm.

Two things to consider:

  1. You'll need to upgrade npm once for each version of node installed by nvm-windows with which you wish to use the different version of npm.
  2. You'll need to manually specify the nvm-windows' installation path for the version of node whose associated npm you wish to upgrade.

First, install npm-windows-upgrade. Then, locate the nvm-windows installation path for the version of node whose npm you wish to upgrade. Usually at C:\Users\[user name]\AppData\Roaming\nvm\[node version].

@kurtmilam
kurtmilam / form.js
Last active May 29, 2017 10:08
calmm-js crud form component experiment
const makeQuery =
U.pipe( U.template
, U.flatMapLatest( L.get( [ 0, U.pipe( Req.withParams( url ), Req.getJSON ) ] ) )
)
const getItem =
U.view( [ 'response', 'body', L.define( {} ) ] )
export const Edit =
U.withContext(
@kurtmilam
kurtmilam / labeled-text-input.js
Last active May 30, 2017 14:07
calmm labeled text input
// View the lensToLabel function in the partial.lenses playground at https://goo.gl/A0BRWa
import * as R from "ramda"
import * as L from "partial.lenses"
import * as React from "karet"
import * as U from "karet.util"
import TextInput from "./text-input"
const uCFirst =
@kurtmilam
kurtmilam / examples.js
Created June 16, 2017 18:56
calmm input example
<LabeledTextAreaInput lens="CONTACT_DETAILS"
formAtom={ formAtom }
{ ...props.opportunity }
/>
<LabeledTextAreaInput lens={ [ 'path', 'to', 'CONTACT_DETAILS' ] }
formAtom={ formAtom }
validAtom={ validAtom }
disabled={ disabled }
/>
const obsv = someObservable // stream, atom, etc.
const record = U.view( 'record', obsv )
const nameDefault = 'nobody'
const nameL = 'name'
const defaultsTemplate = { /* some defaults*/ }
obsv.onValue(
R.pipe( L.transform( [ nameL
, L.when( R.isNil )
@kurtmilam
kurtmilam / RoseTreeToPaths.js
Last active August 9, 2017 18:07
JavaScript: Get a list of all paths from root to leaves (rose tree)
// The rose tree is a data structure that's used to represent hierarchical
// data like XML / HTML documents or filesystems (directory and file structures).
// See this in action on the Ramda REPL: https://goo.gl/XeToZt
// R = Ramda :: http://ramdajs.com/docs/
// much cleaner solution, thanks to @syaiful6 in Ramda's Gitter channel ( https://gitter.im/ramda/ramda )
const listPathsFromRoseTree =
tree =>
!is( Array, tree[ 1 ] )
|| isEmpty( tree[ 1 ] )
@kurtmilam
kurtmilam / objectInitializer.js
Last active October 29, 2017 13:41
What is a POJO in JavaScript?
// Object initializer notation (also known as Object literal notation)
const mediumArticle = {
title: "What is a POJO in JavaScript?",
subTitle: "The Plain Old JavaScript Object",
tldr: "In JavaScript, a POJO is any object that can be created using the Object initializer notation."
}