Spaghetti Sort

image
Truly mind blowing. Sorting done in O(N) time.

ref: https://advent.morr.cc/2018/15

Awk

I forgot most of awk after college. Now that I look at it again, it does help in many cases when I need to work with csv/tsv files. There is no need to write a simple python script to parse lines out and do some printing.

Sample log lines

07.46.199.184 [28/Sep/2010:04:08:20] "GET /robots.txt HTTP/1.1" 200 0 "msnbot"
123.125.71.19 [28/Sep/2010:04:20:11] "GET / HTTP/1.1" 304 - "Baiduspider"

Sample cmds

awk '{print $0}'
awk '{print $1}' logs.txt
awk '{print $1, $(NF-2) }' logs.txt
awk '{print NR ") " $1 " -> " $(NF-2)}' logs.txt
awk '{print $2}' logs.txt
awk '{print $2}' logs.txt | awk 'BEGIN{FS=":"}{print $1}'
awk '{print $2}' logs.txt | awk 'BEGIN{FS=":"}{print $1}' | sed 's/\[//'
awk '{if ($(NF-2) == "200") {print $0}}' logs.txt
awk '{a+=$(NF-2); print "Total so far:", a}' logs.txt
awk '{a+=$(NF-2)}END{print "Total:", a}' logs.txt

Note: awk is 1-based. $NF is number of fields. NR is row number. FS is field separator.

Ref: https://gregable.com/2010/09/why-you-should-know-just-little-awk.html

AdTree

Screen Shot 2019-09-19 at 1.22.56 PM
I don’t quite understand their business model. $0 CPM ??? $0 CPC ???

https://adtree.io/

三体全集 – 宇宙很大 生活更大

Use machine learning to write

Next time when you don’t know how to continue a sentence, use this to help you write your whole essay. =)

https://writeup.ai

Oauth2 protocol

Nice to know what’s going on when we use oauth2 to get access.

https://milapneupane.com.np/2019/09/02/a-complete-guide-to-oauth2-protocol/

Curl Cookbook

Many useful curl arguments.

https://catonmat.net/cookbooks/curl