Skip to content

Instantly share code, notes, and snippets.

@fay
fay / nginx.conf
Created August 21, 2014 05:00 — forked from Stanback/nginx.conf
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your location block(s):
#
# include cors_support;
#
# A limitation to this method is that Nginx doesn't currently send headers
@fay
fay / sort
Created July 11, 2014 10:08
按照count排序
cat q.txt | sort | uniq -c | sort -rn
@fay
fay / 2to3
Last active August 29, 2015 13:57
migrate bootstrap 2.x to 3.x
sed -i "s/span\([0-9][0-9]*\)/col-md-\1/g" `ack-grep --type=html -l "span\d+"`
sed -i "s/row-fluid/row/g" `ack-grep --type=html -l "row-fluid"`
sed -i "s/offset\([0-9][0-9]*\)/col-md-offset-\1/g" `ack-grep --type=html -l "offset\d+"`
# need to revert the `icon-bar`
sed -i "s/icon-/glyphicon glyphicon-/g" `ack-grep --type=html -l "icon-"`
sed -i "s/btn-mini/btn-xs/g" `ack-grep --type=html -l "btn-mini"`
@fay
fay / 0_reuse_code.js
Created October 23, 2013 05:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@fay
fay / ulimit
Created April 8, 2013 02:28
linux ulimit
在etc/security/limits.conf加入:
* soft nofile 51200
* hard nofile 51200
过一会再查看:ulimit -HSn
应用程序需要重新启动才生效
@fay
fay / iptables
Last active October 11, 2015 17:08
iptables
加入白名单:
sudo iptables -I INPUT -i lo -p tcp -s 192.168.1.0/24 -j ACCEPT --dport 6379
删除规则:
sudo iptables -D INPUT 2
拒绝某个端口的任何访问,黑名单:
sudo iptables -A INPUT -p tcp --dport 6379 -j REJECT
端口转发:
@fay
fay / cache
Created September 23, 2012 03:09
nginx cache file
location / {
proxy_temp_path /home/user/www/static_cache/;
root /home/user/www/static_cache/;
proxy_store on;
proxy_store_access user:rw group:rw all:r;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host "static.afaker.com";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
if ( !-e $request_filename) {
proxy_pass http://afaker.com;
@fay
fay / replace.txt
Created September 20, 2012 07:30
替换多个文件中内容
sed -i "s/aaaaaa/bbbbbb/g" `grep "static.shanbay.com" /home/fay/txts/* -rl`
@fay
fay / uwsgi_afaker
Created September 13, 2012 00:00
logrotate
/home/toozoofoo/deploy/afaker/uwsgi.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
copytruncate
}
@fay
fay / rabbitmq
Created September 12, 2012 08:30
rabbit mq
$ rabbitmqctl add_user myuser mypassword
$ rabbitmqctl add_vhost myvhost
$ rabbitmqctl set_permissions -p myvhost myuser ".*" ".*" ".*"