Skip to content

Instantly share code, notes, and snippets.

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
@shirou
shirou / docker-compose.yml
Created September 11, 2017 06:10
docker postgres sample
version: '2'
services:
postgres:
image: postgres:9.5.2
volumes:
- $PWD/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
ports:
- "45432:5432"
pgweb:
go test -bench . -benchmem
BenchmarkOk-4 2000000000 0.32 ns/op 0 B/op 0 allocs/op
BenchmarkErr-4 2000000000 0.32 ns/op 0 B/op 0 allocs/op
# -*- coding: utf-8 -*-
#
# rst2pdf test documentation build configuration file, created by
# sphinx-quickstart on Fri Aug 18 10:40:42 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
const CDP = require('chrome-remote-interface');
CDP((client) => {
// extract domains
const {Network, Page, Input} = client;
// setup handlers
Network.requestWillBeSent((params) => {
console.log(params.request.url);
});
Page.loadEventFired(() => {
@shirou
shirou / consumer.py
Created November 28, 2016 13:31
dockerでkafka
# consumer.py
# pip install kafka-python すること
from kafka import KafkaConsumer, TopicPartition
consumer = KafkaConsumer(bootstrap_servers='localhost:32774') # docker ps でport番号しらべる
consumer.subscribe(['foobar'])
for msg in consumer:
print(msg)