Skip to content

Instantly share code, notes, and snippets.

@Hogeyama
Hogeyama / add_backlinks.ts
Created September 24, 2025 16:01
Add backlinks to markdown
/**
* Example:
*
* ```java
* withEarlyReturn(Result.class, (c) -> {
* var value = switch (someAction()) {
* case Success(var value) -> {
* return value;
* }
* case Failure(var error) -> {
@Hogeyama
Hogeyama / justfile
Last active February 17, 2025 01:56
md2textile by pandoc, textile2md by orchitech/redmine_reformat microservice
init:
#!/usr/bin/env -S bash -euo pipefail -o noclobber
echo "[Generating Dockerfile...]"
cat - > Dockerfile <<'EOF'
FROM redmine:6.0.3
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential=12.9 \
pkg-config=1.8.1-1 \
libxml2-dev=2.9.14+dfsg-1.3~deb12u1 \
libxslt1-dev=1.1.35-1 \
@Hogeyama
Hogeyama / PostgreSQL.hs
Last active November 4, 2024 17:10
Reusable PostgreSQL TestContainer
module TestUtil.PostgreSQL
( PostgreSQL (..)
, withPostgreSQL
, withSharedPostgreSQL
, runQueryBeforeAll
, runQueryBefore
, stopAllContainers
) where
import Control.Monad.Logger (MonadLoggerIO, runNoLoggingT, runStderrLoggingT)
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "ctrl+n",
"command": "workbench.action.files.save"
},
{
"key": "ctrl+s",
"command": "-workbench.action.files.save"
},
-- |
-- import文の後に
-- @
-- -- $setup
-- -- >>> import DoctestUtil
-- @
-- と書いておくと便利
module DoctestUtil
( pretty
, capture
@Hogeyama
Hogeyama / unliftio.hs
Last active October 6, 2024 13:37
MonadUnliftIO (ExceptT e m)
-- [Control.Monad.IO.Unlift](https://hackage.haskell.org/package/unliftio-core-0.2.1.0/docs/Control-Monad-IO-Unlift.html#t:MonadUnliftIO)
-- 定義はできるがInverse lawが成り立たないのでダメ
-- withRunInIO (\_ -> throwIO e) === liftIO (throwIO e)
-- にならないといけないが、pure (Left e)になってしまう。
-- たぶんjoinの保存則も成り立たないんじゃないかな。
--
-- あと、askUnliftIOを使うとtryのスコープを抜けてしまって酷いバグになりそう。
-- askUnliftIO = withRunInIO (\run -> return (UnliftIO run))
instance (MonadUnliftIO m, Exception e) => MonadUnliftIO (ExceptT e m) where
withRunInIO inner =
comm -23 \
<(seq "1" "65535" | sort) \
<(ss -tan | awk '{print $4}' | cut -d: -f2 | tail -n+2 | grep -v '^$' | sort | uniq -u) \
| shuf -n 1
@Hogeyama
Hogeyama / 10-json.conf
Created September 19, 2024 16:37
はじめてのrsyslog
module(load="imudp")
module(load="imtcp")
module(load="mmjsonparse")
# Listen on port 514
input(type="imudp" port="514")
input(type="imtcp" port="514")
template(name="Identity" type="list") {
# GitHubのUIではrebaseすると未解決スレッドを参照するのがとても難しくなるので、コメントに一覧を表示しておく
on:
pull_request:
types:
- opened
- synchronize
pull_request_review_comment:
types:
# TODO コメント追加の度に走るのはまずいかな?2秒で終わっても課金上は1分で計算されるらしい