Skip to content

Instantly share code, notes, and snippets.

View kuboon's full-sized avatar
๐Ÿ 
Working from home

Ohkubo KOHEI kuboon

๐Ÿ 
Working from home
View GitHub Profile
@kuboon
kuboon / trait.ts
Created May 7, 2026 06:06
trait & impl for typescript
type ImplType<I, M, O> = I & ThisType<I & M & {owner: O}>
type ImplFor<X, O = never> = <I, M = X>(trait: ImplType<I, M, O>) => (model: M, owner?: O) => I & M & {owner: O}
// simple but slow
const MutableImpl = <I, M, O>(trait: ImplType<I, M, O>) =>
(model: M, owner?: O) =>
Object.setPrototypeOf(model, Object.assign(trait, {owner}))
// better performance
const CopyImpl = <I, M extends Record<string, unknown>, O>(impl: ImplType<I, M, O>) => (model: M, owner?: O) => {
@kuboon
kuboon / SKILL.md
Created April 1, 2026 23:01
deno/SKILL.md skill deno
@kuboon
kuboon / cryptid-sample.ts
Created March 30, 2026 22:37
cryptid.ts
import CryptID from "https://esm.sh/@cryptid/cryptid-js/lib/node/js/index.js";
(async function main() {
const instance = await CryptID.getInstance();
const setupResult = instance.setup(CryptID.SecurityLevel.LOWEST);
if (!setupResult.success) {
console.log('Failed to setup :(');
return;
@kuboon
kuboon / .remix-component.SKILL.md
Last active February 5, 2026 01:34
remix-component/SKILL.md skill remix component

usage of @remix-run/component

updated_at: 2026-02-05 00:00 +09:00 gist

@kuboon
kuboon / .gist-skills.SKILL.md
Last active April 1, 2026 21:40
gist-skills/SKILL.md skill claude

How to save & load skills from my gist

updated_at: 2026-02-04 13:26 +09:00 gist

@kuboon
kuboon / .remix-interaction.SKILL.md
Last active February 4, 2026 00:16
remix-interaction/SKILL.md remix frontend

usage of @remix-run/interaction

@kuboon
kuboon / deno_cache_fetch-stdio-mcp.ts
Created December 23, 2025 12:07
Local stdio mcp server to get local cache by url from DENO_DIR
import { createCache } from "jsr:@deno/cache-dir";
import { McpServer } from "npm:@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "npm:@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "npm:zod";
const { load } = createCache();
function isUint8Array(arg: string | Uint8Array): arg is Uint8Array {
return arg.constructor === Uint8Array;
}
@kuboon
kuboon / loop_detect.rb
Created September 8, 2025 04:13
ๅฑฑๆ‰‹็ทšใ‚’ๆ–‡ๅญ—ๆ•ฐใง่พฟใฃใฆใ„ใ
require 'set'
Yamanote = %w[ใจใ†ใใ‚‡ใ† ใ‚†ใ†ใ‚‰ใใกใ‚‡ใ† ใ—ใ‚“ใฐใ— ใฏใพใพใคใกใ‚‡ใ† ใŸใพใก ใ—ใชใŒใ‚ ใŠใŠใ•ใ ใ”ใŸใ‚“ใ  ใ‚ใใ‚ ใˆใณใ™ ใ—ใถใ‚„ ใฏใ‚‰ใ˜ใ‚…ใ ใ‚ˆใ‚ˆใŽ ใ—ใ‚“ใ˜ใ‚…ใ ใ—ใ‚“ใŠใŠใใผ ใŸใ‹ใ ใฎใฐใฐ ใ‚ใ˜ใ‚ ใ„ใ‘ใถใใ‚ ใŠใŠใคใ‹ ใ™ใŒใ‚‚ ใ“ใพใ”ใ‚ ใŸใฐใŸ ใซใ—ใซใฃใฝใ‚Š ใซใฃใฝใ‚Š ใ†ใใ„ใ™ใ ใซ ใ†ใˆใฎ ใŠใ‹ใกใพใก ใ‚ใใฏใฐใ‚‰ ใ‹ใ‚“ใ ]
Station = Struct.new(:name, :val)
class Loop
def initialize(array)
@array = array.map do |a|
if a.is_a? Station
@kuboon
kuboon / http_util.rb
Created September 5, 2025 08:28
s3 presign ็”จใซไฝœใฃใŸใ‘ใฉ aws-sdk-s3 ใŒๅ†…้ƒจใง uri encode ใ™ใ‚‹ใฎใงไบ‹ๅ‰ใซ encode ใ—ใฆใฏใƒ€ใƒกใ ใฃใŸใจๅˆคๆ˜Žใ—ไพ›้คŠ
module HttpUtil
class PathSegment < String
MATCHER = Regexp.new("\\A#{URI::RFC3986_Parser::SEG_NC}+\\Z")
def self.encode_from(str, allow_slash: false)
return str if str.is_a?(PathSegment)
raise 'should not include / in element or use allow_slash option to encode' if !allow_slash && str.include?('/')
new(URI.encode_uri_component(str.unicode_normalize(:nfkc)))
end
def initialize(str)
raise "invalid char: #{str}" unless MATCHER.match?(str)
RSpec.configure do |config|
config.before(:suite) { Coverage.start(oneshot_lines: true) }
config.after :suite do
coverage_data = Coverage.result(stop: true, clear: true)
uncovered_lines(coverage_data)
end
end
def parse_git_diff(base_branch)
diff_output, _stderr, _status = Open3.capture3("git diff #{base_branch} --unified=0")