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 / Ubuntu 24.04, VSCode, フォントをモノクロのアンチエリアスを設定する設定.md
Created September 23, 2024 12:21
Ubuntu 24.04, VSCode, フォントをモノクロのアンチエリアスを設定する設定

VSCodeでアンチエイリアスをRGBではなくモノクロに設定するためには、rgbaの設定をnoneに変更する必要があります。rgbaは通常、サブピクセルレンダリングの設定を制御し、rgbbgrなどで赤・緑・青のサブピクセルを使ったアンチエイリアスを行いますが、モノクロに設定したい場合は、それをnoneにします。

以下がその設定例です:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="font">
 
@tos-kamiya
tos-kamiya / json-rpc-test.py
Created September 22, 2024 06:36
json-rpc with flask backend test
"""
python3 -m venv venv; venv/bin/pip install wheel
venv/bin/pip install json-rpc
venv/bin/pip install flask
"""
from flask import Flask
from jsonrpc.backend.flask import api
@tos-kamiya
tos-kamiya / timeg
Created September 15, 2024 18:26
A script to monitor CPU/GPU RAM usage of a command on NVIDIA systems, with process search by keyword and JSON support.
#!/usr/bin/env python3
import argparse
import json
import os
import subprocess
import sys
import time
from typing import List, Tuple, Dict
@tos-kamiya
tos-kamiya / ollama-unload
Created September 14, 2024 16:04
A script to immediately free up VRAM used by ollama services.
#!/bin/bash
# The default ollama server address
OLLAMA_URL="http://localhost:11434"
# Help function
show_help() {
echo "Usage: $0 [OPTIONS] [URL]"
echo "Unload all loaded models in ollama."
echo ""
@tos-kamiya
tos-kamiya / trans
Last active September 4, 2024 04:21
A simple text translator script
#!/bin/bash
# Function to display help message
function show_help() {
echo "Usage: $0 <language_code> [-p] <text_file_or_text>"
echo
echo "Arguments:"
echo " <language_code> The target language code (e.g., 'en' for English, 'ja' for Japanese)."
echo " <text_file_or_text> The path to the text file to be translated, or the text itself if -p is used. Use '-' to read from stdin."
echo
@tos-kamiya
tos-kamiya / git-status-summary.py
Created June 2, 2024 22:13
VSCode like Git status viewer
#!/usr/bin/env python3
from typing import List, Iterable, Iterator, Tuple
import subprocess
import sys
def colorize(text: str, color: str) -> str:
"""
Colorize the text for terminal output.
@tos-kamiya
tos-kamiya / flexcomm.py
Last active March 25, 2024 19:21
flexcomm: flexible comm utility, handle three or more files with use-specified predicates.
import argparse
import ast
import sys
from typing import List, TextIO, Optional
def get_variables(expr: str) -> List[str]:
"""
Given an expression, return a sorted list of variable names used in the expression.
@tos-kamiya
tos-kamiya / csv_to_latex.py
Created December 24, 2023 06:59
Convert CSV file to LaTeX table
#!/usr/bin/env python3
import argparse
import sys
import os
import pandas as pd
def csv_to_latex(input_file, output_file = None):
# Read csv file
@tos-kamiya
tos-kamiya / ai-howdoi
Last active September 2, 2024 15:22
howdoi command with leverage of Phind-CodeLlama
#!/usr/bin/env python3
# ref: https://stackoverflow.com/questions/2804543/read-subprocess-stdout-line-by-line#2813530
import io
import os
import subprocess
import sys
from pygments import highlight
@tos-kamiya
tos-kamiya / lang_ext_counter.py
Created November 19, 2023 16:14
A tool for aggregating file extensions and languages in a directory, compatible with the tokei project (https://github.com/XAMPPRocky/tokei).
# The languages.json is obtained from the tokei project
# Source: https://github.com/XAMPPRocky/tokei/blob/c8e4d0703252c87b1df45382b365c6bb00769dbe/languages.json
from typing import Dict, Counter as CounterType
from collections import Counter
import json
import os
import sys