💾 Archived View for makeworld.gq › one-liners.gmi captured on 2020-09-24 at 02:41:31. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
Last updated: 2020-05-29
Newest ones are always at the top, and any one-liner without a source was written by me.
---
I've used these on my stats page, check it out!
Note that these assume use of Linux and systemd.
All visits, from first to last:
sudo gzip -dc /var/log/daemon.log.*.gz | sudo cat /dev/stdin /var/log/daemon.log.[0-9] /var/log/daemon.log | grep -a jetforce | awk -F' ' '{ print $6 }' | grep '^[0-9]'
Number of unique visitors:
sudo zgrep -a jetforce /var/log/daemon.log* | awk -F' ' '{ print $6 }' | grep '^[0-9]' | sort | uniq | wc -l
Total number of visits:
sudo zgrep -a jetforce /var/log/daemon.log* | awk -F' ' '{ print $6 }' | grep '^[0-9]' | wc -l
Last server start:
sudo systemctl show jetforce.service -p ExecMainStartTimestamp | cut -b 24-
Explanation:
`zgrep` searches through regular and gzip compressed files, which is helpful because older logs get compressed by default on Debian.
Adding the `-a` flag helps fix an issue I experienced, because apparently some of my logs had binary data. That flag ignores that and tries to search through it anyway.
The awk command grabs just the IP addresses, and then the second grep filters out all the non-IP addresses that were grabbed by accident -- maybe it's was an error line instead, and not a request line, for example. The IP check done by grep is very primitive, but it works well enough for most cases.
---
A one-liner that compiles a C program that when run and piped into `aplay`, will play a pretty good song. Make sure to put your volume at like 50%. This is pretty crazy to me, and it sounds good too! Try running it without piping aplay at the end too, to learn a bit more about how it works
echo "g(i,x,t,o){return((3&x&(i*((3&i>>16?\"BY}6YB6$\":\"Qj}6jQ6%\")[t%8]+51)>>o))<<4);};main(i,n,s){for(i=0;;i++)putchar(g(i,1,n=i>>14,12)+g(i,s=i>>17,n^i>>13,10)+g(i,s/3,n+((i>>11)%3),10)+g(i,s/5,8+n-((i>>10)%3),9));}" | gcc -xc -&&./a.out | aplay