Skip to content

Instantly share code, notes, and snippets.

View imchao9's full-sized avatar
🎯
Focusing

JunChao imchao9

🎯
Focusing
View GitHub Profile
@imchao9
imchao9 / proc_demo.proc
Last active January 23, 2016 15:36
mysql procedure
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `proc_update`(in type int,in start int,in end int)
begin
set @start=start;
set @end=end;
while @start<@end
do
update tbl_material set file_type = type where id = @start;
set @start=@start+1;
end while;
@imchao9
imchao9 / deletefile.sh
Last active June 15, 2016 09:42
除指定文件文件夹外删除文件和文件夹并打包 delete file and document and zip
#! /bin/bash
lessonId=(1 2 3 4 5 6 7 8 9 10)
for id in ${lessonId[*]};
do
find ./$id -type f -not \( -name 'challenge.html' -or -name 'receive.html' -or -name 'reward.html' -or -name 'story.html' -or -name 'task.html' \) -delete
find . -type d -not \( -name 'challenge' -or -name 'receive' -or -name 'reward' -or -name 'story' -or -name 'task' \) -delete
zip -r $id.zip $id
done
find . -type d \( -name 'libs' -o -name 'node_modules' \) -exec rm -rf {} \;
@imchao9
imchao9 / qiniu_refresh_cache.sh
Last active January 23, 2016 15:34
七牛刷新缓存 qiniu refresh cache
#! /bin/bash
read lesson
./qshell_darwin_amd64 listbucket [bucket name] $lesson/ filelist.log
egrep -o '.*\.(png|jpg|js|mp4|an|html)' filelist.log > test.txt
sed 's/^/http:\/\/7xq5ra.com2.z0.glb.qiniucdn.com\/&/g' test.txt > refresh.log
./qshell_darwin_amd64 batchrefresh refresh.log
@imchao9
imchao9 / wechat_ua
Created January 24, 2016 05:45
wechat ua
Mozilla/5.0wechat MicroMessenger (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53
@imchao9
imchao9 / gist:847072e5cb60b0526776
Last active February 2, 2016 01:53
上传头像到七牛
function uploadUserAvatar() {
var cdnUploadUrl = "http://up.qiniu.com";
getToken(uploadFile);
}
function getToken(callback) {
$.ajax({
url: apiServer+'/program/cdn/upload/token',
type:"get",
success: function(data) {
@imchao9
imchao9 / rdelete.sh
Created January 30, 2016 08:13
递归删除文件
find . -name .DS_Store -exec rm -rf {} \;
@imchao9
imchao9 / mongodb
Created February 16, 2016 15:37
MongoDB 查询语句 and写法
var startTime = Date.parse(new Date("2016 02-01"))/1000;
var endTime = Date.parse(new Date("2016 02-16"))/1000;
db.getCollection('sqllogs').find(
{$and:[{"create_time":{$lt:endTime}},{"create_time":{$gt:startTime}},
{"content":/update.*praise_times.*35167.*/i}]}).sort({"create_time":1})
@imchao9
imchao9 / mysql
Created February 16, 2016 15:38
MySQL根据时间戳分组
create_time时间格式
SELECT DATE_FORMAT(create_time,'%Y%u') weeks,COUNT(id) COUNT FROM role GROUP BY weeks;
SELECT DATE_FORMAT(create_time,'%Y%m%d') days,COUNT(id) COUNT FROM role GROUP BY days;
SELECT DATE_FORMAT(create_time,'%Y%m') months,COUNT(id) COUNT FROM role GROUP BY months
create_time时间戳格式
@imchao9
imchao9 / nodejs
Created March 7, 2016 15:11
nodejs 捕获uncaughtException 异常
process.on('uncaughtException', function(err) {
//do something
fs.appendFile("E:\\Work\\codemao\\code\\node\\electron-x32\\resources\\1.txt", err.stack, function(err1){
});
});
@imchao9
imchao9 / command
Created March 7, 2016 15:19
windows杀进程
taskkill /F /im frontpg.exe