test @ monster 12:17 > lock tables tbl1 write; Query OK, 0 rows affected (0.00 sec) test @ monster 12:18 > drop trigger birth_update_trig; ERROR 2013 (HY000): Lost connection to MySQL server during query test @ monster 12:20 >
test @ monster 12:20 > show processlist; +------+--------+-----------------+------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +------+--------+-----------------+------+---------+------+-------+------------------+ | 1348 | larryd | localhost:54746 | test | Sleep | 27 | | NULL | | 1349 | larryd | localhost:54747 | test | Query | 0 | NULL | show processlist | +------+--------+-----------------+------+---------+------+-------+------------------+ 2 rows in set (0.01 sec) test @ monster 12:20 > kill 1348; Query OK, 0 rows affected (0.00 sec) test @ monster 12:20 >
CREATE TABLE if not exists `tbl1` ( `name` varchar(64) NOT NULL default '', `birth_year` smallint(4) unsigned NOT NULL default '0', `birth_month` tinyint(2) unsigned ZEROFILL NOT NULL default '0', `birth_day` tinyint(2) unsigned ZEROFILL NOT NULL default '0', `birth_date` date NOT NULL default '0000-00-00' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; DELIMITER | CREATE TRIGGER birth_update_trig BEFORE UPDATE ON tbl1 FOR EACH ROW BEGIN SET NEW.birth_date = IF(NEW.birth_date != OLD.birth_date, NEW.birth_date, CONCAT(LPAD(NEW.birth_year, 4, '0'), '-', LPAD(NEW.birth_month, 2, '0'), '-', LPAD(NEW.birth_day, 2, '0'))); SET NEW.birth_day = IF(NEW.birth_day != OLD.birth_day, NEW.birth_day, DAY(NEW.birth_date)); SET NEW.birth_month = IF(NEW.birth_month != OLD.birth_month, NEW.birth_month, MONTH(NEW.birth_date)); SET NEW.birth_year = IF(NEW.birth_year != OLD.birth_year, NEW.birth_year, YEAR(NEW.birth_date)); END; | CREATE TRIGGER birth_insert_trig BEFORE INSERT ON tbl1 FOR EACH ROW BEGIN SET NEW.birth_date = IF(NEW.birth_date != '0000-00-00', NEW.birth_date, CONCAT(LPAD(NEW.birth_year, 4, '0'), '-', LPAD(NEW.birth_month, 2, '0'), '-', LPAD(NEW.birth_day, 2, '0'))); SET NEW.birth_day = IF(NEW.birth_day != 0, NEW.birth_day, DAY(NEW.birth_date)); SET NEW.birth_month = IF(NEW.birth_month != 0, NEW.birth_month, MONTH(NEW.birth_date)); SET NEW.birth_year = IF(NEW.birth_year != 0, NEW.birth_year, YEAR(NEW.birth_date)); END; | DELIMITER ;
#!/bin/bash USERNAME=$1 BASEPATH="/storage/Games/NDS/${USERNAME}/" LOGFILE="${BASEPATH}/sync.log" SAVESPATH="Saves" GAMESPATH="Games" MUSICPATH="Music" PHOTOPATH="Photo" VIDEOPATH="Video" DEVICE="/dev/${USERNAME}_nds" MOUNTPATH="${BASEPATH}/mount/" function main() { # Do some sanity checks CheckSanity # Mount the drive MountDrive # Sync the saves SyncSaves # Sync the media SyncPath ${GAMESPATH} SyncPath ${MUSICPATH} SyncPath ${PHOTOPATH} SyncPath ${VIDEOPATH} # Unmount the drive UnmountDrive log "----- Finished Successfully -----" exit 0 } function log() { echo "$@" >> ${LOGFILE} } function die() { log `id` log "$@" if [ "${MOUNTED}" == "1" ]; then UnmountDrive fi log "----- Finished With Error -----" exit 1 } function CheckSanity() { [ "${USERNAME}" != "" ] || die "Empty username passed in" [ -d ${BASEPATH} ] || die "Invalid base dir [ ${BASEPATH} ]" # Verify mount path exists [ -d ${MOUNTPATH} ] || mkdir -p ${MOUNTPATH} 2>/dev/null [ -d ${MOUNTPATH} ] || die "Unable to create mount path [ ${MOUNTPATH} ]" } function MountDrive() { log "Mounting drive..." mount ${DEVICE} ${MOUNTPATH} || die "Unable to mount device [ ${DEVICE} ] to mountpath [ ${MOUNTPATH} ]" log "done." } function UnmountDrive() { log "Unmounting drive..." umount ${MOUNTPATH} || die "Unable to unmount [ ${MOUNTPATH} ]" log "done." } function SyncSaves() { if [ "${SAVESPATH}" == "" ]; then log "Skipping [ Saves ]... SLAVESPATH is not defined!" return fi if [ "${GAMESPATH}" == "" ]; then log "Skipping [ ${SAVESPATH} ]... GAMESPATH is not defined!" return fi SAVECOUNT=`ls -al ${MOUNTPATH}/${GAMESPATH}/*.SAV 2>/dev/null |wc -l` if [ ${SAVECOUNT} -lt 1 ]; then log "Skipping [ ${SAVESPATH} ]... No saves found on card" return fi NOWSAVESPATH="${BASEPATH}/${SAVESPATH}/`date +%Y-%m-%d:%H:%M:%S`/" mkdir -p ${NOWSAVESPATH} 2>/dev/null if [ ! -d ${NOWSAVESPATH} ]; then log "Unable to create new saves dir [ ${NOWSAVESPATH} ]" return fi rsync ${MOUNTPATH}/${GAMESPATH}/*.SAV ${NOWSAVESPATH} >> ${LOGFILE} 2>&1 if [ "$?" == "0" ]; then log "Successfully backed up ${SAVECOUNT} save(s) to [ ${NOWSAVESPATH} ]" else log "Failure while backing up savegames to [ ${NOWSAVESPATH} ]" fi # Set permissions if id ${USERNAME} >/dev/null 2>&1; then chown -R ${USERNAME} ${NOWSAVESPATH} || log "Unable to chown save games [ ${NOWSAVESPATH} to [ ${USERNAME} ]" fi } function SyncPath() { TYPENAME="$1" if [ "${TYPENAME}" == "" ]; then log "Empty Typename" return fi MYPATH="${BASEPATH}/${TYPENAME}/" if [ ! -d ${MYPATH} ]; then log "Skipping [ ${TYPENAME} ]... Source directory not found" return fi log "" log "\\/ \\/ \\/ Syncing [ ${TYPENAME} ] \\/ \\/ \\/" log "" rsync -r -v --ignore-existing --delete-before --exclude=*.SAV --exclude=*.sav ${MYPATH} ${MOUNTPATH}/${TYPENAME}/ >> ${LOGFILE} 2>&1 log "" log "/\\ /\\ /\\ Finished Syncing [ ${TYPENAME} ] /\\ /\\ /\\" log "" } main
root@monster:~# lsusb >d1 root@monster:~# # insert card reader root@monster:~# lsusb >d2 root@monster:~# diff d1 d2 5a6 > Bus 001 Device 049: ID 05e3:0715 Genesys Logic, Inc. root@monster:~#
root@monster:~# cat /etc/udev/rules.d/85-nds.rules # ACTION - Match when plugging in card reader # KERNEL - Pattern that your card reader gets mounted as (/dev/sdb1) # SYSFS{idVendor} - VendorId of your card reader (get with lsusb) # SYSFS{idProduct} - ProductId of your card reader (get with lsusb) # SYMLINK - Create a symlink to /dev/username_nds (script expects this) # RUN - Location of script (make sure to pass in the username) ACTION=="add", KERNEL=="sd*1", SYSFS{idVendor}=="0781", SYSFS{idProduct}=="a7a8", SYMLINK+="wife_nds", RUN+="/usr/local/bin/nds_mount_hook.sh wife" ACTION=="add", KERNEL=="sd*1", SYSFS{idVendor}=="05e3", SYSFS{idProduct}=="0715", SYMLINK+="shizno_nds", RUN+="/usr/local/bin/nds_mount_hook.sh shizno" root@monster:~#
diff -q <(df /path/to/file1) <(df /path/to/file2)
test@localhost> select * from foo; +------+--------------------------+ | Id | bar | +------+--------------------------+ | 9 | test test test | | 9 | test test test | | 3 | foo bar | | 99 | yoo zoo | | 5 | yikes | | 5555 | this is a test from code | | 5555 | this is a test from code | +------+--------------------------+ 7 rows in set (0.00 sec)
test@localhost> pager grep 'oo' PAGER set to 'grep 'oo'' test@localhost> select * from foo; | 3 | foo bar | | 99 | yoo zoo | 7 rows in set (0.00 sec)
pagination: pager less edit result: pager vim - pastebin: pager pastebinit save to file: pager cat >filename
#!/bin/bash BOLDSTART=`echo -e "\e[1m"` BOLDEND=`echo -e "\e[m"` COLORSTART=`echo -e "\033["` HILITESTART=`echo -e "\033[30m"` HILITEEND=`echo -e "\033[39m\033[22m"` COL="| [^|]* " sed "s/^\(| \)\([^|]*\) |/\1${BOLDSTART}${COLORSTART}31m\2${HILITEEND}${BOLDEND} |/g" | sed "s/^\(${COL}| \)\([^|]*\) |/\1${BOLDSTART}${COLORSTART}32m\2${HILITEEND}${BOLDEND} |/g" | sed "s/^\(${COL}${COL}| \)\([^|]*\) |/\1${BOLDSTART}${COLORSTART}33m\2${HILITEEND}${BOLDEND} |/g" | sed "s/^\(${COL}${COL}${COL}| \)\([^|]*\) |/\1${BOLDSTART}${COLORSTART}34m\2${HILITEEND}${BOLDEND} |/g" | sed "s/^\(${COL}${COL}${COL}${COL}| \)\([^|]*\) |/\1${BOLDSTART}${COLORSTART}35m\2${HILITEEND}${BOLDEND} |/g" | sed "s/^\(${COL}${COL}${COL}${COL}${COL}| \)\([^|]*\) |/\1${BOLDSTART}${COLORSTART}36m\2${HILITEEND}${BOLDEND} |/g" | sed "s/^\(${COL}${COL}${COL}${COL}${COL}${COL}| \)\([^|]*\) |/\1${BOLDSTART}${COLORSTART}37m\2${HILITEEND}${BOLDEND} |/g" | sed "s/^\(${COL}${COL}${COL}${COL}${COL}${COL}${COL}| \)\([^|]*\) |/\1${COLORSTART}31m\2${HILITEEND} |/g" | sed "s/^\(${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}| \)\([^|]*\) |/\1${COLORSTART}32m\2${HILITEEND} |/g" | sed "s/^\(${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}| \)\([^|]*\) |/\1${COLORSTART}33m\2${HILITEEND} |/g" | sed "s/^\(${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}| \)\([^|]*\) |/\1${COLORSTART}34m\2${HILITEEND} |/g" | sed "s/^\(${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}| \)\([^|]*\) |/\1${COLORSTART}35m\2${HILITEEND} |/g" | sed "s/^\(${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}| \)\([^|]*\) |/\1${COLORSTART}36m\2${HILITEEND} |/g" | sed "s/^\(${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}${COL}| \)\([^|]*\) |/\1${COLORSTART}37m\2${HILITEEND} |/g"
[mysql] pager = /path/to/sqlhilite.sh
test@localhost> show create table old\G *************************** 1. row *************************** Table: old Create Table: CREATE TABLE `old` ( `Id` int(11) NOT NULL auto_increment, `bar` varchar(16) NOT NULL, PRIMARY KEY (`Id`), KEY `barIdx` (`bar`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8
test@localhost> create table new select * from old;
test@localhost> show create table new\G *************************** 1. row *************************** Table: new Create Table: CREATE TABLE `new` ( `Id` int(11) NOT NULL default '0', `bar` varchar(16) character set utf8 NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1
CREATE TABLE new LIKE old; INSERT INTO new SELECT * FROM foo;
test@localhost> show create table new\G *************************** 1. row *************************** Table: new Create Table: CREATE TABLE `new` ( `Id` int(11) NOT NULL auto_increment, `bar` varchar(16) NOT NULL, PRIMARY KEY (`Id`), KEY `barIdx` (`bar`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8
test@localhost> show variables like 'version'; +---------------+----------------------------+ | Variable_name | Value | +---------------+----------------------------+ | version | 5.0.38-Ubuntu_0ubuntu1-log | +---------------+----------------------------+
<link rel="alternate" type="application/rss+xml" title="ldamman.com - MMS Photos" href="/?a=mmsphoto&out=rss" />
shizno@monster:~$ nsupdate -k /path/to/funkykeyfile.key > update add shizno.com 86400 A 83.99.122.23 > update add www.shizno.com 86400 A 83.99.122.23 > update add shizno.com 86400 MX 10 shizno.com > send shizno@monster:~$ dig @ns.linuxrocket.net shizno.com AXFR -k /path/to/funkykeyfile.private