JavaScript 方法[1]

encodeURIComponent # 对连接进行escape



这篇文章: 有用 无用
创建 2016-12-14 09:25:27 / 更新 2018-04-20 04:49:17

Linux 关于系统的一些命令

# 查看系统开机时间
who -b /var/log/wtmp
who -b

# 查看进程树
ps axuwwf

# 查看进程运行的时间
ps -eo pid,etime,cmd

# 系统日志的查看

tail -f /var/log/{kern.log,dmesg,syslog}


dmesg -c # clear kernel ring buffer message to '/var/log/dmesg' file

dmesg -wH # since kernel 3.5.0 

watch -n 1 "dmesg | tail -n $((LINES - 6))"

# netstat - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
# -p Show the PID and name of the program to which each socket belongs.
# -a Show both listening and non-listening sockets. 
# -l Show only listening sockets. (These are omitted by default.)
# -n Show numerical addresses instead of trying to determine symbolic host, port or user names.
# --tcp|-t
# --udp|-u    
netstat -a -p | grep LISTEN

# 查找 process IDs
# pgrep
# -f The pattern is normally only matched against the process name.  When -f is set, the full command line is used.
pgrep -u root,www-data memcached
kill `pgrep memcached`
killall memcached

# find the process ID of a running program
# pidof
kill $(pidof memcached)

# diff
diff -u -d


这篇文章: 有用 无用
创建 2016-11-28 21:28:34 / 更新 2018-04-20 04:49:17

Linux 关于账户的一些命令

# 创建一个组
# groupadd 
groupadd dev

# addgroup
addgroup dev

# 创建一个用户
# useradd - create a new user or update default new user information
useradd -g dev -m -d /home/sxn -s /bin/bash sxn # 如果不指定-s的话,会默认使用/etc/default/useradd里面的SHELL设置

# adduser
adduser --ingroup dev --home /home/sxn --shell /bin/bash sxn # 如果不指定--shell的话,会默认使用/etc/adduser.conf里面的DSHELL设置

# 删除一个用户
userdel sxn
deluser sxn

# 查看用户信息
id - print real and effective user and group IDs  # id 

# 如何修改hostname
# 1) 临时修改主机名
sudo hostname $hostname

# 2) 永久修改主机名
sudo vi /etc/hostname # 打开/etc/hostname文件,将原有的主机名更换为现有的主机名
sudo vi /etc/hosts # 将 ip 地址对应的原有主机名修改为现有主机名


这篇文章: 有用 无用
创建 2016-11-28 21:21:25 / 更新 2018-04-20 04:49:17

MySQL 5.7 忘记root密码怎么解决

添加 skip-grant-tables 配置


重启 mysql server, 使用命令 service mysql restart

mysql -uroot # 使用 root 登录 mysql

update mysql.user set plugin = 'mysql_native_password', authentication_string = password('hello') where user = 'root'; # 把密码设置为hello

屏蔽 skip-grant-tables 配置

# skip-grant-tables

重启 mysql server


这篇文章: 有用 无用
创建 2016-11-28 19:22:35 / 更新 2018-04-20 04:49:17

MIME 和 Perl


Multipurpose Internet Mail Extensions(多用途的网际邮件扩充)

use Encode qw/encode decode/;
$utf8   = decode('MIME-Header', $header);
$header = encode('MIME-Header', $utf8);

This module implements RFC 2047 Mime Header Encoding. There are 3 variant encoding names; MIME-Header , MIME-B and MIME-Q . The difference is described below

            decode()          encode()
MIME-Header Both B and Q      =?UTF-8?B?....?=
MIME-B      B only; Q croaks  =?UTF-8?B?....?=
MIME-Q      Q only; B croaks  =?UTF-8?Q?....?=


use Encode;
use utf8;

my $plain_str = "我爱编程";
my $str = Encode::encode('MIME-Header', $plain_str);
print $str, "\n"; # =?UTF-8?B?5oiR54ix57yW56iL?=

$str = Encode::decode('MIME-Header', $str);
print $str, "\n"; # 我爱编程


use Encode;
use utf8;
use Encode::HanExtra; # 处理gb18030这种编码的, 如果不添加的话, 会报错: "Unknown encoding: gb18030"

my $str = "=?gb18030?B?1tyxqC3A7s6wo6gyMDE2LjEwLjE3o6k=?=";
$str = Encode::decode('MIME-Header', $str);
print $str, "\n";


这篇文章: 有用 无用
创建 2016-11-14 02:48:44 / 更新 2018-04-20 04:49:17