Skip to content

Instantly share code, notes, and snippets.

@na0x2c6
na0x2c6 / claude-pre_tool_use-hook_webfetch.py
Created August 9, 2025 07:59
Claude Code PreToolUse hook for WebFetch matcher
#!/usr/bin/env python3
import json
import re
import sys
# Define validation rules as a list of (regex pattern, message) tuples
VALIDATION_RULES = [
(
r"https://www.notion.so/",
"Notion ページへのアクセスには WebFetch ツールではなく mcp__notion を利用してください",
@na0x2c6
na0x2c6 / claude-pre_tool_use-hook_grep.py
Last active August 9, 2025 07:44
Claude Code PreToolUse hook for Grep matcher
#!/usr/bin/env python3
import json
import re
import sys
# Define validation rules as a list of (validation function, message) tuples
VALIDATION_RULES = [
(
lambda cmd: True,
"git grep --function-context [--and|--or|--not|(|)|-e <pattern>...] -- <pathspec>... を使ってください。--function-context フラグにより出力行が多すぎる場合、 --show-function と -C フラグを利用してください",
@na0x2c6
na0x2c6 / claude-pre_tool_use-hook_bash.py
Last active August 9, 2025 07:44
Claude Code PreToolUse hook for Bash matcher
#!/usr/bin/env python3
import json
import re
import sys
# Define validation rules as a list of (validation function, message) tuples
VALIDATION_RULES = [
(
lambda cmd: cmd.strip().startswith("grep "),
"grep の変わりに git grep --function-context [--and|--or|--not|(|)|-e <pattern>...] -- <pathspec>... を使ってください。--function-context フラグにより出力行が多すぎる場合、 --show-function と -C フラグを利用してください",
@na0x2c6
na0x2c6 / mic-toggle.applescript
Created May 12, 2021 08:10
Mic mute toggle script on Mac
-- refs: https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/ReadandWriteFiles.html
-- refs: https://medium.com/macoclock/how-in-the-bleep-do-i-mute-my-mic-anywhere-on-macos-d2fa1185b13
on writeTextToFile(theText, theFile, overwriteExistingContent)
try
set theFile to theFile as string
set theOpenedFile to open for access file theFile with write permission
if overwriteExistingContent is true then set eof of theOpenedFile to 0
write theText to theOpenedFile starting at eof
close access theOpenedFile
@na0x2c6
na0x2c6 / Vagrantfile
Last active March 17, 2021 12:16
Vagrantfile to use podman on Mac OS
Vagrant.configure("2") do |config|
# refs: https://app.vagrantup.com/fedora
config.vm.box = "fedora/33-cloud-base"
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
end
# https://www.vagrantup.com/docs/synced-folders/nfs
@na0x2c6
na0x2c6 / tmux.conf
Last active August 28, 2021 04:27
a simple tmux conf
# prefix
set -g prefix C-q
unbind C-b
# keystroke delay
set -sg escape-time 1
# to reload
bind r source-file ~/.tmux.conf \; display "Reloaded!"
@na0x2c6
na0x2c6 / fedora-vim-build.sh
Created February 21, 2021 23:51
Script to build Vim on Fedora
CFLAGS=-fPIC ./configure \
--with-tlib=ncurses \
--with-features=huge \
--with-x \
--enable-multibyte \
--enable-luainterp=dynamic \
--enable-gpm \
--enable-cscope \
--enable-fontset \
--enable-fail-if-missing \
@na0x2c6
na0x2c6 / build.sh
Last active March 4, 2022 06:25
build Vim on OS X (Mac)
./configure \
--prefix=$HOME/local \
--enable-multibyte \
--enable-nls \
--enable-perlinterp \
--enable-pythoninterp=dynamic \
--enable-python3interp=dynamic \
--enable-rubyinterp \
--enable-luainterp --with-lua-prefix=/usr/local \
--enable-cscope \
@na0x2c6
na0x2c6 / zshrc.zsh
Last active June 5, 2021 02:50
part of my zshrc
export EDITOR='vim'
export VISUAL='vim'
export PAGER='less'
# for `Ctrl + w`
export WORDCHARS='*?_.[]~-=&;!#$%^(){}<>'
export DIRSTACKSIZE=8
bindkey -e
setopt clobber
@na0x2c6
na0x2c6 / build.sh
Last active May 3, 2020 02:00
Building vim from the source on Ubuntu 18.04 LTS
sudo apt install \
lua5.2 \
liblua5.2-dev \
luajit \
ruby-dev \
xorg-dev \
libncurses5-dev
./configure \
--with-features=huge \