Full Mysql database backup

mysqldump --opt -u root -p pass --all-databases > backup.sql
Posted in mySQL | Leave a comment

CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.

public void onClick(View arg0) {
    new AsyncTask<Object, Object, Object>() {
        @Override
        protected Object doInBackground(Object... params) {
            executeThread();
            return null;
        }
 
        @Override
        protected void onPostExecute(Object result) {
            doAfterExecution();
            super.onPostExecute(result);
        }
 
    }.execute();
}
Posted in Android | Leave a comment

Show contents of a tar

$ tar -ztvf data.tar.gz
Posted in Linux | Leave a comment

Create bootable disk backup with dd | Move system to another hard disk

dd if=/dev/hda of=/dev/hdb
 
tune2fs /dev/hdbX -U UUIDOFhdaX
Posted in Linux | Leave a comment

Device is busy – which process is accessing a device?

lsof /dev/sd**
Posted in Linux | Leave a comment

Mount encrypted software raid

mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1
cryptsetup luksOpen /dev/md0 encrypted
mount /dev/mapper/encrypted /mnt
Posted in Linux | Leave a comment

mount a folder on another system via ssh

sshfs login@server:/mount/this /at/this/location
Posted in Linux | Leave a comment

Backups / exclude directories from being archived

DATUM=`date +%Y-%m-%d`
tar -cf ~/Desktop/backup_$DATUM.tar ~ -X backup_exclude.lst
Posted in Linux | Leave a comment

Display free space on hard disks

df -hT
Posted in Linux | Leave a comment

Regular expressions for checking user input (taken from oscommerce) (mail, domain, ip)

1
2
3
4
5
6
7
8
$mail_pat = '^(.+)@(.+)$';
$valid_chars = "[^] \(\)<>@,;:\.\\\"\[]";
$atom = "$valid_chars+";
$quoted_user='(\"[^\"]*\")';
$word = "($atom|$quoted_user)";
$user_pat = "^$word(\.$word)*$";
$ip_domain_pat='^\[([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\]$';
$domain_pat = "^$atom(\.$atom)*$";
Posted in PHP | Leave a comment