Skip to content

Instantly share code, notes, and snippets.

View hnakamur's full-sized avatar

Hiroaki Nakamura hnakamur

View GitHub Profile
@hnakamur
hnakamur / main_test.go
Created October 8, 2025 02:56
Buffer the first part of the response body and pass through the rest of it
package main
import (
"fmt"
"io"
"net/http"
"net/http/httptest"
"testing"
)
@hnakamur
hnakamur / Dockerfile
Created September 27, 2025 23:05
clang not found for make in fil-c libpas
FROM ubuntu:25.04
RUN apt-get update
RUN apt-get -y install git build-essential cmake ninja-build python3 patchelf autoconf gawk bison ruby
WORKDIR /root
RUN git clone --depth 1 https://github.com/pizlonator/fil-c.git
WORKDIR /root/fil-c
RUN ./build_all_fast_glibc.sh 2>&1 | tee build.log || :
@hnakamur
hnakamur / run-cmd-detached-on-tmux
Created May 5, 2025 14:02
a Python script to run a command in a detached tmux session, forwarding this script's stdin to the command if stdin is not terminal.
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import logging
import os
import shlex
import subprocess
import sys
import tempfile
from types import TracebackType
@hnakamur
hnakamur / a.odin
Created July 17, 2024 13:41
SIMD experiment with Odin
package main
import "core:fmt"
import "core:simd"
main :: proc() {
i := index_any([]u8{'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', '\r', '&', 'a'}, 16)
fmt.println(i)
}
@hnakamur
hnakamur / bash-args-array.sh
Created March 11, 2024 23:41
bash-args-array.sh
#!/bin/bash
# コマンドライン引数を配列に格納
args=("$@")
# 配列の要素を表示
for arg in "${args[@]}"; do
echo $arg
done
@hnakamur
hnakamur / must.go
Created July 12, 2023 23:53
Go generic test must utility
package testx
import "testing"
func Must0(t *testing.T) func(error) {
return func(err error) {
t.Helper()
if err != nil {
t.Fatal(err)
}
@hnakamur
hnakamur / wezterm.lua
Last active July 10, 2023 20:08
My wezterm config
local wezterm = require 'wezterm'
local mux = wezterm.mux
local config = {}
if wezterm.config_builder then
config = wezterm.config_builder()
end
-- set startup Window position
-- https://github.com/wez/wezterm/issues/2976#issuecomment-1419492777
@hnakamur
hnakamur / go.json
Created June 27, 2023 21:03
main.go snippet for VS Code
{
"package main": {
"prefix": "package main",
"body": [
"package main",
"",
"import \"log\"",
"",
"func main() {",
"\tif err := run(); err != nil {",
@hnakamur
hnakamur / source_or_run.sh
Last active June 7, 2023 12:07
Find out whether a bash script is executed or sourced.
#!/bin/bash
if [ $BASH_ARGV0 = -bash ]; then
echo sourced
else
echo executed
fi
@hnakamur
hnakamur / main.go
Created May 3, 2023 23:04
verify Go os.File.Read returns 0, io.EOF at end of file.
package main
import (
"io"
"log"
"os"
)
func main() {
if err := run(); err != nil {