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 os | |
| import time | |
| import asyncio | |
| import aiobotocore | |
| import aiofiles | |
| AWS_ACCESS_KEY_ID = '' # aws access key | |
| AWS_SECRET_ACCESS_KEY = '' # aws secret key | |
| READ_TIMEOUT = 500 |
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 pymysql | |
| import random | |
| SCHEMA = 'schema_name' | |
| TABLE_NAME = 'table_name' | |
| TABLE_FIELDS = [ | |
| 'currency', | |
| 'language', | |
| ] | |
| USER = 'root' |
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 | |
| from tornado.gen import coroutine, Task | |
| from tornado.httpclient import HTTPError, AsyncHTTPClient, HTTPRequest | |
| _http_client = AsyncHTTPClient() | |
| @coroutine | |
| def upload_to_s3(bucket: str, region: str, data, key: str, | |
| aws_access_key_id: str, aws_secret_access_key: str) -> str: |
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 os | |
| import tarfile | |
| PATH_TO_DIR_WITH_TARS = '/home/username/sub_folder/' | |
| files = [file for file in os.listdir(PATH_TO_DIR_WITH_TARS) if | |
| os.path.isfile(os.path.join(PATH_TO_DIR_WITH_TARS, file))] | |
| for file in files: | |
| file_name, file_extension = os.path.splitext(file) |
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 requests | |
| import json | |
| url = 'http://localhost:4151' | |
| topic = 'is-hotel-active' | |
| url = '{url}/pub?topic={topic}'.format(url=url, topic=topic) | |
| rows = [{'hotel_id': '81', 'is_hotel_active': '0'}, | |
| {'hotel_id': '23', 'is_hotel_active': '1'}, | |
| {'hotel_id': '82', 'is_hotel_active': '1'}] |
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 nsq | |
| lookup_http_addresses = ['http://127.0.0.1:4161'] | |
| topic = 'hotel-active' | |
| chanel = 'hotel' | |
| def handler(message): | |
| print(message.body) | |
| return True |
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 trafaret as t | |
| from trafaret import Dict | |
| some_template = { | |
| 'api': { | |
| 'status': 'ok', | |
| 'locale': 'Some str', | |
| 'error': 'None', | |
| 'data': { | |
| 'result': { |
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
| FIRST_FILE_PATH = 'simple_1.csv' | |
| SECOND_FILE_PATH = 'simple_2.csv' | |
| OUTPUT_FILE_PATH = 'file_diff.csv' | |
| with open(FIRST_FILE_PATH, 'r') as first_file, open(SECOND_FILE_PATH, 'r') as second_file: | |
| first_reader = first_file.readlines() | |
| second_reader = second_file.readlines() | |
| with open(OUTPUT_FILE_PATH, 'w+') as output: | |
| for line in first_reader: |
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 redis | |
| import logging | |
| def create_logger(logger_name): | |
| logger = logging.getLogger(logger_name) | |
| return logger | |
| class BatchDateCache: |
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
| data = ['some str', 'longer str', 'the biggest string', 'small one'] | |
| vowels = 'eyuioa' | |
| data.sort(key=lambda x: sum(ch in vowels for ch in x)) |
OlderNewer