Skip to content

Instantly share code, notes, and snippets.

View tasuren's full-sized avatar
😇
angel bro

Takagi Tasuku tasuren

😇
angel bro
View GitHub Profile
@tasuren
tasuren / rock-scissors-paper.lisp
Created September 9, 2025 13:29
勉強でCommon Lispでじゃんけんを作ってみたコード。
; じゃんけん
; 仕様:
; 1 Rock (グー)
; 2 Scissors (チョキ)
; 3 Paper (パー)
(setf *random-state* (make-random-state t))
(print "じゃんけんゲーム\n選択肢はグー・チョキ・パーそれぞれ、1から3(半角)です。")
@tasuren
tasuren / keycode_to_char.json
Last active July 5, 2025 09:37
UI Events KeyboardEvent code Valuesに準拠したキーコードと、WindowsやmacOSでのキーの表示上の文字間の簡易的でAIに雑に作らせたJSONマッピング。
{
"Backquote": {
"type": "common",
"char": "`"
},
"Backslash": {
"type": "common",
"char": "\\"
},
"BracketLeft": {
@tasuren
tasuren / dwm_thumbnail_sample.rs
Created July 4, 2025 10:15
指定されたウィンドウのWindowsのDWM APIのサムネイルを表示するだけのRustプログラム。本番用ではなく、個人的なメモ。⚠️
use std::mem::MaybeUninit;
use windows::{
Win32::{
Foundation::*,
Graphics::Dwm::*,
UI::{HiDpi::GetDpiForWindow, WindowsAndMessaging::*},
},
core::*,
};
@tasuren
tasuren / build_ns_toolbar_delegate_class.rs
Created May 23, 2025 10:38
RustのobjcクレートでNSToolbarで使うデリゲートを作る例。
unsafe fn build_ns_toolbar_delegate_class() -> *const Class {
let mut decl = ClassDecl::new("SampleToolbarDelegate", class!(NSObject)).unwrap();
decl.add_protocol(Protocol::get("NSToolbarDelegate").unwrap());
fn get_toolbar_identifier() -> id {
unsafe { NSString::alloc(nil).init_str("SampleToolbarItem") }
}
extern "C" fn toolbar_identifier(_this: &Object, _: Sel, _toolbar: id) -> id {
@tasuren
tasuren / stripe_error-codes_ja.json
Created January 21, 2025 04:30
Stripeのエラーコードをo1に翻訳してもらって、それをJSONにした。(あってる保証なし)
{
"account_closed": "お客様の銀行口座は閉鎖されています。",
"account_country_invalid_address": "指定された事業住所の国がアカウントの国と一致しません。",
"account_error_country_change_requires_additional_steps": "アカウントの国を変更するには追加の手続きが必要です。",
"account_information_mismatch": "アカウント情報の一部に矛盾があります。",
"account_invalid": "指定されたアカウントIDが無効です。",
"account_number_invalid": "口座番号が無効です(桁数不足など)。",
"acss_debit_session_incomplete": "ACSSデビットセッションが完了していません。時間をおいて再試行してください。",
"alipay_upgrade_required": "このAlipay決済方法はサポートされなくなりました。Sourcesを使用するようにアップグレードしてください。",
"amount_too_large": "指定金額が上限を超えています。金額を下げて再度試してください。",
@tasuren
tasuren / discord_voice_client_for_get_endpoint.py
Last active February 19, 2025 12:10
This is the extended voice client of discord.py to get the endpoint without a voice connection.
from __future__ import annotations
__all__ = ("VoiceClientForGetEndpoint",)
from typing import TYPE_CHECKING
import discord
if TYPE_CHECKING:
from discord.types.voice import (
@tasuren
tasuren / r6_nichidai-bunri-i_ao_pre-prg.py
Created November 6, 2023 00:13
令和六年度における日本大学の文理学部の情報科学科の総合型選抜の事前公開プログラムの改良版。受験時、これをテンプレートとして実際に使った。
# 元のプログラム:https://web.archive.org/web/20231105011711/https%3A%2F%2Fdept.chs.nihon-u.ac.jp%2Fwp-content%2Fuploads%2Finformation_science%2F9cb5143e5ee68a9f9a519b578ca6cd76.pdf
# クラスで抽象化したりリストではなくビット演算で近傍を表現したりと改造した。画面の拡大縮小や移動もできる。
from time import time
def get_neighborhood(width_, state, x):
"""指定された幅と状態そして位置から、近傍(三ビット分の整数)を取得します。
もし端のセルで一ビット足りない状態となったのなら、足りないビットは0にします。"""
# 端を切り取っても三ビット分になるように調整を施す。
@tasuren
tasuren / r5_nichidai-bunri-i_ao_pre-prg.py
Last active November 6, 2023 00:22
令和五年度における日本大学文理学部情報科学科の総合型選抜の事前公開プログラムの改良版。本番を想定して作った。
# 元のプログラム:https://web.archive.org/web/20230328052646/https://dept.chs.nihon-u.ac.jp/wp-content/uploads/information_science/27bb9764f6d3d05585e766a110f748ec.pdf
# 確か、クラスで抽象化したりした。なお、実際に自分が受験したのはこれの次。
GRAVITY = 9.8
COEFFICIENT_OF_RESTITUTION = 0.8
FRICTION = 0.9
BALL_NUMBER = 5
BALL_SIZE = 30
@tasuren
tasuren / mac_simple_count_app.rs
Created June 25, 2023 00:54
Mac用のシンプルなカウントアプリ。Rustのライブラリcacaoの概要把握のために作ったもの。
use cacao::{
appkit::{ App, AppDelegate, window::Window }, notification_center::Dispatcher,
view::{ View, ViewDelegate }, layout::{ Layout, LayoutConstraint },
button::Button, text::Label
};
enum ButtonType { Count, Reset }
type TypedApp = App<CountApp, ButtonType>;
@tasuren
tasuren / psd_drawer.rs
Created June 24, 2023 02:23
PSDファイルをlibuiで描写するためのコード。勉強がてらやってみた。ちゃんとリサイズに対応させていないため、実用的ではない。
use psd::Psd;
use libui::{
controls::{ Area, AreaHandler, AreaDrawParams },
draw::{ Path, FillMode, Brush, SolidBrush }
};
use itertools::Itertools;