Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

yamyamyuo

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

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 Oct 15, 2018
docker remove image with angry
View docker_remove.sh
#!/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
View pandas_reorder_column.py
"""
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 Oct 11, 2018
python logging basic config
View python_logging_config.py
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 Oct 11, 2018
python 2 and python 3 compatible
View python_2_and_3_compatible.py
# -*- 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
View itertools_demo.py
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},
View s3_bucket_list.py
# 找到某个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 Oct 11, 2018
shell date add or substract
View shell_date_add.sh
#!/bin/bash
for i in `seq 1 355`;
do
data_date=`date -v -${i}d +%F`
echo $data_date
done