Skip to content

Instantly share code, notes, and snippets.

View gist:32a327869c40ec2673d622957a7b6289
#! /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 Sep 6, 2017
Collapse JOIN query result sets into a hierarchical object graph
View collapse.js
'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 Dec 27, 2015
Scala Markov chainer for text.
View gist:7381858
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)