Skip to content

Instantly share code, notes, and snippets.

@ohAitch
Last active May 20, 2016 20:20
Show Gist options
  • Select an option

  • Save ohAitch/ce3bd2ff5a007fc203b2158004b0b311 to your computer and use it in GitHub Desktop.

Select an option

Save ohAitch/ce3bd2ff5a007fc203b2158004b0b311 to your computer and use it in GitHub Desktop.
Replay womb transactions using the %lens port. Usage: lsc replay.ls ~2016.4.29..23.30.00 path/to/old/pier
# dependencies
node_modules/
.sass-cache
# OS
.DS_Store
# compiled files
main.css
main.css.map
main.js
/desk
{
"name": "node-womb-replay",
"version": "1.0.0",
"description": "POC: Uses lens API to replay womb events",
"main": "replay.ls",
"dependencies": {
"fs-promise": "^0.5.0",
"any-promise": "^1.1.0",
"promise-map": "^1.1.0",
"request-promise-json": "^1.0.4",
"request-promise": "^3.0.0"
},
"devDependencies": {},
"scripts": {
"test": "lsc replay.ls"
},
"repository": {
"type": "git",
"url": "git+https://gist.github.com/ce3bd2ff5a007fc203b2158004b0b311.git"
},
"author": "~fyr",
"license": "ISC",
"bugs": {
"url": "https://gist.github.com/ce3bd2ff5a007fc203b2158004b0b311"
},
"homepage": "https://gist.github.com/ce3bd2ff5a007fc203b2158004b0b311"
}
fs = require \fs-promise
promise = require \any-promise
request = require \request-promise-json
[,,startDate,pier="zod",port=12321] = process.argv
host = "http://localhost:#port"
womb-events = "#pier/.urb/put/womb-events/"
transactions = []
saveFile = (filename)->
if filename > startDate
fs.readFile "#womb-events#filename" \utf8
.then (s)-> transactions.push s
files <- fs.readdir womb-events .then
<- promise.all (files.map saveFile) .then
transactions.sort!
transactions.push '~'
lens-command =
sink: app: \hood
source: as:
mark: \womb-replay-log
next: [{dojo:t} for t in transactions]
request.post host, lens-command
.then -> process.stdout.write it
.catch ({response:{body}}) -> console.error JSON.parse body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment