Skip to content

Instantly share code, notes, and snippets.

View filviu's full-sized avatar

Silviu Vulcan filviu

View GitHub Profile
@filviu
filviu / find-photos-duplicates.sh
Created August 18, 2014 08:39
Search and clean duplicate phosts (useful if switching to lightroom from digikam)
#!/bin/bash
# cleanup and revert to RAW only library after switching to lightroom after using digikam
# only prints results
PHOTOS_FOLDER="/home/photos"
while read RAWFILE; do
rawpath=$(dirname "$RAWFILE")
filename=$(basename "$RAWFILE")
extension="${filename##*.}"
filename="${filename%.*}"
@filviu
filviu / migrate-innodb.sh
Created August 18, 2014 08:40
Migrate innodb to myisam (low memory systems)
#!/bin/bash
mysql -B -N -e "SHOW DATABASES" | while read database;
do
mysql -B -N -e "SHOW TABLES" $database | while read table; \
do \
echo "+ Converting Table $table"; \
mysql -B -N -e "alter table $table engine=myisam" $database; \
done
@filviu
filviu / optimize-mysql.sh
Created August 18, 2014 08:41
Optimize all mysql tables
#!/bin/bash
mysqlcheck -Aao -auto-repair
@filviu
filviu / optimize_firefox.sh
Created August 18, 2014 08:41
Optimize firefox databases (or any other sqlite db)
#!/bin/bash
for file in ~/.mozilla/firefox/*/*.sqlite; do
sqlite3 $file 'VACUUM;'
done
@filviu
filviu / debug_record.sh
Created August 18, 2014 08:49
Simple script that collects some logs that can help in debugging server issues
#!/bin/bash
# output folder
OUT="/var/log/debug-logs"
# date format
DATE="date +%Y-%m-%d_%H:%M:%S"
# set the log file to "" and no logs will be recorded for that
APACHE_LOG="apache_status.log"
TOP_LOG="top_status.log"
PS_LOG="ps_status.log"
@filviu
filviu / n800-clone.sh
Created August 19, 2014 05:55
n800 sdcard boot
In short, this is what I did to get my N800 to boot OS2008 from MMC. My steps were:
1) upgraded my N800 to OS2008, http://europe.nokia.com/A4305010
2) enabled the Maemo Extras repository in Application Manager and added http://repository.maemo.org, Distribution: (blank) Components: free non-free
3) installed openssh using Application Manager
4) defined a root password (openssh's installer prompted for this)
5) opened xterm and:
# ssh root@localhost
# visudo
@filviu
filviu / screen-items.sh
Created August 19, 2014 05:58
script screen to create multiple windows
#!/bin/bash
screen -dmS servers -T xterm -t "http" sh -c 'cd /servers/start/httpo;run.sh'
screen -T xterm -S "servers" -X screen screen -t "sql" sh -c 'cd /servers/start/sql;run.sh'
# The "-T xterm" switch isn't really necessary, unless you plan to use curses-based programs from inside the screen (mc, less, etc.).
#!/bin/bash
count=0
for DISK in sda sdb sdc sdd sde sdf; do
/usr/sbin/smartctl --all /dev/$DISK > /var/www/htdocs/status/data/smart$count.txt
((count++))
done
@filviu
filviu / export-csv.sql
Created September 1, 2014 06:52
Export mysql data directly to csv from the command line. From http://www.tech-recipes.com/rx/1475/save-mysql-query-results-into-a-text-or-csv-file/
SELECT order_id,product_name,qty
FROM orders
INTO OUTFILE '/tmp/orders.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
@filviu
filviu / get-package-size.sh
Last active August 29, 2015 14:06
What packages use the most diskspace on Slackware
grep "UNCOMPRESSED PACKAGE SIZE" /var/log/packages/* | sed 's/ *//g' | awk -F: '{ print $3" " $1 }' | sort -rh | head -n10