Readit News logoReadit News
wwader commented on Ask HN: What trick of the trade took you too long to learn?    · Posted by u/unsupp0rted
penguin_booze · a month ago
I'd like to give a shoutout to jq for (non-JSON) text processing, and also as an almost-replacement for awk:

  echo "foo bar" | jq -Rr 'split(" ")[0]' # prints foo
I say 'almost', because jq right now can't invoke sub processes from within, unlike awk and bash. But otherwise, it's a fully fledged, functional, language.

wwader · a month ago
Same! and jq's regexp functions are quite powerful for transforming text into something more structured:

  $ echo -e "10:20: hello\n20:39: world" | jq -cR 'capture("^(?<timestamp>.*): (?<message>.*)$")'
  {"timestamp":"10:20","message":"hello"}
  {"timestamp":"20:39","message":"world"}


  $ echo -e "10:20: hello\n20:39: world" | jq -Rn '[inputs | capture("(?<t>.*): (?<m>.*)$").m] | join(" ")'
  "hello world"
Also using inputs/0 etc in combination with reduce and foreach it's possible to process streams of text that might not end.

wwader commented on Ask HN: What Are You Working On? (June 2025)    · Posted by u/david927
MrApathy · 2 months ago
jq Jake: An interactive challenge based approach to learning jq for JSON processing. https://jqjake.com

jq is an incredibly powerful tool, but it's not always the easiest tool to use. LLM's are remarkably good at constructing filters for most uses cases, but for people that work with JSON a lot, learning jq can be real benefit.

wwader · 2 months ago
Very nice! thanks for building this
wwader commented on Xee: A Modern XPath and XSLT Engine in Rust   blog.startifact.com/posts... · Posted by u/robin_reala
bbkane · 5 months ago
I also don't think there's a specification written for the jq query language, unlike https://jmespath.org/ , which as you mentioned also has more client libraries.

I too am probably going to embed jmespath in my app.I need it to allow users to fill CLI flags from config files, and it'll replace my crappy homegrown version ( https://github.com/bbkane/warg/blob/740663eeeb5e87c9225fb627... )

wwader · 5 months ago
The jaq author is working on a formal specification of jq https://github.com/01mf02/jq-lang-spec. I think it has also help that there are several implementations of jq now like, gojq, jaq and jqjq, that has helped finding edge cases and weird behaviours.
wwader commented on Show HN: SQLite disk page explorer   github.com/QuadrupleA/sql... · Posted by u/QuadrupleA
wwader · 7 months ago
The sqlite source includes a CLI tool called showdb that is quite nice for poking around in database files
wwader commented on Cyphernetes: A Query Language for Kubernetes   cyphernet.es/#... · Posted by u/fatliverfreddy
mdaniel · 9 months ago
I am firmly in the camp of jq because (a) I am able to bring my years of muscle memory to this problem (b) jq is without a doubt more expressive than jsonpath (c) related to the muscle memory part I have uncanny valley syndrome trying to context switch between jsonpath and jmespath (used by awscli for some stupid reason) so it's much easier to just use the one true json swiss-army tool upon the json those clis emit
wwader · 9 months ago
Note on (b): As i understand it JSONPath by design is limited to only be able to select things from the input, so can't build a new object, array etc.
wwader commented on Useful built-in macOS command-line utilities   weiyen.net/articles/usefu... · Posted by u/yen223
vbezhenar · 10 months ago
Few additions.

open -n file.pdf : opens new instance of Preview application which is useful if you want to open the same file twice (for example to look at different pages at once).

caffeinate -d : prevents display turning off, useful if you want to look at display without moving mouse.

wwader · 10 months ago
open -a is nice, i use it with alias, ex:

  alias qt='open -a "quicktime player"'
  alias vlc='open -a "vlc"'

wwader commented on Command Line Tools I Like (2022)   rwblickhan.org/newsletter... · Posted by u/yu3zhou4
dredmorbius · a year ago
The syntax (and theory behind it) are really arcane, but jq is phenomenally powerful.

For websites which can publish JSON extracts, piping that through jq to get just what you want and how you want it is an absolute lifesaver.

wwader · a year ago
Yeap the syntax and semantics is quite different to other languages and it really took me a long time and deep understanding to really appreciate how expressive and damn well designed it is.
wwader commented on Command Line Tools I Like (2022)   rwblickhan.org/newsletter... · Posted by u/yu3zhou4
ExtremisAndy · a year ago
I have never heard of “jq”. Oh my goodness. Your comment may have just changed my life. I cannot emphasize enough how many times I have needed a tool like this (and, yes, shame on me for not making a better effort to find one). Thank you!
wwader · a year ago
As a heavy jq user and now a days also maintainer i say welcome! happy to help if you run into some problem
wwader commented on I have 2000 old VHS tapes in my garage and don't know what to do with them   takes.jamesomalley.co.uk/... · Posted by u/keybits
getwiththeprog · a year ago
Great documentary, New York collector (Kim) gifts huge video library to an Italian town. When a former Kim's customer hunts it down, he finds water-damaged tapes in a disused store-room - and mafia overtones standing in his way!
wwader · a year ago
Yeap love things like that, ex https://www.imdb.com/title/tt1787791/ and the mystery show podcast. Let me know if you know any!

u/wwader

KarmaCake day298December 23, 2021View Original