drop function if exists rand_string; create function rand_string(str_length tinyint unsigned, str_type tinyint unsigned) returns varchar(255) begin -- Function : rand_string -- Author : reymondtu#opencfg.com -- Date : 2011/03/27 -- Params : str_length int unsigned -- The random string length of random string -- str_type int unsigned -- The random string type -- 1.0-9 -- 2.a-z -- 3.A-Z -- 4.a-zA-Z -- 5.0-9a-zA-Z -- -- Example : -- -- mysql> select rand_string(32,5) from dual; -- +----------------------------------+ -- | rand_string(32,5) | -- +----------------------------------+ -- | HbPBz4DWSAiJNLt4SgExHVwQI34bI6mt | -- +----------------------------------+ -- 1 row in set declare counter int unsigned default 0; declare const_chars varchar(64) default '0123456789'; declare result varchar(255) default ''; if str_type = 1 then set const_chars = '0123456789'; elseif str_type = 2 then set const_chars = 'abcdefghijklmnopqrstuvwxyz'; elseif str_type = 3 then set const_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; elseif str_type = 4 then set const_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; elseif str_type = 5 then set const_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; else set const_chars = '0123456789'; end if; while counter < str_length do set result = concat(result,substr(const_chars,ceil(rand()*(length(const_chars)-1)),1)); set counter = counter + 1; end while; return result; end
分类目录归档:Uncategorized
Fedora 20安装Fcitx输入法并安装搜狗资源包
原文链接:http://yanue.net/post-140.html
1、先卸载系统自带的Ibus输入法
sudo yum remove ibus
gsettings set org.gnome.settings-daemon.plugins.keyboard active false
2、安装Fcitx输入法
yum install fcitx fcitx-devel fcitx-configtool fcitx-cloudpinyin fcitx-pinyin
3、配置一下Fcitx、在~/.bashrc中添加:如下内容
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"
4、注销或重启后完成安装
上面步骤完成之后其实就可以使用Fcitx输入法
不过看到搜狗输入法都已经出deb包了
所以就想着安装个搜狗输入法到Fcitx上去。
5、安装搜狗资源包
从下面的连接地址下载对应的deb包、32位系统用i386.deb、64位系统用amd64.deb
http://mirrors.ustc.edu.cn/deepin/pool/non-free/f/fcitx-sogoupinyin-release/
随便在从如下地址下载一个搜狗输入法的皮肤
http://mirrors.ustc.edu.cn/deepin/pool/main/f/fcitx-skins/
6、下载完成之后双击打开amd64.deb、将里面的data.tar.bz提取出来、然后到解压压缩文件
接着我们把解压出来的.so文件移动到Fcitx的指定目录即可(64位为例)
cp /usr/lib/x86_64-linux-gnu/fcitx/fcitx-sogoupinyin.so /usr/lib64/fcitx/
最后加上执行权限
chmod +x /usr/lib64/fcitx/fcitx-sogoupinyin.so
mysql批量导入导出
备份数据库到脚本(20分钟)
mysqldump -u username -p password --all-databases --flush-privileges | gzip > all.sql.gz
拷贝到新机器(20分钟)
scp -P xxx -r all.sql.gz root@host:~
解压缩(2分钟)
gunzip all.sql.gz
解决掉视图权限问题(1分钟)
sed '/\/*!50013/d' all.sql > all_without_50013.sql
导入(40分钟)
mysql -u username -p password < all_without_50013.sql
wordpress屏蔽fonts.googleapis.com
最近wordpress打开慢,发现一直连接在fonts.googleapis.com。
搜索后发现可以安装插件解决 http://wordpress.org/plugins/disable-google-fonts/
- 点击后台插件,搜索Disable Google Fonts
- 点击安装
- 启用插件
ubuntu安装php的redis扩展
下载安装扩展
首先下载包,http://pecl.php.net/package/redis
sudo aptitude install php5-dev sudo wget http://pecl.php.net/get/redis-2.2.5.tgz sudo tar zxf redis-2.2.5.tgz cd redis-2.2.5/ sudo phpize sudo ./configure sudo make sudo make install
修改ini配置
sudo vim /etc/php5/fpm/conf.d/redis.ini
extension=redis.so
测试运行
sudo php5-fpm -t sudo php5-fpm -m sudo service php5-fpm reload