Skip to content

Instantly share code, notes, and snippets.

View demitas1's full-sized avatar

DEMI demitas1

View GitHub Profile
@demitas1
demitas1 / wezterm_start_work.sh
Created October 26, 2025 06:36
wezterm: setup new tab and split panes
#!/bin/bash
setup_new_tab_2L_1R() {
# Open new tab (= pane 1)
PANE1_ID=$(wezterm cli spawn)
# Split pane 1 horizontally to generate pane 2
PANE2_ID=$(wezterm cli split-pane --pane-id $PANE1_ID --horizontal --percent 60)
# Split pane 1 vertically to generate pane 3
@demitas1
demitas1 / git_tree.py
Created October 20, 2025 00:02
tree only git files
#!/usr/bin/env python3
import subprocess
import argparse
from pathlib import Path
# 無視するディレクトリ
IGNORE_DIRS = {"venv", "node_modules", "__pycache__", ".git"}
# ANSIカラー
COLOR_DIR = "\033[34m" # 青
@demitas1
demitas1 / wezterm_split_2_and_1.sh
Created September 24, 2025 01:16
Wezterm: new tab with three panes split
#!/bin/bash
PROJECT_DIR=$HOME/work
# Open new tab (= pane 1)
PANE1_ID=$(wezterm cli spawn)
# Split pane 1 horizontally to generate pane 2
PANE2_ID=$(wezterm cli split-pane --pane-id $PANE1_ID --horizontal --percent 60)
@demitas1
demitas1 / cleanblank.sh
Created July 22, 2025 05:41
Clean blank space
#!/bin/bash
# ソースコードから空白のみの行を改行のみに変換し、行末の空白を削除するスクリプト
# 使用方法: ./noblank.sh [ファイル名またはパターン]
# 引数が指定されていない場合のデフォルト
FILES="${1:-*.py}"
echo "Processing Python files: $FILES"
@demitas1
demitas1 / update-frontmatter.sh
Created February 27, 2025 01:37
Update frontmatter date field
#!/bin/bash
# ヘルプメッセージ
show_help() {
echo "使用方法: $0 [オプション] <ファイルパスまたはディレクトリパス>"
echo "オプション:"
echo " -n プレビューモード(実際の変更は行わない)"
echo " -h このヘルプメッセージを表示"
echo ""
echo "ファイルパスまたはディレクトリパスは必須です。"
@demitas1
demitas1 / git-catfiles.sh
Last active December 28, 2024 02:14
List repository files
#!/bin/bash
# List of files to skip
skip_files=(
".gitignore"
"package-lock.json"
"yarn.lock"
"README.md"
"LICENSE.txt"
"gpl*.txt"
@demitas1
demitas1 / ffmpeg-screenshot.py
Created November 5, 2024 05:33
python script to take screenshot periodically
import subprocess
from datetime import datetime
import time
import os
import sys
def take_screenshot(save_dir='screenshots'):
# 保存ディレクトリが存在しない場合は作成
if not os.path.exists(save_dir):
os.makedirs(save_dir)
@demitas1
demitas1 / start-browser.sh
Created November 4, 2024 08:00
bash script: wait for server ready, and then open URL by browser
#!/bin/bash
until curl -s http://localhost:8188 >/dev/null; do
echo "Waiting for server..."
sleep 2
done
echo "Server is ready!"
brave-browser "http://localhost:8188"
@demitas1
demitas1 / ipadic-dl.sh
Created April 21, 2024 00:02
IPA辞書をダウンロードしてutf8に変換
#!/bin/bash
# mecab ipadicをダウンロードし、辞書元のcsvファイルをutf8に変換する
# mecab ipadicのダウンロード
curl -LJO "https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7MWVlSDBCSXZMTXM"
# 解凍
tar_file=$(find . -name "mecab*.tar.gz")
tar zxvf $tar_file
@demitas1
demitas1 / get_pc_status.py
Created February 18, 2024 11:02
Get CPU and GPU status
from subprocess import Popen, PIPE
import re
# check command availabity by using 'command -v'
# $ commnad -v <command>
def check_command_available(command_name):
# Run the command -v to check if the command is available
process = Popen(f'command -v {command_name}', shell=True, stdout=PIPE, stderr=PIPE)
out, err = process.communicate()