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 / 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 / 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 / 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]
When you're ready to publish to bower, NPM, etc., do the following:
1. Figure out what the new NPM version number will be (semver major.minor.patch)
2. Update the version numbers to the (soon to be) new NPM version number in bower.json, component.json, etc. (but not in package.json)
3. Commit the repo with a message like "Updated version number in bower and component.json"
4. Run the NPM version command:
> npm version major|minor|patch|[new version number] -m "Updating NPM version"
//This step updates the version number in package.json. If you did steps 1-3 correctly, the version number in package, bower and component.json should be the same
5. Run the NPM publish command:
> npm publish
@kurtmilam
kurtmilam / gist:012b95c9def2723049f9
Created November 3, 2014 11:29
Handlebars Helpers & Nodejs Trouble
Handlebars.registerHelper("testHelper", function(options) {
console.log('testHelper')
return 'testHelper'
})
var template = "{{testHelper}}"
var ret = Handlebars.parse(template).statements
if (typeof ret[0] == 'undefined' || typeof ret[0].type == 'undefined' || ret[0].type != 'content') {
console.log('tags', ret, 'template', template)
@kurtmilam
kurtmilam / deep_compact_javascript_objects_underscore_lodash_mixin
Last active April 16, 2016 05:20
Underscore.js / Lodash Mixin to deep compact an object
/*The MIT License (MIT)
Copyright (c) 2014 Kurt Milam - http://xioup.com | Source: https://gist.github.com/kurtmilam/886b705fb0eb03001c77
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN AC
@kurtmilam
kurtmilam / make promise wait for property
Last active November 6, 2017 19:00
Make a promise wait for a specific object property to be set
// Semi reusable factory for promises waiting on an object property to be defined
function waitForIt (objectToObserve, propertyToObserve) {
return new Promise(function (resolve, reject) {
var checkIt = function (objectToObserve, propertyToObserve){
if (typeof objectToObserve[propertyToObserve] == 'undefined'){
setTimeout(checkIt, 500, objectToObserve, propertyToObserve)
} else {
resolve(objectToObserve[propertyToObserve])
}
}
@kurtmilam
kurtmilam / slenderize_flatten_javascript_object_.js
Last active July 31, 2018 19:17
Underscore/Lodash slenderize / flatten object mixin
/* Copyright (C) 2014 Kurt Milam - http://xioup.com | Source: https://gist.github.com/kurtmilam/7006dc1c2123787f9679
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTI
@kurtmilam
kurtmilam / Webfaction-CouchDB-config.log
Created July 8, 2014 13:57
config.log for CouchDB 1.6.0 installation on Webfaction
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by Apache CouchDB configure 1.6.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure --prefix=/home/USER --with-js-lib=/home/USER/lib --with-js-include=/home/USER/include/js --with-erlang=/home/USER/lib/erlang/usr/include
## --------- ##
## Platform. ##
@kurtmilam
kurtmilam / gravity_forms_custom_webhooks.php
Last active December 21, 2015 13:59
Create custom webhooks for Gravity Forms submissions
/* Copyright (C) 2012-2014 Kurt Milam - http://xioup.com | Source: https://gist.github.com/6316124
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TO