Skip to content

Instantly share code, notes, and snippets.

@ohAitch
ohAitch / urb-auth.ls
Last active August 3, 2016 18:38
Minimal urb.js protocol authenticator in node, sends a test |hi
request = require \request-promise-json
prompt = require \inquirer .createPromptModule!
port = process.env.URB_PORT or 8443
host = "http://localhost:#port"
message = {appl:'hood', mark:'helm-hi', data: 'auth-test'}
getCode = (ship, cb)->
code = process.env.URB_CODE
if code => cb {code}
else prompt [name: 'code' message: "Enter code for ~#ship"] .then cb
@ohAitch
ohAitch / urb-without-py.fish
Created April 14, 2016 19:17
Simple markdown conversion via json sent to the %chis interface
echo '""' | lsc -je 'source:(as:mark:"html",next:as:mark:"md", next:data:"*test*"), sink:stdout:null' | curl localhost:12321 -X POST -d @-
@ohAitch
ohAitch / .gitignore
Last active May 20, 2016 20:20
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
:: Rosettacode dijkstra algorithm, translated from LUA
::
:::: /hoon/dijkstra/gen
::
|%
:: Graph type
++ a-graph (map term (map term @u))
--
|%
++ math-huge `(unit @u)`~ :: use actual maybe type
@ohAitch
ohAitch / retag.ls
Created November 22, 2016 02:15
usage: jq '.' -s -R oldzuse.hoon | lsc -je "(require './retag.ls') @" | jq -r '.' > newzuse.hoon
RANGE=[ '(2)', '++ zuse']
strip_tags = (.filter -> it isnt /^( |::)* \+\+[a-z0-9:]*$/)
retag = (untagged)->
stack = []
already_tagged = {}
res = []; emit = (-> res.push it)
started = no
for untagged
if ..includes RANGE[0]
|= a/(list @ud) ^- (unit @ud)
%+ roll a
|= {b/@ud c/(unit @ud)}
?~ c `b
?: (lth b u.c) `b
c
@ohAitch
ohAitch / deco-inverted.md
Created April 7, 2017 20:41
Actually literate gen/deco.hoon

this is a sample file designed to set conventions for high-quality conventional hoon.

all lines must be under 80 characters. no blank lines. any line longer than 60 characters is probably too long. uppercase or non-ascii letters are strongly discouraged.

informal comments (lines with ::) should be used only for meta-discussion about the code.

@ohAitch
ohAitch / deco-extracted.md
Created April 7, 2017 20:42
Further rendering of deco-inverted

this is a sample file designed to set conventions for high-quality conventional hoon.

all lines must be under 80 characters. no blank lines. any line longer than 60 characters is probably too long. uppercase or non-ascii letters are strongly discouraged.

informal comments (lines with ::) should be used only for meta-discussion about the code.

@ohAitch
ohAitch / index.html
Last active January 28, 2018 15:36
"IDE"
<body>
<script src="https://code.jquery.com/jquery.js"></script>
<pre id="boot" contenteditable style="background:#eea">inp.onkeyup = inp.onfocus = () =&gt; {
var a
try{ a = eval(inp.innerText)} catch(_a){ a = _a}
res.innerText = a
}</pre>
<pre id="inp" contenteditable style="background:#bdb">
@ohAitch
ohAitch / code.js
Last active June 5, 2018 18:27
Wast bootstrap under data:text/html,<textarea%20onkeyup="out.innerText=eval(this.value)"></textarea><pre%20id=out>
/*
- panes: input | compiler | wast | runtime | output
TODO
- snapshot button that saves json of [date input compiler runtime] to localStorage
- timestamp buttons to cycle through old versions - also sth with diffs?
- <details> on "foo =\n", w/ collapse back if backspace on beginning
*/
document.body.querySelector('script') || document.body.appendChild(
document.createRange().createContextualFragment(
'<script src=https://cdn.rawgit.com/WebAssembly/wabt/aae5a4b7/demo/libwabt.js>'