Skip to content

Instantly share code, notes, and snippets.

View BrambleXu's full-sized avatar

BrambleXu BrambleXu

  • Tokyo
View GitHub Profile
@BrambleXu
BrambleXu / AGENTS.md
Created September 5, 2026 01:37
Reusable coding-agent guidelines for simple, modular, verifiable software development, including Conventional Commits.

AGENTS.md

  • Do not preserve backward compatibility. Remove obsolete paths instead of adding compatibility layers, fallbacks, or migrations.
  • Choose the simplest implementation that fully meets the current requirements. Avoid speculative abstractions, configuration, and indirection.
  • Grow the system in layers. Start from the smallest version that works end to end, and add each new capability on top of a product that already works. Never trade a working product for unfinished complexity.
  • Keep components modular and concerns clearly separated.
  • Prefer established, well-maintained libraries when they reduce overall complexity or improve reliability. Do not reimplement common functionality without a clear reason.
  • Lean on the dependencies already in the project before writing your own implementation or adding packages. Do not assume a library lacks a capability without checking its documentation and types.
  • Make architectural decisions for the long term. Do not accept a stopgap that only works for now an
@BrambleXu
BrambleXu / commit-msg-checker.sh
Last active February 13, 2023 08:18 — forked from umutdz/commit-msg-checker.sh
Add your own custom commit message check into git hooks. The checker control commit messages whether correct according to conventional commit .
#!/usr/bin/env bash
if [ ! -x .git/hooks/commit-msg ] || [ ! -f .git/hooks/commit-msg ] || ! cmp ./hooks/commit-msg.sh .git/hooks/commit-msg
then
echo -e "\033[33m Setting Up Git commit Hook..."
mkdir -p .git/hooks/
cp ./hooks/commit-msg.sh .git/hooks/commit-msg
chmod +x .git/hooks/commit-msg
echo -e "\033[32m Done"
echo -e "\033[33m You can make commit now."
@BrambleXu
BrambleXu / download_zip_file_&unzip.py
Created October 28, 2022 05:34
download zip file and up zip
import os
import tarfile
import urllib.request
from datetime import datetime
import zipfile
data_dir = "./data/"
if not os.path.exists(data_dir):
os.mkdir(data_dir)
@BrambleXu
BrambleXu / History|-1092e9ab|entries.json
Last active October 6, 2022 06:19
Convert jsonl bytes to string
{"version":1,"resource":"file:///Users/smap/Project/seqal/seqal/stoppers/__init__.py","entries":[{"id":"F4pE.py","timestamp":1658194872996}]}
import unicodedata
from typing import List
from pathlib import Path
from collections import defaultdict
from ahocorasick import Automaton
def read_dictionary(dict_path: str) -> dict:
with open(dict_path, 'r', encoding='utf-8') as f:
from typing import List, Dict, Sequence
class Matrics:
def __init__(self, sents_true_labels: Sequence[Sequence[Dict]], sents_pred_labels:Sequence[Sequence[Dict]]):
self.sents_true_labels = sents_true_labels
self.sents_pred_labels = sents_pred_labels
self.types = set(entity['type'] for sent in sents_true_labels for entity in sent)
self.confusion_matrices = {type: {'TP': 0, 'TN': 0, 'FP': 0, 'FN': 0} for type in self.types}
self.scores = {type: {'p': 0, 'r': 0, 'f1': 0} for type in self.types}
"""
pip install torch==1.4.0 torchvision==0.5.0 tensorboard==2.1.0
command:
python tensorboard_epoch_demo.py
tensorboard --logdir=runs
"""
import torch
import torch.nn as nn
@BrambleXu
BrambleXu / tensorboard_demo.py
Created January 18, 2020 02:00
TensorBoard with PyTorch
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torchvision
import torchvision.transforms as transforms
from torch.utils.tensorboard import SummaryWriter
print(torch.__version__)
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
st = {2: 1478515,
3: 449113,
4: 646495,
5: 166796,
@BrambleXu
BrambleXu / github_api_realtime.py
Created November 29, 2019 01:39
Get activity stream by GitHub API
import requests
headers ={
'Authorization': 'token <TOKEN>', # replace <TOKEN> with your token
}
response = requests.get('https://api.github.com/users/<username>/received_events', headers=headers) # replace <username> with your user name
data = response.json()
event_actions = {'WatchEvent': 'starred', 'PushEvent': 'pushed to'}