Skip to content

Instantly share code, notes, and snippets.

View weixinfree's full-sized avatar

BeyoundBoundary weixinfree

  • beijing,China
View GitHub Profile
@weixinfree
weixinfree / cr.py
Created July 16, 2024 07:56
code review by llm using groq
#! /usr/bin/env python3
from groq import Groq
import pyperclip
import re
from fuzzywuzzy import process
import fire
from rich.console import Console
from rich.markdown import Markdown
@weixinfree
weixinfree / ParseCombinator.kt
Last active September 12, 2023 13:56
kotlin 实现的 parse combinator
@file:Suppress("MemberVisibilityCanBePrivate", "RemoveExplicitTypeArguments")
package com.duomi.parser
class ParseException(msg: String, src: Source) : RuntimeException("$msg, occur at src: $src")
var enableAutoSkipSpace = true
class Source(val src: String) {
@weixinfree
weixinfree / kotlin_test.kt
Last active January 10, 2023 10:56
kotlin test routine 封装 given,when,then
fun <T> given(desc: String = "", block: () -> T): TestRoutine<T> {
return TestRoutine("given: $desc", block)
}
class TestRoutine<T>(
private val message: String = "",
private val block: () -> T
) {
fun <R> when_(desc: String = "", whenBlock: (T) -> R): TestRoutine<R> {
@weixinfree
weixinfree / deps-code.py
Created May 13, 2022 08:01
可视化 java/kotlin 项目的依赖关系
#! /usr/bin/env python3
USAGE = """
# 需要的依赖
brew install graphviz # 可视化渲染
python3 -m pip install simpletemplate # 生成dot 语言的文本描述
python3 -m pip install fire # 解析命令行参数
Usage: deps-code [--exlude 想要排除的类] [--engine graphviz 渲染引擎,默认为dot] interesting-code-path
@weixinfree
weixinfree / deps-gradle.py
Last active May 13, 2022 09:26
可视化 android 工程(gradle)的 不同模块之间的依赖关系
#! /usr/bin/env python3
USAGE = """
# 需要的依赖
brew install graphviz # 可视化渲染
python3 -m pip install simpletemplate # 生成dot 语言的文本描述
python3 -m pip install fire # 解析命令行参数
Usage: deps-gradle [--pattern re] [--src_pattern re] [--target_pattern re] [--engine graphviz渲染引擎默认为dot] interesting-code-path
@weixinfree
weixinfree / gitx.sh
Last active April 29, 2022 07:35
enhance git operation
#!/usr/bin/env bash
COLOR_NORMAL="\033[0m"
COLOR_GREEN="\033[1;32m"
COLOR_YELLOW="\033[1;33m"
COLOR_RED="\033[1;35m"
function error() {
echo -e "${COLOR_RED}[error]: $1${COLOR_NORMAL}"
}
@weixinfree
weixinfree / jsonparser.py
Last active March 1, 2022 03:12
json parser
from parser import (
a,
sepby,
maybe,
many,
string,
java_float,
java_int,
const,
forward_decl,
@weixinfree
weixinfree / parser.py
Last active March 1, 2022 03:11
parser combinator
from abc import abstractmethod
import re
from typing import Callable, Any, List, Sequence, Union, Optional
import logging
class State:
def __init__(self, src: str):
self.src = src
self._index = 0
@weixinfree
weixinfree / auto_inject.py
Created June 8, 2021 05:36
自动注入
#! /usr/bin/env python3
"""
install:
pip3 install fire
"""
import re
import fire
import os
@weixinfree
weixinfree / json2model.py
Last active March 1, 2022 03:12
将json转换为Gson Style的model
#! /usr/bin/env python3
"""
# install requirements:
pip3 install fire # 解析命令行参数
pip3 install simpletemplate # 生成代码
pip3 install pyperclip # 控制剪切版
pip3 install termcolor # 彩色打印
"""