Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View hotta's full-sized avatar

HOTTA, Michihide hotta

View GitHub Profile
@hotta
hotta / base64decode.php
Last active August 29, 2015 14:01
a filter to conver the result of ldapsearch
#!/usr/bin/php
<?php
// base64encode.php by M.Hotta
// a filter to conver the result of ldapsearch command
//
function output($attr, $value, $encoded) {
if ($encoded) {
print $attr . ':: ' . base64_decode($value) . "\n";
} else {
print $attr . ':' . $value . "\n";
#!/usr/bin/php
<?php
if ($argc == 1) {
printf("Retrieve JSON data from specified URl and then decode.\n");
printf("Usage: %s URL_that_returns_JSON\n", $argv[0]);
exit(0);
}
$a = file_get_contents($argv[1]);
$a = preg_replace('/^[\r\n\(]*/', '', $a);
$a = preg_replace('/\)$/', '', $a);
@hotta
hotta / Mailman2Groups.gs
Last active November 18, 2016 01:34
Mailman to Google Groups member list migration sample using Google Apps Script
/*********************************************************************************
* Mailman からのリスト移行サンプル using Google Apps Script
* 2015.09.07 M.Hotta
*
* Mailman における情報取得方法
* リスト一覧の取得 mailman:/usr/lib/mailman/bin$ sudo ./list_lists | nkf -w
* (文字化けする場合は管理画面から取得)
* 購読者一覧の取得 mailman:/usr/lib/mailman/bin$ sudo ./list_members リスト名
* 管理者一覧の取得 mailman:/usr/lib/mailman/bin$ sudo ./list_owners リスト名
*
@hotta
hotta / custom_503.html
Created August 8, 2017 03:06
always return http status 503 with custom error page using nginx.
<!-- /var/www/http503/custom_503.html -->
<html>
<body>
<h1>custom_503.html</h1>
<img src='images/job_it_dokata.png' alt='IT Dokata'>
</body>
</html>
@hotta
hotta / cvtlog.php
Last active August 8, 2017 03:09
Display data encoded as UTF-8 strings
#!/usr/bin/php
<?php
//---------------------------------------------------------------------
// Display data encoded as UTF-8 strings
//
// Usage: tail -f log-files-etc | cvtlog.php
//---------------------------------------------------------------------
function pack_func($matches) // $matches[] = array('\xXX', '\xXX');
{
$tmp = sscanf('0' . substr($matches[0], 1), "%x");
@hotta
hotta / ib-csv-cleanup.sh
Created March 21, 2018 04:57
インターネットバンキングで取得した入出金明細のCSVをまともにするスクリプト
#!/bin/bash
cat $1 | \
nkf -Sw -Lu -Z4 -X | \
sed -e '1,5d' | \
head -n -2 | \
sed -e 's/","/\t/g'
-e 's/"//g' \
-e 's/フリカエ/振替/g' \
-e 's/コクミンネンキン/国民年金/g' \
-e 's/ホケンリヨウ/保険料/g' \
@hotta
hotta / build.gradle
Last active August 27, 2019 04:11
Gradle QuickStart
// Gradle QuickStart - 7.2. 基本的なJavaプロジェクト
// cf. http://gradle.monochromeroad.com/docs/userguide/userguide.html
// Gradle が使用する JRE
// システムの JDK/JRE。デフォルト以外の JDK を使用したい場合は
// JAVA_HOME 環境変数を調整する。
// Gradle が使用する Groovy
// Gradle 同梱の Groovy。システムの Groovy は参照されない。
@hotta
hotta / Vagrantfile
Last active January 17, 2020 02:24
Vagrantfile with multiple NICs and additional storage enabled
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "private_network", ip: "192.168.56.13"
config.vm.network "private_network", ip: "172.16.32.4"
config.vm.network "private_network", ip: "172.16.0.7"
config.vm.hostname = "db2"
config.vm.synced_folder ".", "/vagrant", disabled: true
@hotta
hotta / pgpool-check.sh
Created June 17, 2021 23:47
A script to monitor pgpool status
#!/bin/bash
MAILTO=mhotta@example.com
_INITDIR=~/.pgpool-check/init/
_CHECKDIR=~/.pgpool-check/current/
function _die {
echo $1
exit 1
}