Skip to content

Instantly share code, notes, and snippets.

View koteitan's full-sized avatar

koteitan koteitan

View GitHub Profile
@koteitan
koteitan / find-twin.js
Last active August 9, 2025 02:03
find twin of nostr nsec
#!/usr/bin/env node
import { nip19, getPublicKey } from 'nostr-tools'
// secp256k1 curve order
const n = 115792089237316195423570985008687907852837564279074904382605163141518161494337n
// Get nsec from command line argument
const input_nsec = process.argv[2]
// Check arguments
@koteitan
koteitan / nsec-pair-gen.js
Last active August 8, 2025 15:21
Genrates a pair of secret keys that share the same public key
import { nip19, getPublicKey } from 'nostr-tools'
import crypto from 'crypto'
// secp256k1の位数
const n = 115792089237316195423570985008687907852837564279074904382605163141518161494337n
// シードから秘密鍵ペアを生成
function generatePair(seed) {
// シードをSHA256でハッシュ化して32バイトの値を作る
const hash = crypto.createHash('sha256').update(seed).digest()
@koteitan
koteitan / chargraph.py
Created July 27, 2025 16:18
draw a number-of-char-graph of your repository into charcount.png
import subprocess
import os
import csv
import shutil
from datetime import datetime
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
# Save current branch name
@koteitan
koteitan / deploy-submodule
Last active September 25, 2025 14:16
add, commit and push the submodule's update
#!/bin/bash
# Find the root of the git repository
git_root=$(git rev-parse --show-toplevel 2>/dev/null)
if [ $? -ne 0 ]; then
echo "Error: Not in a git repository"
exit 1
fi
# Check if we're in a submodule
@koteitan
koteitan / blind-oracle-and-Jade.pu
Last active April 29, 2025 21:51
Blind Oracle と Jade が PIN を守る仕組みの PlantUML を書きたい
' 正しいかは分かりませんが…
' References:
' https://github.com/Blockstream/Jade/blob/master/main/process/pinclient.c
' https://github.com/Blockstream/blind_pin_server
' https://help.blockstream.com/hc/en-us/articles/9639949755673-How-does-Blockstream-Jade-s-oracle-enforced-PIN-protection-work
' https://help.blockstream.com/hc/en-us/articles/15884462476953-Blockstream-Jade-Security-Model-FAQs
@startuml
participant "ユーザー" as U
participant "Jade\n(ハードウェアウォレット)" as HW
@koteitan
koteitan / .bashrc
Created December 15, 2024 04:02
cd with history
# sudo apt install fzf
export DIR_HIST_FILE="$HOME/.dir_history"
function d {
if [[ ! -f "$DIR_HIST_FILE" ]]; then
touch "$DIR_HIST_FILE"
fi
if [[ -z "$1" ]]; then
selected=$(tac "$DIR_HIST_FILE" | fzf --height 40% --reverse --prompt="Select directory: ")
@koteitan
koteitan / .bashrc
Last active December 15, 2024 04:03
waitdeploy - to wait deploying of github pages
# sudo apt install wslu
# install and login to gh https://docs.github.com/github-cli/github-cli/about-github-cli
alias waitdeploy='wslview $(gh run list --repo koteitan/koteitan.github.io --limit 1 --json url -q ".[0].url")'
@koteitan
koteitan / myeyes.c
Created December 3, 2024 14:50
pseudo xeyes
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
// 瞳の座標を計算する関数
void calculate_pupil_position(int eye_x, int eye_y, int eye_radius, int mouse_x, int mouse_y, int *pupil_x, int *pupil_y) {
double dx = mouse_x - eye_x;
double dy = mouse_y - eye_y;
double distance = sqrt(dx * dx + dy * dy);
@koteitan
koteitan / custom-vim-make
Last active September 3, 2024 18:45
:Make
function! SilentMake()
write
cclose
let l:make_output = system('make')
if v:shell_error != 0
cgetexpr l:make_output
cwindow
wincmd p
#!/bin/bash
# OpenAI APIキーを環境変数から取得
API_KEY="$OPENAI_API_KEY"
# APIキーが設定されているか確認
if [ -z "$API_KEY" ]; then
echo "Error: OPENAI_API_KEY is not set. Please set your OpenAI API key."
exit 1
fi