2013年11月

在Ubuntu中一些经常使用的参数操作方法,脚本环境为 sh / bash

#最后一个守护进程pid
echo " last daemon process id : $! "

#exit退出状态
echo " exit status : $? "

#当前脚本进程
echo " process id of this script : $$ "

#脚本名
echo " script name : `basename $0` "

#第一个参数
echo " first param : $1 "

#所有参数
echo " all params : $* "

#所有参数
echo " all params : '$@' "

#参数长度
echo " params length : $# "

以下一些扩展方法,需要 bash 环境


#倒数第一个参数
#或 ${$#}, 但由于大括号中不能嵌套$符号, 要用!代替
echo " last param : ${!#} "
echo " last param : ${@:${#@}} "

#倒数第二个参数
echo " last 2nd param : ${@:${#@}-1:1} "

#最后两个参数
echo " last 2 param : ${@:${#@}-1} "

#从第二个到最后一个参数
echo " from 2nd to last param : ${@:2} "

#从第2个参数开始,连续2个参数
echo " from 2nd, count 2 : ${@:2:2} "

这是一个纯CSS写的带方向箭头的消息提示框,支持左上、右上、左下、右下、纯左、纯右五种方向箭头,对应的Class分别为 ark-poptip-arrow-a/b/c/d/e/f ,效果图如下:

效果图

CSS部分

.ark-poptip{ position: absolute; color: #db7c22; z-index: 101; line-height: 1.5; zoom: 1; }
.ark-poptip-shadow{ background-color: rgba(229,169,107,0.15); FILTER: progid:DXImageTransform.Microsoft.Gradient(startColorstr=#26e5a96b,endColorstr=#26e5a96b); border-radius: 2px; padding: 2px; zoom: 1; _display: inline; }
.ark-poptip-container{ position: relative; background-color: #fffcef; border: 1px solid #ffbb76; border-radius: 2px; padding: 5px 22px 5px 10px; zoom: 1; _display: inline; }
.ark-poptip:after,.ark-poptip-shadow:after,.ark-poptip-container:after{ visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0; }
.ark-poptip a.ark-poptip-close{ position: absolute; right: 3px; top: 3px; border: 1px solid #ffc891; text-decoration: none; border-radius: 3px; width: 12px; height: 12px; font-family: tahoma; color: #dd7e00; line-height: 10px; line-height: 10px\0; *line-height: 12px; text-align: center; font-size: 14px; background: #ffd7af; background: -webkit-gradient(linear,left top,left bottom,from(#fff0e1),to(#ffe7cd)); background: -moz-linear-gradient(top,#fff0e1,#ffe7cd); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFF0E1',endColorstr='#FFE7CD'); background: -o-linear-gradient(top,#fff0e1,#ffe7cd); background: linear-gradient(top,#fff0e1,#ffe7cd); overflow: hidden; }
.ark-poptip a.ark-poptip-close:hover{ border: 1px solid #ffb24c; text-decoration: none; color: #dd7e00; background: #ffd7af; background: -webkit-gradient(linear,left top,left bottom,from(#ffe5ca),to(#ffcc98)); background: -moz-linear-gradient(top,#ffe5ca,#ffcc98); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFE5CA',endColorstr='#FFCC98'); background: -o-linear-gradient(top,#ffe5ca,#ffcc98); background: linear-gradient(top,#ffe5ca,#ffcc98); }
.ark-poptip-arrow,.ark-poptip-arrow em,.ark-poptip-arrow span{ position: absolute; font-size: 14px; font-family: SimSun,Hiragino Sans GB; font-style: normal; line-height: 21px; z-index: 10; *zoom: 1; }
.ark-poptip-arrow em{ color: #ffbb76; }
.ark-poptip-arrow span{ color: #fffcef; top: 0; left: 0; }
.ark-poptip-arrow-a{ left: 14px; top: -10px; top: -9px\0; }
.ark-poptip-arrow-a em{ top: -1px; left: 0; }
.ark-poptip-arrow-b{ right: 28px; top: -10px; top: -9px\0; }
.ark-poptip-arrow-b em{ top: -1px; left: 0; }
.ark-poptip-arrow-c{ left: 14px; bottom: 10px; }
.ark-poptip-arrow-c em{ top: 1px; left: 0; }
.ark-poptip-arrow-d{ right: 28px; bottom: 10px; }
.ark-poptip-arrow-d em{ top: 1px; left: 0; }
.ark-poptip-arrow-e{ top: 6px; left: -6px; }
.ark-poptip-arrow-e em{ top: 0; left: -1px; }
.ark-poptip-arrow-f{ top: 6px; right: 7px; }
.ark-poptip-arrow-f em { top: 0; left: 1px; }
.ark-poptip-content{ float: none; display: inline; *zoom: 1; }
.ark-poptip-content:after{ visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0; }
:root .ark-poptip-shadow{ FILTER: none\9; }

HTM部分

<div class="ark-poptip" style="top: 10px;">
    <div class="ark-poptip-shadow">
        <div class="ark-poptip-container">
            <div class="ark-poptip-arrow ark-poptip-arrow-a">
                *◆*<span>◆</span>
            </div>
            <div class="ark-poptip-content">欢迎访问技术写真 の 若海 & 尐岢 http://www.anrip.com</div>
        </div>
    </div>
</div>

源码下载
css-tips

Incapsula是与CloudFlare齐名的国外CDN加速服务商,对于将网站空间放在国外访问速度不理想的朋友,推荐大家使用。

IP地址列表<

http://support.incapsula.com/entries/20199668

199.83.128.0/21  OR  199.83.128.1 - 199.83.135.254
198.143.32.0/19  OR  198.143.32.1 - 198.143.63.254
149.126.72.0/21  OR  149.126.72.1 - 149.126.79.254
103.28.248.0/22  OR  103.28.248.1 - 103.28.251.254
185.11.124.0/22  OR  185.11.124.1 - 185.11.127.254

PHP的header状态代码,经常用,却总是忘记;今天整理了一下,备忘!

//200 正常状态
header('HTTP/1.1 200 OK');

//301 永久重定向,记得在后面要加重定向地址 Location:$url
header('HTTP/1.1 301 Moved Permanently');

//重定向,其实就是302 暂时重定向
header('Location: http://www.maiyoule.com/');

//设置页面304 没有修改
header('HTTP/1.1 304 Not Modified');

//显示登录框,
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="登录信息"');
echo '显示的信息!';

//403 禁止访问
header('HTTP/1.1 403 Forbidden');

//404 错误
header('HTTP/1.1 404 Not Found');

//500 服务器错误
header('HTTP/1.1 500 Internal Server Error');

//3秒后重定向指定地址(也就是刷新到新页面与 <meta http-equiv="refresh" content="10;http://www.maiyoule.com/ /> 相同)
header('Refresh: 3; url=http://www.maiyoule.com/');
echo '10后跳转到http://www.maiyoule.com';

//重写 X-Powered-By 值
header('X-Powered-By: PHP/5.3.0');
header('X-Powered-By: Brain/0.6b');

//设置上下文语言
header('Content-language: en');

//设置页面最后修改时间(多用于防缓存)
$time = time() - 60; //建议使用filetime函数来设置页面缓存时间
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');

//设置内容长度
header('Content-Length: 39344');

//设置头文件类型,可以用于流文件或者文件下载
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="example.zip"'); 
header('Content-Transfer-Encoding: binary');
readfile('example.zip');//读取文件到客户端

//禁用页面缓存
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 
header('Pragma: no-cache');

//设置页面头信息
header('Content-Type: text/html; charset=iso-8859-1');
header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/plain'); 
header('Content-Type: image/jpeg'); 
header('Content-Type: application/zip'); 
header('Content-Type: application/pdf'); 
header('Content-Type: audio/mpeg');
header('Content-Type: application/x-shockwave-flash');