summary |
shortlog | log |
commit |
commitdiff |
tree
first ⋅ prev ⋅ next
Mischa POSLAWSKY [Sun, 8 Sep 2019 15:34:44 +0000 (17:34 +0200)]
shorten human-readable values to 2-3 digits
Similar to ls e.a. Previously reserved 5 characters in order to align
decimal points, but this is pointless with mixed magnitudes.
Mischa POSLAWSKY [Sun, 8 Sep 2019 14:44:39 +0000 (16:44 +0200)]
fix sival log for negative/zero values
Mischa POSLAWSKY [Sun, 8 Sep 2019 14:39:03 +0000 (16:39 +0200)]
optional decimal point for human-readable integers
Retain input value precision.
Mischa POSLAWSKY [Sun, 8 Sep 2019 14:28:33 +0000 (16:28 +0200)]
declare pod encoding
Most renderers will output in the same encoding as the pod document,
which is ascii (causing an unaccented e for E<eacute>) or worse, latin1.
Best to explicitly use UTF-8 as all i/o should be.
Mischa POSLAWSKY [Sun, 8 Sep 2019 14:16:41 +0000 (16:16 +0200)]
escape unicode character in pod
Avoid perldoc error:
> Non-ASCII character seen before =encoding in 'Pokémon'. Assuming UTF-8
Mischa POSLAWSKY [Sun, 8 Sep 2019 14:12:06 +0000 (16:12 +0200)]
json example alternative without jq
External dependency not usually installed, so describe separately.
Mischa POSLAWSKY [Sun, 8 Sep 2019 14:10:31 +0000 (16:10 +0200)]
explain options introduced in examples
Mischa POSLAWSKY [Sun, 8 Sep 2019 14:11:17 +0000 (16:11 +0200)]
read utf-8 input in letter frequency example
Mischa POSLAWSKY [Sun, 8 Sep 2019 14:02:27 +0000 (16:02 +0200)]
reorder examples by complexity
Move snippets around to logically introduce different features.
Mischa POSLAWSKY [Sat, 7 Sep 2019 18:49:39 +0000 (20:49 +0200)]
do not trim valueless contents
Mischa POSLAWSKY [Sat, 7 Sep 2019 18:28:17 +0000 (20:28 +0200)]
omit empty value statistics
Mischa POSLAWSKY [Sat, 7 Sep 2019 17:32:07 +0000 (19:32 +0200)]
order incoming values before interval
If Tie::Array::Sorted is available, use it to insert input in order instead
of recalculating on every interval. Assumes frequent refreshes of thousands
of lines, in which case it saves significantly, also slowing down less
exponentially (probably O(l) instead of O(t*l²)).
Mischa POSLAWSKY [Sat, 7 Sep 2019 17:04:08 +0000 (19:04 +0200)]
keep ordered values, only resort on interval
Massive speedup per calculation.
Mischa POSLAWSKY [Sat, 7 Sep 2019 16:11:46 +0000 (18:11 +0200)]
indicate limited results in stats
Mischa POSLAWSKY [Sat, 7 Sep 2019 16:10:54 +0000 (18:10 +0200)]
silence warnings on empty input
Mischa POSLAWSKY [Sat, 7 Sep 2019 16:10:03 +0000 (18:10 +0200)]
include total, min, avg, max in stat details
Mischa POSLAWSKY [Sat, 7 Sep 2019 16:05:26 +0000 (18:05 +0200)]
stat (-s) option to summarise totals at end
Mischa POSLAWSKY [Sat, 7 Sep 2019 18:36:44 +0000 (20:36 +0200)]
minor code cleanup for human formatting
Mischa POSLAWSKY [Sat, 7 Sep 2019 14:14:50 +0000 (16:14 +0200)]
align human values, reserve constant length
Mischa POSLAWSKY [Sat, 7 Sep 2019 14:54:18 +0000 (16:54 +0200)]
omit source code position in regex error message
Mischa POSLAWSKY [Sat, 7 Sep 2019 14:39:29 +0000 (16:39 +0200)]
compile regular expression to -f (without /x)
Reports syntax errors immediately.
Mischa POSLAWSKY [Sat, 7 Sep 2019 14:30:38 +0000 (16:30 +0200)]
support values with float suffixes e±N
Mischa POSLAWSKY [Sat, 7 Sep 2019 14:30:03 +0000 (16:30 +0200)]
prepare anchor match during option parsing
Mischa POSLAWSKY [Sat, 7 Sep 2019 14:17:35 +0000 (16:17 +0200)]
prepare regex to match values
Code cleanup, slight speedup.
Mischa POSLAWSKY [Sat, 7 Sep 2019 14:03:35 +0000 (16:03 +0200)]
exponent fallback in case of unit overflow
Guard against missing units.
Mischa POSLAWSKY [Sat, 7 Sep 2019 13:49:36 +0000 (15:49 +0200)]
move human formatting code into sival() function
Mischa POSLAWSKY [Sat, 7 Sep 2019 13:43:10 +0000 (15:43 +0200)]
decrease divider for small human numbers
Mischa POSLAWSKY [Sat, 7 Sep 2019 13:41:57 +0000 (15:41 +0200)]
human-readable (-H) option to abbreviate numbers
Retain 2-3 significant digits and letter n-T for size. Similar to -h in
ls, du, df, free, rsync, sort; except forgoing byte-specific powers of 1024
in favour of actually _human_ SI powers of 1000.
Common option shorthand -h conflicts with help, but capital -H has a
precedent in df --si so may be more appropriate.
Mischa POSLAWSKY [Sat, 7 Sep 2019 03:14:43 +0000 (05:14 +0200)]
combined limit minimum-maximum
Mischa POSLAWSKY [Sat, 7 Sep 2019 02:41:55 +0000 (04:41 +0200)]
minimum limit to override start line number
Internal option --hidemin or by negative -L instead of maximum.
Mischa POSLAWSKY [Sat, 7 Sep 2019 02:40:01 +0000 (04:40 +0200)]
empty limit support (hidemax internally)
Mischa POSLAWSKY [Sat, 7 Sep 2019 01:51:01 +0000 (03:51 +0200)]
limit (-L) option to stop output
Mischa POSLAWSKY [Fri, 6 Sep 2019 22:22:12 +0000 (00:22 +0200)]
hello barcat =^.^=
Everybody loves cats!
Mischa POSLAWSKY [Fri, 6 Sep 2019 22:22:12 +0000 (00:22 +0200)]
rename program to barcat
English word `graph` is too common and indistinct for general distribution,
already conflicting with /usr/bin/graph from plotutils (Debian bug #61319).
Mischa POSLAWSKY [Fri, 6 Sep 2019 22:52:43 +0000 (00:52 +0200)]
graph length rounded to nearest integer
Even distribution, and fixes unexpected overflows due to inexact float
representation after size calculation (round decimals being decremented).
Mischa POSLAWSKY [Fri, 6 Sep 2019 23:47:10 +0000 (01:47 +0200)]
value-length option to override $lenval
Mischa POSLAWSKY [Fri, 6 Sep 2019 22:58:44 +0000 (00:58 +0200)]
field selection by regex anchor
Backwards-compatible with field numbers as digits should not be number
delimiters, or could be queried like -f'(?:0)'.
Mischa POSLAWSKY [Fri, 6 Sep 2019 23:26:20 +0000 (01:26 +0200)]
retain unsubstituted line contents
Fix length recalculation after interval.
Mischa POSLAWSKY [Fri, 6 Sep 2019 22:28:57 +0000 (00:28 +0200)]
field (-f) option to select later values
Mischa POSLAWSKY [Fri, 6 Sep 2019 22:42:45 +0000 (00:42 +0200)]
value placeholder in contents
Replace original position to support later occurrences.
Mischa POSLAWSKY [Fri, 6 Sep 2019 22:19:08 +0000 (00:19 +0200)]
ignore length of valueless lines in padding
Excluded from graph, so do not pad other contents to align.
Mischa POSLAWSKY [Fri, 6 Sep 2019 22:18:29 +0000 (00:18 +0200)]
shorthand -C to disable color
There is precedent for capitalisation to negate, along with +c which is not
supported by Getopt::Long.
Mischa POSLAWSKY [Fri, 6 Sep 2019 21:33:26 +0000 (23:33 +0200)]
rename follow option to --interval or -t
Initially copied f(ollow) from tail, but that letter will be better suited
for field selection, and the function is only similar.
Alternatives include -s (closer equivalent to tail, also in free --seconds),
-i as in ping --interval (best match, but should be reserved for interactive
or ignore-case), -n like watch --interval, and -v as verbose interpretation.
Settle on -t for best mnemonics; common for time(out) and found in preferred
longhand of inTerval.
Mischa POSLAWSKY [Fri, 6 Sep 2019 21:27:19 +0000 (23:27 +0200)]
another json example with multiple columns
Also found this API with the same results (and more), but needs separate
queries which is slow and unwanted so unsuitable as a fun snippet:
curl -s https://pokeapi.co/api/v2/pokemon/{1..151} |
jq -r '[.height/10,.id,.name|tostring] | join(" ")' | graph
Mischa POSLAWSKY [Fri, 6 Sep 2019 21:26:39 +0000 (23:26 +0200)]
examples with csv, xml, and json data
Practical usage with most common file types.
Mischa POSLAWSKY [Thu, 5 Sep 2019 21:46:21 +0000 (23:46 +0200)]
calculate length percentages of width
Shorthand to facilitate relative sizes without manual preparation.
Allow strings so trailing % can be accepted.
Mischa POSLAWSKY [Thu, 5 Sep 2019 20:09:14 +0000 (22:09 +0200)]
enable lexical subs before perl v5.26
Introduced in perl v5.18 and experimental until recently.
Mischa POSLAWSKY [Thu, 5 Sep 2019 20:08:37 +0000 (22:08 +0200)]
skip recalculation of unprogressed data
Mischa POSLAWSKY [Thu, 5 Sep 2019 20:08:13 +0000 (22:08 +0200)]
strip trailing carriage returns
Support CRLF line termination regardless of system record separator,
preventing mangled output due to column returns before appended graphs.
Besides Windows files, \r is also added by unbuffer -p for some reason.
Mischa POSLAWSKY [Thu, 5 Sep 2019 21:46:57 +0000 (23:46 +0200)]
describe -u, rename to --unmodified
Mischa POSLAWSKY [Thu, 5 Sep 2019 20:07:49 +0000 (22:07 +0200)]
unclean (-u) option to keep leading whitespace
Mischa POSLAWSKY [Thu, 5 Sep 2019 16:48:53 +0000 (18:48 +0200)]
man page rendering of --help pod
Emulate git --help including terminal escapes.
Mischa POSLAWSKY [Thu, 5 Sep 2019 16:46:45 +0000 (18:46 +0200)]
transition bar to visualise changed scale
Indicate increased maximum with --follow.
Mischa POSLAWSKY [Thu, 5 Sep 2019 16:07:43 +0000 (18:07 +0200)]
ignore SIGINT so partial input is shown
Assume interrupt stops pipes and we can continue. Subsequent signals will
then be reset so calculation can still be killed.
Mischa POSLAWSKY [Thu, 5 Sep 2019 16:06:53 +0000 (18:06 +0200)]
color default depends on stdout being isatty
Mischa POSLAWSKY [Thu, 5 Sep 2019 15:07:05 +0000 (17:07 +0200)]
follow (-f) option to output partial results
Calculate and display on every SIGALRM, with scale and statistics upto that
point. Named like equivalent tail -f.
Mischa POSLAWSKY [Thu, 5 Sep 2019 15:05:39 +0000 (17:05 +0200)]
parse values while reading lines
Manipulate input as it comes in, spreading the load and having values ready
for upcoming interrupts without a separate phase to repeat.
Mischa POSLAWSKY [Thu, 5 Sep 2019 03:16:49 +0000 (05:16 +0200)]
separate project repository
Commits moved out of home and cleaned for public distribution.
Version bump to celebrate.
Mischa POSLAWSKY [Thu, 5 Sep 2019 02:45:25 +0000 (04:45 +0200)]
avoid drawing empty graph
Mischa POSLAWSKY [Thu, 5 Sep 2019 01:54:41 +0000 (03:54 +0200)]
markers < > at standard deviation offsets
Mischa POSLAWSKY [Wed, 4 Sep 2019 22:50:04 +0000 (00:50 +0200)]
disable markers without graph
Avoid error "Modification of non-creatable array value attempted"
trying to access unallocated positions.
Mischa POSLAWSKY [Wed, 4 Sep 2019 22:20:35 +0000 (00:20 +0200)]
cut after assumed delimiter on --trim=0
Mischa POSLAWSKY [Wed, 4 Sep 2019 21:55:58 +0000 (23:55 +0200)]
omit abbreviation mark on --trim=1
The first character should be whitespace or another delimiter to be kept.
Contents can be assumed cut and does not need an indicator.
Mischa POSLAWSKY [Wed, 4 Sep 2019 21:28:42 +0000 (23:28 +0200)]
include value delimiter in trim length
Mischa POSLAWSKY [Wed, 4 Sep 2019 21:06:06 +0000 (23:06 +0200)]
trim maximum unless negative
Mischa POSLAWSKY [Wed, 4 Sep 2019 20:36:05 +0000 (22:36 +0200)]
trim (-l) option to abbreviate contents
Mischa POSLAWSKY [Wed, 4 Sep 2019 20:22:01 +0000 (22:22 +0200)]
markers (-m) option to omit statistical markers
Support leaving bars untouched for either aesthetical reasons or to avoid
calculation (which may yet be(come) costly or buggy).
String argument is only checked for emptiness, otherwise all positions are
enabled. Effectively boolean but with future compatibility for more
detailed customisation.
Mischa POSLAWSKY [Wed, 4 Sep 2019 18:56:22 +0000 (20:56 +0200)]
negative values less than positive
Extend graph to the lowest value, with axis marked by |.
Mischa POSLAWSKY [Wed, 4 Sep 2019 18:39:10 +0000 (20:39 +0200)]
pass through numberless lines
Ignore in statistics, and silence perl warnings about arguments not being
numeric.
Mischa POSLAWSKY [Wed, 4 Sep 2019 18:29:09 +0000 (20:29 +0200)]
floating point value support
Include numbers after decimal point; perl will handle it no problem.
Replace stupid digit calculation without number reformatting by simple
string length, also fixing log error on 0 values.
Mischa POSLAWSKY [Wed, 4 Sep 2019 18:24:17 +0000 (20:24 +0200)]
negative value support
Include integers less than zero; treat as positive for bar sizes.
Mischa POSLAWSKY [Wed, 4 Sep 2019 18:23:23 +0000 (20:23 +0200)]
assume standard input/output is utf8
Fixes length calculation of unicode data.
Mischa POSLAWSKY [Wed, 4 Sep 2019 18:22:23 +0000 (20:22 +0200)]
color option to disable formatting codes
Mischa POSLAWSKY [Wed, 4 Sep 2019 18:21:24 +0000 (20:21 +0200)]
document practical example oneliners
Some shell commands adapted from personal history. After pictures,
code should also be worth quite some words.
Mischa POSLAWSKY [Thu, 5 Sep 2019 01:02:38 +0000 (03:02 +0200)]
short and long help options
Emulate git commands in having -h for usage distinct from --help for full
documentation.
Mischa POSLAWSKY [Wed, 4 Sep 2019 16:52:19 +0000 (18:52 +0200)]
minimal documentation and help options
Mischa POSLAWSKY [Wed, 4 Sep 2019 16:35:54 +0000 (18:35 +0200)]
parse options to override width
Mischa POSLAWSKY [Wed, 4 Sep 2019 14:57:08 +0000 (16:57 +0200)]
indicate average value in bar
Mischa POSLAWSKY [Wed, 4 Sep 2019 18:22:54 +0000 (20:22 +0200)]
coloured bar markers
Mischa POSLAWSKY [Wed, 4 Sep 2019 14:55:32 +0000 (16:55 +0200)]
prepare to facilitate other distribution markers
Mischa POSLAWSKY [Wed, 4 Sep 2019 14:45:49 +0000 (16:45 +0200)]
prepare bar positions of (mean) indicators
Mischa POSLAWSKY [Wed, 4 Sep 2019 14:22:04 +0000 (16:22 +0200)]
indicate mean value in bar position
Better visual, and accurate in case of split middle.
Mischa POSLAWSKY [Wed, 4 Sep 2019 14:12:13 +0000 (16:12 +0200)]
distinguish median value
Greater number in case of even lines.
Mischa POSLAWSKY [Wed, 4 Sep 2019 14:10:29 +0000 (16:10 +0200)]
minimum and maximum values in red and green
Mischa POSLAWSKY [Wed, 4 Sep 2019 13:59:49 +0000 (15:59 +0200)]
reformat and colourise numbers
Replace captured values in dark grey, with minimal padding
(uniq adds at least 6 spaces we can use for graphing).
Mischa POSLAWSKY [Wed, 4 Sep 2019 13:16:23 +0000 (15:16 +0200)]
write out script, enable warnings
Mostly the same code but more readable and maintainable.
Integers are captured and bars enlarged to fill screen width.
Mischa POSLAWSKY [Fri, 23 Mar 2007 15:08:59 +0000 (16:08 +0100)]
draw bar graph for input values
Written as one-liner to visualise output from uniq -c (i.e. git history).