Skip to content

Instantly share code, notes, and snippets.

#! /bin/bash
for i in {100000..1}; do
d=$(($(date +%s) - i))
cmd="vi $i.txt"
mod=$((i % 10))
if [[ $mod -eq 1 ]]; then
cmd="cat $i.txt | grep $d"
@dmfay
dmfay / collapse.js
Last active September 6, 2017 17:56
Collapse JOIN query result sets into a hierarchical object graph
'use strict';
/**
* Collapses tabular result sets into a (hierarchical) object graph based on
* column nomenclature. Given a query that selects parent and child columns as
* parent__id, parent__val, children__id, children__val, this will return an
* array of objects in the form
*
* {id: 1, val: 'parent val', children: [{id: 11, val: 'child val'}]}
*
@dmfay
dmfay / gist:7381858
Last active December 27, 2015 20:09
Scala Markov chainer for text.
import scala.io.Source
import scala.util.Random
object Markov extends App {
val outputLength: Int = args(0).toInt
val prefixLength: Int = if (args.length > 1) args(1).toInt else 2
val in = Source.fromInputStream(System.in).mkString("").split("""\s+""").toList
val tokens = tokenize(in)