Rails command-line tricks

Kill all screen sessions

screen -ls | grep pts | cut -d. -f1 | awk '{print $1}' | xargs kill  

Kill all running Sidekiqs

ps aux | grep '[s]idekiq.*busy]' | awk '{print $2}' | xargs kill -9  

Remove binary characters from a .csv file

Ruby's CSV parser fails to read files containing non utf-8 characters.

brew install iconv dos2unix  
iconv -f utf-8 -t utf-8 -s -c file.csv | dos2unix -q > file.csv.export && mv file.csv.export file.csv  
Find binary characters in Vim


Remove binary characters in Vim

:%s/\%xYY/substitute/g where YY is a binary code of the character