This file contains 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 shutil | |
from datetime import datetime | |
def move(suffix=None): | |
extension = suffix or 'jpg' | |
file_names = [f.name for f in os.scandir() if f.name.endswith(f'.{extension}')] | |
for file_name in file_names: | |
date_data = datetime.fromtimestamp(os.stat(file_name).st_mtime) |
This file contains 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 shutil | |
from datetime import datetime, date, timedelta | |
def get_next_date(base_date): | |
next_month = date(base_date.year, base_date.month, 1) + timedelta(days=35) | |
return date(next_month.year, next_month.month, 1) | |
This file contains 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 json | |
dictionary = {} | |
json.dumps(dictionary, indent=2, separators=(',', ': '), sort_keys=True) |
This file contains 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, print_function, unicode_literals | |
try: | |
from urllib.parse import parse_qsl, urlencode, urlparse, urlunparse | |
except ImportError: | |
from urllib import urlencode | |
from urlparse import parse_qsl, urlparse, urlunparse |
This file contains 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)] |
This file contains 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 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 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 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 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) |
NewerOlder