Skip to content

Instantly share code, notes, and snippets.

@ant-hill
ant-hill / function or not
Created August 15, 2017 19:00
function or not hasckerrank
import Control.Monad
import Data.List (sortBy)
sortGT (a1, b1) (a2, b2)
| a1 < a2 = GT
| a1 > a2 = LT
| a1 == a2 = compare b1 b2
compare' :: [(Int, Int)] -> Bool
compare' [(x,y)] = True
#source http://stackoverflow.com/a/948364
get_git_branch() {
echo `git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
}
alias gpull='git pull origin `get_git_branch`'
alias gpush='git push origin `get_git_branch`'
git ls-remote --tags origin | awk '/^(.*)(s+)(.*[a-zA-Z0-9])$/ {print ":" $2}' | xargs git push origin
// from http://www.alwaystwisted.com/articles/deleting-git-tags-locally-and-on-github
#http://lzone.de/cheat-sheet/ulimit
lsof -n 2>/dev/null | awk '{print $1 " (PID " $2 ")"}' | sort | uniq -c | sort -nr | head -25
# or
lsof -n 2>/dev/null | awk '{print $1,$2}' | sort | uniq -c | sort -nr | head -25 | while read nr name pid ; do printf "%10d / %-10d %-15s (PID %5s)\n" $nr $(cat /proc/$pid/limits | grep 'open files' | awk '{print $5}') $name $pid; done
# https://www.reddit.com/r/linux/comments/2p9igm/how_does_one_investigate_potential_ulimit_issues/cmumf2j
for USER in `ps -ef | egrep -v '^UID' | awk '{ print $1 }' | sort -u`; do echo -n "$USER: "; ps -u $USER -L | wc -l; done | sort -rn -k2