Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
tkuchiki / setusergroups.spec
Created February 9, 2016 04:11
setusergroups.spec
Summary: Set uid/pid/supplementary groups
Name: setusergroups
Version: 0.1.0
Release: 1%{?dist}
License: MIT
Group: Applications/Utilities
URL: https://github.com/tokuhirom/setusergroups/
Source: https://github.com/tokuhirom/setusergroups/archive/master.zip
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildRequires: make
@tkuchiki
tkuchiki / fluentdlog2json.go
Last active May 12, 2016 06:16
fluentd のログを Redshift に COPY できるようにする(JSON)
package main
import (
"bufio"
"encoding/json"
"flag"
"fmt"
"log"
"os"
"regexp"
@tkuchiki
tkuchiki / error.md
Created January 19, 2016 11:28
error lambda
Unable to import module 'lambda_function': /var/task/array.so: undefined symbol: PyUnicodeUCS2_FromUnicode
@tkuchiki
tkuchiki / grep.md
Last active January 15, 2016 10:20
grep でマッチした行と、その次のN行を除外する
@tkuchiki
tkuchiki / check_ssl_wildcard.sh
Last active March 11, 2016 02:22
ワイルドカード証明書が使われているドメインを列挙する
#!/bin/bash
WILDCARD="\*.example.com"
ROUTEFILE=/path/to/routefile
for domain in $(grep rrset ${ROUTEFILE} | awk '{print $2}' | sed -e 's/[",]//g' | sed -e 's/[.]$//g' | sort | uniq); do
if echo $domain | grep ^\* -qs ; then
d=$(echo $domain | sed -e 's/\*/test/')
curl --connect-timeout 1 curl -s --head -v https://${d}/ 2>&1 | grep -qs "Server certificate: ${WILDCARD}"
else
@tkuchiki
tkuchiki / Dockerfile
Last active January 14, 2016 03:33
CentOS6 で norikra(+ listener-mackerel) を動かす
FROM centos:centos6
WORKDIR /usr/local
RUN yum update -y && yum install -y java-1.7.0-openjdk tar
RUN curl -L https://s3.amazonaws.com/jruby.org/downloads/9.0.4.0/jruby-bin-9.0.4.0.tar.gz | tar zxf -
ENV PATH /usr/local/jruby-9.0.4.0/bin:$PATH
RUN gem install norikra --no-ri --no-rdoc
RUN gem install norikra-listener-mackerel --no-ri --no-rdoc
RUN gem install norikra-udf-percentile --no-ri --no-rdoc
@tkuchiki
tkuchiki / at.md
Last active January 4, 2016 03:23
at コマンド
$ at "14:50 2015-12-28" -f /path/to/file
job 1 at 2015-12-28 14:50
$ at $(LANG=C date +"%H:%M %Y-%m-%d" -d "2015-12-28T14:51") -f /path/to/file
job 2 at 2015-12-28 14:51
@tkuchiki
tkuchiki / dc01-client1.consul.conf.json
Last active August 25, 2016 07:43
Consul Multi-DC 検証用設定ファイル
{
"datacenter": "dc01",
"data_dir": "/tmp/dc01/node4",
"log_level": "INFO",
"dns_config": {
"allow_stale": true,
"node_ttl": "60s",
"max_stale": "60s",
"service_ttl": {
"*": "15s"
@tkuchiki
tkuchiki / bash_complesin.config.ssh.bash
Last active December 7, 2015 17:16
mackerel のホスト一覧をファイルに書いて、ssh 補完できるようにする (required jq)
# ~/.ssh/config
_known_hosts_real()
{
export NSS_SDB_USE_CACHE=yes
local config_file=~/.ssh/config
local ctime=0
[ -f $config_file ] && ctime=$(stat -c %Y $config_file)
local t=$(($(date +%s) - $ctime))
local interval=60
local search_word="# mackerel"
@tkuchiki
tkuchiki / _result.md
Created November 27, 2015 14:00
haproxy.spec
yum install -y pcre-devel
wget http://www.haproxy.org/download/1.6/src/haproxy-1.6.2.tar.gz
mv haproxy-1.6.2.tar.gz /path/to/rpmbuild/SOURCES/
# put /path/to/rpmbuild/SPECS/haproxy.spec
rpmbuild -ba /path/to/rpmbuild/SPECS/haproxy.spec