Skip to content

Instantly share code, notes, and snippets.

@shirou
shirou / dummy.go
Last active October 19, 2019 13:13
marketstore dummy plugin
package main
import (
"context"
"math/rand"
"time"
)
// DummySubscriber is an dummy
type DummySubscriber struct {
@shirou
shirou / race_pipe.go
Last active April 21, 2019 05:52
go version go1.11.1 linux/amd64 build with `go build -race`
package main
import (
"bytes"
"context"
"fmt"
"os/exec"
)
// copied from internal/common/common.go
package info.tdoc.spring.example.tracer;
import io.opencensus.trace.Tracing;
import io.opencensus.trace.Tracer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.hibernate.resource.jdbc.spi.StatementInspector;
import io.opencensus.trace.AttributeValue;
import org.springframework.stereotype.Component;
package main
import (
"fmt"
"github.com/shirou/gopsutil/disk"
)
func main() {
parts, err := disk.Partitions(true)
@shirou
shirou / ssm-connect.sh
Last active October 21, 2020 05:21
connect instance via ssm selecting with peco
#!/bin/bash
# fetch Inventory from SSM
INVENTORY=$(aws ssm get-inventory --output json | jq -r '.Entities[].Id' )
# select with Tag.Name by peco
EC2=$(aws ec2 describe-instances --instance-ids $INVENTORY --output json --query 'Reservations[].Instances[*].{Id:InstanceId,Name:Tags[?Key==`Name`].Value}' | jq -r '.[][0] | (.Id) + " " + (.Name[0])' | peco)
# parse instance-id
INSTANCE_ID=$(echo ${EC2} | cut -f 1 -d " ")
package main
import (
"fmt"
"net"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/disk"
"github.com/shirou/gopsutil/host"
"github.com/shirou/gopsutil/mem"
@shirou
shirou / main.go
Created March 11, 2018 04:50
gopsutil netcounter
package main
import (
"fmt"
"time"
"github.com/shirou/gopsutil/net"
)
func run() error {
@shirou
shirou / a.md
Created January 26, 2018 12:54
sphinx 1.7.0b1 error

json

json is a most imporant keyword to reproduce.

{
  "key": "hoge"
}
@shirou
shirou / contextnize.py
Created December 31, 2017 06:24
add WithContext func to gopsutil
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division, print_function, absolute_import
# python contextanize.py *.go
# after that, goimports -w is required to add import "context"
#
# ex
# + return TimesWithContext(context.Background())
# +}
@shirou
shirou / node_exporter_init
Last active November 24, 2017 07:54
node_exporter init script
#!/bin/bash
#
#
#
# Start on runlevels 3, 4 and 5. Start late, kill early.
# chkconfig: 345 95 05
#
#
#!/bin/bash