ubuntu nodejs 8

Read full article  | 评论关闭

 

 

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

sudo apt-get install -y nodejs

 

 

npm install pm2 -g

Read More

ubuntu remove package

Read full article  | 评论关闭

 

apt-get autoclean:
如果你的硬盘空间不大的话,可以定期运行这个程序,将已经删除了的软件包的.deb安装文件从硬盘中删除掉。

 

apt-get clean:
类似上面的命令,但它删除包缓存中的所有包。这是个很好的做法,因为多数情况下这些包没有用了。

 

apt-get autoremove:
删除为了满足其他软件包的依赖而安装的,但现在不再需要的软件包。

 

其它:

apt-get remove 软件包名称:
删除已安装的软件包(保留配置文件)。

apt-get –purge remove 软件包名称:
删除已安装包(不保留配置文件)。

Read More

mongo explain

Read full article  | 评论关闭

 

db.test.explain("executionStats").find({"user":"1332200000"})

Read More

mongo add index

Read full article  | 评论关闭

 

db.user.ensureIndex({“name”:1,”age”:1})

 

db.COLLECTION_NAME.getIndexes()

db.sites.dropIndex("name_1_domain_-1")

Read More

mongo count distinct

Read full article  | 评论关闭

 

 

db.collection_name.distinct(‘types2′)

Read More

nginx upstream based on URL parameter

Read full article  | 评论关闭

 

 

location / {

if ( $arg_parameterName = “test1″ ) {
proxy_pass http://server1;
}
if ( $arg_parameterName = “test2″ ) {
proxy_pass http://server2;
}
}

Read More

delete old data from elasticsearch

Read full article  | 评论关闭

 

get indices info

curl 'localhost:9200/_cat/indices?v'

delete old data:
curl -v -X DELETE http://localhost:9200/logstash-$day*

Read More

nginx upstream based on http header

Read full article  | 评论关闭

upstream apache {
     server 127.0.0.1:8080;
}

upstream staging {
     server 127.0.0.1:8081;
}

upstream development {
     server 127.0.0.1:8082;
}

# map to different upstream backends based on header
map $http_x_server_select $pool {
     default "apache";
     staging "staging";
     dev "development";
}

server {
     listen 80;
     server_name example.com;
     location / {
          proxy_pass http://$pool;

          #standard proxy settings
          proxy_set_header X-Real-IP $remote_addr;
          proxy_redirect off;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_redirect off;
          proxy_set_header X-Forwarded-Proto $scheme;
          proxy_set_header X-NginX-Proxy true;
          proxy_connect_timeout 600;
          proxy_send_timeout 600;
          proxy_read_timeout 600;
          send_timeout 600;
     }
}

Read More

mongo collection name have -

Read full article  | 评论关闭

 

 

db['construction-places'].count()
42

Read More

BMI 计算公式

Read full article  | 评论关闭

 

EX:70kg÷(1.75×1.75)=22.86

成人的BMI数值:
过轻:低于18.5
正常:18.5-23.9
过重:24-27
肥胖:28-32
非常肥胖, 高于32
bmi 标准

Read More