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
相关文章
相关标签/搜索