Skip to content

Instantly share code, notes, and snippets.

View hellertime's full-sized avatar
🏠
Working from home

Chris Heller hellertime

🏠
Working from home
View GitHub Profile
@andymatuschak
andymatuschak / States-v3.md
Last active May 1, 2024 12:32
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@krishnanraman
krishnanraman / results.txt
Created January 21, 2014 22:38
Pail-ish results. The goal is to extract tickers from firehose & dump 1 file per ticker on disk.
import com.twitter.scalding._
import java.io.PrintWriter
/* Goals: Find finance related tweets, uid & date from firehodse data
*/
class FinanceTweets(args:Args) extends Job(args) {
val junk = (0,"","","", "")
val regex = """^\$[A-Z]{1,5}""" // cashtag regex
@krishnanraman
krishnanraman / n records => 38 services == 38 directories
Last active December 18, 2015 09:29
Scalding job to read a Tsv of ~6000 "Sample" records & write to pail based on some partition criteria. Partition Criteria: All Samples with a common service go to the same pail subdirectory. Notice that each record goes to 1 pail => ~6000 pailfiles will be created.
$ tree pailtest/tfe
pailtest/tfe
├── part-000130.pailfile
├── part-000140.pailfile
├── part-000440.pailfile
├── part-000451.pailfile
├── part-000460.pailfile
├── part-000470.pailfile
├── part-000481.pailfile
├── part-000491.pailfile
@ndarville
ndarville / business-models.md
Last active January 13, 2024 17:27
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google