Skip to content

Instantly share code, notes, and snippets.

View buty4649's full-sized avatar

buty4649 buty4649

View GitHub Profile
@buty4649
buty4649 / gen_rrd_nighttime.sh
Created June 19, 2014 10:41
1年前からの日付からRRDを生成。6~19時は0、それ以外は1を書き込む
#!/bin/sh
rrdtool create nighttime.rrd -b $(date -d "1 years ago" +%s) DS:night:GAUGE:600:0:U RRA:MAX:0.5:1:576 RRA:MAX:0.5:6:432 RRA:MAX:0.5:24:540 RRA:MAX:0.5:288:450
perl -MRRDs -e '
$e=time;
$s=$e-3600*24*365;
while($s<=$e) {
$d=($s + 9 * 3600)%(24 * 3600);
if($d >= (19 * 3600) || $d <= (6 * 3600)) {
@buty4649
buty4649 / infra_auto.md
Created October 9, 2014 15:13
ITインフラ業務自動化現状確認会の資料

hubotを使ってIRCから便利にする

自己紹介

  • 高谷雄貴
  • 2014/02にペパボに入社
    • 前職ではSEとかSIerとか言われることをやっていた
@buty4649
buty4649 / dstat_disk_latency.py
Created November 10, 2014 11:33
dstatでディスクレイテンシ取るやつ
class dstat_plugin(dstat):
def __init__(self):
self.nick = ('latency',)
self.type = 'd'
self.width = 4
self.scale = 34
self.diskfilter = re.compile('^(dm-[0-9]+|md[0-9]+|[hs]d[a-z]+[0-9]+)$')
self.open('/proc/diskstats')
self.cols = 1
@buty4649
buty4649 / ansi2irc-color.pl
Created January 23, 2015 09:50
ANSIカラーコードからIRCカラーコードに変換する奴
#!/usr/bin/env perl
use strict;
my @t = qw/1 5 3 7 2 6 10 14 15 4 9 8 12 13 11 0/;
while(<STDIN>) {
s/\e\[0m//g;
s/\e\[(\d\d)m/"\x03".$t[$1-30]/ge;
print;
{
init: function(elevators, floors) {
var FLOOR_NUM = floors.floorNum;
var elevator1 = elevators[0]; // 初号機
var elevator2 = elevators[1]; // 弐号機
elevator1
.on("idle", function() {
elevator1.goToFloor(0);
});
@buty4649
buty4649 / mackerel-snmp-agent.sh
Created December 22, 2015 14:53
Ciscoスイッチ向けmackerel agentスクリプト
#!/bin/bash
if [ -z "$1" ];
then
echo "Usage $(basename $0) <host>"
exit 1
fi
TARGET="$1"
MACKEREL_APIKEY="API Key"
@buty4649
buty4649 / smartctl.md
Created January 23, 2016 16:13
ADATAのSSDのSMART
$ date
2016年  1月 24日 日曜日 01:13:14 JST
$ sudo smartctl -a /dev/sde
smartctl 6.4 2015-06-04 r4109 [x86_64-linux-3.17.8-gentoo-r1] (local build)
Copyright (C) 2002-15, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     SandForce Driven SSDs
Device Model:     ADATA SSD S510 120GB
@buty4649
buty4649 / keyboard-layout_helix_default.json
Last active March 6, 2018 10:08
keyboard-layout-editor.com のHelixテンプレート
[
{
"name": "Helix (https://github.com/MakotoKurauchi/helix)",
"author": "@pluis9"
},
[
"~\n\n\n\n\n\n\n\n\n`",
"!\n\n\n\n\n\n\n\n\n1",
"@\n\n\n\n\n\n\n\n\n2",
"#\n\n\n\n\n\n\n\n\n3",

GR-CITRUSにKernel#shiftOutを実装したので、SN74HC595Nを使って制御してみた。

動画: https://youtu.be/y6mvuK9XPx8

接続方法

GR-CITRUS SN74HC595N
5V -> Vcc
QA~QH -> LEDへ
@buty4649
buty4649 / led.cow
Created June 6, 2018 08:19
cowsayのLED
$color1=`tput setaf 7;tput setab 21`;
$color2=`tput setaf 7;tput setab 19`;
$color3=`tput setaf 7;tput setab 17`;
$clear=`tput sgr0`;
$the_cow = <<EOC;
$thoughts
$thoughts
$color3 $clear
$color3 $color2 $color1.-.$color2 $color3 $clear
$color3 $color2 $color1.' '.$color2 $color3 $clear