Skip to content

Instantly share code, notes, and snippets.

View yamyamyuo's full-sized avatar
🎯
Focusing

yamyamyuo

🎯
Focusing
View GitHub Profile
快捷键 功能
cmd + shift + p 打开命令菜单
cmd + t 模糊搜索工作目录下的文件
cmt + b 搜索已经打开的文件
ctrl + 0 焦点移动到文件目录
cmd + \ 隐藏左侧目录树
ctrl + [ 目录中展开结点
ctrl + ] 目录中缩起结点
d / a / m 对目录选中的结点进行 删除 / 添加 / 移动
@yamyamyuo
yamyamyuo / delete_git_submodule.md
Created December 18, 2018 06:00 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@yamyamyuo
yamyamyuo / docker_remove.sh
Created October 15, 2018 12:01
docker remove image with angry
#!/bin/bash
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
docker images | grep "superset" | awk '{print $3}' | xargs docker rmi
@yamyamyuo
yamyamyuo / pandas_reorder_column.py
Created October 15, 2018 11:32
reorder dataframe column
"""
sort by column in multi level dataframes
"""
import pandas
data = {'active_days': [2,6,1, 2],
'province': ['beijing', 'shanghai', 'shanghai','beijing'],
'__timestamp': ['2018-09-17', '2018-09-24', '2018-08-20', '2018-09-17'],
'sum(active_days_user)': [1033604, 256682, 3613940, 1]}
@yamyamyuo
yamyamyuo / python_logging_config.py
Created October 11, 2018 06:07
python logging basic config
import logging
logging.basicConfig(
level=logging.INFO,
format=
'%(asctime)s pid:%(process)d %(levelname)s (%(filename)s:%(lineno)d)- %(message)s'
)
@yamyamyuo
yamyamyuo / python_2_and_3_compatible.py
Created October 11, 2018 06:06
python 2 and python 3 compatible
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
if sys.version_info >= (3, 0):
from urllib.parse import urlparse
else:
from urlparse import urlparse
@yamyamyuo
yamyamyuo / itertools_demo.py
Last active October 11, 2018 06:05
python group by
import os
from itertools import groupby
input2 = [
{'dept': '001', 'sku': 'foo', 'transId': 'uniqueId1', 'qty': 100},
{'dept': '001', 'sku': 'bar', 'transId': 'uniqueId2', 'qty': 200},
{'dept': '001', 'sku': 'foo', 'transId': 'uniqueId3', 'qty': 300},
{'dept': '002', 'sku': 'baz', 'transId': 'uniqueId4', 'qty': 400},
{'dept': '002', 'sku': 'baz', 'transId': 'uniqueId5', 'qty': 500},
@yamyamyuo
yamyamyuo / s3_bucket_list.py
Created October 11, 2018 06:03
AWS S3 code
# 找到某个bucket 下, 限定prefix下, 所有的key
import os
import boto3
bucket_name = 'tmp-bucket'
_s3 = boto3.resource('s3',region_name='cn-north-1')
print _s3
bucket = _s3.Bucket(bucket_name)
print bucket.name
all_objects = _s3.meta.client.list_objects(Bucket = bucket_name)
@yamyamyuo
yamyamyuo / shell_date_add.sh
Created October 11, 2018 06:02
shell date add or substract
#!/bin/bash
for i in `seq 1 355`;
do
data_date=`date -v -${i}d +%F`
echo $data_date
done