Skip to content

Instantly share code, notes, and snippets.

View bench_count.php
<?php
runs(array(1, 1, 10, 100, 1000, 10000, 100000, 1000000), array(
'$count' => function () {
$data = range(1, 25);
for ($i = 0, $count = count($data); $i < $count; $i++) {
$data[$i];
}
},
@te2u
te2u / getopts.sh
Last active Aug 29, 2015
bashでコマンドオプションを解析する(getopts)
View getopts.sh
#!/bin/bash
set -eu
help_exit() {
echo "Usage:" `basename $0` "[-f] [-b dir] [arg ...]" 1>&2
exit ${1:-0}
}
FOO=
BAR=
@te2u
te2u / ntpupdate.sh
Created Sep 11, 2013
ntpdateコマンドを使った時刻同期。 ローカルの仮想マシンを立ち上げた際に実行して時刻を同期する。
View ntpupdate.sh
#!/bin/bash
set -eu
NTP_SERVER="ntp.nict.jp"
sudo ntpdate -u $NTP_SERVER
@te2u
te2u / imap.rb
Last active Dec 16, 2015
rubyを使った未読メール取得のサンプル(IMAP)
View imap.rb
#!/usr/bin/ruby -Ku
require 'net/imap'
require 'kconv'
# imapのsslを有効にする
imap_usessl = true
imap_host = 'imap.example.com'
# ssl有効なら993、そうでなければ143
@te2u
te2u / dbdoc_bar.sh
Last active Jan 16, 2017
SchemaSpy sample2
View dbdoc_bar.sh
#!/bin/sh
set -eu
SCRIPT_DIR=$(cd $(dirname $0);pwd);
SCHEMASPY_JAR=$SCRIPT_DIR/schemaSpy_5.0.0.jar
JDBC_DRIVER_PATH=$ORACLE_HOME/jdbc/lib/ojdbc5.jar
DBTYPE=orathin
HOST="192.168.0.100"
@te2u
te2u / dbdoc_foo.sh
Last active Jan 16, 2017
SchemaSpy sample1
View dbdoc_foo.sh
#!/bin/sh
set -eu
SCRIPT_DIR=$(cd $(dirname $0);pwd);
SCHEMASPY_JAR=$SCRIPT_DIR/schemaSpy_5.0.0.jar
JDBC_DRIVER_PATH=$ORACLE_HOME/jdbc/lib/ojdbc5.jar
DBTYPE=ora
DBNAME=foo # tnsname