Skip to content

Instantly share code, notes, and snippets.

View wjkoh's full-sized avatar
🎯
Focusing

Woojong Koh wjkoh

🎯
Focusing
View GitHub Profile
@wjkoh
wjkoh / unix_time.go
Created November 12, 2025 08:52
Go: How to Unmarshal Unix Time from JSON Correctly
type UnixTime struct{ time.Time }
func (t *UnixTime) UnmarshalJSON(b []byte) error {
if string(b) == "null" {
t.Time = time.Time{}
return nil
}
var value any
if err := json.Unmarshal(b, &value); err != nil {
return err
@wjkoh
wjkoh / the_grug_brained_developer_ko.md
Last active November 10, 2025 01:58
그럭 뇌 개발자: 자각 있는 작은 뇌처럼 생각하기 위한 평신도 안내서 by Carson Gross

Important

This is an unofficial Korean translation of The Grug Brained Developer by Carson Gross.

grug

그럭 뇌 개발자: 자각 있는 작은 뇌처럼 생각하기 위한 평신도 안내서

| 상품

소개

@wjkoh
wjkoh / buffered_iterator.go
Last active November 7, 2025 10:17
Go: BufferedIterator uses a goroutine and a buffered channel to pre-fetch the next page of data while the current page is being processed, optimizing for slow network calls.
// BufferedIterator returns an iterator over data pages.
//
// This implementation uses a goroutine and a buffered channel
// to pre-fetch the next page of data while the current page
// is being processed, optimizing for slow network calls.
//
// This version starts the producer goroutine *lazily* (only when
// iteration begins) to prevent resource leaks if the
// iterator is created but never used.
func BufferedIterator(ctx context.Context, releaseID int) iter.Seq2[*Data, error] {
@wjkoh
wjkoh / fx_sort_by.sh
Created October 29, 2025 08:46
fx: How to Sort JSON array in-place
#!/usr/bin/env bash
fx ./data/podcasts.json '{...x, podcasts: sortBy(x => x.title)(x.podcasts)}' save
@wjkoh
wjkoh / unix_time.go
Created October 18, 2025 07:21
Go: UnixTime
type UnixTime struct{ time.Time }
func (t *UnixTime) UnmarshalJSON(b []byte) error {
if string(b) == "null" {
t.Time = time.Time{}
return nil
}
var timestamp float64
if err := json.Unmarshal(b, &timestamp); err != nil {
return err
@wjkoh
wjkoh / job_manager.go
Created October 10, 2025 17:24
Go: Background Job Manager
package main
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"log/slog"
"sync"
@wjkoh
wjkoh / sqlite_lru_cache.go
Last active October 2, 2025 06:07
Go: SQLite-based, On-disk LRU Cache
package fred
import (
"context"
"database/sql"
"errors"
"log/slog"
"time"
)
@wjkoh
wjkoh / levenshtein.go
Last active September 23, 2025 17:22
Go: Levenshtein Distance
package main
import "golang.org/x/text/unicode/norm"
type levenshteinDistancer struct {
deletionCost int
insertionCost int
substitutionCost int
}
@wjkoh
wjkoh / audio_cutter.go
Last active September 22, 2025 18:57
Go: How to Cut or Chunk an Audio File using FFmpeg
package main
import (
"context"
"encoding/json"
"fmt"
"io"
"log/slog"
"os/exec"
"strings"
@wjkoh
wjkoh / esc_to_switch_to_english.json
Last active September 2, 2025 16:59
MacOS: Press Escape to switch to English (sends Escape multiple times)
{
"description": "Press Escape to switch to English (sends Escape multiple times)",
"manipulators": [
{
"conditions": [
{
"input_sources": [{ "language": "^en$" }],
"type": "input_source_unless"
}
],