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
| # -*- coding: utf-8 -*- | |
| from __future__ import print_function | |
| sparkydog = r''' | |
| -os+` | |
| `hmmds------------------------------------. | |
| -oymddddddddddddddddddddddddddddddddddddd+ | |
| :dmmmmmmmmmd+///////////////////////hmm+ | |
| `smmmmmmmmd+ -::::. ymm+ | |
| `ydmmmdds: :/sy/` ..` ymm+ | |
| `odmdy-` `` /ddy. ymm+ |
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 numpy as np | |
| class rint(object): | |
| def __init__(self,stat='A'): | |
| self.val = 0 | |
| if stat == 'train': | |
| self.rng = np.random.RandomState(seed=100) | |
| else: | |
| self.rng = np.random.RandomState(seed=None) |
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 logging | |
| if __name__ == '__main__': | |
| logging.basicConfig(filename='example.log',format='%(asctime)s %(process)s %(module)s %(message)s',level=logging.DEBUG) | |
| logging.debug('This message should go to the log file') | |
| logging.info('So should this') | |
| logging.warning('And this, too') | |
| logging.warning('Watch out!') # will print a message to the console | |
| logging.info('I told you so') # will not print anything |
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
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| # Author: Axel Angel, copyright 2015, license GPLv3. | |
| import sys | |
| import caffe | |
| import numpy as np | |
| import lmdb | |
| import argparse |
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
| #!/usr/bin/env python | |
| """Simple HTTP Server With Upload. | |
| This module builds on BaseHTTPServer by implementing the standard GET | |
| and HEAD requests in a fairly straightforward manner. | |
| """ | |
| __version__ = "0.2" | |
| __all__ = ["SimpleHTTPRequestHandler"] |
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 time | |
| from tqdm import tqdm | |
| if __name__ == '__main__': | |
| s = 0 | |
| t = tqdm(range(100)) | |
| for i in t: | |
| s += i | |
| time.sleep(0.05) | |
| t.set_description("step{0:3d}".format(i)) |
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
| \usepackage[textsize=tiny]{todonotes} | |
| \usepackage{marginnote} | |
| \paperwidth=\dimexpr \paperwidth + 6cm\relax | |
| \oddsidemargin=\dimexpr\oddsidemargin + 3cm\relax | |
| \evensidemargin=\dimexpr\evensidemargin + 3cm\relax | |
| \marginparwidth=\dimexpr \marginparwidth + 3cm\relax |
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 evenFilter(d): | |
| if d['idx'] % 2 == 0: | |
| return True | |
| else: | |
| return False | |
| if __name__ == '__main__': | |
| L = [] | |
| for i in range(10): | |
| d={} |
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 sys | |
| import os | |
| import subprocess | |
| ROOTDIR = '<you path>/hexo/public' | |
| YEAR = ['2017','2018','2019'] | |
| URLList = [] | |
| BEGIN = 0 | |
| NUM = 10 | |
| if __name__ == '__main__': | |
| for year in YEAR: |
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 torch | |
| from tqdm import tqdm | |
| import time | |
| # declare which gpu device to use | |
| cuda_device = '0' | |
| def check_mem(cuda_device): | |
| devices_info = os.popen('"/usr/bin/nvidia-smi" --query-gpu=memory.total,memory.used --format=csv,nounits,noheader').read().strip().split("\n") |