site-josuah

/usr/josuah
Log | Files | Refs

commit cab9ddf63e1d83afcba05ee763940b3d0e907c16
parent 3e5b90a66164881c82eb8936302998c259a54309
Author: Josuah Demangeon <me@josuah.net>
Date:   Mon, 20 Apr 2020 22:23:00 +0200

html leigibility fix

Diffstat:
Mhead.html | 6+++---
Mwiki/awk/index.md | 3+++
Mwiki/jj/jj-log | 27+++++++++++++--------------
3 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/head.html b/head.html @@ -2,8 +2,9 @@ <meta charset="UTF-8"/> <style> -body { max-width:80ch; margin:auto; padding:5em 5ch; } -pre { margin-left:4ch; } +body { max-width: 80ch; margin: auto; padding: 5em 5ch; } +pre { margin-left: 4ch; } +blockquote { border-left: solid 1px grey; } </style> <title>josuah.net</title> @@ -18,4 +19,3 @@ pre { margin-left:4ch; } </nav> <hr/> - diff --git a/wiki/awk/index.md b/wiki/awk/index.md @@ -22,6 +22,9 @@ but many things are. I use it for multiple projects: [parser]: //code.z0.is/git/notwiki/files/ [jj]: /wiki/jj/ +Below are multiple ways of using awk for getting the best out of it. These are +partly by myself, partly collected from what I saw in the wild. + CSV fields with header ---------------------- diff --git a/wiki/jj/jj-log b/wiki/jj/jj-log @@ -49,29 +49,29 @@ function gmtime(sec, tm) tm["sec"] = sec } -function init_timezone( \ - cmd, date, h, m) +function localtime(sec, tm, + tz, h, m) { - cmd = "date +%z" - cmd | getline date - close(cmd) - - h = substr(date, 2, 2) - m = substr(date, 4, 2) - TZOFFSET = substr(date, 1, 1) (h * 3600 + m * 60) + if (!TZOFFSET) { + "date +%z" | getline tz + close("date +%z") + h = substr(tz, 2, 2) + m = substr(tz, 4, 2) + TZOFFSET = substr(date, 1, 1) (h * 3600 + m * 60) + } + return gmtime(sec + TZOFFSET, tm) } function parse_msg(s, msg, nickend, text) { nickend = index($2, ">") - gmtime($1 + TZOFFSET, TM) + localtime($1, TM) msg["type"] = substr($2, nickend + 1) msg["text"] = substr($0, index($0, ">") + 2 + length(msg["type"])) msg["nick"] = substr($2, 2, nickend - 2) msg["date"] = sprintf("%04d/%02d/%02d", TM["year"], TM["mon"], TM["mday"]) msg["time"] = sprintf("%02d:%02d", TM["hour"], TM["min"]) - } function parse_bold(s, @@ -89,15 +89,14 @@ function parse_bold(s, BEGIN { FS = " " - init_timezone() } -# Handle tail's "==> filename <==" headers. - !NF { next } +# Handle tail's "==> filename <==" headers. + $1 == "==>" { sub(".log <==", "") sub("/channels/", " ")