Skip to content

Instantly share code, notes, and snippets.

View kouichi-c-nakamura's full-sized avatar

Kouichi C. Nakamura kouichi-c-nakamura

View GitHub Profile
@kouichi-c-nakamura
kouichi-c-nakamura / .gitignore
Created January 30, 2026 02:52
.gitignore template for Python
# Python Bytecode
__pycache__/
*.py[cod]
*$py.class
# Jupyter Notebook
.ipynb_checkpoints
# VS Code settings
.vscode/
@kouichi-c-nakamura
kouichi-c-nakamura / import_openslide_.py
Created January 29, 2026 14:22
openslide for Windows
# --- OpenSlide Setup for Windows ---
openslide_bin_path = r'C:\Users\*****\*****\openslide-bin-4.0.0.11-windows-x64\bin'
if os.name == 'nt' and os.path.exists(openslide_bin_path):
if hasattr(os, 'add_dll_directory'):
try:
os.add_dll_directory(openslide_bin_path)
except Exception as e:
print(f"Warning: Failed to add DLL directory: {e}")
@kouichi-c-nakamura
kouichi-c-nakamura / autoreload.py
Created January 27, 2026 05:14
Use this in Jupyter notebook to automatically reload imported modules
%load_ext autoreload
%autoreload 2
@kouichi-c-nakamura
kouichi-c-nakamura / tree_folders.py
Last active January 29, 2026 06:27
Modified from https://stackoverflow.com/questions/9727673/list-directory-tree-structure-in-python This version supports suppression of file names, just printing folder structure by option
# Source - https://stackoverflow.com/a/59109706
# Posted by Aaron Hall, modified by community.
# Modified by Assistant to include dirs_only, limit_to_depth, and exclude_hidden options.
# Retrieved 2026-01-26, License - CC BY-SA 4.0
from pathlib import Path
# prefix components:
space = ' '
branch = '│ '
@kouichi-c-nakamura
kouichi-c-nakamura / import_git_repo.md
Created January 8, 2026 00:16
学習用にrepoをPrivateにインポート。Cloneでは自分の変更をpushできない。Forkだと、元がPublicのときPublicになってしまう。
  1. + on top > Import repository
  2. The URL for your source repository*: https://github.com/owner_name/repo_name.git
  3. Your new repository details: Owner + Repo_Name
  4. Make Private
  5. Begin Import
  6. Clone
@kouichi-c-nakamura
kouichi-c-nakamura / private_copy_repo.bash
Created January 7, 2026 23:38
学習用に履歴を捨ててrepoのprivateコピーを作る
# 1. 元のリポジトリを普通にクローン
git clone https://github.com/author/original-repo.git
# 2. フォルダに入る
cd original-repo
# 3. 過去の履歴(.gitフォルダ)を完全に削除(これでただのファイルの束になる)
rm -rf .git # Windowsなら rmdir /s /q .git
# 4. 新しいGitリポジトリとして初期化
@kouichi-c-nakamura
kouichi-c-nakamura / python_venv_setup.sh
Created December 14, 2025 12:54
Python virtualenv set up
# ----------------------------------------------------
# Python 仮想環境 (Virtual Environment) セットアップ手順
# ----------------------------------------------------
# 1. virtualenv が未インストールの場合はインストール
# (多くの場合、Pythonに標準搭載されている venv モジュールで代替可能ですが、
# 互換性のために必要な場合は実行してください)
# pip install virtualenv
# 2. 新しい仮想環境を作成 (フォルダ名は 'venv')
@kouichi-c-nakamura
kouichi-c-nakamura / lock_screen.scpt
Created December 17, 2024 14:01
AppleScript to set a timer to lock the screen of a Mac
-- Prompt user to enter the delay time in minutes
display dialog "停止までの時間を分単位で入力してください:" default answer "30"
set delayMinutes to text returned of result as integer
-- Convert minutes to seconds and wait
set delaySeconds to delayMinutes * 60
delay delaySeconds
-- Show a notification when the music starts playing
display notification "もうすぐ時間です"
@kouichi-c-nakamura
kouichi-c-nakamura / activateHyperlinks.vba
Last active October 10, 2022 17:52
Taken from this site https://www.extendoffice.com/documents/excel/4321-excel-activate-hyperlinks.html with a modification (`xTitleId` had to be declared in advance). Copy this into a Module in VBA editor. Make a selection of a range on a spreadsheet. And then press F5.
@kouichi-c-nakamura
kouichi-c-nakamura / CEDS64ChanList.m
Last active June 12, 2019 11:21
CEDS64ChanList MATLAB function returns a table of channels in the Spike2 data file specified by a handle fhand.
function T = CEDS64ChanList(fhand)
% CEDS64ChanList returns a table of channels in the Spike2 data file
% specified by a handle fhand.
%
% SYNTAX
% T = CEDS64ChanList(fhand)
%
%
% INPUT ARGUMENTS
% fhand integer