-
-
Save siers/059f60e24615ecc63af2 to your computer and use it in GitHub Desktop.
Plot the active hours of an IRC channel based on your own logs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# usage: n=$(pwd); cd ~/.weechat/logs; cp $n/{plot,activity} .; ./plot *math.weechatlog | |
# Be aware that if your client's not receiving messages 24/7, | |
# some hours will not receive coverage or some might be underrepresented. | |
# Furthermore, using a bouncer with a long scrollback will create pikes. | |
! [ -z "$1" ] && (tail -n100000 "$1" | ./activity > data) | |
[ -e data ] && gnuplot -p -e \ | |
"set xrange [1:$(tail -n1 data | sed 's/ .*//')]; plot '-' using 1:2 with l" \ | |
< data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env runhaskell | |
-- vim: ft=haskell | |
-- requires `cabal install MissingH' | |
import Data.List | |
import Data.Maybe | |
import System.Locale | |
import System.Time | |
import System.Time.ParseDate | |
import Text.Printf | |
type Key = Int | |
scale = 12 | |
hour = 60 `div` scale | |
range = [0..24 * hour - 1] | |
key c = (ctHour c) * hour + (ctMin c) `div` scale | |
-- describe key = printf "%02i:%02i" (key `div` hour) (key `mod` scale) | |
-- present (a, b) = printf "%s %i %i" (describe a :: String) a b | |
present (a, b) = printf "%i %i" a b | |
addNones :: [(Key, Int)] -> [(Key, Int)] | |
addNones stats = sort . (++ stats) . map (\a -> (a, 0)) $ range \\ (map fst stats) | |
calculate :: [String] -> [(Key, Int)] | |
calculate = map (\as@(a:_) -> (a, length as)) . group . sort . map (key . fromJust . parse) | |
where parse = parseCalendarTime defaultTimeLocale "%Y-%m-%d %H:%M:%S" | |
main = getContents >>= mapM_ (putStrLn . present) . addNones . calculate . lines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment