Skip to content

Instantly share code, notes, and snippets.

6c6,7
< use Time::Local;
---
> use DateTime;
> use DateTime::Format::Strptime;
12,13c13
< $NTP_LI = timegm( 0, 0, 0, 31, 12-1, 05 ); # 05/12/31 00:00:00 UTC
< $NTP_LEAP = timegm( 0, 0, 0, 1, 1-1, 06 ); # 06/01/01 00:00:00 UTC
---
> my $current_time_zone = DateTime::TimeZone->new(name => 'local')->name();
@tkuchiki
tkuchiki / get_remote_origin_url.sh
Created June 16, 2015 06:29
指定ディレクトリ以下の git の remote url 一覧を出力
find ./ -name '.git' -type d -print0 | xargs -0 -I % git -C % config --get remote.origin.url | xargs -I % echo git clone %
@tkuchiki
tkuchiki / awscli-completer.py.patch
Last active August 29, 2015 14:21
patching file awscli/completer.py(https://github.com/aws/aws-cli)
@@ -34,6 +34,9 @@
self.non_options = None
def _complete_option(self, option_name):
+ if option_name == '--color':
+ cli_data = self.driver.session.get_data('cli')
+ return cli_data['options']['color']['choices']
if option_name == '--endpoint-url':
return []
if option_name == '--output':
@tkuchiki
tkuchiki / duplicate_directory.sh
Last active August 29, 2015 14:21
apache の Directory ディレクティブの重複しているパスを出力する
grep -h -r '<Directory' /path/to/httpd/vhost/conf/dir | sed -e 's/"//g' | sed -e 's/<Directory \(.*\)>/\1/' | sed -e 's/ *//g' | sed -e 's/\/$//' | sort | uniq -c | awk 'BEGIN { status=0 } { if ($1 > 1) { print $2; status=1} } END { exit status }'
@tkuchiki
tkuchiki / gist:cb8313ef33bbe9116185
Created March 24, 2015 13:44
mongodb データ移行

server1

mongodump --db DBNAME --out  /tmp
rsync -av /tmp/DBNAME server2:/tmp/

server2

@tkuchiki
tkuchiki / php-build-patch
Last active November 21, 2015 00:36
php-build の libphp5.so を上書きしないようにする
#!/bin/bash
PHP_BUILD="${1}"
sed -i"" -e "$(grep -n 'configure_option "--with-apxs2"' $PHP_BUILD | cut -d ':' -f 1)a APXS_PATH=\"\$apxs\"" $PHP_BUILD
LINES=$(grep -n 'log "Compiling" "$source_path"' $PHP_BUILD | cut -d ':' -f 1)
sed -i"" -e "${LINES}a if [ -n \"\$APXS_PATH\" ]; then\n_LIBEXECDIR=\`\$APXS_PATH -q LIBEXECDIR\`\\nsed -i\"\" -e \"s|LIBEXECDIR='\\\\\$(INSTALL_ROOT)\$_LIBEXECDIR'|LIBEXECDIR=\$PREFIX/libexec|\" \"\$source_path/Makefile\"\nfi" $PHP_BUILD
@tkuchiki
tkuchiki / gist:014336b82c0a439cc62f
Created March 18, 2015 09:03
KVM で Device eth0 does not seem to be present, delaying initialization が出た場合の対処法
cat /root/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
@tkuchiki
tkuchiki / Dockerfile
Last active August 29, 2015 14:11
Docker provisioning for chef
FROM centos:centos6
EXPOSE 80
ADD cookbooks /root/chef/cookbooks/
ADD nodes /root/chef/nodes/
ADD roles /root/chef/roles/
ADD client.rb /root/chef/client.rb
RUN curl -L https://www.opscode.com/chef/install.sh | bash
@tkuchiki
tkuchiki / Gemfile
Last active August 29, 2015 14:11
setup chef-zero (ubuntu14.04)
source 'https://rubygems.org'
gem 'chef-zero', '3.2'
@tkuchiki
tkuchiki / gist:581a5a92bad89044a505
Last active August 29, 2015 14:11
consul-template
curl -XPUT -d '65' http://127.0.0.1:8500/v1/kv/nginx/keepalive_timeout
curl -XPUT -d '120' http://127.0.0.1:8500/v1/kv/nginx/proxy_read_timeout
curl -XPUT -d '130' http://127.0.0.1:8500/v1/kv/nginx/proxy_send_timeout
curl -XPUT -d '140' http://127.0.0.1:8500/v1/kv/nginx/proxy_connect_timeout