|
|
|
Saturday, 22 October 2011 01:48 |
// To make it work with strings long than 128 characters, change its input and return declarations accordingly.
DROP FUNCTION IF EXISTS proper;
SET GLOBAL log_bin_trust_function_creators=TRUE;
DELIMITER |
CREATE FUNCTION proper( str VARCHAR(128) )
RETURNS VARCHAR(128)
BEGIN
DECLARE c CHAR(1);
DECLARE s VARCHAR(128);
DECLARE i INT DEFAULT 1;
DECLARE bool INT DEFAULT 1;
DECLARE punct CHAR(17) DEFAULT ' ()[]{},.-_!@;:?/';
SET s = LCASE( str );
WHILE i < LENGTH( str ) DO
BEGIN
SET c = SUBSTRING( s, i, 1 );
IF LOCATE( c, punct ) > 0 THEN
SET bool = 1;
ELSEIF bool=1 THEN
BEGIN
IF c >= 'a' AND c <= 'z' THEN
BEGIN
SET s = CONCAT(LEFT(s,i-1),UCASE(c),SUBSTRING(s,i+1));
SET bool = 0;
END;
ELSEIF c >= '0' AND c <= '9' THEN
SET bool = 0;
END IF;
END;
END IF;
SET i = i+1;
END;
END WHILE;
RETURN s;
END;
|
DELIMITER ;
 Read more: |
|
|
Saturday, 22 October 2011 01:47 |
// If you have 2 servers with identical database structure, and some of the tables have different engine type, then create a federated table to connect to the original server and compare the engines type with the current table's engine. (useful while comparing master - slave tables)
CREATE TABLE test.`TABLES2` (
`TABLE_CATALOG` varchar(512) default NULL,
`TABLE_SCHEMA` varchar(64) NOT NULL default '',
`TABLE_NAME` varchar(64) NOT NULL default '',
`TABLE_TYPE` varchar(64) NOT NULL default '',
`ENGINE` varchar(64) default NULL,
`VERSION` bigint(21) default NULL,
`ROW_FORMAT` varchar(10) default NULL,
`TABLE_ROWS` bigint(21) default NULL,
`AVG_ROW_LENGTH` bigint(21) default NULL,
`DATA_LENGTH` bigint(21) default NULL,
`MAX_DATA_LENGTH` bigint(21) default NULL,
`INDEX_LENGTH` bigint(21) default NULL,
`DATA_FREE` bigint(21) default NULL,
`AUTO_INCREMENT` bigint(21) default NULL,
`CREATE_TIME` datetime default NULL,
`UPDATE_TIME` datetime default NULL,
`CHECK_TIME` datetime default NULL,
`TABLE_COLLATION` varchar(64) default NULL,
`CHECKSUM` bigint(21) default NULL,
`CREATE_OPTIONS` varchar(255) default NULL,
`TABLE_COMMENT` varchar(80) NOT NULL default ''
)
ENGINE=FEDERATED DEFAULT CHARSET=latin1
CONNECTION='mysql://
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
/information_schema/TABLES';
SELECT b.TABLE_SCHEMA as remote_database, b.TABLE_NAME as remote_tableName, b.ENGINE as remote_engine, a.ENGINE AS local_engine
FROM test.TABLES2 AS a INNER JOIN information_schema.TABLES as b
ON a.TABLE_SCHEMA = b.TABLE_SCHEMA AND a.TABLE_NAME = b.TABLE_NAME AND a.ENGINE != b.ENGINE;
 Read more: |
|
Monday, 21 February 2011 10:43 |
|
How To Install Railo 3.2 Under OpenSUSE 11.3 Running Apache2 Tomcat 6
Virtual Host
Railo Server 3.2 Final (3.2.1.000) has been released. As you know
Railo is an Open Source ColdFusion Markup Language (CFML) engine. It is
free and pretty fast. For the new 3.2 version railo stop running resin, but tomcat as the
default web server. Instead of compile apache2 with tomcat 6 by
yourself, the railo team had created the default installation script
which help you setup railo on tomcat6 and using apache2 to connect to
tomcat via mod_jk. Instead of using tomcat default webapps directory, we will modify the
server.xml file and DocumentRoot will point back to default apache
DocumentRoot directory defined under the virtual host configuration
file. Read more: |
|
|
Wednesday, 04 August 2010 09:11 |
// description of your code here
#!/bin/sh
#
# Dies ist ein einfaches BackupScript welches
# Datenbanken und Ordner synchronisiert und
# das mittels SSH (AuthKey) und rsync.
#
# Name: SSHBackup
# Version: 1.2 (02.08.2010)
# Copyright: 2008-2010 by sp3x, www.sp3x.de
# _____
# ___ _ __|___ /_ __
# / __| '_ \ |_ \ \/ /
# \__ \ |_) |__) > <
# |___/ .__/____/_/\_\
# (c)|_| www.sp3x.de
#
#################
# KONFIGURATION #
#################
#
# Workingdir
#
WDIR="/root/backup/"
#
# Database-Backup History in Days
#
HISTORY=7
#
# Remote IP
#
HOST="localhost"
#
# MySQL-Datenbanken sichern?
# 1 = ja, 0 = nein
#
MYSQL=1
#
# Dateien sichern?
# 1 = ja, 0 = nein
#
FILESYSTEM=1
#
# MySQL-Datenbank Benutzer
#
MYSQL_USR="root"
#
# MySQL-Datenbank Password
#
MYSQL_PWD=""
#
# MySQL-Port
#
MYSQL_PORT=3306
#
# SSH-Port
#
SSH_PORT=9990
#
# SSH-Auth Key (default: ssh/key)
#
SSH_KEY="ssh/key"
#
# SSH-User (default: root)
#
SSH_USER="root"
#
# Maximale Geschwindigkeit in KByte/s
#
SPEED=99999
######################
# KONFIGURATION ENDE #
#####################Ã#
# Text formatiert in Konsole ausgeben
function cout() {
if [ "$2" = "" ]; then
MSG=$1
else
MSG="\033\13301;$2m$1\033\1330m"
fi
if [ "$3" = "1" ]; then
MSG="$MSG\a"
fi
echo -e -n "$MSG"
}
# Commando remote ausfuehren
function scmd() {
ssh -q $HOST -p$SSH_PORT -l$SSH_USER -i $SSH_KEY $1 $2 $3 $4 $5 $6 $7 $8 $9
}
#################################
# Backupvorgang vorbereiten
# und starten
cout "\n\tStarting backup... "
cd $WDIR
set $(date)
DATE=`date "+%Y-%m-%d_%H-%M"`
let deathline=`date "+%Y%m%d"`-$HISTORY+1
deathline=$deathline"0000"
#################################
# Alte Backups löschen
#
for dir in `ls ./DATABASE/`; do
cleandir=`echo $dir |sed s/_// |sed s/-// |sed s/-// |sed s/-//`
if [ $cleandir -lt $deathline ]; then
rm -Rf ./DATABASE/$dir
fi
done
#################################
# MYSQL - Backup
if [ "$MYSQL" = "1" ]; then
cout "\n\n\t\tStarting MySQL backup... "
# Backupscript erstellen
SCRIPT=`cat tpl/mysql`
sed -e "s/{MYSQL_USR}/$MYSQL_USR/" tpl/mysql > tmp.1
sed -e "s/{MYSQL_PWD}/$MYSQL_PWD/" tmp.1 > tmp.2
sed -e "s/{MYSQL_PORT}/$MYSQL_PORT/" tmp.2 > tmp.3
chmod +x tmp.3
scmd rm ~/tmp.dbbackup.sh 2> /dev/null
scp -P$SSH_PORT -i $SSH_KEY tmp.3 $SSH_USER@$HOST:~/tmp.dbbackup.sh 1> /dev/null
rm tmp.*
# Datenbank backup
scmd ~/tmp.dbbackup.sh
# Datenbankbackups synchronisieren
rsync -a -z -e "ssh -q -i$SSH_KEY -p$SSH_PORT" --bwlimit=$SPEED --stats "$SSH_USER@$HOST:/root/tmp.database/" ./DATABASE/ > log/${DATE}_database.log
# Datenbankordner loeoeschen
scmd rm -R ~/tmp.database
cout "\tDone" 32
fi
#################################
# FILESYSTEM - Backup
if [ "$FILESYSTEM" = "1" ]; then
cout "\n\t\tStarting Files backup... "
for x in `cat rpath.conf`; do
IFS=":"
data=($x)
mkdir FILE/${data[1]} 2> /dev/null
rsync -a -z -e "ssh -i$SSH_KEY -p9990" --bwlimit=$SPEED --stats --delete "$SSH_USER@$HOST:${data[0]}/" FILE/${data[1]}/ > log/${DATE}_file.log
done;
cout "\tDone" 32
fi
cout "\n\n\n\tFinished backup!\n\n" 32
 Read more: |
|
Monday, 12 July 2010 15:01 |
Send Text-to-speech voice (phone call) via www.smsmatrix.com Gateway
See SMS Gateway page for details.
use LWP::UserAgent;
use HTTP::Request::Common;
my $ua = LWP::UserAgent->new();
my $res = $ua->request
(
POST 'http://www.smsmatrix.com/matrix_tts',
Content_Type => 'application/x-www-form-urlencoded',
Content => [ 'username' => '
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
',
'password' => 'password',
'phone' => '12506063167',
'repeat' => 1, ## Optional (default is 0)
'gender' => 'male', ## Optional, 'female' is default
'language' => 'us', ## Optional ('us' or 'es', 'us' is default)
'response' => 0, ## Optional, set to 1 if recipient's response needed
'txt' => 'Adam, web server is down' ]
);
if ($res->is_error) { die "HTTP Error\n"; }
print "Matrix API Response: " . $res->content . "\n\n";
 Read more: |
|
|
|
|
|
|
|