Skip to content

Instantly share code, notes, and snippets.

View nabeken's full-sized avatar

Tanabe Ken-ichi nabeken

View GitHub Profile
#!/bin/bash
CONSUL_VERSION=${CONSUL_VERSION:-0.4.1}
source /etc/environment
name=$(cat /etc/machine-id)
if [ ! -f /opt/consul ]; then
[ -d /opt ] || mkdir /opt
mkdir /var/lib/consul
wget -q -O- https://dl.bintray.com/mitchellh/consul/${CONSUL_VERSION}_linux_amd64.zip | funzip - > /opt/consul
nabeken@miyo ~ % dig d36cz9buwru1tt.cloudfront.net
; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> d36cz9buwru1tt.cloudfront.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62732
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;d36cz9buwru1tt.cloudfront.net. IN A
@nabeken
nabeken / docker-volume-cleanup.py
Last active August 29, 2015 14:05
cleanup vfs directory
#!/usr/bin/env python
import json
import os
import shutil
import subprocess
import re
dockerdir = '/var/lib/docker'
volumesdir = os.path.join(dockerdir, 'volumes')
@nabeken
nabeken / fig.yml
Created August 27, 2014 15:34
fig-jenkins
jenkinsvol:
image: nabeken/docker-volume-container-rsync
environment:
OWNER: 102
GROUP: 106
ports:
- "10873:873"
jenkins:
image: jenkins
@nabeken
nabeken / gist:d5efc9a84627672e64dd
Created June 18, 2014 01:12
Traceroute6 with DIgital Ocean Singapole
Src: 2400:6180:0:d0::25:XXXX/64
traceroute to orange.kame.net (2001:200:dff:fff1:216:3eff:feb1:44d7) from 2400:6180:0:d0::25:1001, 30 hops max, 24 byte packets
1 2400:6180:0:d0:ffff:ffff:ffff:fff2 (2400:6180:0:d0:ffff:ffff:ffff:fff2) 595.557 ms 0.323 ms 1.055 ms
2 2400:6180::601 (2400:6180::601) 0.45 ms 0.228 ms 0.198 ms
3 10gigabitethernet1-1.core1.sin1.he.net (2001:de8:4::6939:1) 4.201 ms 0.871 ms 0.86 ms
4 10ge10-8.core1.par2.he.net (2001:470:0:2df::1) 184.934 ms 187.81 ms 179.406 ms
5 100ge7-1.core1.lon2.he.net (2001:470:0:2ce::1) 222.892 ms 193.384 ms 211 ms
6 ge-0.linx.londen03.uk.bb.gin.ntt.net (2001:7f8:4::b62:1) 181.468 ms 181.451 ms 181.486 ms
7 ae-0.r23.londen03.uk.bb.gin.ntt.net (2001:728:0:2000::116) 181.86 ms 181.795 ms 181.742 ms
#!/bin/bash
# wait for docker ready
sleep 10
FIRST=$(/sbin/ifconfig eth0 | grep -i global | awk '{ print $3 }' | cut -d":" -f1-4)
SECOND=$(/sbin/ifconfig eth0 | grep -i global | cut -d":" -f6,7,8,9 | cut -d"/" -f1)
IPV6=${FIRST}:a${SECOND}
for SUFFIX in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do
ip -6 route add "${IPV6}${SUFFIX}"/128 dev docker0
@nabeken
nabeken / chat1.go
Last active December 27, 2015 20:09
http://talks.golang.org/2012/chat.slide#14 Some improvement (or not) to detect a connection timeout websocket + tcp6 version
package main
import (
"fmt"
"html/template"
"io"
"log"
"net"
"net/http"
"time"
@nabeken
nabeken / tour-of-go-71.go
Created November 4, 2013 07:54
A tour of Go #71
package main
import (
"fmt"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
Fetch(url string) (body string, urls []string, err error)
@nabeken
nabeken / tour-of-go-70.go
Last active December 27, 2015 08:39
A tour of Go #70
package main
import "code.google.com/p/go-tour/tree"
import "fmt"
// Walk walks the tree t sending all values
// from the tree to the channel ch.
// FIXME: In this way how to close a channel when function returns the last value to terminate a loop
func Walk2(t *tree.Tree, ch chan int) {
if t.Left != nil {
@nabeken
nabeken / solo_patch.rb
Created July 21, 2013 02:53
Put ~/.chef/plugins/knife then you can load json from nodes/#{node_name}/node.json in knife solo cook.
require 'chef/knife'
module KnifeSolo
module NodeConfigCommand
def node_config
Pathname.new(@name_args[1] || "#{nodes_path}/#{node_name}/node.json")
end
end
end