Skip to content

Instantly share code, notes, and snippets.

@rohannog
rohannog / install-deb.sh
Created March 27, 2013 09:04
Installing deb packages on Fedora
ar vx your-package.deb data.tar.gz
sudo tar xzvf data.tar.gz -C /
@rohannog
rohannog / gist:3861442
Last active December 15, 2017 23:18
Decrypt pdf on command-line
qpdf --password=passwd --decrypt orig.pdf decrypted.pdf
#To input the password
read -s -p "Password: " password && qpdf --password=$password --decrypt orig.pdf decrypted.pdf
@rohannog
rohannog / group.awk
Created July 2, 2012 13:07
awk group by calculation
NR!=1 {a[$NF]++; total++;}
END {
for (i in a)
printf("Field %2d: %3d (%3.2f\%)\n", i, a[i], a[i]/total*100);
printf ("Total: %d\n", total)
}
@rohannog
rohannog / gist:2964218
Created June 21, 2012 06:29
MyISAM table repair
myisamchk -rq --sort_buffer_size=512M --tmpdir=/home/fubar/tmp/ /var/mysql/data/database/table.MYI
@rohannog
rohannog / gist:1815881
Created February 13, 2012 10:36
mysqldump with the AUTO_INCREMENT values removed
mysqldump -u root <DB-name-here> -d --skip-add-drop-database --skip-add-drop-table | sed -e 's/AUTO_INCREMENT=[[:digit:]]* //' > <sql-output-file.sql>
@rohannog
rohannog / emacs-bkup-clean.sh
Created November 5, 2011 21:37
Remove emacs backup files if newer versions exist
for i in `find . -name "*~"`; do orig=`echo $i | sed -e s/~$//`; if [[ -f $orig && $orig -nt $i ]]; then rm $i; fi; done
@rohannog
rohannog / backup-command.sh
Created September 10, 2011 20:38
Backup list of files to a backup directory
for i in `cat <dir-and-file-list>`; do rsync -av $i <dest-dir>; done
@rohannog
rohannog / get-debs.sh
Last active September 26, 2015 20:08
Get list of deb files to be downloaded
sudo apt-get -qqy --print-uris <upgrade | install pkgname> | awk -F "'" '{print $2}' >> deb-list.txt
wget -bc -i deb-list.txt
@rohannog
rohannog / domain-grp.sql
Created August 11, 2011 09:03
Grouping by domains in MySQL
SELECT
SUBSTRING( REPLACE( REPLACE( URL, 'https://', ''), 'http://', ''), 1, LOCATE('/', REPLACE(REPLACE(URL, 'https://', ''), 'http://', '')) - 1) as domain,
COUNT(*)
FROM urlData
GROUP BY domain