Skip to content

Instantly share code, notes, and snippets.

View tekei's full-sized avatar

Masanori Takeda tekei

  • Japan
View GitHub Profile
@tekei
tekei / gist:3773496
Created September 24, 2012 00:01
(Sinatra) エラー発生時にprowlに通知
# 事前に、環境変数 APP_NAME、PROWL_APIを設定しておく
#
# なお、下記ソースではエラーの重複排除を行っていないため
# 連続エラーで大量に送信されることになるので注意
require 'prowler'
# prowlの困ったところとして、メッセージの終端がきちんと表示出来ないことがある。
# そのため、メッセージに改行2つ付け加えてます。
def notify_sys_error(msg)
@tekei
tekei / ifunbox_conv.sh
Created September 24, 2012 00:04
ifunboxの文字化け解消
#!/bin/bash
# macでフォーマットしたipodをWindowsに持ってきたときUnicodeの正規化により
# 困ったことになるのを解消
# Windows上で、cygwinとnkfが入っている環境を想定。
CMD_NKF=nkf32
CMD_AWK=gawk
IFS=$'\n'
@tekei
tekei / gist:3775681
Created September 24, 2012 12:20
ネストしたArray, Hashに対する stringify_keys
require 'active_support/core_ext'
Array.class_eval do
def stringify_keys
map { |v| v.respond_to?('stringify_keys') ? v.stringify_keys : v }
end
end
Hash.class_eval do
alias :old_stringify_keys :stringify_keys
@tekei
tekei / gist:3798571
Created September 28, 2012 08:07
QQ English (http://www.qqeng.com) のレッスン予約をToodledoに登録する
# -*- coding: utf-8 -*-
require 'mail'
require 'active_support/core_ext'
require 'date'
require 'toodledo'
gmail_account = 'xxxxxxxxx'
gmail_password = 'xxxxxxxx'
@tekei
tekei / date_sugest.coffee
Created July 7, 2013 09:30
HTML キーボード入力を考慮したフィールド制御 まずは、カレンダフィールドの日付補完部分 (モジュール化前の動作仕様の検討版)
# キーボード入力向け日付補完
# 動作検討版
#
# sugar.jsに依存しています
class DateSuggest
now: new Date()
japan_year:
"m": 1867,
"t": 1911,
@tekei
tekei / ping_check.sh
Created May 6, 2015 10:39
pingが通るまで待つ処理。jenkinsからのサーバ自動起動用。
#!/bin/sh
PING_TARGET=$1
COUNT_LIMIT=$2
echo "try ping to ${PING_TARGET}"
COUNT=1
while true;do
@tekei
tekei / check_global_ip.sh
Created May 6, 2015 10:41
グローバルIP変化監視。変化したらprowlに通知。
#!/bin/sh
IP_ADDR_FILE="/var/lib/jenkins/current_global_ip"
CURRENT_IP_ADDR=`curl --max-time 10 -s http://inet-ip.info/`
CURL_STATUS=$?
if [ ${CURL_STATUS} -ne 0 ]; then
echo "error HTTP response / connect NG"
exit 1
@tekei
tekei / get_power_on_vmid.sh
Created May 6, 2015 10:59
VMWare ESXi 5.5 : 起動中のVMIDを取得
#!/bin/sh
for mid in `vim-cmd vmsvc/getallvms | awk '{print $1}' | grep -v "Vmid"`
do
if [ "`vim-cmd vmsvc/power.getstate ${mid} | grep 'Powered'`" == "Powered on" ]; then
echo "power on : ${mid}"
fi
done
@tekei
tekei / get-ansible-galaxy-jdk180.sh
Created February 27, 2016 14:29
install oracle java 1.8.0_45 use "williamyeh.oracle" (ansible-garaxy)
#!/bin/sh
ANSIBLE_DIR=$1
mkdir -p ${ANSIBLE_DIR}/roles
cd ${ANSIBLE_DIR}
cat << EOS > galaxy.yml
# java install
- src: williamyeh.oracle-java
@tekei
tekei / disable-ipv6.yml
Created February 27, 2016 14:31
ansible : (ubuntu) disable IPv6
---
- hosts: localhost
connection: local
become: yes
tasks:
- name: remove ipv6 hosts entry
shell: sed -i -e '/::/d' -e '/IPv6/d' /etc/hosts
- name: find ipv6 kernel parameter
shell: sysctl --all | egrep '^net.ipv6\..*disable' | awk '{print $1}'
register: ipv6_sysctl_list