2018-08-29 技巧總結

1.mongo 查詢python

  通用聚合:git

db.getCollection('poi').aggregate([

   {
         
          $match: {
               'ts_string':'2018-08-27',
          }
     },
     {
       $project:
          {
            id: 1,
            oid: { $substr: [ '$oid', 0, 1 ] },
          }
      },
     
     {
         
          $group: {
               _id:  {  
                  'id': '$id',
                  category:'$category'
               }

          }
     }
     ,
     {
         
          $group: {
               _id: '$_id.category',
               count: { $sum : 1 }
          }
     }
     

], { 'allowDiskUse' : true })

datetime:github

find({'ts':{$gt: new Date('2017/11/25 00:24:38')}})
db.getCollection('goods3').find({'ts':{"$gte":ISODate("2018-09-12T01:16:33.303Z")}}).count()

2.redis 相關redis

鏈接:redis-cli -h 127.0.0.1 -p 6379 -a passwd
最大的key:redis-cli -a bigone2016 --bigkeys
刪除包含某個關鍵字的全部key:
redis-cli -h host -p 6379 -a passwd keys "jd*" | xargs redis-cli -h host -p 6379  -a passwd del

3.unicode 相關json

print("自行車".encode("unicode_escape").decode())

3.git 相關服務器

 強制恢復到某個版本:  
    git reset --hard a8339a2d90d890cc93cbe8c4c34eb93b28b9a347
      git push origin HEAD --force
 git pull 失敗:
    git fetch --all
    git reset --hard origin/master
    git fetch origin --prune  更新本地分之與遠程同步。
    強制覆蓋本地文件

4.pip安裝失敗ide

pip install --trusted-host pypi.python.org linkchecker
pip install --index-url=http://pypi.python.org/simple/ --trusted-host pypi.python.org -r requirements.txt
pip3.6 install -i  https://pypi.doubanio.com/simple/  --trusted-host pypi.doubanio.com linkchecker -U

5.不一樣服務器傳文件fetch

登陸當前服務器,執行scp -r data2 heng@10.9.105.xxx:/data2/ebay_bat_data/176

6.kill 包含某個關鍵字的進程ui

ps -ef|grep keyword|grep -v grep| awk '{print $2}' | xargs kill -9

7.刪除包含關鍵字的文件夾url

find . -name ".idea" | xargs rm -rf

8.複製表結構

CREATE TABLE sold_detial_2018_07_04 as SELECT * FROM sold_detial where 1=2

9.uiautomator double click

def double_click(*args, **kwargs):
    # set ack timeout
    config = d.server.jsonrpc.getConfigurator()
    config['actionAcknowledgmentTimeout'] = 10 #不一樣模擬器或真機可適當調節該參數
    d.server.jsonrpc.setConfigurator(config)
    # double click
    d(*args, **kwargs).click()
    d(*args, **kwargs).click()
    # restore previous config
    config['actionAcknowledgmentTimeout'] = 3000
    d.server.jsonrpc.setConfigurator(config)

 10.ssl error參考:

https://stackoverflow.com/questions/10667960/python-requests-throwing-sslerror

 11.百度雲mac 破解:

cd ~/Downloads && git clone https://github.com/CodeTips/BaiduNetdiskPlugin-macOS.git && ./BaiduNetdiskPlugin-macOS/Other/Install.sh