Skip to content

Instantly share code, notes, and snippets.

View hiroakis's full-sized avatar

Hiroaki Sano hiroakis

View GitHub Profile

Keybase proof

I hereby claim:

  • I am hiroakis on github.
  • I am hiroakis (https://keybase.io/hiroakis) on keybase.
  • I have a public key ASBKQZEisRZCgOs-Cr_5JFfXL-A6nahRyh5F-S_k46tGuAo

To claim this, I am signing this object:

@hiroakis
hiroakis / main.go
Created December 14, 2018 12:19
ast
package main
import (
"bytes"
"fmt"
"go/ast"
"go/parser"
"go/token"
"io"
"log"
@hiroakis
hiroakis / status.rb
Created April 11, 2017 06:12
mkr command wrapper
require 'json'
service = ARGV[0]
role = ARGV[1]
status = ARGV[2]
roleFullnames = "#{service}:#{role}"
hosts = JSON.parse(`mkr hosts`)
target_host_ids = []
@hiroakis
hiroakis / tail.go
Created January 15, 2017 17:14
The tail command implementation written in go. The command support -F option. It is default action.
package main
import (
"flag"
"fmt"
"io"
"os"
"time"
"github.com/fsnotify/fsnotify"
@hiroakis
hiroakis / fsnotify_example.go
Last active April 21, 2022 10:56
fsnotify example: Detect file changes in real time.
package main
import (
"log"
"os"
"time"
"github.com/fsnotify/fsnotify"
)
@hiroakis
hiroakis / IAM
Created January 22, 2016 12:17
IAM
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"NotAction": "iam:*",
"Resource": "*"
},
{
"Effect": "Allow",
#!/bin/sh
touch production staging
mkdir group_vars
touch group_vars/group1
touch group_vars/group2
mkdir host_vars
touch host_vars/hostname1
touch host_vars/hostname2
mkdir library
@hiroakis
hiroakis / enqueue.rb
Last active March 27, 2017 20:50
queue implementation using MySQL
require 'mysql2-cs-bind'
def get_db
return Mysql2::Client.new(
:host => 'localhost',
:port => 3306,
:username => 'root',
:password => '',
:database => 'queue_test',
:reconnect => true,
backend default {
.host = "127.0.0.1";
.port = "8000";
}
sub vcl_recv {
if (req.request == "POST") {
ban("req.url ~ /");
return(pass);
@hiroakis
hiroakis / error
Last active August 29, 2015 14:03
fluentd 0.10.51 error occurred when "include" tag exists in td-agent.conf
[root@xxxxx gems]# /etc/init.d/td-agent start
Starting td-agent: /usr/lib64/fluent/ruby/lib/ruby/gems/1.9.1/gems/fluentd-0.10.51/lib/fluent/config/parser.rb:57:in `process_include': uninitialized constant Fluent::Config::Parser::URI (NameError)
from /usr/lib64/fluent/ruby/lib/ruby/gems/1.9.1/gems/fluentd-0.10.51/lib/fluent/config/parser.rb:41:in `parse!'
from /usr/lib64/fluent/ruby/lib/ruby/gems/1.9.1/gems/fluentd-0.10.51/lib/fluent/config/parser.rb:8:in `parse'
from /usr/lib64/fluent/ruby/lib/ruby/gems/1.9.1/gems/fluentd-0.10.51/lib/fluent/config.rb:33:in `parse'
from /usr/lib64/fluent/ruby/lib/ruby/gems/1.9.1/gems/fluentd-0.10.51/lib/fluent/supervisor.rb:364:in `apply_system_config'
from /usr/lib64/fluent/ruby/lib/ruby/gems/1.9.1/gems/fluentd-0.10.51/lib/fluent/supervisor.rb:110:in `initialize'
from /usr/lib64/fluent/ruby/lib/ruby/gems/1.9.1/gems/fluentd-0.10.51/lib/fluent/command/fluentd.rb:160:in `new'
from /usr/lib64/fluent/ruby/lib/ruby/gems/1.9.1/