Skip to content

Instantly share code, notes, and snippets.

View foru17's full-sized avatar
🎯
Focusing

Luo Lei foru17

🎯
Focusing
View GitHub Profile
@foru17
foru17 / handleFile.js
Last active August 29, 2015 14:13
几个进行文件操作的js方法
//判断文件类型
function checkFileType(file) {
allowedDocTypes = ["application/pdf", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];
if (file.type.indexOf("image/") == 0) {
return "image"
} else if (allowedDocTypes.indexOf(file.type) > -1) {
return "doc"
}
return false
}
@foru17
foru17 / nohup.sh
Created March 4, 2015 15:02
linxu在后台运行程序
nohup ssserver -c /etc/shadowsocks.json > /dev/null 2>&1 &
@foru17
foru17 / php_site.conf
Created April 14, 2015 07:51
php nginx 配置
server {
listen 80;
server_name im;
access_log /var/www/website/access.log;
error_log /var/www/website/error.log;
location / {
root /var/www/website;
index index.html index.htm index.php;
}
@foru17
foru17 / websocket_nginx.conf
Created April 18, 2015 07:18
nginx websocket配置
# we're in the http context here
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# Node Nginx 配置
server {
server_name yourdomain.com;
@foru17
foru17 / cut_log.sh
Created May 12, 2015 07:29
自动分割nginx日志
#!/bin/bash
#function:cut nginx log files for lnmp v0.5 and v0.6
#author: http://lnmp.org
#set the path to nginx log files
log_files_path="/home/wwwlogs/"
log_files_dir=${log_files_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")
#set nginx log files you want to cut
log_files_name=(access vpser licess)
#set the path to nginx.
@foru17
foru17 / node.conf
Created May 26, 2015 12:21
端口转发 nginx 配置
server {
listen 80;
server_name yitest.is26.com;
location /{
root /home/project/
index index.php index.html;
}
@foru17
foru17 / urlparam.js
Created June 12, 2015 06:41
获得URL中的参数
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
var r = window.location.search.substr(1).match(reg); //匹配目标参数
if (r != null) return unescape(r[2]);
return null; //返回参数值
}
@foru17
foru17 / wechatua.js
Created June 18, 2015 04:02
微信UA
//微信安卓UA
mozilla/5.0 (linux; u; android 4.1.2; zh-cn; mi-one plus build/jzo54k) applewebkit/534.30 (khtml, like gecko) version/4.0 mobile safari/534.30 micromessenger/5.0.1.352
//微信iPhone UA
mozilla/5.0 (iphone; cpu iphone os 5_1_1 like mac os x) applewebkit/534.46 (khtml, like gecko) mobile/9b206 micromessenger/5.0
@foru17
foru17 / changsuffix.sh
Created August 4, 2015 03:18
修改文件后缀
#修改文件后缀
for f in *.txt; do
mv -- "$f" "${f%.txt}.text"
done
@foru17
foru17 / rename.sh
Created November 24, 2015 11:04
脚本批量改名 替换参数
#当前文件夹
for file in ACDC*.xxx; do
mv "$file" "${file//ACDC/AC-DC}"
done
#子目录
find . -type f -name "ACDC*" -print0 | while read -r -d '' file; do
mv "$file" "${file//ACDC/AC-DC}"
done