Skip to content

Instantly share code, notes, and snippets.

View matchy256's full-sized avatar

MACHIDA Hideki matchy256

View GitHub Profile
@matchy256
matchy256 / int2textcast.sql
Created June 24, 2015 00:56
古いPostgreSQLから移設したデータベースでキャストエラーが出るとき
-- for PostgreSQL 8.2
CREATE FUNCTION int4text(int4) RETURNS text AS 'SELECT textin(int4out($1))' LANGUAGE sql IMMUTABLE STRICT;
CREATE CAST (int4 AS text) WITH FUNCTION int4text(int4) AS IMPLICIT;
CREATE FUNCTION int8text(int8) RETURNS text AS 'SELECT textin(int8out($1))' LANGUAGE sql IMMUTABLE STRICT;
CREATE CAST (int8 AS text) WITH FUNCTION int8text(int8) AS IMPLICIT;
-- for PostgreSQL 8.4 or later
CREATE CAST (int4 AS text) WITH INOUT AS IMPLICIT;
CREATE CAST (int8 AS text) WITH INOUT AS IMPLICIT;
@matchy256
matchy256 / clamscan.sh
Last active December 9, 2015 21:59
ClamAV でシステム全体をスキャンして、問題があったらメールするスクリプト。 除外ディレクトリは /etc/clamscan.exclude ファイルに1行ずつ書いとく。/proc は入れといた方がいい。
#!/bin/bash
MAILTO="root"
PATH=/usr/bin:/bin
# excludeopt setup
excludelist=/etc/clamscan.exclude
if [ -s $excludelist ]; then
for i in `cat $excludelist`
do
@matchy256
matchy256 / dropcaches.sh
Created December 21, 2012 02:08
Linux のスワップとかキャッシュとかをクリアする
#!/bin/sh
# swap clear
/sbin/swapoff -a && /sbin/swapon -a
# disk sync
/bin/sync
/bin/sync
/bin/sync
@matchy256
matchy256 / wordpagenum.rb
Last active December 17, 2015 03:49
指定ディレクトリのすべてのWordファイルのフッタを「ページ番号/ページ数」にする (要 win32ole)
#!/usr/bin/env ruby
require 'win32ole'
abort("Usage: #{$0} WordFilesDirectory") if ARGV.length < 1
fso = WIN32OLE.new('Scripting.FileSystemObject')
wordFiles = []
Dir.foreach(ARGV[0]) do |f|
path = File.join(ARGV[0], f)
@matchy256
matchy256 / .ng
Created January 19, 2014 12:59
Ng (Nihongo micro Gnu emacs) 用設定ファイル例
; ~/.ng
;
; for more detail, please read Ng.doc
;
; 'next-line' doesn't insert newline at the end of buffer.
(next-line-add-newlines nil)
; exchange C-h with DEL.
(bsmap-mode)
@matchy256
matchy256 / docker-cleanup-volumes.sh
Created May 20, 2016 04:38
docker で使っていないデータボリュームを一括削除する
#!/bin/bash
function do_cleanup {
docker volume rm $(docker volume ls -qf dangling=true)
}
LIST=`docker volume ls -qf dangling=true`
if [ -n "$LIST" ]; then
echo $LIST
echo "Cleanup ? (y/N)"
@matchy256
matchy256 / radiko2gmusic.py
Last active October 12, 2016 05:55
rec_radiko.sh / rec_nhk.sh で録音したmp3ファイルをパラメータに渡すと GoogleMusic にアップロードしてファイル名から日付をカットしたプレイリストに整理するスクリプト。要 https://github.com/simon-weber/Unofficial-Google-Music-API 。Google ID とパスワードは自分のものに書き換えること
#!/usr/bin/env python
from gmusicapi import Musicmanager
from gmusicapi import Mobileclient
import sys
import os.path
params = sys.argv
@matchy256
matchy256 / jqmSimpleMessage.js
Created December 27, 2016 23:38
jQuery Mobile 1.4系で簡易なポップアップメッセージ
function jqmSimpleMessage(message) {
var parent = $('.ui-page-active');
if (parent.length === 0) {
parent = $('body');
}
var div = $('<div data-role="popup" id="__popupmsg" class="ui-content" data-theme="a"></div>');
div.append($('<p></p>').text(message));
var a = $('<a href="#__popupmsg" data-rel="popup" data-position-to="window" id="__popupkicker">popup</a>');
a.css('display', 'none');
[Desktop Entry]
Name=1Password Browser Helper
Comment=Allow browser plugins to interact with the 1Password database
Exec=env WINEPREFIX="/home/<username>/.wine" wine "/home/<username>/.wine/drive_c/Program Files (x86)/1Password 4/Agile1pAgent.exe"
Type=Application
StartupNotify=true
Path=/home/<username>/.wine/drive_c/Program Files (x86)/1Password 4
Icon=C775_1Password.0
StartupWMClass=Agile1pAgent.exe
@matchy256
matchy256 / web_alive.sh
Last active July 24, 2018 15:51
wget を使った Web 死活監視スクリプト
#!/bin/bash
if [ $# -eq 2 ]; then
URL=$1
MAILTO=$2
else
echo "usage : $0 check_url alert_mail_address"
exit 1
fi