Skip to content

Instantly share code, notes, and snippets.

View hrchu's full-sized avatar
:octocat:
Have an Octotastic day!

petertc hrchu

:octocat:
Have an Octotastic day!
View GitHub Profile
from confluent_kafka import Consumer, KafkaError
c = Consumer({
'bootstrap.servers': 'mybroker',
'group.id': 'mygroup',
'default.topic.config': {
'auto.offset.reset': 'smallest'
}
})
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="logstash" class="org.apache.log4j.net.SocketAppender">
<param name="Port" value="9527"/>
<param name="RemoteHost" value="127.0.0.1"/>
</appender>
Given max locate time is 102s and available size per wrap is 57.7GB, define the following formulas:
g(x) = 1 - x/57.7
f(x) = {
(1 - ⌊x⌋ - x) * 102, if ⌊x⌋ = 2k + 1
(⌊x⌋ - x) * 102, if ⌊x⌋ = 2k
}
Estimated locate time is (f ∘ g)(x) where x is the used size in the tape and k is integer.
@hrchu
hrchu / README
Last active May 30, 2018 09:15
documents extracted from cygwin.com/packages/x86_64/mt/mt-2.5.2-1
*mt 2.5*
------
- system
- All x86 and x64 Windows versions supported by Cygwin 1.7 and later.
- notes
- The default device name is "/dev/tape". Since that doesn't
exist in Cygwin by default, just create a convenient symlink.
It's done the same way on Linux.
17 sudo apt-get remove docker docker-engine docker.io
18 apt-get install docker-ce
19 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
20 $(lsb_release -cs) \
21 stable"
22 apt update
23 sudo curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
24 sudo chmod +x /usr/local/bin/docker-compose
25 docker-compose --version
26 cd
@hrchu
hrchu / mhVTL_install_ubuntu.sh
Last active September 19, 2022 19:57
mhVTL install script for Ubuntu 16.04 (tested on the kernel version that less or equal 4.15.0)
#!/bin/sh
# Script to download, compile and install mhvtl
# Tested on ubuntu 16.04
# Origin: http://mhvtl-a-linux-virtual-tape-library.966029.n3.nabble.com/Easy-Install-for-Debian-Ubuntu-td4025413.html
# 03/04/13
# Added libconfig-general-perl (ensures tgt-admin can run)
# 04/04/13
# Added line to append www-data to sudoers automatically
# Added check for sudo/root
# Added copy for tgt-admin in sbin (fixes persistant config in tgt mhvtl-gui)
@hrchu
hrchu / test_s3.sh
Created November 6, 2017 08:55
Script to test s3 service powered by s3cmd
#!/bin/bash
TEST_FILE="${PWD}/test1m"
TEST_FILE2="${PWD}/test2m"
TEST_OPT=" -c .s3cfg"
CleanEnv() {
echo "------------------------- remove all objects"
s3cmd ${TEST_OPT} ls | awk -F'/' '{ printf "%s\n",$3 }' | xargs -i s3cmd ${TEST_OPT} ls s3://{} | awk -F' ' '{printf "%s\n",$4}' | xargs -i s3cmd ${TEST_OPT} del {}
echo "------------------------- remove all buckets"
@hrchu
hrchu / ckshBBS.sh
Created May 23, 2017 06:30
Emulate cksh.twbbs.org
#!/bin/bash
echo -e "\033[H\033[mbbs.cksh.tp.edu.tw ⊙ 濟城歲月 ⊙ 203.64.138.4 [CKSHBBS Ver.1225]"
echo -e "\033[65D歡迎光臨【\033[1;33;46m 濟城歲月 \033[m】。系統負載:0.00 0.01 0.00 [負載正常]"
echo -e "\033[60D"
echo -e "\033[8D\033[1;34m └──┘ ─ │ ├── ┌──────┐\033[m"
echo -e "\033[77D\033[1;34m └─┘└─┬─┬─┘ ┌──┼─┐ ─┴─┴─── │ │\033[m"
echo -e "\033[77D\033[1;36m └┐└┬┘┌┘ │ │ │ ┌───┼─┼┐ │ │\033[m"
echo -e "\033[79D\033[1m └─┘┌┴┐│┌┴┐ └┼┘├─┐└┐ │└┬┘│ ├──────┤\033[m"
echo -e "\033[85D\033[1m │ │││ │ │ │ │ │┐ │┌│┌└─┐ │ │\033[m"
echo -e "\033[86D\033[1;36m ├────┤ │ │ │┌┼┘ ││││ │┐ ├──────┤\033[m"
@hrchu
hrchu / nginxSsl.md
Created May 2, 2017 11:02
SSL offload with Nginx and ubuntu 16.04 for radosgw
  • $ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt
  • $ apt install nginx
  • $ vim /etc/nginx/sites-available/default
upstream backends {
    server 10.144.225.175:8080;
}

server {
 listen 443 ssl;
@hrchu
hrchu / subuser (swift)
Last active December 30, 2016 02:48
coidc rgw install log
{
"user_id": "testuser",
"display_name": "First User",
"email": "",
"suspended": 0,
"max_buckets": 1000,
"auid": 0,
"subusers": [
{
"id": "testuser:swift",