Skip to content

Instantly share code, notes, and snippets.

View takahirom's full-sized avatar

Takahiro Menju takahirom

View GitHub Profile
@takahirom
takahirom / commit-graph-figures.md
Created August 7, 2026 10:18
commit-graph-figures-SKILL.md
name commit-graph-figures
description Draw commit-graph comparison figures (hand-written SVG in HTML) for articles, PR descriptions, and docs. Use when the user wants a git graph diagram showing which two commits/refs get compared (baselines, merge refs, fork points), wants multi-panel figures of the same graph with different comparisons highlighted, or asks to visualize CI/merge-ref behavior.

Commit-graph comparison figures

One topology, many panels. The graph (commits, branches, synthetic merge commits) is defined once as data; each panel re-renders that identical topology and varies only its spotlight — which pair is compared, what is dimmed — and its verdict. Readers keep a single mental model across panels; hand-drawing any panel separately breaks that and is the primary failure to avoid.

Steps

@takahirom
takahirom / branch
Last active June 19, 2025 07:44
my stacked pr workflow
#!/bin/bash
if [[ $# == 0 ]]; then
git branch --sort=-committerdate
else
name=$(echo "$*" | \
iconv -f UTF-8 -t ASCII//TRANSLIT | \
tr '[:upper:]' '[:lower:]' | \
sed -E 's/[^a-zA-Z0-9]+/-/g; s/^-+//; s/-+$//; s/^-+//')
git checkout -b "tm/${name}/$(date +%Y-%m-%d)"
@takahirom
takahirom / SingleSourceStateFlow.kt
Last active January 30, 2025 07:47
Solution for the "Combined StateFlow getValue Not Updated" Problem https://pl.kotl.in/eEOTmPYEI
/**
Copyright 2025 takahirom
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@takahirom
takahirom / calc_softmax.py
Created November 9, 2024 13:23
Softmax calculation in Python in Japanese
import torch
from transformers import top_k_top_p_filtering
logits = torch.tensor([2.0, 1.8, 1.5, 1.0, 0.5])
words = ["頑張る", "成長する", "学ぶ", "健康", "新しい"]
def get_probabilities_hf(temperature, k=None, p=None):
scaled_scores = logits / temperature
# kとpがNoneの場合、デフォルト値を設定
@takahirom
takahirom / ja_softmax.kt
Created November 9, 2024 13:21
Softmax calculation in Kotlin in Japanese
val logits = arrayOf(2.0, 1.8, 1.5, 1.0, 0.5)
val words = arrayOf("頑張る", "成長する", "学ぶ", "健康", "新しい")
fun getProbabilitiesHf(temperature: Double, k: Int? = null, p: Double? = null) {
val defaultK = k ?: 0 // kがnullの場合は0(フィルタリングなし)
val defaultP = p ?: 1.0 // pがnullの場合は1.0(フィルタリングなし)
// スコアを温度でスケーリング
val scaledScores = logits.map { it / temperature }.toDoubleArray()
println("scaledScores:" + scaledScores.joinToString())
# You will need to take full responsibility for your action.
# only once
brew install mitmproxy
ifconfig|grep 192.168 |awk '{print $2}'|xargs -IIPADDRESS adb shell settings put global http_proxy IPADDRESS:8083
mitmweb -p 8083
adb shell am start -a android.intent.action.VIEW -d "http://mitm.it"
# download and install pem
# each time you want to do mitm
@takahirom
takahirom / OneOffEventForSnackbar.kt
Created June 2, 2022 23:41
One-off event for snackbar message
// ---- User side (Write every time) ----
val scaffoldState = rememberScaffoldState()
val viewModel = hiltViewModel<FooViewModel>()
SnackbarMessageEffect(
scaffoldState = scaffoldState,
messageStateHolder = viewModel
)
Scaffold(scaffoldState = scaffoldState) {
...
// ----UI Layer----
// -UI Layer(UI element)-
@AndroidEntryPoint
class ArticlesActivity : AppCompatActivity() {
// UI 1. ✅ You shouldn't store or keep in memory any application
// data or state in your app components
lateinit var binding: ActivityArticlesBinding
private val articlesViewModel by viewModels<ArticlesViewModel>()
@Stable
data class UiModel(val articles: Articles)
@Composable
fun Composable2(uiModel: UiModel) {
Text(text = "Hello $uiModel!")
}
data class Articles(val articles: List<Article>)
data class Article(val title: String)