Skip to content

Instantly share code, notes, and snippets.

View hiroakis's full-sized avatar

Hiroaki Sano hiroakis

View GitHub Profile
@hiroakis
hiroakis / example_rabbitmq_api.py
Last active August 21, 2023 13:33
Calling the RabbitMQ api from Python sample
#!/usr/local/bin/python
import requests
import json
def call_rabbitmq_api(host, port, user, passwd):
url = 'http://%s:%s/api/queues' % (host, port)
r = requests.get(url, auth=(user,passwd))
return r
@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"
)

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 / 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,
@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 / spec_helper.rb.patch
Last active October 14, 2016 05:46
A patch for spec_helper.rb in serverspec. This patch enables "rake spec" command to require server login password.
--- spec_helper.rb.org 2013-11-04 19:21:50.000000000 +0900
+++ spec_helper.rb 2013-11-04 23:01:26.000000000 +0900
@@ -6,12 +6,9 @@
include Serverspec::Helper::DetectOS
RSpec.configure do |c|
- if ENV['ASK_SUDO_PASSWORD']
- require 'highline/import'
- c.sudo_password = ask("Enter sudo password: ") { |q| q.echo = false }
- else
@hiroakis
hiroakis / Rakefile_serverspec
Last active June 5, 2016 21:27
serverspec for my environment
require 'rake'
require 'rspec/core/rake_task'
require 'yaml'
require 'highline/import'
properties = YAML.load_file('properties.yaml')
ENV['SSH_USER'] = ask("Enter ssh user: ") { |q| q.echo = true }
ENV['SSH_PASSWORD'] = ask("Enter ssh password: ") { |q| q.echo = false }
@hiroakis
hiroakis / IAM
Created January 22, 2016 12:17
IAM
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"NotAction": "iam:*",
"Resource": "*"
},
{
"Effect": "Allow",