Skip to content

Instantly share code, notes, and snippets.

View tos-kamiya's full-sized avatar
:octocat:
one by one

Toshihiro Kamiya tos-kamiya

:octocat:
one by one
View GitHub Profile
@tos-kamiya
tos-kamiya / update-vscode-extensions
Last active March 30, 2023 03:34
cli tool to update vscode extensions
#!/usr/bin/env bash
# Temporary files for storing the list of extensions
tempfile1=$(mktemp)
tempfile2=$(mktemp)
# Save versions of extensions before the extension update process
code --list-extensions --show-versions > "$tempfile1"
# Print a message to indicate that the extension update process starts
@tos-kamiya
tos-kamiya / markthem
Created February 14, 2023 08:44
Search and mark strings
#!/usr/bin/env python3
from typing import Iterator, List, Optional, Tuple
import re
import sys
CIRCLED_NUMBERS = [
# 0
@tos-kamiya
tos-kamiya / convert-doc-to-docx.py
Created January 10, 2023 02:54
Convert old-format MS Office files (.doc, .xls) into newer format (.docx, .xlsx)
# ref: https://stackoverflow.com/questions/66781927/doc-to-docx-conversion-in-python
from glob import glob
import os
import win32com.client as win32
from win32com.client import constants
def save_as_docx(path):
word = win32.gencache.EnsureDispatch('Word.Application')
doc = word.Documents.Open(path)
@tos-kamiya
tos-kamiya / Ubuntu 22.04 に Alacritty ターミナルを導入しよう 2022.11.07.md
Last active November 8, 2022 05:16
Ubuntu 22.04 に Alacritty ターミナルを導入しよう 2022.11.07

Ubuntu 22.04 に Alacritty ターミナルを導入しよう 2022.11.07

インストール

UbuntuでAlacrittyを利用する場合、現状では フォントサイズの設定の設定に難がある ため、方法2を推奨

方法1: snapでインストール

sudo snap install alacritty --classic
@tos-kamiya
tos-kamiya / to_moodle_html.py
Last active October 17, 2022 06:46
コードブロックやテーブルを含むMarkdown文書を装飾をそれなりに残しつつMoodleのエディタに貼り付けるためのスクリプト(手抜き版)
#!/usr/bin/env python3
import sys
from bs4 import BeautifulSoup
from markdown import markdown
from docopt import docopt
__doc__ = '''Convert markdown to Moodle-ish html
@tos-kamiya
tos-kamiya / imo.py
Last active September 27, 2022 09:18
A command-line interactive transcription tool using whisper
I moved it to https://github.com/tos-kamiya/imo/tree/main
because I thought it needed manuals, such as some dependencies that cannot be installed with pip.
@tos-kamiya
tos-kamiya / win_wildcard.py
Last active September 10, 2022 17:26
Expanding wildcards in shells of Windows using the dir or the ls commands
# **DEPLICATED** the updated version is available at https://github.com/tos-kamiya/win_wildcard
# ref: https://stackoverflow.com/questions/55597797/detect-whether-current-shell-is-powershell-in-python
from typing import List, Optional
import locale
import os
import psutil
import re
import subprocess
@tos-kamiya
tos-kamiya / justpy_with_browser.py
Created July 13, 2022 00:46
A web-gui app implementation with justpy and pyqt5
import sys
import threading
# requirements: pyqt5, justpy
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import QWebEngineView
import justpy
@tos-kamiya
tos-kamiya / show_time_prompt.fish
Last active March 21, 2022 16:01
show execution time of commands and git branch, fish shell
function fish_prompt
# show execution time
set hh (math -s0 "$CMD_DURATION / 3600000")
set mm (math -s0 "$CMD_DURATION % 3600000 / 60000")
set ss (math -s0 "$CMD_DURATION % 60000 / 1000")
set ms (math -s3 "$CMD_DURATION / 1000")
set t ""
if [ $hh -gt 0 ]
set t "$t$hh""h "
@tos-kamiya
tos-kamiya / Initialize_attributes_with_keyword_arguments_test.py
Last active December 17, 2021 11:43
Initialize attributes with keyword arguments (license: Public Domain https://creativecommons.org/publicdomain/zero/1.0/deed)
# a revised and unit-tested version has been published at https://github.com/tos-kamiya/init_attrs_with_kwargs
from typing import get_type_hints
from enum import Enum
class InitAttrsWKwArgs:
@staticmethod
def _convert_option_name_to_attr_name(name: str) -> str:
if name.startswith('--'):