Skip to content

Instantly share code, notes, and snippets.

View hotta's full-sized avatar

HOTTA, Michihide hotta

View GitHub Profile
@hotta
hotta / pg-persist.php
Last active June 17, 2021 23:51
Pgpool 通常稼働のため、Pgpool を定期的にポーリングしてDB接続を維持する
#!/usr/bin/php
<?php
//
// pg-persist.php
// pgpool ではクライアントからの接続がない場合は障害時でもフェイルオーバー
// しないため、DB接続を維持するため(だけ)のスクリプトを準備した。
// cron から起動する場合はバックグラウンド起動とすること。
// テスト側でのみ必要。
//
// https://www.php.net/manual/ja/ref.pdo-pgsql.connection.php
@hotta
hotta / .bashrc
Created September 1, 2021 23:40
Small TIPS on CentOS
# Enable git-bash-prompt
if [ ! -d $HOME/bash-git-prompt ]; then
git clone https://github.com/magicmonty/bash-git-prompt.git
fi
if [ -f "$HOME/bash-git-prompt/gitprompt.sh" ]; then
GIT_PROMPT_ONLY_IN_REPO=1
source $HOME/bash-git-prompt/gitprompt.sh
fi
@hotta
hotta / Vagrantfile
Last active September 2, 2021 04:36
Vagrant TIPS
# Tune resolver settings to prevent from yum slow down (for use in Japan)
config.vm.provision "shell", inline: <<-SHELL
sudo nmcli con mod "System eth0" ipv4.ignore-auto-dns Yes ipv4.dns 8.8.8.8
sudo systemctl restart NetworkManager
echo "include_only=.jp" | sudo tee -a /etc/yum/pluginconf.d/fastestmirror.conf
SHELL
@hotta
hotta / phpdbg.md
Last active December 15, 2023 06:25
phpdbg 簡易マニュアル
@hotta
hotta / lastlog.sh
Created February 13, 2024 01:20
display last login date for each users
#!/bin/bash
#
# display last login date for each users
#
for user in vagrant dirsrv dummy ; do
if ! id $user >& /dev/null ; then
echo -e "$user\tno such user"
continue
fi
LINE="$(LANG=C lastlog -u $user | tail -1)"
@hotta
hotta / find-latest-files.sh
Last active February 28, 2024 05:50
Scans the directories immediate under /home and find the last updated files (excluding dot files).
#!/bin/bash
#
# /home/直下のディレクトリをスキャンし、ユーザーごとに最終更新ファイルを表示する(ドットファイルは除く)。
# 該当ファイルがない場合はディレクトリ名(ユーザー名)を表示する。
#
TMP_OUTPUT=/tmp/a.txt
if [ "$#" -eq 1 ]; then
TARGET="$1"
fi
cd /home
@hotta
hotta / dotfiles.sh
Created March 21, 2024 05:23
指定したユーザーのドットファイルをまとめて収集する。
#!/bin/bash
# Gather dotfiles of specified users.
ARC=/tmp/dotfiles.tar
USERS=(user1 user2 user3)
sudo sh -c "tar cf $ARC /home/etl/.??*" || exit 1
for u in ${USERS[@]} ; do
echo $u
sudo sh -c "tar rf $ARC /home/$u/.??*" || exit 1
done
sudo gzip $ARC