Skip to content

Instantly share code, notes, and snippets.

View wtnb75's full-sized avatar

Watanabe Takashi wtnb75

  • IIJ
  • Kawasaki, Japan
View GitHub Profile
@wtnb75
wtnb75 / babanuki.py
Created January 22, 2014 15:47
babanuki
#! /usr/bin/python
# encoding: UTF-8
import os,sys
import random
class babanuki:
allcards="A234567890JQK"*4+"X"
normcard="A234567890JQK"
cardtypes=normcard+"X"
@wtnb75
wtnb75 / iptables.rb
Created February 3, 2014 15:51
Chef definitions/iptables.rb
define :iptables_open_tcp, :port => -1 do
if params[:port]>0 then
bash "iptables-#{params[:port]}" do
code <<-EOH
sed -i.bak -e '/--dport 22/a\-A INPUT -m state --state NEW -m tcp -p tcp --dport #{params[:port]} -j ACCEPT' /etc/sysconfig/iptables
EOH
not_if "grep -q -- \"--dport #{params[:port]} \" /etc/sysconfig/iptables"
end
service "iptables-restart-#{params[:port]}" do
service_name "iptables"
@wtnb75
wtnb75 / gist:8826126
Created February 5, 2014 15:31
multi-node vagrant
boxes = [
["host1", "192.168.3.2"],
["host2", "192.168.3.3"],
]
Vagrant.configure("2") do |config|
config.vm.box = "cent65"
config.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.1/centos65-x86_64-20131205.box"
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.auto_detect=true
#! /bin/sh
CC=${CC-gcc}
lang=${lang-c}
incfs=()
structs=()
for i; do
if [ -f "$i" ] ; then
incfs+=("$i")
@wtnb75
wtnb75 / json2go.go
Created December 10, 2014 15:08
go run json2go.go < input.json > test.go ; go run test.go < input.json
package main
import (
"encoding/json"
"io"
"log"
"os"
"reflect"
"strings"
"unicode"
@wtnb75
wtnb75 / s3fs-fuse-1.78-osxfuse.patch
Last active August 29, 2015 14:12
s3fs-fuse 1.78 + osxfuse patch
--- s3fs-fuse-1.78/configure.ac.orig 2014-09-15 22:30:51.000000000 +0900
+++ s3fs-fuse-1.78/configure.ac 2014-12-30 20:27:36.000000000 +0900
@@ -156,13 +156,13 @@ dnl
dnl For PKG_CONFIG before checking nss/gnutls.
dnl this is redundant checking, but we need checking before following.
dnl
-PKG_CHECK_MODULES([common_lib_checking], [fuse >= 2.8.4 libcurl >= 7.0 libxml-2.0 >= 2.6])
+PKG_CHECK_MODULES([common_lib_checking], [osxfuse >= 2.7.3 libcurl >= 7.0 libxml-2.0 >= 2.6])
AC_MSG_CHECKING([compile s3fs with])
@wtnb75
wtnb75 / rotatewriter.go
Last active August 29, 2015 14:13
/some/program | go run rotatewriter.go /path/to/out.%Y%m-%d%H
package main
import (
"bitbucket.org/tebeka/strftime"
"io"
"log"
"os"
"os/exec"
"strings"
"time"
@wtnb75
wtnb75 / gcodecomment.sh
Created November 10, 2015 16:53
MicroPrint + Slic3r
#! /bin/sh
for i; do
#awk '{print;}/move to next layer/{ly=$(NF);gsub("[()]","",ly);print ";LAYER:"ly;}' ${i} > ${i}.new
awk 'BEGIN{ly=0;}{print;}/^G1 Z/{ly++;print ";LAYER:"ly;}' ${i} > ${i}.new
if cmp ${i} ${i}.new > /dev/null ; then
rm ${i}.new
else
mv $i ${i}.bak
mv ${i}.new ${i}
@wtnb75
wtnb75 / copyto.go
Created January 12, 2016 12:21
copy pictures to /path/to/photo/yyyy/mm/dd/HHMMSS.ext
// Usage: $0 srcdir dstdir
// TODO: keep timestamp: os.Chtimes(name, atime, mtime)
package main
import (
"bytes"
"fmt"
"io"
"log"
"os"
@wtnb75
wtnb75 / docker-compose.yml
Last active December 5, 2019 22:08
gogs + drone
version: '3'
services:
gogs:
container_name: gogs
image: gogs/gogs
ports:
- 3000:3000
volumes:
- ./gogs:/data