Skip to content

Instantly share code, notes, and snippets.

Avatar
I may be slow to respond.

hzbd

I may be slow to respond.
View GitHub Profile
@hzbd
hzbd / kafkakit.py
Last active Mar 28, 2021
kafka python3 handler kit.(writer&reader&admin)
View kafkakit.py
# -*- coding: utf-8 -*-
#
# Copyright (c) 2021 六二三
# Licensed under the MIT License.
# All rights reserved.
#
# Deps:
# pip3 install kafka-python==2.0.2
#
#
@hzbd
hzbd / dingtalkkit.py
Last active Jan 28, 2021
github action dingtalk bot
View dingtalkkit.py
# -*- coding:utf-8 -*-
#
# Copyright (c) 623 MIT
#
#---------------------------------+
# * PyEnv: Python3
# * Things to do before starting:
# 1.add action secrect `DINGTALK_ACCESS_TOKEN` & `DINGTALK_SECRET`.
# 2.add job action step.
#---------------------------------+
@hzbd
hzbd / 00_make_city_geo.ipynb
Created Dec 24, 2020 — forked from junkor-1011/00_make_city_geo.ipynb
市区町村界、都道府県界データ作成
View 00_make_city_geo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hzbd
hzbd / oss-upload.sh
Created Dec 19, 2020 — forked from jsoendermann/oss-upload.sh
阿里云 Aliyun OSS curl upload 上传
View oss-upload.sh
RESOURCE="/${OSS_BUCKET_NAME}/${OBJECT_NAME}"
CONTENT_MD5=$(openssl dgst -md5 -binary "${FILEPATH}" | openssl enc -base64)
CONTENT_TYPE=$(file -ib "${FILEPATH}" |awk -F ";" '{print $1}')
DATE_VALUE="`TZ=GMT date +'%a, %d %b %Y %H:%M:%S GMT'`"
STRING_TO_SIGN="PUT\n${CONTENT_MD5}\n${CONTENT_TYPE}\n${DATE_VALUE}\n${RESOURCE}"
SIGNATURE=$(echo -e -n $STRING_TO_SIGN | openssl dgst -sha1 -binary -hmac $OSS_ACCESS_KEY_SECRET | openssl enc -base64)
URL="http://${OSS_BUCKET_NAME}.${OSS_REGION}.aliyuncs.com/${OBJECT_NAME}"
curl -i -q -X PUT -T "${FILEPATH}" \
-H "Host: ${OSS_BUCKET_NAME}.${OSS_REGION}.aliyuncs.com" \
-H "Date: ${DATE_VALUE}" \
@hzbd
hzbd / Apache_APISIX_Consul
Created Oct 29, 2020 — forked from moonming/Apache_APISIX_Consul
How to use Consul as Registration Center in Apache APISIX?
View Apache_APISIX_Consul
## Install Consul
1. download consul
```
wget https://releases.hashicorp.com/consul/1.7.3/consul_1.7.3_linux_amd64.zip
```
2. unzip to `/usr/bin`
```
sudo unzip consul_1.7.3_linux_amd64.zip -d /usr/bin
@hzbd
hzbd / auto_cmd.py
Created Oct 19, 2020 — forked from himanshurawlani/auto_cmd.py
Script to automate starting and stopping of Flask and TF_Serving servers
View auto_cmd.py
import os
import signal
import subprocess
# Making sure to use virtual environment libraries
activate_this = "/home/ubuntu/tensorflow/bin/activate_this.py"
exec(open(activate_this).read(), dict(__file__=activate_this))
# Change directory to where your Flask's app.py is present
os.chdir("/home/ubuntu/Desktop/Medium/keras-and-tensorflow-serving/flask_server")
@hzbd
hzbd / nginx_logging_http_and_stream.conf
Last active Apr 22, 2021
Nginx logging json format(http(s)&stream)
View nginx_logging_http_and_stream.conf
log_format json_http_combined escape=json
'{ "@timestamp":"$time_iso8601",'
'"server_name":"$server_name",'
'"status":$status,'
'"bytes_sent":$bytes_sent,'
'"body_bytes_sent":$body_bytes_sent,'
'"remote_addr":"$remote_addr",'
'"request_time":$request_time,'
'"request_id":"$request_id",'
@hzbd
hzbd / db-setup.sql
Created Aug 16, 2020 — forked from gka/db-setup.sql
load geoip database into mysql
View db-setup.sql
DROP TABLE IF EXISTS location;
CREATE TABLE IF NOT EXISTS `location` (
`locId` int(11) unsigned NOT NULL AUTO_INCREMENT,
`country` varchar(2) DEFAULT NULL,
`region` varchar(2) DEFAULT NULL,
`city` varchar(1000) DEFAULT NULL,
`postalCode` varchar(10) DEFAULT NULL,
`latitude` float DEFAULT NULL,
`longitude` float DEFAULT NULL,
@hzbd
hzbd / subnet.py
Created Nov 3, 2019 — forked from vndmtrx/subnet.py
Python 3 simple subnet calculator
View subnet.py
#!/usr/bin/env python3
# Use: ./subnet.py <ip/cidr>
# Alt: ./subnet.py <ip> <mask>
import sys
if __name__=="__main__":
addr = [0, 0, 0, 0]
mask = [0, 0, 0, 0]
cidr = 0
@hzbd
hzbd / subnet.py
Created Nov 3, 2019 — forked from vndmtrx/subnet.py
Python 3 simple subnet calculator
View subnet.py
#!/usr/bin/env python3
# Use: ./subnet.py <ip/cidr>
# Alt: ./subnet.py <ip> <mask>
import sys
if __name__=="__main__":
addr = [0, 0, 0, 0]
mask = [0, 0, 0, 0]
cidr = 0