Skip to content

Instantly share code, notes, and snippets.

View kotoripiyopiyo's full-sized avatar

Ichiru Kiyota kotoripiyopiyo

View GitHub Profile
@kotoripiyopiyo
kotoripiyopiyo / mapIt.py
Created January 24, 2021 13:35
地図検索
#! /usr/bin/env python3
# mapIt.py コマンドラインやクリップボードに指定した住所の地図を開く
import webbrowser, sys, pyperclip, urllib.parse
if len(sys.argv) > 1:
# コマンドラインから住所を取得する
address = ' '.join(sys.argv[1:])
else:
# クリップボードから住所を取得する
@kotoripiyopiyo
kotoripiyopiyo / mailer.py
Created January 24, 2021 13:25
コマンドライン電子メーラー(挫折)
# #!/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 コマンドラインからメアドと本文を受け取る
@kotoripiyopiyo
kotoripiyopiyo / downloadxkcd.py
Created January 24, 2021 13:22
XKCDコミックをひとつずつダウンロードする
#!/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('#'):
# ページをダウンロードする
@kotoripiyopiyo
kotoripiyopiyo / lucky.py
Created January 24, 2021 13:20
Google検索結果をいくつか開く(途中まで)
#!/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()
@kotoripiyopiyo
kotoripiyopiyo / mapIt.py
Created January 6, 2021 13:24
住所を渡すとGoogle mapを表示
#! /usr/bin/env python3
# mapIt.py コマンドラインやクリップボードに指定した住所の地図を開く
import webbrowser, sys, pyperclip, urllib.parse
if len(sys.argv) > 1:
# コマンドラインから住所を取得する
address = ' '.join(sys.argv[1:])
else:
# クリップボードから住所を取得する
@kotoripiyopiyo
kotoripiyopiyo / makenumbering.py
Created December 29, 2020 13:18
連番ファイルを作る
#! python3
# 連番ファイルを作る
import os
# 連番のリストを作る
numbering_files = [f'sample{i:03d}.txt' for i in range(1,21)]
# ディレクトリを作り、基本のパスを決める
os.mkdir('./numbering')
@kotoripiyopiyo
kotoripiyopiyo / numbering.py
Last active December 29, 2020 12:44
フォルダの中で連番が飛んでいる箇所を見つける
#! python3
# 連番ファイルの穴を見つけ、リストアップ
import re, os
# 正規表現を作る
snumber_regex = re.compile(r'^sample(\d{3}).txt')
# 基準パスはここ
path = './numbering'
@kotoripiyopiyo
kotoripiyopiyo / gigafiles
Created December 25, 2020 15:27
ディレクトリツリーを渡り歩き1GB以上のファイルをリストアップする
#! 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))
@kotoripiyopiyo
kotoripiyopiyo / selectedcopy.py
Created December 25, 2020 15:25
pdfとjpgをそれぞれ特定のフォルダにコピーする
#! python3
# ディレクトリツリーを渡り歩き、pdfファイルはpdfsフォルダに、jpgファイルはjpgsフォルダにコピーする
import os, re, shutil
def copies(folder):
# 名前を絶対パスにする
folder = os.path.abspath(folder)
@kotoripiyopiyo
kotoripiyopiyo / renamedate.py
Created December 25, 2020 15:22
ファイル名の米国風日付部分を日本付日付に変える
#! Python3
# renameDates.py 米国式日付MM-DD-YYYYを日本式日付YYYY-MM-DDに書き換える
import shutil
import os
import random
import re
import string
# ランダムな日付や文字列が入ったファイルを大量生成する。不要ならコメントアウト