Skip to content

Instantly share code, notes, and snippets.

Last active May 1, 2023 10:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
cd /tmp
(echo "SET TIME ZONE 'UTC' ;" ; printf "%s\n" '\pset format unaligned' ; printf "%s\n" '\pset fieldsep '\'','\''' ; printf "%s\n" '\pset t' ; printf "%s\n" '\o blog-stats.csv' ; echo 'SELECT id , cdate , length(content::text) FROM entries ORDER BY id ;') | psql weblog
gnuplot << '__EOF__'
set terminal pngcairo size 1280,960
set output "blog-stats-2023.png"
set datafile separator ","
stats "blog-stats.csv" using ($1):($3) name "st"
set xdata time
set timefmt "%Y-%m-%d %H:%M:%S"
set format x "%Y-%m"
set mxtics 4
set yrange [0:3000]
set ytics 500 nomirror
set mytics 5
set y2range [0:3000*ratio]
set y2tics 5000 nomirror
set my2tics 5
plot "blog-stats.csv" using 2:($1) with lines lw 2 title "entries (left scale)", "blog-stats.csv" using 2:($3/1024.) smooth cumulative with lines lw 2 title "kibichars (right scale)" axes x1y2
convert blog-stats-2023.png -resize 960x480 blog-stats-2023-small.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment