Skip to content

Instantly share code, notes, and snippets.

View itchyny's full-sized avatar
🏠
Working from home

itchyny itchyny

🏠
Working from home
  • Cybozu, Inc.
  • Kyoto, Japan
View GitHub Profile
@itchyny
itchyny / go-importers.sh
Last active July 6, 2026 10:26
List the GitHub repositories that import a Go package, ranked by star count.
#!/bin/bash
set -euo pipefail
prog=${0##*/}
usage() {
cat >&2 <<EOF
$prog - list the GitHub repositories that import a Go package
Usage: $prog <package-path> [limit]
@itchyny
itchyny / update-github-actions.sh
Last active July 9, 2026 13:39
Update GitHub Actions
#!/bin/bash
set -euo pipefail
git grep -hoP '^\s*-?\s*uses:\s*\K\S+@\S+(\s+#\s+\S+)?' .github | sort -u | while IFS= read -r spec; do
if [[ "$spec" =~ ^([^@[:space:]]+)@([0-9a-fA-F]{7,40})[[:space:]]+#[[:space:]]+(v[0-9][^[:space:]]*)$ ]]; then
action=${BASH_REMATCH[1]} cur_ref=${BASH_REMATCH[3]} pinned=sha
elif [[ "$spec" =~ ^([^@[:space:]]+)@(v[0-9][^[:space:]]*)$ ]]; then
action=${BASH_REMATCH[1]} cur_ref=${BASH_REMATCH[2]} pinned=tag
else
continue
import * as zlib from 'minizlib';
new zlib.Gzip({});
@itchyny
itchyny / chsh-to-brew-zsh.sh
Created February 26, 2023 13:47
Change the login shell to zsh installed by Homebrew
#!/bin/bash
set -euo pipefail
echo "Checking zsh installed by Homebrew ..."
if version="$(brew list --versions zsh)"; then
echo "Found: $version"
else
echo "Could not find zsh installed by Homebrew"
exit 1
fi
@itchyny
itchyny / mackerel-plugin-filecount.zsh
Last active February 28, 2023 00:03
Mackerel plugin for file count
#!/bin/zsh
if [[ "$MACKEREL_AGENT_PLUGIN_META" == 1 ]]; then
cat <<EOF
# mackerel-agent-plugin
{
"graphs": {
"filecount.#": {
"label": "File count",
"unit": "integer",
#!/bin/bash
set -euo pipefail
cmdname="${BASH_SOURCE[0]##*/}"
temp=$(mktemp -t "$cmdname")
trap 'unlink "$temp"' EXIT
go test -cover -coverprofile="$temp" "$@"
go tool cover -html="$temp"
@itchyny
itchyny / main.go
Last active January 27, 2022 11:19
Lock-free snowflake-like id generator in Golang
package main
import (
"fmt"
"os"
"sync"
"sync/atomic"
"time"
)
@itchyny
itchyny / main.go
Created February 24, 2021 11:22
Performance comparison of implementations of strings.Join
package main
import (
"bytes"
"strings"
)
func main() {}
func JoinPlus(xs []string, sep string) string {
@itchyny
itchyny / check-go-repo.sh
Last active July 10, 2026 12:03
A checker for my own Go product repositories
#!/bin/bash
set -euo pipefail
git status >/dev/null || exit 1
err=
error_message() {
printf '%s\n\n' "$*" >&2
err=1
}
@itchyny
itchyny / buildvim.sh
Last active November 21, 2020 03:46
Build Vim from 7.3 to the latest with 100 patches step on macOS (x86_64) with clang 12 (clang-1200.0.32.27)
#!/bin/bash
set -euxo pipefail
git clone https://github.com/vim/vim.git /tmp/vim
cd /tmp/vim
BACKUP_DIR=/tmp/vim-backup
mkdir -p "$BACKUP_DIR"
while true; do