Skip to content

Instantly share code, notes, and snippets.

View imchao9's full-sized avatar
🎯
Focusing

JunChao imchao9

🎯
Focusing
View GitHub Profile
@imchao9
imchao9 / rmspecifyfile.sh
Created May 11, 2016 03:23
linux 删除指定时间内的文件
find .type f -atime -300 -print -maxdepth 1 -exec rm {} \;
@imchao9
imchao9 / recursion_obj_proterties.js
Created June 20, 2016 08:55
递归遍历对象属性
function TraversalObject(obj) {
for (var a in obj) {
if (typeof (obj[a]) == "object") {
TraversalObject(obj[a]); //递归遍历
} else {
var RegUrl = new RegExp();
RegUrl.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
if (RegUrl.test(obj[a])) {
fileDownload.push(obj[a]);
}
@imchao9
imchao9 / get_url_filename.js
Created June 20, 2016 08:56
获取url的文件名
var RegUrl = new RegExp();
RegUrl.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
@imchao9
imchao9 / downfile.js
Created June 20, 2016 09:47
nodejs下载文件
function downloadFile(url) {
var httpClient = url.slice(0,5) === "https"? https:http;
httpClient.get(url,function(response) {
var RegFileName = new RegExp();
RegFileName.compile(".*%2F(.*?)$");
var fileName = RegFileName.exec(url)[1];
console.log(fileName);
if(fileName) {
var writer = fs.createWriteStream(resPath+fileName);
@imchao9
imchao9 / iptonum.sql
Last active June 23, 2016 15:29
mysql ip转数字 数字转ip
#ip转数字
update tbl_mc_server s set s.`ip`= inet_aton("183.16.194.104")
#数字转ip
select inet_ntoa(ip) from tbl_mc_server
var win = nw.Window.get();
var child_process = require('child_process');
var path = require('path');
win.on('close', function() {
child_process.exec(path.dirname(process.execPath)+'\\stop-server.bat');
win.close(true);
})
@imchao9
imchao9 / tmux-cheatsheet.markdown
Created November 29, 2016 05:55 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

Tmux 快捷键 & 速查表

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

tmux at [-t 会话名]
@imchao9
imchao9 / bash
Created December 1, 2016 06:12
本地通过ssh执行远程服务器的脚本
#!/bin/bash
#变量定义
ip_array=("192.168.1.1" "192.168.1.2" "192.168.1.3")
user="test1"
remote_cmd="/home/test/1.sh"
#本地通过ssh执行远程服务器的脚本
for ip in ${ip_array[*]}
@imchao9
imchao9 / bash
Created December 1, 2016 06:12
本地通过ssh执行远程服务器的脚本
#!/bin/bash
#变量定义
ip_array=("192.168.1.1" "192.168.1.2" "192.168.1.3")
user="test1"
remote_cmd="/home/test/1.sh"
#本地通过ssh执行远程服务器的脚本
for ip in ${ip_array[*]}
@imchao9
imchao9 / gist:e1823eb48e77b944fb67751507c592cb
Created December 5, 2016 08:42
use lodash sortby to sort the array by specifc array
var sortedCollection = _.sortBy(collection, function(item){
return firstArray.indexOf(item.id)
});