Skip to content

Instantly share code, notes, and snippets.

@JoshCheek JoshCheek/scrape_sigs
Last active Jun 16, 2019

Embed
What would you like to do?
My hydra signature scraping script
#!/usr/bin/env bash
node -e 'console.log(JSON.stringify(require("./src/composable-glsl-functions.js")))' \
| ruby -r json -e '
puts JSON.parse($stdin.read, symbolize_names: true)
.map { |name, defn| {**defn, name: name} }
.group_by { |defn| defn[:type] }
.sort
.each { |cat, defns| defns.sort_by! { |defn| defn[:name] } }
.map { |category, defns|
defns.zip([category]).map.with_index { |(defn,category),i|
cc, mc, tc, pc, dc = "\e[95m", "\e[9#{6+i%2}m", "\e[38;2;150;150;150m", "\e[34m", "\e[32m"
args = defn.fetch(:inputs,[]).map { |arg|
default = "#{tc}=#{dc}#{arg[:default]}" if arg.key? :default
"#{tc}#{arg[:type]} #{pc}#{arg[:name]}#{default}"
}
meth = "#{mc}#{defn[:name]}(#{args.join(mc+", ")}"
"#{cc}#{category.to_s.ljust 15}\e[34m#{meth}#{mc})\e[0m"
}*"\n"
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.