social.tchncs.de is one of the many independent Mastodon servers you can use to participate in the fediverse.
A friendly server from Germany – which tends to attract techy people, but welcomes everybody. This is one of the oldest Mastodon instances.

Administered by:

Server stats:

3.8K
active users

#parsing

1 post1 participant0 posts today
Replied in thread

@Sidneys1 Using that page I've been able to build a fancy test query. I am using the NVD API since it doesn't require authentication and the data that comes back is complicated enough to give me lots to try.
I've built this up over the last few days. I am querying NVD for all CVEs that are in the CISA KEVC then pulling out just the ones that apply to Windows Server 2008, 2012, 2016, and 2019. I could have just done different NVD searches but this was an exercise for how to parse JSON with jq
A week ago, jq '.' was about all I knew how to do.
Now I have created this.

curl https://services.nvd.nist.gov/rest/json/cves/2.0?hasKev | jq '. | .vulnerabilities | map(
if isempty(
.cve.configurations | map(
.nodes | map(
.cpeMatch | map(
if (
.criteria | test(
"windows_server_20(08)|(1[269])"
)
)
then .
else empty
end
)
)
)
)
then empty
else .
end
)'

Which seems to do what I want it to do.
I was deleting some fields at one point just to see if I knew how to do it, but I took that part out.
I found type and keys to be indispensable for figuring out what each new layer was offering me to work with.

That manual page jqlang.org/manual is fantastic. I also found out that it is designed to work just as well on a computer screen as a mobile device screen. I was able to keep reading through it with no loss in usability when I only had my phone handy.

If any jq devs or anybody responsible for that website is on the Fediverse, let them know how much I appreciate the work that was put into creating the tool and documenting how to use it.

jqlang.orgjq 1.7 Manualjq is a lightweight and flexible command-line JSON processor

Pyparsing sightings - some recent posts/pages using pyparsing (1/2):

- Pyparsing is embedded as a parsing engine for Juniper Networks Junos PyEZ automation environment for smart devices.
juniper.net/documentation/us/e

- Pyparsing included in the examples for the Python Packaging User Guide.
packaging.python.org/en/latest

- Papercrawler uses pyparsing to extract metadata from published papers, journals, and conference proceedings.
github.com/sucv/paperCrawler

Some things I'm especially proud of in plusminus (my Python package for parsing and evaluating infix notation arithmetic):
- |absolute value| expressions
- ° symbol as a unary postfix operator, to convert degrees to radians: sin(π/2) vs. sin(90°)
- exponents ² and ³
- √ and ³√ operators (both unary and binary, so you can write 2√2)
- mathematical constants e, π, φ, and τ
- set operators ∈, ∉, ∩, and ∪
- safe eval of untrusted inputs
Try it at ptmcg.pythonanywhere.com/plusm
#python #parsing #infix

ptmcg.pythonanywhere.comPlusminus +/- Parser/Evaluator Tester - 0.8.1

Very happy with my final solution for today's Advent of Code problem. I used the parseq parser combinator library to chew through the input and get a clean series of multiplied numbers, and :do/:don-t symbols.

github.com/coderfrog256/Advent

My first solution was to throw regexes at it, which worked but was not quite as clean.

Next up I'll be looking into how best to write this in Clojure, the loop with mutable state is definitely out! :p

GitHubAdventOfCode/2024/lisp/Day3.lisp at main · coderfrog256/AdventOfCodeAdvent Of Code Snippets and Solutions. Contribute to coderfrog256/AdventOfCode development by creating an account on GitHub.