Skip to content

Instantly share code, notes, and snippets.

View itomg's full-sized avatar

Jimmy Zhao itomg

View GitHub Profile
var str = 'asdfasflasjfasjfasfapple;asdfasfasfas';
var keyword = 'apple';
if(str.search(new RegExp(keyword, 'i')) == -1){
alert('Found ' + keyword);
}
select substring_index(substring(field_name, instr(field_name, "@")+1), " ", 1)
cd ~/www/albicilla/api
forever start -l ~/.forever/api.log -e ~/.forever/err.api.log -w -a app.js
cd ~/www/albicilla/public
forever start -l ~/.forever/public.log -e ~/.forever/err.public.log -w -a app.js
#分析日志中的UserAgent
cat access_20130704.log | awk -F "\"" '{print $(NF-3)}' | sort | uniq -c | sort -nr | head -20
#上面的脚本将分析出日志文件中最多的20个UserAgent
#分析日志中那些IP访问最多
cat access_20130704.log | awk '{print $1}' | sort | uniq -c | sort -nr | head -20
#分析日志中那些Url请求访问次数最多
cat access_20130704.log | awk -F "\"" '{print $(NF-5)}' | sort | uniq -c | sort -nr | head -20
pt-query-digest slow.log > digest.log
select column_name from information_schema.columns where TABLE_NAME = 'your table name' order by ordinal_position;
@itomg
itomg / statPermissionNum.sh
Last active December 30, 2015 07:59
Show file or directory permission number, like ls -l, used for chmod 644 [file or directory path]
## Linux
stat -c %a [file or directory path]
## Mac OS X
stat -f "%Lp" [filename]
@itomg
itomg / mysqlAddSuperUser.sql
Created December 20, 2013 07:00
How to add a mysql super user
# login to mysql client as root
GRANT ALL PRIVILEGES ON *.* TO '[user name]'@'localhost' IDENTIFIED BY '[password]' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO '[user name]'@'%' IDENTIFIED BY '[password]' WITH GRANT OPTION;
@itomg
itomg / checkMysqlEngineType.sql
Last active August 29, 2015 13:56
How can I check MySQL engine type for a specific database?
SELECT `ENGINE` FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA`='your_database_name' AND `TABLE_NAME`='your_table_name';
@itomg
itomg / untitled
Created June 20, 2014 06:37
How do I update npm
npm update npm -g