Skip to content

Instantly share code, notes, and snippets.

View shtoma's full-sized avatar

Toma Shingo shtoma

View GitHub Profile
@shtoma
shtoma / # vim - 2016-06-24_12-34-14.txt
Created June 24, 2016 04:37
vim on Mac OS X 10.11.5 - Homebrew build logs
Homebrew build logs for vim on Mac OS X 10.11.5
Build date: 2016-06-24 12:34:14
<?xml version="1.0" encoding="UTF-8"?>
<results>
<error>1</error>
<message>エラーです。エラーです。エラーです。エラーです。</message>
</results>
<?xml version="1.0" encoding="UTF-8"?>
<results>
<error>0</error>
<image_url>http://upload.wikimedia.org/wikipedia/commons/d/d3/Little_kitten.jpg</image_url>
<template_id>99</template_id>
</results>
@shtoma
shtoma / getTotalCandy
Created April 26, 2014 10:01
問題「食べ終わった棒を3本集めると、もう1本もらえるアイスキャンディーがあります。このアイスキャンディーを20本買うと、何本食べることができるでしょう。」
#!/usr/bin/ruby
def getTotalCandy(candy)
bonus = candy / numForBonus
rest = candy % numForBonus
candy += bonus
nextExchangeableCandy = bonus + rest
until nextExchangeableCandy < numForBonus
bonus = nextExchangeableCandy / numForBonus
rest = nextExchangeableCandy % numForBonus
nextExchangeableCandy = bonus + rest
@shtoma
shtoma / snmp memo
Created December 15, 2013 01:57
snmpについてのメモ
■概要
Simple Network Management Protocol(シンプル ネットワーク マネージメント プロトコル、SNMP)は、DARPAモデルに準じたIP ネットワーク上のネットワーク機器を監視(モニタリング)・制御するための情報の通信方法を定めるプロトコルである。
※wikiより
http://ja.wikipedia.org/wiki/Simple_Network_Management_Protocol
■砕けて言うと
サーバのNFSマウント情報、負荷情報、ネットワーク情報などいろんな情報が
サーバに入らなくてもわかる。
@shtoma
shtoma / commandOnManyHosts.sh
Created December 15, 2013 01:34
single shell command executer on multiple hosts.
#!/bin/sh
if [ $# -ne 2 ]; then
echo "you need 2 args, hostlist file and shell command string" 1>&2
echo "ex) $0 hostlist.txt \"grep FATAL /usr/local/var/log/php/error.log\"" 1>&2
exit 1
fi
HOSTLIST=$1
COMMAND=$2
echo "TARGET HOSTS ARE"
cat ${HOSTLIST}
@shtoma
shtoma / nonPathCreate.sh
Last active December 31, 2015 07:49
To put ssh public keys on target servers
#!/bin/sh
##BEFORE DOING THIS, YOU NEED TO CREATE SSH id_rsa.pub##
##
#ssh-keygen -t rsa
#ls -l ~/.ssh/id_rsa
#chmod 600 ~/.ssh/id_rsa
########################################################
if [ $# -ne 1 ]; then
echo "you need a host list file." 1>&2
@shtoma
shtoma / sshWithKnownHosts.sh
Last active December 31, 2015 07:49
ssh with known hosts
#!/bin/bash
if [ $# -ne 1 ]; then
echo "you need a search word to grep your known_hosts" 1>&2
echo "ex) $0 shashinkan" 1>&2
exit 1
fi
SEARCH_WORD=$1
echo "what server do you wanna ssh?"
select ANS in `cut -f1 -d, ~/.ssh/known_hosts | grep ${SEARCH_WORD}`