Skip to content

Instantly share code, notes, and snippets.

@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 / 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.

|= a/(list @ud) ^- (unit @ud)
%+ roll a
|= {b/@ud c/(unit @ud)}
?~ c `b
?: (lth b u.c) `b
c
@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]
:: 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 / .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
@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 / 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
fooBarReducer = (fooBar=0,{addFooBar,clearFooBar})->
switch
when addFooBar? then fooBar + addFooBar
when clearFooBar? then 0
else fooBar
connect(({fooBar})-> count: fooBar) ({count, dispatch})->
div {},
button {onClick: -> dispatch addFooBar:5}, "Bump ", count
@ohAitch
ohAitch / mini-redux.ls
Last active April 2, 2016 10:40
The abstraction model of Redux, implemented in 7 lines. Learning project.
## Info ##
# requires jquery, zepto, or such
# live demo at https://jsbin.com/kuyukucoxe/edit?js,output
## shim('react'): render an html string to the page
$ \#mount .remove!
$ \body .append '<div id="mount"/>'
mount = -> $ \#mount .html it
## shim('react-dom'): functionally compose html