Skip to content

Instantly share code, notes, and snippets.

View ktilcu's full-sized avatar

kyle tilman ktilcu

View GitHub Profile
@ktilcu
ktilcu / .block
Last active February 23, 2016 00:22 — forked from mbostock/.block
Force-Directed Graph with Mouseover
license: gpl-3.0
@ktilcu
ktilcu / .block
Last active February 23, 2016 05:56 — forked from mbostock/.block
Hierarchical Edge Bundling
license: gpl-3.0
@ktilcu
ktilcu / .block
Created February 23, 2016 05:39 — forked from mbostock/.block
The Euro Debt Crisis
license: gpl-3.0
@ktilcu
ktilcu / search.js
Last active August 15, 2017 20:48
kyle-Refactor: Autocomplete functionality
// Before
// Ad-hoc polymorphism (changing internal function logic based on datatype)
// Does extra work on an empty string
// repeats the toLowerCase().indexOf() portion internally
// Doesn't have tests
// Dangles a return in an unecessary else statement
function searchContains (query, value) {
var stringifiedNumber;
if (typeof value === 'string') {
return value.toLowerCase().indexOf(query) > -1;
@ktilcu
ktilcu / index.html
Last active July 1, 2016 03:12 — forked from anonymous/index.html
JS Bin Template for testing
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.rawgit.com/lodash/lodash/4.5.1/dist/lodash.min.js"></script>
<script src="https://cdn.rawgit.com/zloirock/core-js/master/client/shim.min.js"></script>
<script src="https://wzrd.in/standalone/tape@latest"></script>
<script src="https://wzrd.in/standalone/tap-browser-color@latest"></script>
<script src="https://wzrd.in/standalone/tape-catch@latest"></script>
<meta charset="utf-8">
@ktilcu
ktilcu / custom-domain-apg-lambda.md
Last active August 15, 2017 20:43
kyle-Experience: Setting up a Custom Domain For API Gateway and Lambda

AWS has come out with some pretty rad stuff recently. Lambda has my functional microservice pants in a twist. I have bult tons of nodejs services in the past but with Lambda I can forget about the wholle HTTP/s bitand just write some code. So, after using serverless to deploy my functions and set up the api gateway, I needed to put all this AWS goodness behind my own URL. Unfortunately, API Gateway requires a certificate and it can't be one create in ACM. So using certbot I ran the following:

certbot certonly --config-dir `pwd` --logs-dir `pwd` --work-dir `pwd` -a manual --rsa-key-size 2048 -d api.kyletilman.com

(for some reason certbot only looks in /etc for config and stuff)

Certbot is put together by EFF and letsencrypt.org.

@ktilcu
ktilcu / fanout.promise.js
Last active August 15, 2017 20:42
kyle-Snippet: Promise fanout
// Concurrently process a single result with many promises and return as params
// i.e., fanout(queue.getMessage(), storeInS3, fillWithDbData).then(function(s3Results, dbresults){})
function fanout (src /* Potentially any number of remianing thenables */) {
var consumers = _.tail(_.values(arguments));
var results = consumers.map(function (consumer) {
return src.then(consumer);
});
return Promise.join.apply(Promise, results);
}
@ktilcu
ktilcu / wait-on-await--syntax.js
Created April 6, 2017 17:31
Promise syntax vs Async/Await
// Promise
const makeRequest = () =>
getJSON()
makeRequest
.then(console.log)
// A/A
const makeRequest = async () =>
await getJSON()
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.22.1/ramda.min.js"></script>
<script src="https://cdn.rawgit.com/zloirock/core-js/master/client/shim.min.js"></script>
<script src="https://wzrd.in/standalone/tape@latest"></script>
<script src="https://wzrd.in/standalone/tap-browser-color@latest"></script>
<script src="https://wzrd.in/standalone/tape-catch@latest"></script>
</head>
<body>
@ktilcu
ktilcu / point-free-ramda.js.md
Last active August 15, 2017 20:40
kyle-Refactor: Point free with Ramda goodness

The initial function seemed straightforward and very close to functional programming but there was a bit of buried complexity.

function generate(seedWords) {
  const filteredWords = filterInputs(seedWords);
  const initialHash = R.head(filteredWords) || 'thunder';
  const hashWithRandom = appendRandom(initialHash);
  return generateHelper(hashWithRandom, R.tail(filteredWords));
}