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 -*- | |
| #!/usr/bin/env python | |
| import codecs | |
| import sys | |
| from bs4 import BeautifulSoup | |
| def main(argv): | |
| file_path = argv[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 commands | |
| def ls(path): | |
| return commands.getoutput('ls -m {}'.format(path)).replace('\n', '').split(', ') | |
| ls('~') |
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 echo(message, message_type=None): | |
| colors = { | |
| "OK": '\033[94m', | |
| "SUCCESS": '\033[92m', | |
| "WARNING": '\033[93m', | |
| "FAIL": '\033[91m', | |
| } | |
| color = colors.get(message_type) | |
| print "".join([color, message, '\033[0m']) if color else message |
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 | |
| # -*- coding: utf-8 -*- | |
| import os | |
| import shlex | |
| import subprocess | |
| _env = 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 csv | |
| import os | |
| def replace_csv_file(file_path, old_str, new_str): | |
| count = 0 | |
| temp_path = '_' + file_path | |
| with open(file_path, 'r') as read_file: | |
| with open(temp_path, 'w') as write_file: | |
| reader = csv.reader(read_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
| class TransformTools(object): | |
| @staticmethod | |
| def str_to_time(log_date_str): | |
| DATETIME_FORMAT = '%Y/%m/%d %H:%M:%S' | |
| return datetime.strptime(log_date_str, DATETIME_FORMAT) | |
| @staticmethod | |
| def datetime2epoch(target_datetime): | |
| return int(time.mktime(target_datetime.timetuple())) |
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 absolute_import | |
| from __future__ import unicode_literals | |
| from __future__ import print_function |
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
| ## | |
| ## プロ生ちゃん | |
| ## | |
| ## | |
| $the_cow = <<EOC; | |
| $thoughts | |
| $thoughts | |
| ` ` ` ` `` ` ` | |
| ` ` ` ` ` ...J&ggmQHMHHHHNgg&J... ` | |
| ` `..JgMMMH9UVOOllllllllllOVVWMMMHJ,.`` ` |
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
| gitco() { | |
| git checkout `git branch | peco | awk '{print $NF}'` | |
| } |
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 math | |
| from typing import List | |
| def split_list(_list, n) -> List[list]: | |
| """リストを均等に分ける""" | |
| sp = [0] + [math.ceil(len(_list) / n * (i + 1)) for i in range(n)] | |
| return [_list[sp[i]: sp[i + 1]] for i in range(n)] |