Search This Blog

Saturday, April 21, 2018

elephant cheatsheet


table rows

-- works bad

SELECT schemaname,relname,n_live_tup
  FROM pg_stat_user_tables
  ORDER BY n_live_tup DESC;

Tuesday, September 6, 2016

linux cheat sheet


# resources
ps -eo size,rss,pid,user,comm --sort -rss | head -n 30
ps -eo size,rss,pcpu,pid,user,comm --sort -pcpu | head -n 30

# memstat
atop -L160 1 1 | grep MEM

# caches

# chmod directories

# awk epoch to timestamp in logs
awk '{a = strftime("%F %T", $1); $1 = "" ; print a" "$0}'

# safe file delete

# some magic in resolv.conf

# default browser ( set default apps )
xdg-mime default firefox.desktop x-scheme-handler/http
xdg-mime default firefox.desktop x-scheme-handler/https

# keyboard
setxkbmap -layout us,ru -option grp:toggle

# qt crutch
export QT_GRAPHICSSYSTEM=native | raster | opengl

# swap usage by pid

# sqlite

# get url
wget -qO- http://foo/response
wget -qO- http://bar/api/json/response | python -m json.tool
wget -qO- http://bar/api/json/response | jq
wget -qO- http://bar/api/json/response | jq '.[] | select((.k_1 == 1) or (.k_2 == 2)) | "k1:\(.k_1) k2:\(.k_2)"'

# ssh/sshfs
sshfs -o reconnect -o auto_unmount 192.168.5.5:/mnt/data/usorted/ ~/sshfs/unsorted/

Wednesday, March 23, 2016

to remember

CLUSTERFUCK

Military term for an operation in which multiple things have gone wrong. Related to "SNAFU" (Situation Normal, All Fucked Up") and "FUBAR" (Fucked Up Beyond All Repair).

In radio communication or polite conversation (i.e. with a very senior officer with whom you have no prior experience) the term "clusterfuck" will often be replaced by the NATO phonetic acronym "Charlie Foxtrot."

Wednesday, January 13, 2016

Wonderful!

Bill Gates: “So, how’s heaven, Steve?”
Steve Jobs: “Great! It just doesn’t have any wall or fence.”
Bill Gates: “So…?”
Steve Jobs: “So, we don’t need any Windows and Gates. I’m sorry, Bill, I didn’t mean to offend you.”
Bill Gates: “It’s ok Steve, but I heard a rumor.”
Steve Jobs: “Oh, what rumor?”
Bill Gates: “That nobody is allowed to touch Apple there, and there are no Jobs in heaven.”
Steve Jobs : “Oh no, definitely there are, but only no–pay Jobs. Therefore definitely no Bill in heaven as everything will be provided free….”

Monday, October 5, 2015

How to chmod all directories except files (recursively)


find /path/to/base/dir -type d -print0 | xargs -0 chmod 755
find /path/to/base/dir -type f -print0 | xargs -0 chmod 644