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
#! /usr/bin/env python3 | |
# mapIt.py コマンドラインやクリップボードに指定した住所の地図を開く | |
import webbrowser, sys, pyperclip, urllib.parse | |
if len(sys.argv) > 1: | |
# コマンドラインから住所を取得する | |
address = ' '.join(sys.argv[1:]) | |
else: | |
# クリップボードから住所を取得する |
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
# #!/usr/bin/env python3 | |
# mailer.py コマンドラインからメール送信 | |
import sys | |
from selenium import webdriver | |
from selenium.webdriver.support.ui import WebDriverWait | |
from selenium.webdriver.support import expected_conditions as EC | |
from selenium.common.exceptions import TimeoutException | |
# todo コマンドラインからメアドと本文を受け取る |
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
#!/usr/bin/env python3 | |
# downloadxkcd.py XKCDコミックをひとつずつダウンロードする | |
import requests, os, bs4 | |
url = 'http://xkcd.com' | |
os.makedirs('xkcd', exist_ok=True) | |
while not url.endswith('#'): | |
# ページをダウンロードする |
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
#!/usr/bin/env python3 | |
# lucky.py Google検索結果をいくつか開く | |
import requests, sys, webbrowser, bs4 | |
# 引数からGoogle検索して結果ページをダウンロード | |
print('Googleしています…') # Googleページをダウンロード中にテキストを表示 | |
res = requests.get('https://www.google.co.jp/search?q=' + ''.join(sys.argv[1:])) | |
res.raise_for_status() |
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
#! /usr/bin/env python3 | |
# mapIt.py コマンドラインやクリップボードに指定した住所の地図を開く | |
import webbrowser, sys, pyperclip, urllib.parse | |
if len(sys.argv) > 1: | |
# コマンドラインから住所を取得する | |
address = ' '.join(sys.argv[1:]) | |
else: | |
# クリップボードから住所を取得する |
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
#! python3 | |
# 連番ファイルを作る | |
import os | |
# 連番のリストを作る | |
numbering_files = [f'sample{i:03d}.txt' for i in range(1,21)] | |
# ディレクトリを作り、基本のパスを決める | |
os.mkdir('./numbering') |
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
#! python3 | |
# 連番ファイルの穴を見つけ、リストアップ | |
import re, os | |
# 正規表現を作る | |
snumber_regex = re.compile(r'^sample(\d{3}).txt') | |
# 基準パスはここ | |
path = './numbering' |
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
#! python3 | |
# ディレクトリツリーを渡り歩き1GB以上のファイルをリストアップする | |
import os | |
def gigafile(folder): | |
for foldername, subfolders, files in os.walk(folder): | |
for file in files: | |
if os.path.getsize(os.path.join(foldername, file)) > 1000000000: | |
print(str(os.path.getsize(os.path.join(foldername, file))) + ' ; ' + os.path.join(foldername, file)) |
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
#! python3 | |
# ディレクトリツリーを渡り歩き、pdfファイルはpdfsフォルダに、jpgファイルはjpgsフォルダにコピーする | |
import os, re, shutil | |
def copies(folder): | |
# 名前を絶対パスにする | |
folder = os.path.abspath(folder) |
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
#! Python3 | |
# renameDates.py 米国式日付MM-DD-YYYYを日本式日付YYYY-MM-DDに書き換える | |
import shutil | |
import os | |
import random | |
import re | |
import string | |
# ランダムな日付や文字列が入ったファイルを大量生成する。不要ならコメントアウト |