Skip to content

Instantly share code, notes, and snippets.

View skiano's full-sized avatar

Greg Skiano skiano

View GitHub Profile
@skiano
skiano / gridf.js
Last active December 17, 2017 20:37
2D letter grid compression
// TAKES A 2D ARRAY OF LETTERS AND COMPRESSES TO STRING
// for example ...
// compressGrid([
// ['A','A','A','B','B'],
// ['B','A','B','B','B'],
// ['B','A','B','B','B'],
// ['B','A','B','B','B'],
// ])
// becomes...
// 'A2B1,BAB2,2'
@skiano
skiano / cursor.js
Last active December 20, 2017 19:47
const createCursor = (directions, onMove) => {
const dirKeys = Object.keys(directions);
const cursor = {};
let location = 0;
cursor.max = 1000;
cursor.get = () => location;
@skiano
skiano / stableMatch.js
Created April 12, 2017 21:32
Thinking about stable matching within a homogeneous group based on similarity
const diff = (a, b) => Math.abs(a - b);
const removeSelf = (items, self) => (id) => items[id] !== items[self];
const makeComparator = (items, target) => (a, b) =>
diff(items[target], items[b]) - diff(items[target], items[a]);
const getStableMatches = (items) => {
const matches = [];
const available = [...items.keys()];
const preferences = available.map(id =>
available.filter(removeSelf(items, id)).sort(makeComparator(items, id)));
typography.inject(typePallette)
color.inject(colorPallette)
<TypographyStyles/>
// <Style>
// .heading1 {
// ...
// }