Profile img

Hi, I'm who's behind Fedify, Hollo, BotKit, and this website, Hackers' Pub! My main account is at @hongminhee洪 民憙 (Hong Minhee).

Fedify, Hollo, BotKit, 그리고 보고 계신 이 사이트 Hackers' Pub을 만들고 있습니다. 제 메인 계정은: @hongminhee洪 民憙 (Hong Minhee).

FedifyHolloBotKit、そしてこのサイト、Hackers' Pubを作っています。私のメインアカウントは「@hongminhee洪 民憙 (Hong Minhee)」に。

Website
hongminhee.org
GitHub
@dahlia
Hollo
@hongminhee@hollo.social
DEV
@hongminhee
velog
@hongminhee
Qiita
@hongminhee
Zenn
@hongminhee
Matrix
@hongminhee:matrix.org
X
@hongminhee
2
1
5

Open source projects I'm currently maintaining:

  • Fedify, an ActivityPub server framework for TypeScript
  • Hollo, an ActivityPub-enabled single-user microblogging software
  • BotKit, an ActivityPub bot framework for TypeScript
  • LogTape, a modern logging library for TypeScript
  • Upyo, a simple and modern email sending library for TypeScript
  • Optique, a type-safe combinatorial CLI parser for TypeScript
7
2
1
8
2
6
3

GitHub Classroom을 사용해서 온라인 저지 시스템을 구축해본 후기입니다.

https://theeluwin.github.io/article/online-judge-with-github-classroom/

실제로 사용하고 싶었으나, 제 결론은... 안쓰는쪽으로 났습니다. 이유는 결국, 문제 출제하는 UI/UX가 좋지 않다는 것입니다. 제가 고생을 덜 해야만 하니까요(,,,,) 암튼 GitHub Classroom이 문서도 제대로 안되어있기도 하고, 기능이 아직 좀 오락가락 합니다. 없는 기능도 너무 많구요. 제 검토를 참고해주십시오, , ,

2
3

https://github.com/makachanm/questionbasket

셀프호스트 1인용 익명 질문함 서비스의 백엔드까지는 전부 짜긴 했지만 프론트엔드를 맡아줄 사람이 없어서 그냥 백엔드 API만 작동하는 정도로 남겨두었다. 언젠간 완성할수도 있지만... 일단은 이정도 완성시킨걸로 만족하기로 하자. Gemini 없었으면 4달 전에 진행하다 버린 프로젝트를 오늘 완성시킬순 없었을거다.

4
9
5
2
5
4
5
3

오늘의 서커스 내용 세션의 정보를 가져오는데 세션의 앱은 ApplicationGrants를 받아야 하고 세션의 프로필 ID는 ApplicationGrantProfiles으로 프로필별 승인을 받거나 전체 프로필 승인(ApplicationGrantProfiles.profileId == null)을 받야아 가져올 수 있는데 세션의 프로필을 헤더로 오버라이드할 수 있고 오버라이드된 프로필 역시 위 조건을 지키는 경우만 리턴되게 하는 쿼리를 짰어요

const headerProfileId = c.req.header('X-Actor-Profile-Id');
    const session = await db
      .select({
        id: Sessions.id,
        applicationId: Sessions.applicationId,
        accountId: Sessions.accountId,
        scopes: Sessions.scopes,
        languages: Accounts.languages,
        profileId: Profiles.id,
      })
      .from(Sessions)
      .innerJoin(Accounts, eq(Sessions.accountId, Accounts.id))
      .innerJoin(ApplicationGrants, eq(Sessions.applicationId, ApplicationGrants.applicationId))
      .leftJoin(
        ApplicationGrantProfiles,
        eq(ApplicationGrants.id, ApplicationGrantProfiles.applicationGrantId),
      )
      .leftJoin(
        Profiles,
        and(
          eq(Profiles.id, headerProfileId ?? Sessions.profileId),
          eq(Profiles.state, ProfileState.ACTIVE),
          isNotNull(ApplicationGrantProfiles.id),
          or(
            eq(ApplicationGrantProfiles.profileId, Profiles.id),
            isNull(ApplicationGrantProfiles.profileId),
          ),
        ),
      )
      .where(eq(Sessions.token, accessToken))
      .limit(1)
      .then(first);
1

오늘의 서커스 내용 세션의 정보를 가져오는데 세션의 앱은 ApplicationGrants를 받아야 하고 세션의 프로필 ID는 ApplicationGrantProfiles으로 프로필별 승인을 받거나 전체 프로필 승인(ApplicationGrantProfiles.profileId == null)을 받야아 가져올 수 있는데 세션의 프로필을 헤더로 오버라이드할 수 있고 오버라이드된 프로필 역시 위 조건을 지키는 경우만 리턴되게 하는 쿼리를 짰어요

const headerProfileId = c.req.header('X-Actor-Profile-Id');
    const session = await db
      .select({
        id: Sessions.id,
        applicationId: Sessions.applicationId,
        accountId: Sessions.accountId,
        scopes: Sessions.scopes,
        languages: Accounts.languages,
        profileId: Profiles.id,
      })
      .from(Sessions)
      .innerJoin(Accounts, eq(Sessions.accountId, Accounts.id))
      .innerJoin(ApplicationGrants, eq(Sessions.applicationId, ApplicationGrants.applicationId))
      .leftJoin(
        ApplicationGrantProfiles,
        eq(ApplicationGrants.id, ApplicationGrantProfiles.applicationGrantId),
      )
      .leftJoin(
        Profiles,
        and(
          eq(Profiles.id, headerProfileId ?? Sessions.profileId),
          eq(Profiles.state, ProfileState.ACTIVE),
          isNotNull(ApplicationGrantProfiles.id),
          or(
            eq(ApplicationGrantProfiles.profileId, Profiles.id),
            isNull(ApplicationGrantProfiles.profileId),
          ),
        ),
      )
      .where(eq(Sessions.token, accessToken))
      .limit(1)
      .then(first);
3
3
2
5
2
2

튜링에서 한 프로세스를 실행하고, 다음 프로세스를 실행하는 걸 "명시"하지 않는데, 이를 명시적으로 어떤 combinator로 보고, 전역 변수등은 또 람다로 감싸서, 람다 컨텍스트에 있는 변수를 보게 하면, 람다와 다를게 없다.
튜링과 람다가 철학이 다르다기 보다, 마치 튜링에서 암묵적으로 하던 동작들을 모두 명시적으로 바꿔 놓은 게 람다 대수인 건 아닐까?

1
3
7
1

I've recently been working on Optique, a CLI parser combinator for TypeScript. Optique allows you to describe complex CLIs by combining smaller parts. You can also handle the CLI parsing results in a type-safe manner (see code below). The idea came from Haskell's optparse-applicative, but since TypeScript's API style is so different from Haskell's, I referenced Zod and similar libraries for the API design. For a more detailed introduction, please refer to the article I posted on Hackers' Pub!

const parser = or(
  object({
    type: constant("network"),
    host: option(
      "-h", "--host",
      string({ metavar: "HOST" }),
    ),
    port: option(
      "-p", "--port",
      integer({ metavar: "PORT", min: 0, max: 65535 }),
    ),
  }),
  object({
    type: constant("local"),
    file: option(
      "-s", "--socket-file",
      string({ metavar: "FILE" }),
    ),
  }),
)

type Result = InferValue<typeof parser>;

// The above type is inferred as:
type Result = {
    readonly type: "network";
    readonly host: string;
    readonly port: number;
} | {
    readonly type: "local";
    readonly file: string;
}

最近、OptiqueというTypeScript向けのCLIパーサー「コンビネーター」を作っています。Optiqueは、複雑なCLIを小さなパーツの組み合わせで記述できる様にしてくれます。そして、そのCLIのパース結果を型安全に扱う事が出来ます。(下記のコード参照)アイデアはHaskellのoptparse-applicative から得ましたが、TypeScriptはHaskellとAPIのスタイルがかなり異なる為、APIの面ではZod等を参考にしました。詳しい紹介はHackers' Pubに投稿した記事をご覧ください!

const parser = or(
  object({
    type: constant("network"),
    host: option(
      "-h", "--host",
      string({ metavar: "HOST" }),
    ),
    port: option(
      "-p", "--port",
      integer({ metavar: "PORT", min: 0, max: 65535 }),
    ),
  }),
  object({
    type: constant("local"),
    file: option(
      "-s", "--socket-file",
      string({ metavar: "FILE" }),
    ),
  }),
)

type Result = InferValue<typeof parser>;

// Resultの推論された型
type Result = {
    readonly type: "network";
    readonly host: string;
    readonly port: number;
} | {
    readonly type: "local";
    readonly file: string;
}
0

I've recently been working on Optique, a CLI parser combinator for TypeScript. Optique allows you to describe complex CLIs by combining smaller parts. You can also handle the CLI parsing results in a type-safe manner (see code below). The idea came from Haskell's optparse-applicative, but since TypeScript's API style is so different from Haskell's, I referenced Zod and similar libraries for the API design. For a more detailed introduction, please refer to the article I posted on Hackers' Pub!

const parser = or(
  object({
    type: constant("network"),
    host: option(
      "-h", "--host",
      string({ metavar: "HOST" }),
    ),
    port: option(
      "-p", "--port",
      integer({ metavar: "PORT", min: 0, max: 65535 }),
    ),
  }),
  object({
    type: constant("local"),
    file: option(
      "-s", "--socket-file",
      string({ metavar: "FILE" }),
    ),
  }),
)

type Result = InferValue<typeof parser>;

// The above type is inferred as:
type Result = {
    readonly type: "network";
    readonly host: string;
    readonly port: number;
} | {
    readonly type: "local";
    readonly file: string;
}
3
2

mcp에 툴을 계속 쥐어주는게 불만이다. 불안하지도 않나? 아니 pg를 관리하는 mcp를 쓰는것보다 pg를 관리하는데 사용되는 명령어를 물어보고 그걸 내가 확인 후 실행하는게 맞지 않나? deno로 권한 다 뺏고서 mcp를 실행하면 좀 방지가 되려나?

3

러스트의 ICE 관련 이슈는 파보면 확실히 난이도가 높다. 이번에 본건 조기 종료 때문에 에러가 전파되지 않는 것이 문제인 줄 알았는데, Higher-Rank Trait Bound와 concrete 타입 간의 불일치를 처리하지 못해서 equality 검사를 하기 직전에 뻗는 것이였음.

4

박준규 replied to the below article:

Optique: 타입 안전한 CLI 파서 컴비네이터

洪 民憙 (Hong Minhee) @hongminhee@hackers.pub

이 글에서는 Haskell의 `optparse-applicative`와 TypeScript의 Zod에서 영감을 받아 제작된 새로운 CLI 파서 라이브러리인 Optique를 소개합니다. Optique는 파서 컴비네이터를 활용하여 CLI의 구조를 레고 블록처럼 조립할 수 있게 해줍니다. `option()`, `optional()`, `multiple()`, `or()`, `object()`, `constant()`, `command()`, `argument()` 등의 다양한 파서와 컴비네이터를 통해 복잡한 CLI 구조를 유연하게 정의할 수 있습니다. 특히, `or()`와 `object()` 컴비네이터를 사용하여 상호 배타적인 옵션이나 서브커맨드를 쉽게 구현하는 방법을 예제를 통해 설명합니다. Optique는 단순한 CLI 파서 역할에 집중하고 있어 모든 기능을 제공하지는 않지만, 복잡한 CLI 구조를 표현하는 데 유용하며, 소개 문서와 튜토리얼을 통해 더 자세한 내용을 확인할 수 있습니다.

Read more →
13
2
2
3

맥 미니가 자꾸 혼자 슬립 상태로 들어가길래 쓰고 있던 카페인의 문제인가 싶어서 지우고 keepingyouawake를 설치했는데 잘 될지 모르겠네...

사실 홈 서버는 맥 미니가 아니고 딴 거긴 한데 곧 얘를 중심으로 클러스터?를 만들어봐야 할 것 같기도..

2
2

洪 民憙 (Hong Minhee) shared the below article:

Par 언어 테스트 프레임워크 구현 -- Iterative Box Choice 패턴 적용

notJoon @joonnot@hackers.pub

Par 언어에 테스트 프레임워크를 구현하면서 `box choice` 타입의 소비 동작으로 인해 하나의 테스트 함수에서 여러 assertion을 처리하는 데 어려움을 겪었습니다. 기존 `box choice` 타입은 값을 한 번 사용하면 소비되어 재사용이 불가능했기 때문입니다. 이를 해결하기 위해 `iterative box choice` 타입을 도입하여 반복적인 사용이 가능하도록 개선했습니다. `iterative box choice` 타입은 `iterative`, `box`, `choice` 타입들을 조합하여 여러 번 사용 가능하고, 메서드 선택을 제공하며, 외부 구현과 연동할 수 있는 장점을 제공합니다. 새로운 타입 구조에 맞춰 테스트 실행 함수를 재귀적으로 수정하여 메서드 체이닝 방식과 순차적 명령문 방식 모두를 지원할 수 있게 되었습니다. 이로써 Par 언어는 더욱 유연하고 강력한 테스트 환경을 제공할 수 있게 되었습니다.

Read more →
4

내가 어쩌다가 이런 짓을 하게 되었나 타임라인을 정리하자면...

문제 파악

  1. 내가 만들고 있는 NestJS 앱에 fedify/nestjs 설치하고, FedifyModule 세팅해놓은 이후에 POST 요청 자체가 안 가고 있었음
  2. 왜 에러가 발생하나하고 들여다봤더니 TypeError: Response body object should not be disturbed or locked 이런 에러가 떴음.
  3. 오류가 발생한 위치는 fedify/express에서 코드 복붙할때 들어갔던 fromERequest 함수 호출 부분 이었음.
  4. 혹시나 하고, 비슷한 이슈가 있나하고 찾아봤는데 Fedify 279번 이슈에도 딱 내가 밟고 있는거랑 똑같은 에러메시지를 내뱉고 있었음.
  5. 이런 에러가 왜 발생했는지, 여기저기 찾아봤는데 hono에서도 비슷한 오류가 있었고 그걸 해결한 사례를 발견. 요약하자면, request의 body를 두번 읽으려고 해서 생긴 문제. req에 rawBody가 들어있으면 rawBody를 ReadableStream에 넣는 것으로 분기처리하고, 아니라면 기존의 코드(Readable.toWeb(req)) 그대로 사용하는 것.

해결 시도

  1. 도커 이미지 내부에는 에디터가 설치가 되어 있지 않음. 그래서, Dockerfile.dev 파일에 vim 의존성을 먼저 깔아둠
  2. vim 설치 후에는 docker compose exec app /bin/bash 커맨드로 도커 컨테이너 안쪽으로 들어가서, hono에서 하던 방식대로 시도하려고 했으나.... console.log 로 까보니 rawBody는 없고, 이미 파싱이 되어 있는 body만 남아있었음. -> 여기서 알게 된 점은.... "다른 미들웨어에 통과시키기도 전에 request에 있는 rawBody는 이미 읽혀져있구나..."
  3. NestJS의 소스코드를 까보긴 해야겠지만, 다시 돌아와서 여기Readable.toWeb(req)req.body로 바꾸니까 기적같이 그냥 돌아감...

NestJS 분석글... 쓰긴 해야겠지...? 근데, PR에도 올리긴 해야겠는데 어떡하지.... "이렇게 고치니까 되더라!!"는 좀 아닌 것 같다.

4
1
4

AI 기술이 발달하면서 글이나 코드 같은건 프롬프트를 잘 던지면 굉장히 그럴싸한 결과물을 내놔서 세상이 많이 좋아졌다고 느끼는데 디자인에선 아직 잘 모르겠다. 디자인이라해도 웹이나 앱 같은 경우엔 https://www.layermate.ai/ 같이 꽤 괜찮은 도구들이 있는데 포스터 같은걸 만들면서 나는 클립아트 정도만 AI의 도움을 (그것도 몇 번이나 삽질을 해서...) 받았다.

도둑놈 심보라는 것은 알고 있지만 포스터 같은걸 만들 때도 쓸 수 있는 저런 Layermate같은 도구가 있었으면 좋겠다는 생각을 무척이나 했다. "색상은 ..., ...를 주로 활용한 A4 사이즈 포스터를 만들어줘. 안에 이미지로는 어떠한 것들이 들어가야하고, 텍스트로는 어떤 것들이 들어가야 해." 같이 프롬프트를 잘 적으면 괜찮은 포스터 시안 몇 개가 뚝딱 나오면 세상이 오죽 편할까...

1
2
2
1
6
6

블로깅의 쇠퇴, AI의 끝없는 학습, 비공개 플랫폼(Discord 등)으로의 이주, 짧고 중독성만을 강조하는 피드와 BM, 한 번 보면 다시 찾기도 힘든 SNS 포스트, 범람하는 가짜뉴스와 개소리와 혐오... 웹은 정보의 망망대해도 아닌 소행성대로 변해가고 있다.

9
0
0