Skip to content

Instantly share code, notes, and snippets.

@grdscrc
grdscrc / jazz.sh
Last active November 17, 2023 00:32
jazz : list paths from a json input, fuzzy search a node, get its content ; useful with large payloads
#!/usr/bin/env bash
# Tested with jq 1.6 & fzf 0.42.0
# Inspired by https://github.com/reegnz/jq-zsh-plugin
# Call with `jazz <big_file_with_many_paths>.json` or `<command producing a valid json> | jazz`
# End command with `... | pbcopy` or `... > output.json` to save selection
input=$1
TMP_DIR=$(mktemp -d /tmp/jazz_XXX)
chmod 700 "$TMP_DIR"
@grdscrc
grdscrc / hash_node_lineages.rb
Last active June 18, 2019 14:59
List the lineages of every node in a hash
#!/usr/bin/env ruby
class Hash
def node_lineages
reduce_to_node = Proc.new do |prefix_key,value|
if value.is_a?(Hash)
value.map do |child_key,child_value|
new_prefix = [prefix_key,child_key].join('.')
reduce_to_node.call(new_prefix,child_value)
end