Skip to content

Instantly share code, notes, and snippets.

View vvatikiotis's full-sized avatar

Bill Vatikiotis vvatikiotis

View GitHub Profile
const curry = fn => (...args1) => {
if (args1.length === fn.length) {
return fn(...args1);
}
return (...args2) => {
const args = [...args1, ...args2];
if (args.length >= fn.length) {
return fn(...args);
@vvatikiotis
vvatikiotis / appEntryPoint.js
Created May 13, 2018 19:24 — forked from markerikson/appEntryPoint.js
Webpack React/Redux Hot Module Reloading (HMR) example
import React from "react";
import ReactDOM from "react-dom";
import configureStore from "./store/configureStore";
const store = configureStore();
const rootEl = document.getElementById("root");
@vvatikiotis
vvatikiotis / ex1.js
Created October 9, 2017 13:48 — forked from getify/ex1.js
class vs OLOO
class Foo {
constructor(x,y,z) {
Object.assign(this,{ x, y, z });
}
hello() {
console.log(this.x + this.y + this.z);
}
}
function downloadFiles(files /*: Array<string> */) {
// Do not fetch more than 8 files at a time
const PARALLEL_DOWNLOADS = Math.min(8, files.length);
// Create an Iterator from the array, this is our download queue
const queue = files[Symbol.iterator]();
// Channels are our download workers. As soon as a channel finishes downloading a file,
// it begins fetching another file from the queue. Best effort
const channels = [];
// Create only PARALLEL_DOWNLOADS number of channels
@vvatikiotis
vvatikiotis / FlowTutorial.js
Created October 3, 2017 07:41 — forked from busypeoples/FlowTutorial.js
Flow Fundamentals For JavaScript Developers
// @flow
// Flow Fundamentals For JavaScript Developers
/*
Tutorial for JavaScript Developers wanting to get started with FlowType.
Thorough walkthrough of all the basic features.
We will go through the basic features to gain a better understanding of the fundamentals.
You can uncomment the features one by one and work through this tutorial.
@vvatikiotis
vvatikiotis / type.js
Created September 30, 2017 10:07 — forked from kirilloid/type.js
getType
function getType (value) {
let type = typeof value;
if (type === 'object') {
return value ? Object.prototype.toString.call(value).slice(8, -1) : 'null';
}
return type;
}
[NaN, 0, 1, Infinity, // numbers
null, undefined, false, 'str', // other primitives
@vvatikiotis
vvatikiotis / *state-machine-component.md
Created September 7, 2017 07:22 — forked from developit/*state-machine-component.md
265b lib for building pure functional state machine components. https://npm.im/state-machine-component

state-machine-component

A tiny (265 byte) utility to create state machine components using two pure functions.

🔥 JSFiddle Demo

Usage

The API is a single function that accepts 2 pure functions as arguments:

@vvatikiotis
vvatikiotis / client.js
Last active August 23, 2017 12:24
WIP: Client-server PoC using gulf. Incomplete so far. Changes flow from server to client but not the opposite direction.
const textOT = require('ot-text').type
const gulf = require('gulf')
const net = require('net')
var doc = new gulf.EditableDocument({
storageAdapter: new gulf.MemoryAdapter,
ottype: textOT,
})
let content
// Takes an array of objects and turns it into an object where:
// - keys are specified by the key argument
// - values are the the initial object, minus the specified key
// Example:
// const arr = [
// { id: 1, name: 'blah', address: 'qwerqwer' },
// { id: 2, name: 'blah', address: 'qwerqwer' },
// { id: 6, name: 'blah', address: 'qwerqwer' },
// ]
//
// npm i -S react-autosuggest autosuggest-highlight
import Autosuggest from 'react-autosuggest'
const match = require('autosuggest-highlight/match')
const parse = require('autosuggest-highlight/parse')
const onSuggestionsFetchRequested = curry((suggest, { value }) => {
return suggest(value)
.then((fsa) => {
return { options: fsa.payload }