Skip to content

Instantly share code, notes, and snippets.

View naoki-sawada's full-sized avatar
🐴

Naoki Sawada naoki-sawada

🐴
View GitHub Profile
@naoki-sawada
naoki-sawada / main.go
Created May 17, 2022 14:18
Go generics example
package main
import "fmt"
type Base interface {
getID() int64
}
type Person struct {
ID int64
import hexRgb from "hex-rgb";
// see: https://www.w3.org/TR/WCAG20/#relativeluminancedef
export function isDarkColor(hexColor: string): boolean {
const { red, green, blue } = hexRgb(hexColor);
const [r, g, b] = [red / 255, green / 255, blue / 255].map((v) =>
v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4)
);
#!/bin/bash
# Read JSON data that Claude Code sends to stdin
input=$(cat)
# Extract fields using jq
MODEL=$(echo "$input" | jq -r '.model.display_name // "Unknown"')
DIR=$(echo "$input" | jq -r '.workspace.current_dir // .cwd // "."')
PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
# Get token counts from context_window