Skip to content

Instantly share code, notes, and snippets.

@holly
holly / mysql_localforward.sh
Created September 27, 2025 10:47
SSH local port forward for MySQL with health-check & auto-reconnect
#!/usr/bin/env bash
# mysql_localforward.sh — SSH local port forward for MySQL with health-check & auto-reconnect
# - カレントの ./.env を読み込み(あれば)
# - さらに -f /path/to/.env で指定した .env を読み込み(上書き)
# - フォワード断検知で自動再接続、排他実行、ローカルバインドがデフォルト
set -Eeuo pipefail
show_help() {
cat <<'EOF'
@holly
holly / wp_autologin.php
Last active March 16, 2025 03:05
wordpress auto login
<?php
define('WP_USE_THEMES', false);
require_once __DIR__ . '/wp-load.php';
$user_id = 1;
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id, true);
wp_redirect(admin_url());
@holly
holly / htaccess
Created March 9, 2025 06:45
wordpress htaccess
<FilesMatch "^(xmlrpc|wp-cron|wp-trackback)\.php$">
Require all denied
</FilesMatch>
# ${image}.jpg.webp, ${image}.png.webというファイルがあればURLは${image}.jpg, ${image}.pngというアクセスでも内部的に.webpファイルをレスポンスとして返す
<IfModule mod_mime.c>
AddType image/webp .webp
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
@holly
holly / add_samesite_cookie
Last active February 23, 2025 06:01
wordpress snippets
#!/usr/bin/env python
# vim:fileencoding=utf-8
""" [NAME] script or package easy description
[DESCRIPTION] script or package description
"""
import os, sys, io
import json
import boto3
#!/usr/bin/env python
import os
import sys
import urllib
import io
import tarfile
import re
GEOIP_LICENSE_KEY = "your maxmind geoip license key"
!/usr/bin/env bash
GEOIP_LICENSE_KEY=your_maxmind_geoip_license_key
for GEOIP_EDITION in GeoLite2-Country GeoLite2-ASN GeoLite2-City; do
tarball="${GEOIP_EDITION}.tar.gz"
curl -sSL "https://download.maxmind.com/app/geoip_download?edition_id=${GEOIP_EDITION}&license_key=${GEOIP_LICENSE_KEY}&suffix=tar.gz" -o $tarball
tar -xzf $tarball --wildcards "*/${GEOIP_EDITION}.mmdb" --strip=1
rm $tarball
done
@holly
holly / mkcertdir.pl
Last active July 27, 2024 16:10
download ca-bundle(cacert.pem from curl website) and extract and make hash symlink
#!/usr/bin/env perl
use strict;
use warnings;
use autodie qw(open chdir symlink);
use feature qw(say);
use HTTP::Request;
use LWP::UserAgent;
our $CACERT = "ca-bundle.crt";
@holly
holly / sakura_delete_trashmail.sh
Last active June 9, 2024 16:20
Auto old mail spool file for SAKURA Internet Web Hosting Service
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
set -C
MAILDIR=$HOME/MailBox
MTIME=30
#!/usr/bin/env python
import os
import sys
import requests
import csv
from bs4 import BeautifulSoup
URL = "https://jprs.jp/registration/list/meibo/meibo_list_{0}.html"