Skip to content

Instantly share code, notes, and snippets.

[Unit]
Description=Kafka publish-subscribe messaging system
Requires=zookeeper@kafka.service
After=network.target zookeeper@kafka.service
[Service]
ExecStart=/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties
[Install]
WantedBy=multi-user.target
@zaftzaft
zaftzaft / traf.sh
Created May 29, 2018 11:48
instant traffic monitor
#!/bin/bash
dev=$1
b=0
while :
do
a=`cat /proc/net/dev | grep $dev | sed "s/\s\{1,\}/ /g" | cut -d" " -f 11`
#echo $(($a-$b))
byte=`expr $a - $b`
echo `expr $byte \* 8`
#include <time.h>
#include <stdio.h>
int main(void) {
printf("time_t: %d\n", sizeof(time_t));
printf("long: %d\n", sizeof(long));
printf("timespec: %d\n", sizeof(struct timespec));
return 0;
}
@zaftzaft
zaftzaft / 4div.py
Last active April 22, 2018 05:30
画像を分割するやつ
import sys
from PIL import Image
im = Image.open(sys.argv[1])
(w, h) = im.size
im.crop((0, 0, w/2, h/2)).save("f/a.png")
im.crop((w/2, 0, w, h/2)).save("f/b.png")
'use strict';
const readline = require("readline");
const fs = require("fs");
const {spawn} = require("child_process");
//<flag 2byte><timestamp 4><addr 4><mask 4><asn 4>
const packEvent = ev => {
const buf = Buffer.alloc(18, 0);
const timestamp = +new Date/1000|0;
@zaftzaft
zaftzaft / .vimrc
Created March 29, 2018 07:27
simple vimrc
set nocompatible
set number
set autoindent
set shiftwidth=2
set softtabstop=2
set tabstop=2
set expandtab
set list
set listchars=tab:>-,trail:-,extends:>
set noundofile
brctl addbr yabai
ip link set dev yabai up
ip a a 192.168.100.10/24 dev yabai
ip link add y-to-ns1 type veth peer name ns1-to-y
ip link add y-to-ns2 type veth peer name ns2-to-y
ip netns add ns1
ip netns add ns2
#!/usr/bin/env python3
import argparse
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *
parser = argparse.ArgumentParser()
parser.add_argument("-r", "--read", required=True, help="filename", default=None)
args = parser.parse_args()
@zaftzaft
zaftzaft / .vimrc
Created February 23, 2018 07:02
compact vimrc
set nocompatible
set number
set autoindent
set shiftwidth=2
set softtabstop=2
set tabstop=2
set expandtab
set list
set listchars=tab:>-,trail:-,extends:>
set noundofile
v=2.10.0
version=v$v
file=gobgp_${v}_linux_amd64
service=gobgpd
wget https://github.com/osrg/gobgp/releases/download/${version}/${file}.tar.gz \
-O /tmp/$file.tar.gz