Skip to content

Instantly share code, notes, and snippets.

View jemgold's full-sized avatar
👽
vibing

Jem jemgold

👽
vibing
View GitHub Profile
import expect from 'expect';
import { countByFrom, probablize } from 'src/MarkovMatrix';
describe('MarkovMatrix', () => {
it('counts by from-state', () => {
const input = [
['foo', 'bar'],
['foo', 'bar'],
['foo', 'bar'],
['foo', 'baz'],
import { compose, countBy, divide, filter, groupBy, head, last, toLower, map, prop, sum, values } from 'ramda';
const sumValues = compose(sum, values);
export function countByFrom(input) {
return compose(
map(countBy(last)),
groupBy(head),
filter((x) => {
return x.length > 1;
/* @flow */
import type { Action, AppState, StyleProp } from '../../Types';
import { append, compose, equals, init, last, lensPath, over, reject, set,
update, view } from 'ramda';
const UNDO = 'UNDO';
export function undo(): Action {
return {
type: UNDO,
data: true,
/* @flow */
import { compose, contains, filter, forEach, flip, map, prop } from 'ramda';
type TypekitFont = {
descriptors: {
featureSettings: string,
subset: string,
unicodeRange: string,
weight: number,
},
@jemgold
jemgold / carry.md
Last active September 20, 2016 14:49

Backpack criteria.todo

  • All black, no tacky logos
  • Laptop sleeve
  • Not too officey for hiking or cycling; not too outdoorsy for commuting
  • Waterproofish
  • External water bottle pocket (negates GoRucks etc)
  • ~20-25L
    • small enough to be a personal item on a plane
    • big enough for day-to-day use
  • Doesn't make you look like an accountant
import expect from 'expect';
import { flatten, unflatten } from 'src/flatten';
describe('Flatten', () => {
it('flattens an object, prefixed by original keys', () => {
const input = {
foo: {
bar: 'baz',
qux: 'zip',
},

Flatten / Unflatten

So I'm trying to calculate the cartesian product of object's properties

const style = {
  fontFamily: ['helvetica', 'comic sans'],
  fontWeight: [300, 700],
}

const expected = [
import { StyleMatrix, Style, StyleProp } from './Types';
import { addIndex, assoc, concat, keys, map, prop, reduce } from 'ramda';
const reduceIndexed = addIndex(reduce);
function product([head, ...tail]) {
if (head === undefined) { return [[]]; }
const prod = product(tail);
const Xray = require('x-ray')
const x = Xray()
x('https://www.typewolf.com/site-of-the-day/', '.item', [{
title: '.item-title',
date: '.item-date',
fonts: ['.item-tags a']
}])
.paginate('.btn-more:nth-child(2)@href')
.limit(165)