This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| call plug#begin() | |
| " syntax check | |
| Plug 'w0rp/ale' | |
| " Autocomplete | |
| Plug 'ncm2/ncm2' | |
| Plug 'roxma/nvim-yarp' | |
| Plug 'ncm2/ncm2-path' | |
| Plug 'ncm2/ncm2-jedi' | |
| " Formater |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def dataframe_difference(df1, df2, which=None): | |
| """Find rows which are different.""" | |
| comparison_df = df1.merge(df2, | |
| indicator=True, | |
| how='outer') | |
| if which is None: | |
| diff_df = comparison_df[comparison_df['_merge'] != 'both'] | |
| else: | |
| diff_df = comparison_df[comparison_df['_merge'] == which] | |
| diff_df.to_csv('data/diff.csv') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| def validate_phone(phone): | |
| if re.match(r'^\+1?\d{9,15}$', phone): | |
| print(f'{phone} is valid number') | |
| else: | |
| print(f'{phone} is not valid') | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def clean_empty_or_none(d): | |
| """ | |
| Clean empty or None values from dict | |
| """ | |
| clean = {} | |
| for k, v in d.items(): | |
| if isinstance(v, dict): | |
| nested = clean_empty_or_none(v) | |
| if len(nested.keys()) > 0: | |
| clean[k] = nested |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| from http.client import HTTPConnection | |
| def httpclient_logging(): | |
| HTTPConnection.debuglevel = 1 | |
| requests_log = logging.getLogger("urllib3") | |
| requests_log.setLevel(logging.WARNING) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto3 | |
| import logging | |
| from botocore.exceptions import ClientError | |
| class S3Imgs: | |
| def __init__(self, aws_access_key_id, aws_secret_access_key, region_name): | |
| """S3 secrests config. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AttrDict(dict): | |
| def __init__(self, *args, **kwargs): | |
| super(AttrDict, self).__init__(*args, **kwargs) | |
| self.__dict__ = self | |
| config = AttrDict() | |
| # Example | |
| config['name'] |

