Skip to content

Instantly share code, notes, and snippets.

@blzjns
blzjns / trivy_templating.md
Last active March 29, 2022 22:10
How to use golang templates for generating custom trivy reports

Trivy templating

Trivy uses golang templates. Thus, whenever opening a tag {{an_opening_tag}}, most likely it needs to be closed with {{end}}.

For example:

The tag range works similarly to a for-each loop, where . represents an initial object

{{range . as $myObj}}--- This a text concatenating {{$myObj.Target}} ---{{end}}
@blzjns
blzjns / trie.js
Last active April 11, 2022 07:24
Find words using a tree-like struct (Trie)
/*
E.g.:
[root-node]
/ | \
B D S
/ | \
A O__ E__
/\ \ \ \
@blzjns
blzjns / evenlySpaced.java
Created June 17, 2025 17:04
Check whether 3 nums are evenly spaced. E.g. Get the smallest, and largest numbers and use them to calculate the medium, then return whether the diff from mid to small equals the diff from large to mid.
public boolean evenlySpaced(int a, int b, int c) {
int sm = Math.min(Math.min(a, b), c);
int lg = Math.max(Math.max(a, b), c);
//int md = (a+b+c) - (Math.min(Math.min(a,b),c) + Math.max(Math.max(a,b),c));
int md = (a+b+c)-(sm+lg);
return md-sm == lg-md;
}