Skip to content

Instantly share code, notes, and snippets.

@7c00
7c00 / hudi-connector-dev-setup.md
Created June 16, 2022 10:19
How to set up a dev environment for hudi connector
@7c00
7c00 / KafkaProducerIT.java
Created August 24, 2019 08:57 — forked from asmaier/KafkaProducerIT.java
Simple java junit test of an apache kafka producer (works with Kafka 0.11.0.2) (see also https://github.com/asmaier/mini-kafka)
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Properties;
import org.I0Itec.zkclient.ZkClient;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
@7c00
7c00 / trend.py
Created August 5, 2019 02:39
Send GitHub Trending via WeChat Work robots. 通过企业微信机器人发送 GitHub Trending.
#!/usr/bin/env python
# coding: utf-8
"""trend.py"""
import logging
import os
import requests
_SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
@7c00
7c00 / ftp_upload.py
Created February 1, 2019 12:30
You don't need an FTP client. Python provides one!
#!/usr/bin/env python
# encoding: utf-8
import ftplib
import sys
ftp_server = sys.argv[1]
ftp_port = sys.argv[2]
filename = sys.argv[3]
package main
import (
"fmt"
"os"
"reflect"
)
func main() {
if len(os.Args) >= 2 && os.Args[1] == "-p" {
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
@7c00
7c00 / gist:dcd0b132634bdd56a2f5141571d8621c
Created July 27, 2016 08:42 — forked from cridenour/gist:74e7635275331d5afa6b
Setting up Vim as your Go IDE

Setting up Vim as your Go IDE

The final IDE

Intro

I've been wanting to do a serious project in Go. One thing holding me back has been a my working environment. As a huge PyCharm user, I was hoping the Go IDE plugin for IntelliJ IDEA would fit my needs. However, it never felt quite right. After a previous experiment a few years ago using Vim, I knew how powerful it could be if I put in the time to make it so. Luckily there are plugins for almost anything you need to do with Go or what you would expect form and IDE. While this is no where near comprehensive, it will get you writing code, building and testing with the power you would expect from Vim.

Getting Started

I'm assuming you're coming with a clean slate. For me this was OSX so I used MacVim. There is nothing in my config files that assumes this is the case.

@7c00
7c00 / minimal-autocomplete.vim
Created January 22, 2016 04:27 — forked from qstrahl/minimal-autocomplete.vim
Super lightweight autocomplete using vim's built-in <C-n> completion
set cot=menu,menuone
ino <BS> <BS><C-r>=getline('.')[col('.')-3:col('.')-2]=~#'\k\k'?!pumvisible()?"\<lt>C-n>\<lt>C-p>":'':pumvisible()?"\<lt>C-y>":''<CR>
ino <CR> <C-r>=pumvisible()?"\<lt>C-y>":""<CR><CR>
ino <Tab> <C-r>=pumvisible()?"\<lt>C-n>":"\<lt>Tab>"<CR>
ino <S-Tab> <C-r>=pumvisible()?"\<lt>C-p>":"\<lt>S-Tab>"<CR>
augroup MyAutoComplete
au!
au InsertCharPre * if
set cot=menu,menuone
ino <BS> <BS><C-r>=getline('.')[col('.')-3:col('.')-2]=~#'\k\k'?!pumvisible()?"\<lt>C-n>\<lt>C-p>":'':pumvisible()?"\<lt>C-y>":''<CR>
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : ""
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
function! s:skinny_insert(char)
if !pumvisible() && !exists('s:skinny_complete') &&
\ getline('.')[col('.') - 2].a:char =~# '\k\k'
import itertools
def parse_ip(ip):
rans = map(lambda x: range(x[0], x[-1] + 1),
[map(int, part.split('-')) for part in ip.split('.')])
return ['.'.join(map(str, i)) for i in itertools.product(*rans)]
if __name__ == '__main__':
print('\n'.join(parse_ip('192.168.1-2.1-10')))