Post B2LOHSCk6N44EHA9ei by flyingsaceur@ioc.exchange
 (DIR) More posts by flyingsaceur@ioc.exchange
 (DIR) Post #B2KyFhm4e2aJ8BC6O8 by clacke@libranet.de
       2026-01-16T08:46:28Z
       
       0 likes, 0 repeats
       
       I gave the team a half-hour crash course in jq, some of the key features of its data and execution model, and how to do a handful of useful everyday things.After, I had so many questions for myself that I spent over an hour learning more jq. I now have a greater understanding for how brilliant the language is, and I would do that crash course differently.I think I owe @hpr an episode, if there isn't one.I found many cheat sheets and liked none of them. A cheat sheet would be perfect to go in the show notes.#jq
       
 (DIR) Post #B2Kz33zKqJOIDQvttQ by clacke@libranet.de
       2026-01-16T08:55:11Z
       
       0 likes, 0 repeats
       
       In Github Actions, jq comes pre-installed in the default worker. This can save you a lot of headache. Don't try to manipulate JSON with bash or Python, that's just clunky and error-prone when you can use jq instead.I rewrote some of my own code from half a year ago. It's now shorter, more readable (if you know jq – hence the crash course), has zero quoting issues and provides better error messages.#GithubActions
       
 (DIR) Post #B2KzLVjcQ8Z1TyNVDs by clacke@libranet.de
       2026-01-16T08:58:46Z
       
       0 likes, 0 repeats
       
       A team member suggested we might want to replace some or all of our jinja use with jq. Makes sense. Would save us some Python setup too, which would simplify things.There is yq for yaml as well, but JSON is valid yaml, so jq is enough.
       
 (DIR) Post #B2L4EQlmyudppMpvYu by clacke@libranet.de
       2026-01-16T09:53:23Z
       
       0 likes, 0 repeats
       
       @jamey I mean we don't need yq, because anything we need to express can be expressed as JSON. Then we won't have to install anything extra, as jq comes  preinstalled.I think you can even tell kubectl to read your input as JSON, and avoid any potential ambiguity.
       
 (DIR) Post #B2L62Nk0cGRErqO0wK by clacke@libranet.de
       2026-01-16T10:13:45Z
       
       0 likes, 0 repeats
       
       This is data-oriented programming. And the simplest forms of it looks just like the data. The brilliance of the language is on several planes: - The syntax: Superficially it looks like JSON, but there is so much more going on, e.g. [1, 2, 3] is not a list ... it's three constant filters whose outputs are coalesced into a list ... but it looks just like a list in JSON! - The library: The language has a few primitives, and most of the functions you see are or can be implemented in the langage itself, using those primitives, including the all-important select(). It gives me LISP goosebumps. - The data model: How the idea of multiple values, immutability and pipes-and-filters seeps into everything and allows for some very simple yet powerful operations that would be awkward in almost any other language.You come for something that can extract an attribute in a datastructure for you, and it excels at that, and then as you dig deeper, you discover that underneath, it's a fusion-powered nanorobot assembly factory.It's wonderful to see Small Languages make a comeback.#jq
       
 (DIR) Post #B2L6rFPVLi5Xnb3Arg by clacke@libranet.de
       2026-01-16T10:22:52Z
       
       0 likes, 0 repeats
       
       @jamey Yeah, we create the inputs ourselves, and then our target (kubernetes) accepts YAML.I don't remember if absolutely all possible JSON is valid YAML 1.2 and equivalent to what YAML 1.2 would parse it as. But probably all JSON we would produce would be.
       
 (DIR) Post #B2LB5LTbzWq6U3wuKe by wader@fosstodon.org
       2026-01-16T11:10:14Z
       
       1 likes, 0 repeats
       
       @qmacro @clacke yeap! probably the most elegant yet practical language i've ever used
       
 (DIR) Post #B2LFdD8bttyQHgWtsG by ken_fallon@mastodon.sdf.org
       2026-01-16T12:01:06Z
       
       1 likes, 0 repeats
       
       @clacke i think @perloid also had shows on the topic.I'd love to hear this. @hpr
       
 (DIR) Post #B2LIv0qQe3WJETCnqq by perloid@mastodon.sdf.org
       2026-01-16T12:37:55Z
       
       1 likes, 0 repeats
       
       @clacke@hpr I have done three jq episodes. I have the next waiting to record. I had something of a burnout in 2024 after 12 years of HPR janitorial work! It's been difficult to resume making shows. Now I'm 76 my energy is less also.
       
 (DIR) Post #B2LOHSCk6N44EHA9ei by flyingsaceur@ioc.exchange
       2026-01-16T13:38:03Z
       
       1 likes, 0 repeats
       
       @clacke it’s kind of amazing that forty years later we have a new tool to add to the coreutils boxMaybe there’s something out there that fills this gap, but it bugs me that jq tends to be embedded as a string in shell scripts or YAML the way that awk is embedded in shell scripts or shell scripts get embedded in YAML and then the tooling isn’t there to check it: a hole where bugs can sneak in. How do you handle these cases?
       
 (DIR) Post #B2NQAcEwynctYFyy24 by clacke@libranet.de
       2026-01-17T12:23:22Z
       
       0 likes, 0 repeats
       
       @flyingsaceur We don't; Embedding a jq call in a shell script feels like the normal way to do it.If we put the jq code in a file instead of inline, is there tooling that could check it, that could prove something about it?
       
 (DIR) Post #B2NQAoz7axgn4vg0fI by clacke@libranet.de
       2026-01-17T12:28:52Z
       
       0 likes, 0 repeats
       
       @ken_fallon I'll check it out. Knowing @perloid 's past work, they're probably the jq reference I've been looking for that I'd want to share with others. 🥰
       
 (DIR) Post #B2NWw6GHmGC1zsdGvg by flyingsaceur@ioc.exchange
       2026-01-17T14:24:28Z
       
       0 likes, 0 repeats
       
       @clacke I’ll typically do that for shell scriptt, I put them in separate files so I can run spellcheck against them, I can also ensure that ‘set -e’ is the case for what it does. I’m sure there’s a way to run jq/awk checks on shell strings in YAML but that’s another layer to check, or could run ci to build my ci config, but down that path lies madness, dawg
       
 (DIR) Post #B2NfLIhXSoPFRzuJiS by perloid@mastodon.sdf.org
       2026-01-17T15:58:22Z
       
       1 likes, 1 repeats
       
       @clacke @ken_fallon The show numbers of the episodes I have already done are: 4104, 4114, and 4227I will strive to record and upload the fourth in the next couple of weeks.
       
 (DIR) Post #B2Rk4rzhzUa47tmT20 by clacke@libranet.de
       2026-01-19T11:31:08Z
       
       0 likes, 0 repeats
       
       @perloid Read the show notes a bit and saw a challenge I couldn't resist:hackerpublicradio.org/eps/hpr4…As a point of interest, I wrote a little Bash loop to show the positive and negative offsets of the characters in the test string - just to help me visualise them.Could I do this in jq? I could!$ echo '"asdf"' | jq -c '. as $in | [ range(length) | . as $i | { "key": "\(.)", "value": ( $in | explode | [.[$i]] | implode ) } ] | from_entries'{"0":"a","1":"s","2":"d","3":"f"}Negative indexes left as an exercise for the reader.@ken_fallon
       
 (DIR) Post #B2Rk5LMkmtFJDlmmTg by perloid@mastodon.sdf.org
       2026-01-19T11:36:58Z
       
       1 likes, 0 repeats
       
       @clacke @ken_fallon Very good!Having done a bit of programming language teaching in my time (though never having been trained to do it!), I always felt that using features that haven't been introduced yet would confuse people more than help them.It might just be that I am easily confused, and assume others are the same, of course. 😉
       
 (DIR) Post #B2Rk5RWts4vYKyZy7s by clacke@libranet.de
       2026-01-19T11:39:02Z
       
       0 likes, 0 repeats
       
       @perloid From a pedagogical perspective, I 100% agree! This was just my own code golfing. 😇@ken_fallon
       
 (DIR) Post #B2hrQ5ADkLy6ZsfFdQ by clacke@libranet.de
       2026-01-27T09:47:56Z
       
       0 likes, 0 repeats
       
       Turns out that not only do Actions runners come with jq preinstalled, but yq is there too.hollycummins.com/using-yq-in-g…There was a featured snippet for “is yq available on GitHub actions,” which directed me to a marketplace installer. The yq project itself had a marketplace installer. Clearly, I needed to install it before using it. Right?My colleague George Gastaldi looked at what I’d done, and pointed out yq was available on the runners. This matters, because we try and limit our use of external, ‘non-official’ actions, for supply chain security reasons.So I searched again to confirm, and … still found very little. To actually confirm, I had to merge and experiment. And, indeed, the GitHub runners do come with yq pre-installed. They’ve had yq since 2021.#yaml #yq #jq #GithubActions#CICD#ContinuousIntegration#ContinuousDeployment
       
 (DIR) Post #B2nXBIznCoZEzvDruK by clacke@libranet.de
       2026-01-30T02:56:31Z
       
       0 likes, 0 repeats
       
       TIL #jq can do HTML/XML escaping, URI encoding, URI decoding, shell quoting, even base64 encoding and decoding.This will come in handy for sure.jqlang.org/manual/#format-stri…
       
 (DIR) Post #B2nXBMBbLMnOtPlqEK by clacke@libranet.de
       2026-01-30T03:01:00Z
       
       0 likes, 0 repeats
       
       ... and csv!