-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
实用技巧
索引
top 移动端页面开头
<head lang="en">
<meta charset="UTF-8">
<!-- 优先使用 IE 最新版本和 Chrome -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<!-- 为移动设备添加 viewport -->
<meta name="viewport" content="width=device-width,initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<!-- 添加到主屏后的标题(iOS 6 新增) -->
<meta name="apple-mobile-web-app-title" content="">
<!-- 是否启用 WebApp 全屏模式,删除苹果默认的工具栏和菜单栏 -->
<meta name="apple-mobile-web-app-capable" content="yes"/>
<!-- 设置苹果工具栏颜色 -->
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<!-- 添加智能 App 广告条 Smart App Banner(iOS 6+ Safari) -->
<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL">
<!-- 忽略页面中的数字识别为电话,忽略email识别 -->
<meta name="format-detection" content="telphone=no, email=no"/>
<!--下面三个是清除缓存 微信浏览器缓存严重又无刷新;这个方法调试的时候很方便-->
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">
<title>web前端</title>
</head>top js多行字符串转换
ecmascript 6 已经支持多行字符串写法,但对浏览器的兼容欠缺,不过可以使用Babel转码器,ecmascript 6语法转为浏览器所兼容的ecmascript 5语法。
var doc = function (fn) {
// 1. 移除起始的 function(){ /*!
// 2. 移除末尾的 */ }
// 3. 移除起始和末尾的空格
return fn.toString()
.replace(/^[^\/]+\/\*!?/, '')
.replace(/\*\/[^\/]+$/, '')
.replace(/^[\s\xA0]+/, '').replace(/[\s\xA0]+$/, '') // .trim()
}top smarty保留两位小数
{{$date_price=$date_price|string_format:'%.2f'}}top 工具插件
- 百度图表工具
生成可视化图表,自定义很强大
top 排错代码
window.onerror = testError;
function testError() {
arglen = arguments.length;
var errorMsg = "参数个数:" + arglen + "个";
for (var i = 0; i < arglen; i++) {
errorMsg += "/n参数" + (i + 1) + ":" + arguments[i];
}
alert(errorMsg);
window.onerror = null;
return true;
}用于排错,安卓部分机型浏览器会启用严格模式,遇到错误会很难排查,用此代码可以把错误输出
top mac添加环境变量
#查看当前环境变量
echo $PATH
#添加环境变量
echo 'export PATH=/user/localhost/mongodb/bin:$PATH'>>./bash_profile
#添加环境变量,需要重启,如果想立即生效可以输入
source .bash_profile
top AdvancedNewFile(快速新建文件)
用于批量更改项目里git用户名和邮箱的shlle
#!bin/bash
#用于批量更改项目里git用户名和邮箱
current_path=pwd;
set_git_config() {
cd $1
for file in ./*
do
pa="${file}/.git"
if [[ -d $file && -d "${file}/.git" ]];
then
cd $file && git config user.name $2 && git config user.email $3 && cd ..
fi
done
}
set_git_config ~/cold "ColdXu" "coldxuweb@163.com"
set_git_config ~/git "zhiyong.xu" "zhiyong.xu@wenba100.com"
echo "modification git config �success!"
模拟rm改成移动到回收站
#!bin/bash
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
alias rm=trash #命令别名 rm改变为trash,通过将rm命令别名值trash来实现把rm改造成删除文件至回收站
alias r=trash
alias rl='ls /.trash' # rl 命令显示回收站中的文件
alias ur=undelfile # ur命令找回回收站中的文件
#这个函数的作用是找回回收站下的文件
undelfile(){
mv -i /.trash/\$@ ./
}
#这个函数是将指定的文件移动到指定的目录下,通过将rm命令别名值trash来实现把rm改造成删除文件至回收站
trash(){
mv $@ /.trash/
}
#这个函数的作用是清空回收站目录下的所有文件
cleartrash(){
read -p 'clear sure?[n]' confirm
[$confirm == 'y' ] || [ $confirm == 'Y' ] && /bin/rm -rf /.trash/*
}
改变系统ll命令显示所有
#!bin/bash
alias ll='ls -alF'
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels