MIME 和 Perl

Encode::MIME::Header

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";

Perl

这篇文章: 有用 无用
创建 2016-11-14 02:48:44 / 更新 2016-11-14 04:05:47

MySQL utf8mb4

my.cnf

[client]
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
collation-server = utf8mb4_unicode_ci
init-connect='SET NAMES utf8mb4'
character_set_server = utf8mb4

如果是设置成utf8的话

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8

如果你的数据表不是utf8mb4,那么我们应该如何存储utf8mb4的字符呢?

你可以 uri_escape 后再存储,用的时候 uri_unescape


MySQL

这篇文章: 有用 无用
创建 2016-11-08 07:23:39 / 更新 2017-02-03 14:34:20

硬盘的挂载

什么是 sda sdb

/dev/sda 表示第一块硬盘

/dev/sda1 表示第一块硬盘的第一个分区

/dev/sda2 表示第一块硬盘的第二个分区

/dev/sdb 表示第二块硬盘

怎样查看硬盘

sudo fdisk -l

怎样查看已经挂载的硬盘

df -h    
mount
nfsstat -m
cat /etc/mtab
cat /etc/fstab

怎样挂载硬盘

# -o 如果有多个参数,用","隔开
mount -a # 依照配置文件 /etc/fstab 的数据将所有的未挂载的磁盘都挂载上来
mount /dev/sdc2 /mnt/sdc2 # 挂载Ext2/Ext3文件系统
mount -t vfat -o iocharset=cp950 /dev/sdb1 /mnt/flash  # 挂载U盘

怎样将设备文件卸载

unmount [-fn] 挂载点 
-f 强制卸载 
-n 不更新 /etc/mtab 的情况下卸载    

unmount /mnt/flash

文件系统 NFS

Network File System

挂载上了,但是 df -h 看不到

挂载的时候需要添加 -o nfsvers=2 或者 -o vers=2

nfsvers=2 or nfsvers=3 — Specifies which version of the NFS protocol to use. This is useful for hosts that run multiple NFS servers. If no version is specified, NFS uses the highest supported version by the kernel and mount command. This option is not supported with NFSv4 and should not be used.

Liunx

这篇文章: 有用 无用
创建 2016-10-31 00:58:22 / 更新 2016-11-25 03:55:25

JavaScript DOM 学习[2]

document.title
document.baseURI    
document.URL
document.documentURI
document.referrer
document.domain

document.body                  # Returns the <body> element
document.documentElement           # Returns the <html> element
document.cookie

document.scripts                   # Returns all <script> elements
document.forms
document.links                     # Returns all <area> and <a> elements that have a href attribute

JavaScript

这篇文章: 有用 无用
创建 2016-10-27 06:37:49 / 更新 2016-10-27 06:40:34

JavaScript DOM 学习[1]

http://www.w3schools.com/js/js_htmldom.asp

# DOM(Document Object Model)

# The document object represents your web page.

# If you want to access any element in an HTML page, you always start with accessing the document object.

# The innerHTML property can be used to get or change any HTML element, including <html> and <body>.

# document.getElementById(id)
# document.getElementsByTagName(name)
# document.getElementsByClassName(name)

# element.innerHTML =  new html content
# element.attribute = new value
# element.setAttribute(attribute, value)
# element.style = new style

<html>
<body>

<p id="demo">Hi</p>

<script>
alert(document.getElementById("demo").innerHTML);
document.getElementById("demo").innerHTML = "Hello World!";
</script>

</body>
</html>

JavaScript

这篇文章: 有用 无用
创建 2016-10-26 22:01:56 / 更新 2017-02-07 14:58:21