Skip to content

Instantly share code, notes, and snippets.

@shirou
shirou / main.go
Created May 2, 2014 10:18
emit host information to influxdb
package main
import (
"github.com/shirou/gopsutil"
"github.com/influxdb/influxdb-go"
"fmt"
"time"
)
const (
@shirou
shirou / mqtt_to_norikra.py
Last active March 27, 2016 22:36
Subscribe MQTT messages (with JSON format) and send to norikra in order to Stream Processing.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# norikra-client-python
# https://github.com/norikra/norikra-client-python
import json
import sys
import mosquitto
builder/html.pyのwrite_doc()で
self.env.toc_secnumbers.get(docname, {})
しているが、singlehtmlでは、docnameは必ずindexのため、空となる。
また、toc_secnumbersには
{
'aaa': {'': (9,), '#id2': (9, 1, 2), '#id3': (9, 2), '#hige': (9, 1), '#hoge': (9, 1, 1)},
'bbb': {'': (7,), '#id2': (7, 1), '#id3': (7, 2), '#id4': (7, 3), '#id5': (7, 4)},
}
というデータで入っているため、'#id2'が重複している。
@shirou
shirou / README
Last active October 8, 2018 14:53
ansible docker direct connection plugin
前提
-----------
- docker 0.9.1
- lxcを入れること
- linux 3.11で確認。 3.8以上じゃないとだめっぽい。
- ubuntu image (docker pull ubuntuで取ってきたもので試してみた)
- imageにはpython2を入れておくこと
- /usr/bin/tee がimageにあること
@shirou
shirou / conf.py
Created March 26, 2014 07:48
SphinxでlatexpdfjaでPDFを生成するときの設定。 (試行錯誤中)
latex_elements = {
'pointsize': '11pt',
'papersize': 'a4paper',
'transition': '',
'extraclassoptions': ',openany,oneside',
'babel': '\\usepackage[japanese]{babel}',
}
latex_docclass = {'manual': 'jreport'}
@shirou
shirou / init.yml
Created March 24, 2014 13:52
create user ansible playbook
---
- hosts: all
sudo: yes
vars:
- user_name: worker
- github_name: shirou
roles:
- initilize_user
@shirou
shirou / gist:9658377
Created March 20, 2014 06:30
zcat vs gzip module
import sys
import gzip
def zcat():
count = 0
for line in sys.stdin:
count += 1
print count
@shirou
shirou / mqtt.md
Last active August 29, 2015 13:57
mqttのmsgとclientのテーブル設計案。
  • msgid table

msgid tableはmsgidごとに実際のパケットを 以下の形式で保存する。

  #{msgid => #{packet => packet, ref_count => integer}}
@shirou
shirou / lineinfile.yml
Created March 14, 2014 13:15
あるファイル内に特定の記述(複数行)が無いときには入れる、みたいなの
---
- hosts: localhost
sudo: no
gather_facts: no
tasks:
- shell: grep ham /tmp/testfile | grep spam # pipeを使うのでshellじゃないとだめ
register: grep # grep変数に入れる
ignore_errors: yes # エラーになっても無視する
failed_when: false # これを入れると赤い文字にならない
- lineinfile: dest=/tmp/testfile insertafter=EOF line='ham'
@shirou
shirou / rst
Created March 7, 2014 03:43
子要素にラベルを付ける
.. _ul:
- hoge
.. _ul-child:
- hige
- :ref:`箇条書き <ul>`