FIreHAzaR:-D CRiB

This is not a blog. This is my diary.

Useful bash scripts

Tar

Drop all database tables

Save this code as "db-truncate.sh".

#!/bin/bash
mysqldump -u$1 -p$2 --add-drop-table --no-data $3 | grep -e '^DROP \| FOREIGN_KEY_CHECKS' | mysql -u$1 -p$2 $3

For database dump: db-dump.sh

#!/bin/bash
mysqldump -hHOST -uUSER -pPASS DATABASE --no-data > DATABASE.schema.sql
mysqldump -hHOST -uUSER -pPASS DATABASE --ignore-table=DATABASE.search_index --ignore-table=DATABASE.cache% --extended-insert=FALSE --no-create-info --add-drop-table --compress | split --line-bytes=20000000 - DATABASE.sql.
gzip DATABASE.sql.*

Show hidden files on console

If you need to copy directory including the hidden files, you need this.

  1. Set shopt dotglobe option to enable.

    shopt -s dotglob
  2. Copy hidden files and folder.

    cp -pr SOURCEDIR TARGETDIR
  3. Set shopt dotglobe option to disable.

    shopt -u dotglob

Source: labtestproject.com.

Disable touchpad (any input device actually)

I have a problem with my touchpad being too sensitive, there's a better way via syncdaemon, an app brought by synaptics package that will monitor keyboard input and disable touchpad temporarily. But I can't get my touchpad recognized by the kernel yet.

This is a quick solution.

  1. Install xinput.
  2. Show all input devices.

    xinput list
  3. Look for property number that mention "Device Enabled".

    xinput list-props DEVICEID
  4. Disable, set the property to 0.

    xinput set-prop DEVICEID PROPID 0

Source: Nico Schottelius' blog.

Useful bash aliases

Set them in your .bash_aliases file in home directory. If your system doesn't call this file, you need to add this code in your .bashrc file (in home directory).

source .bash_aliases

Source: