Skip to content

Instantly share code, notes, and snippets.

@thuwyh
thuwyh / settings-shared.json
Created March 20, 2026 01:44
Claude Code settings.json (sanitized)
{
"permissions": {
"allow": [
"Read",
"Glob",
"Grep",
"Bash(curl:*)",
"Bash(python3:*)",
"Bash(python:*)",
"Bash(python -c:*)",
@thuwyh
thuwyh / approve_readonly_bash.py
Created March 16, 2026 03:11
Claude Code PreToolUse hook: auto-approve read-only Bash commands
#!/usr/bin/env python3
"""Claude Code PreToolUse hook: auto-approve read-only Bash commands.
Deny-first, then allowlist. Unknown commands fall through to user prompt.
Returns JSON with permissionDecision and reason for better diagnostics.
"""
import json
import re
import sys
@thuwyh
thuwyh / .py
Last active June 2, 2020 01:13
fgm
# FGM class
class FGM():
def __init__(self, model):
self.model = model
self.backup = {}
def attack(self, epsilon=1., emb_name='word_embeddings'):
for name, param in self.model.named_parameters():
if param.requires_grad and emb_name in name:
self.backup[name] = param.data.clone()