mastodon.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
The original server operated by the Mastodon gGmbH non-profit

Administered by:

Server stats:

360K
active users

#jq

3 posts3 participants0 posts today
Replied in thread

@glyph OK, I thought of something. Over the last few months I kept seeing #jq mentioned in passing all over the place. I finally realised it was installed by default on all my machines and looked up the manual. I've now used it to poke around in unfamiliar datasets, extract data from huge JSON files into user-friendly CSVs, and alongside #jc I've been able to convert YAML files to JSON, and pull out just the interesting parts of my Apache log files. Sure I could do all this in Python but I'm old enough to have used sed, awk, and plain old grep, so I love a versatile tool that can manipulate standard input. I don't know why I overlooked jq for so long.

Niche GitHub cli / jq tip: you can pretty much turn anything in jq into an interpolated string. Just pipe the data into a double-quoted string and escape the fields using "\(.FIELD_NAME)". Also good to see that GitHub CLI help now lists all the JSON fields that are available for a given command.

🏷️ #github_cli #json #jq #nichetips

Everybody who is happy about having rolled out in the and has now enabled in their account but still want to script a thing or two with and from the site, rejoice… My login script can now deal with that, too… Love and

github.com/michael-simons/garm

Now I wait for a new firmware for my watch, because I'm on a beta on which ECG is disabled, lol…

Tooling for the archive created by Garmin datamanagement. - michael-simons/garmin-babel
GitHubgarmin-babel/bin/retrieve_garmin_tokens_2fas.sh at main · michael-simons/garmin-babelTooling for the archive created by Garmin datamanagement. - michael-simons/garmin-babel
Continued thread

Also, stop memorising the vimrc setup and #kubectl command completion. These are now standard in the environment.

Be prepared for a horrible test environment. It's like a VNC web client connected to the Linux desktop with a terminal and Firefox. Copy and paste between the browser and local to the VM is janky.

It looks like can install extra software I was able to install gron, but I did this via apt. So anything that requires a curl shell install script may not work. I noticed that kubernetes.io search still listed community topics but did not let you click on them.

You're expected to know #JSONPath / #jq. If you're mind goes blank (remember you won't be able to search StackOverflow), get the format of the output from kubectl correct and then use grep (the old ways are the best).

If you do use #Kubernetes but in a managed environment (EKS, AKS, etc) you'll want to drill the labs on installing/maintaining clusters, etcd maintenance and deployments (including network policies, ingresses, etc). Same applies if you're used to an automated deployment CD environment like #ArgoCD. Remember "--dry-run=client --output yaml" is your friend.

Finally, be aware there are multiple cluster environments in the exam (questions will tell you which context to use), so if you know how to mod your PS1 prompt make sure it includes the output from "kubectl config current-context". Alternatively, create an alias 😉

Do you have any useful tips? Share them in the replies?

Links 🔗
⭐ udemy.com/course/certified-kub
⭐ github.com/tomnomnom/gron

I've always been annoyed by GitHub not giving the exact number of stars a project has.

Also their rounding is as useful as "... ago" for displaying dates.

That's the perfect opportunity to share how to use #curl to make an API call and parse the #JSON result with builtin #perl (no need for #jq)

curl -s api.github.com/repos/gpakosz/. | perl -MJSON::PP=decode_json -CO -0777 -E '$response = decode_json(readline *STDIN); say ($response->{stargazers_count})'

Narzędzie nazywane jq to coś, co może pomóc nam w obsłudze JSON-ów, a w przypadku dużych struktur tego typu dobrze wiemy, że pomoc bywa przydatna. Warto zatem sprawdzić tutorial, który mieści się pod poniższym linkiem.

#JSON #parser #JQ

navendu.me/posts/jq-interactiv

Navendu Pottekkat · An Interactive Guide to Transforming JSON with jqLearn to use jq through incremental, interactive examples right in your browser.

I needed to find and script a little around the platforms of a multi-architecture container image. This is what I came up with:

docker manifest inspect path-to/image:tag |\
jq -r '.manifests[].platform | select(.os != "unknown" and .architecture != "unknown") | "\(.os)-\(.architecture)"' |\
sort |\
uniq

It omits any unknown entries as they're frequently attestations or signatures. It outputs a lovely list as follows:

linux-386
linux-amd64
linux-arm
linux-arm64
linux-ppc64le
linux-s390x
windows-amd64

The full shell wrapper, which includes a help message and only needs the image name as an argument, is [here](../grimoire/kubernetes-and-more/#return-a-list-of-architectures-for-a-multi-arch-image).

i should not be proud of myself for this. i should be ashamed.

jq -c '.[] | select(.shortcode | contains("flan_")) | {shortcode, static_url}' emojis.json \
| while read flan; do \
code=$(jq -cr '.shortcode' <<< "${flan}"); \
url=$(jq -cr '.static_url' <<< "${flan}"); \
curl -o "flans/${code}.png" -sSL $url; \
done

(it finds all the flan_ entries in a list and downloads them)

(in retrospect i could have used the category prop for that)

(look i said i should be ashamed ok)

#bash#jq#cursed