Rails command-line tricks

Kill all screen sessions

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

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

/[^\d0-\d127]

Remove binary characters in Vim

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