Month: May 2016

This is the most realistic video of what it is to be a programmer that I have ever seen. They read the docs and the source a majority of the time in order to be able to write what they are writing. This is rarely demonstrated when I hear people describe programming to new or would-be programmers.

In working with juju, we work with json formatted cookies in a ~/.go-cookies file. Sometimes we need to investigate these cookies to develop, verify, and debug our services.

An unexpired cookie value might be as good as a password or authentication token and so for the purpose of our debugging sometimes everything but the value is good enough. The jq filter ‘.[]|del(.Value)‘ strips all of the .Value properties from every object in the input array. This results in:

Now lets say you want to remove the cookie with the Path value “/NEENR/”.

The jq filter: ‘.[] | select(.Path!=”/NEENR/”)’ does that job.

These examples show filter and map, but what about reduce?

Min, max, min_by and max_by are nice default reducers.

min_by(.Expires) shows the next expiring cookie.

max_by(.Created) shows the most recently created cookie.

[.[]|.Expires]|max if you don’t care about the rest of the cookie and just want the max date.

[.[]|.Expires]|min if you just want the min date.

See the Array Construction section of the manual for the details on the syntax. I like to think of it as the .[]|.NAME returns elements and if I want them in an array I wrap it in [] for array construction.