Skip to content

Instantly share code, notes, and snippets.

export default function registerContent(uri) {
const tree = {}
const files = fs.readdirSync(uri)
files.forEach((fileName) => {
const fileUri = path.join(uri, fileName)
if(fs.lstatSync(fileUri).isDirectory()) {
tree[fileName] = registerContent(fileUri)
} else {
@melbourne2991
melbourne2991 / Levenshtein.js
Last active September 22, 2016 12:51
Levenshtein (edit) Distance in JS
function getDistance(strA, strB) {
const matrix = [];
const arrA = strA.split('');
const arrB = strB.split('');
// fill matrix with a row for each character and
// for each row add a single column with incrementing (0 to length)
for(let a = 0; a < arrA.length + 1; a++) {
matrix[a] = [a]
const subject$ = new Rx.Subject();
const bindAction = (action) => (...args) => subject$.next(action(args));
const doSomething = () => ({ type: 'DO_SOMETHING' })
const doSomethingAsyncComplete = () => {
return {
type: 'DO_SOMETHING_COMPLETE'
}
const HeaderAPI = {};
HeaderAPI.updateAuthenticated = function() {
console.log('UPDATING!');
}
class Header {
constructor() {
}
}
const storiesEndpoint = 'https://hacker-news.firebaseio.com/v0/topstories.json?limit=10';
const storiesFetch$ = Rx.Observable.fromPromise(fetch(storiesEndpoint));
const decoder = new TextDecoder();
const storyIds$ = storiesFetch$
.map(response => response.body)
.map(body => body.getReader())
.switchMap((reader) => {
return Rx.Observable.create((observer) => {
function search() {
// import cycle from '@cycle/core';
const Cycle = require('@cycle/core');
// import Rx from 'rxjs';
const mount = document.createElement('div');
document.body.appendChild(mount)
function main(sources) {
const click$ = sources.DOM;
return {
local function next(self, value)
for i = 1, self.observerCount do
self.observers[i](value)
end
end
local function subscribe(self, observer)
table.insert(self.observers, observer)
self.observerCount = self.observerCount + 1
end
@melbourne2991
melbourne2991 / gist:8be0645b8347aaac34b147db836258a8
Created June 3, 2017 05:36
OSX LUAROCKS INSTALL ./configure
./configure --with-lua=/usr/local --lua-suffix=jit --with-lua-include=/usr/local/include/luajit-2.0
@melbourne2991
melbourne2991 / cleandocker.sh
Last active October 21, 2017 16:48
Docker cleanup
# https://gist.github.com/bastman/5b57ddb3c11942094f8d0a97d461b430
function cleandocker-images {
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
}
function cleandocker-containers {
docker rm $(docker ps -qa --no-trunc --filter "status=exited")
}
# resource "aws_ecs_service" "scraper" {
# name = "scraper_service"
# cluster = "${aws_ecs_cluster.scraper_cluster.name}"
# # Track the latest ACTIVE revision
# task_definition = "${aws_ecs_task_definition.scraper_task.family}:${max("${aws_ecs_task_definition.scraper_task.revision}", "${data.aws_ecs_task_definition.scraper_task.revision}")}"
# desired_count = 1
# }
data "aws_ecs_task_definition" "scraper_task" {