Skip to content

Instantly share code, notes, and snippets.

View TakamiChie's full-sized avatar
:octocat:

高見知英 TakamiChie

:octocat:
View GitHub Profile
@TakamiChie
TakamiChie / ListupFileSize.ps1
Created June 7, 2022 16:19
特定フォルダ配下各フォルダのファイル数・サイズを集計表示しトップ20を表示するスクリプト
<#
元ネタは→PowerShellを使ってサイズの大きいフォルダを検出する / 開発者向けブログ・イベント | GMO Developers https://developers.gmo.jp/2035/
上記スクリプトからの主な変更点は
・コンソールに直接貼り付けで動くようにした(なのでルートフォルダはカレントフォルダに変更)
・ファイルのフルパスではなくファイル名を表示するようにした
・フォルダ内のファイル総数を表示するようにした
以上の3点。
#>
$RootFolder = "."
@TakamiChie
TakamiChie / digest.py
Created January 31, 2022 14:43
Markdown形式の日記ファイルから日付を指定してダイジェストを作るやつ
# python .\digest.py -s 2022/01 -e 2022/01 -o 202201digest.md -> 2022年1月のダイジェストを作る。
from datetime import datetime
from datetime import timedelta
from argparse import ArgumentParser
import calendar
import sys
p = ArgumentParser()
p.add_argument("-s", "--start_date", type=lambda s: datetime.strptime(s, "%Y/%m"), required=True, help="開始月。yyyy/mm形式の年月")
p.add_argument("-e", "--end_date", type=lambda s: datetime.strptime(s, "%Y/%m"), required=True, help="終了月。yyyy/mm形式の年月")
@TakamiChie
TakamiChie / main.gs
Created January 15, 2022 06:42
YouTube playlist auto-configuration tool
/**
* # Usage
* 1. start a new Google Apps Script project and paste this code into the script area.
* 2. After saving, set the `main()` function to be executed automatically.
* # Operation
* 1. Create a playlist.
* 2. Set the title of the video you want to add to the playlist as "Playlist Name:Video Title"(Colons can be full-size or half-size).
*/
function main() {
// Get the necessary items (own channel object, playlist list, video list).
@TakamiChie
TakamiChie / PassGen.ps1
Created January 13, 2022 06:08
Simple Password Generator
# PassGen -> Output 8-character password
# PassGen 10 -> Output a 10-character password.
# PassGen 10 $false -> Do not include symbols.
# PassGen 10 $false $false -> Do not include symbols and numbers.
# PassGen 10 $true $false $false -> Symbols only (setting all to false will of course result in an error)
# The maximum length of the password that can be output is 93 characters.
# Useful Usage).
# PassGen | clip -> Copy the generated password directly to the clipboard
# Write a function in WindowsPowerShell\Microsoft.PowerShell_profile.ps1(PowerShell folder for PowerShell 7.x) -> You can use the PassGen command at any time.
@TakamiChie
TakamiChie / 0001prepare.bat
Created September 15, 2021 09:36
standfm_bgm, standfm_photoを使って、複数の音声ファイルにBGMをつける
rem あらかじめstandfm_bgm, standfm_photoのリポジトリは、ドキュメント\Github\にクローンしてあるものとする
@echo off
prompt $G$G$S
@echo on
cd %USERPROFILE%\Documents\Github\standfm_photo
pipenv run title.py %*
cd %USERPROFILE%\Documents\Github\standfm_bgm
pipenv run main.py %*
echo Complete
@TakamiChie
TakamiChie / chocolateyxml.py
Created June 13, 2021 14:41
choco list --localonlyから一括処理用のXMLファイルを作る
import sys
print("""<?xml version="1.0" encoding="utf-8"?>
<packages>""")
for line in sys.stdin:
l = line.strip().split(" ")
if l[1] != "packages":
print(f' <package id="{l[0]}" version="{l[1]}" />')
print("</packages>")
@TakamiChie
TakamiChie / mp3tomp4.bat
Last active April 30, 2021 08:21
画像と音声を結合する
@echo off
rem パスの通ったフォルダにファイルを置いておくと、`mp3tomp4 abc.mp3 abc.png`みたいな感じでコマンドを呼べる。デスクトップにabc.mp4が生成される。
set %FILES=
rem Create file args
if "%~2"=="" (
echo Drop two or more files.
pause
exit /b
)
@TakamiChie
TakamiChie / createfolders.ps1
Created January 7, 2021 13:28
カレントフォルダに1~12月のフォルダを作成する
# プロンプトにコピペする
foreach($n in 1..12){New-Item "${n}月" -ItemType Directory}
@TakamiChie
TakamiChie / testpdf_creator.py
Created December 8, 2020 16:20
任意のページサイズ、ページ数のPDFファイルを作成する。
# ReportLab, PyPDF2, TQDMは事前にpipでインストールしておいてください。
import random
import sys
import os
from pathlib import Path
from argparse import ArgumentParser
from tqdm import tqdm
from PyPDF2 import PdfFileReader, PdfFileWriter
from reportlab.pdfgen import canvas
@TakamiChie
TakamiChie / copytool.py
Last active October 19, 2020 14:47
ヨドバシドットコム購入明細メールの商品一覧から商品名と価格を抜き出す
import re
import pyperclip
import sys
from time import sleep
n = []
p = []
text = pyperclip.paste()
for m in re.finditer(r"「([^」]*)」", text, re.MULTILINE):
n.append(re.sub(r"\n\s*", "", m[1]))
for m in re.finditer(r"([\d,]+)\s*円", text, re.MULTILINE):