Last active
May 20, 2016 20:20
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # dependencies | |
| node_modules/ | |
| .sass-cache | |
| # OS | |
| .DS_Store | |
| # compiled files | |
| main.css | |
| main.css.map | |
| main.js | |
| /desk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "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" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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