Skip to content

Instantly share code, notes, and snippets.

View Nymphium's full-sized avatar
⚜️
百合

Satoru Kawahara Nymphium

⚜️
百合
View GitHub Profile
@Nymphium
Nymphium / AGENT.md
Last active February 5, 2026 02:07
BetterDisplay auto brightness automation for macOS dark mode

AGENT.md - BetterDisplay Auto Brightness

Project Overview

This project provides a Swift-based automation tool for macOS to control external display brightness via BetterDisplay based on the system's appearance (Light/Dark mode) and power state (Wake/Sleep).

Key Components

1. AutoBrightness.swift

  • Language: Swift (compiled).
  • Function:
let reporter ~env ~sw =
let stdout = Eio.Stdenv.stdout env in
let report (type a b) _src _level ~over (k : unit -> b) (msgf : (a, b) Logs.msgf) : b =
let res = Atomic.make None in
let k () =
match Atomic.get res with
| Some v -> v
| None ->
let v = k () in
Atomic.set res (Some v);
@Nymphium
Nymphium / dune
Created October 2, 2025 02:44
tunneling effects between domains
(executable
(name hoge)
(libraries eio_main domainslib))
#lang racket
(provide (except-out (all-defined-out) with-free Pure Free))
(require racket/control)
(struct Pure (r) #:transparent)
(struct Free (a k) #:transparent)
; (: compose [All (a b c) (-> (-> a b) (-> b c) (-> c d))])
@Nymphium
Nymphium / 集計くん.sh
Last active April 15, 2025 07:51
./集計くん.sh "2024-01-01" "2024-12-31" # displays the PRs each which you created between $1 and $2, and merged under the current dir, recursively
#!/usr/bin/env bash
set -eu
from_date=${1:-"2024-10-01"}
to_date=${2:-"2025-03-31"}
total=0
f() {
local eff = require('eff')
local inst, perform, handler = eff.inst, eff.perform, eff.handler
local Twice = inst()
local Exit = inst()
--[[
co = {
print(1)
coroutine.yield() -- *1
@Nymphium
Nymphium / main.ml
Last active February 8, 2023 14:21
[@@@alert "-unstable"]
[@@@warning "-32"]
(* Reimplementation of Go's worker pools using Eio and Domainslib.Chan
https://gobyexample.com/worker-pools
*)
module Stdenv = struct
type _ Effect.t += Get : (Eio.Stdenv.t * Eio.Switch.t) Effect.t
@Nymphium
Nymphium / eff.ml
Last active December 7, 2021 07:35
type (_, _) operation = ..
type 'a computation =
| Return : 'a -> 'a computation
| Call : ('arg, 'res) operation * 'arg * ('res -> 'a computation) -> 'a computation
type ('a, 'b) handler = {
return : 'a -> 'b computation;
operations : 'arg 'res. ('arg, 'res) operation ->
'arg -> ('res -> 'b computation) -> 'b computation
@Nymphium
Nymphium / main.ts
Created July 22, 2019 00:30
algebraic effects using stricter generator (is too hard or impossible).
interface Get {
readonly _tag: 'Get';
readonly _ans: number;
}
interface Put {
readonly _tag: 'Put';
readonly _ans: void;
value: number;
}
type (_, _) cont =
Cont : (('a -> 'r) -> 'r) -> ('r, 'a) cont
let runCont : ('r, 'a) cont -> ('a -> 'r) -> 'r
= fun (Cont f) k -> f k
let runCont' k cf = runCont cf k
let return x = Cont((|>) x)