Skip to content

Instantly share code, notes, and snippets.

@hgfkeep
hgfkeep / Producer.java
Last active August 10, 2020 10:56 — forked from sdpatil/Producer.java
kafka value Serialized with JsonSerializer
package com.mapr.kafka.serializer.json;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.connect.json.JsonSerializer;
import java.util.Properties;
@hgfkeep
hgfkeep / confluent.repo
Last active July 20, 2020 01:41
confluent centos 7 repo
[Confluent.dist]
name=Confluent repository (dist)
baseurl=https://packages.confluent.io/rpm/5.5/7
gpgcheck=1
gpgkey=https://packages.confluent.io/rpm/5.5/archive.key
enabled=1
[Confluent]
name=Confluent repository
baseurl=https://packages.confluent.io/rpm/5.5
@hgfkeep
hgfkeep / ubuntu-python.sh
Created June 3, 2020 07:56
ubuntu python env
#!/bin/bash
sudo apt-get update
sudo apt-get install python3 python-virtualenv
virtualenv --python /usr/bin/python3
@hgfkeep
hgfkeep / zh.py
Created June 3, 2020 07:52
繁体简体转化 映射表(基于维基百科)
# -*- coding: utf-8 -*-
# copy fom wikipedia
zh2Hant = {
'呆': '獃',
"打印机": "印表機",
'帮助文件': '說明檔案',
"画": "畫",
"龙": "竜",
"板": "板",
@hgfkeep
hgfkeep / green_thread.rs
Last active May 18, 2020 09:37
green_thread 实现原理
#![feature(asm)]
#![feature(naked_functions)]
use std::ptr;
// MAC 用户不支持很小的stack, 需要至少为624
pub const DEFAULT_STACK_SIZE: usize = 1024 * 1024 * 2; // 2MB的栈,即2M个u8类型的Vec
pub const MAX_THREADS: usize = 4; // 最大的 任务 线程数量
pub static mut RUNTIME: usize = 0; // 运行时
@hgfkeep
hgfkeep / clean_out_of_date_backupfile.sh
Created April 26, 2020 09:47
清理备份文件夹中过时文件clean directory with specific file suffix
#!/bin/sh
backdir="/data/tagging_system_backup"
suffix=".tgz$"
duration=864000
now=`date '+%s'`
for f in `ls $backdir|grep $suffix`;
do
name=${f%.tgz}
@hgfkeep
hgfkeep / LZ4Utils.java
Created April 7, 2020 07:23
LZ4 压缩文件和文件夹工具方法
import lombok.extern.slf4j.Slf4j;
import net.jpountz.lz4.LZ4FrameInputStream;
import net.jpountz.lz4.LZ4FrameOutputStream;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import java.io.*;
import java.nio.file.Path;
@hgfkeep
hgfkeep / custom_object_spec.json
Last active April 7, 2020 07:24
core file when generate kubernetes client custom api with metrics api
{
"paths":{
"/apis/{group}/{version}/{plural}":{
"parameters":[
{
"uniqueItems":true,
"type":"string",
"description":"If 'true', then the output is pretty printed.",
"name":"pretty",
"in":"query"