Skip to content

Instantly share code, notes, and snippets.

View ueokande's full-sized avatar
🙆‍♀️
LGTM

Shin'ya Ueoka ueokande

🙆‍♀️
LGTM
View GitHub Profile
xwininfo
ffmpeg -video_size ${w}x${height} -framerate 12 -f x11grab -i :0.0+${x},${y} output/%04d.png
@ueokande
ueokande / shell-ip-address
Last active February 21, 2024 12:39
Calculating network addresses in tthe shell script
#!/bin/sh
# converts IPv4 as "A.B.C.D" to integer
# ip4_to_int 192.168.0.1
# => 3232235521
ip4_to_int() {
IFS=. read -r i j k l <<EOF
$1
EOF
echo $(( (i << 24) + (j << 16) + (k << 8) + l ))
@ueokande
ueokande / leader-election-with-etcd.sh
Last active January 25, 2018 13:13
Leader election with etcd
#!/bin/sh
ID=$(uuidgen)
LEADER_KEY="localhost:2379/v2/keys/master"
TTL=5
INTERVAL=1
i_am_leader() {
echo "I am leader";
while true; do

bootstrap.servers

A list of host/port pairs to use for establishing the initial connection to the Kafka cluster. The client will make use of all servers irrespective of which servers are specified here for bootstrapping—this list only impacts the initial hosts used to discover the full set of servers. This list should be in the form host1:port1,host2:port2,.... Since these servers are just used for the initial connection to discover the full cluster membership (which may change dynamically), this list need not contain the full set of servers (you may want more than one, though, in case a server is down).

key.deserializer

Deserializer class for key that implements the Deserializer interface.

value.deserializer

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
(1..2).each do |n|
config.vm.define "ap-#{n}" do |node|
node.vm.provider "docker" do |docker|
docker.build_dir = "vanilla"
docker.expose = [8000, 12201]
@ueokande
ueokande / print-rowkey
Created May 18, 2017 03:25
Print rowkey
#!/usr/bin/env ruby
utsname = []
topic = []
if ARGV.length < 1
STDERR.puts("Missing arguments")
exit 1
end
var page = require('webpage').create();
page.open('http://www.tamagoya.co.jp/menu_list.html', function() {
var rect = page.evaluate(function() {
var menuDate = Array.prototype.find.call(
document.querySelectorAll('.menutitle_date'),
(e) => e.textContent.includes("26") );
var menuTitle = menu_date.parentElement;
var menuList = menuTitle.nextElementSibling
var menuBottom = menuList.nextElementSibling
April 2017
Su Mo Tu We Th Fr Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
@ueokande
ueokande / benchmark-commands.md
Last active January 22, 2024 12:38 — forked from jkreps/benchmark-commands.txt
Kafka Benchmark Commands

Benchmark commands

Producer

Setup

bin/kafka-topics.sh \
  --zookeeper zookeeper.example.com:2181 \
  --create \
@ueokande
ueokande / timeout.java
Created February 23, 2017 01:50
Timeout in java
String synchronizedHeavyMethod(Duration timeout) throws TimeoutException {
Instant deadline = Instant.now().plus(timeout);
while (Instant.now().isBefore(deadline)) {
// doSomething() resutrns nullable String
String result = doSomething();
if (Objects.isNull(result)) {
continue;
}
return result;
}