Skip to content

Instantly share code, notes, and snippets.

View michaelguse's full-sized avatar
🏠
Working from home

Michael Guse michaelguse

🏠
Working from home
View GitHub Profile
@jaymecd
jaymecd / a_json_data_pivot_with_jq.md
Created June 2, 2020 11:57
This JQ one-liner to pivot JSON data

Pivot JSON data

This one-liner pivots data from group>users or user>groups:

$ cat incoming.json \
  | jq 'map(. as $in | .users[] | . as $u | {user:$u, group:$in.group}) | group_by(.user) | map({user:.[0].user, groups: map(.group)})'

[
 {
@leesei
leesei / colors.source
Created November 28, 2014 09:05
#bash #color-source Color macro for BASH
# prompt color and format variables
# A color init string consists of one or more of the following numeric codes:
# * Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# * Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# * Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
# * Extended color codes for terminals that support more than 16 colors: