Skip to content

Instantly share code, notes, and snippets.

View gengen1988's full-sized avatar
😀
Happya

Gen Liu gengen1988

😀
Happya
View GitHub Profile
@gengen1988
gengen1988 / main.py
Created April 17, 2024 10:58
quick expose gradio python api to http
import asyncio
from typing import Annotated
from fastapi import Body, FastAPI
from gradio_client import Client
app = FastAPI()
@app.post("/gradio_proxy/{api_name}")
async def proxy(api_name: str, parameters: Annotated[dict, Body()]):
@gengen1988
gengen1988 / SelectionHistory.cs
Last active August 20, 2022 17:23
An Unity editor script to help navigating in hierarchy or project browser
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
public class SelectionHistory
{
private const int MAX_HISTORY_COUNT = 10;
@gengen1988
gengen1988 / CharacterFSM.cs
Last active October 12, 2022 23:51
A simple state pattern implements for Unity Engine
public class CharacterFSM : FsmBehaviour<CharacterFSM>
{
public float variable = 1f;
protected override State<CharacterFSM> InitState()
{
return new Natural();
}
class Natural : State<CharacterFSM>, ITickable
#!/usr/bin/env python
import math
import os
import shutil
import time
TODAY_DIR = r'F:\fences-portals\today'
WEEK_DIR = r'F:\fences-portals\this-week'
ARCHIVES_DIR = r'F:\fences-portals\archives'
@gengen1988
gengen1988 / Gun.cs
Created April 22, 2021 16:07
turret tutorial scripts
using UnityEngine;
public class Gun : MonoBehaviour
{
public GameObject shotPrefab;
public Transform[] gunPoints;
public float fireRate;
bool firing;
@gengen1988
gengen1988 / symbols.custom.yaml
Created December 7, 2020 07:15
rime 技术文档用的标点符号配置。方便写 markdown
patch:
punctuator/half_shape/+:
# 半角西文,方便写文档时加 markdown 符号
"#": "#"
"[": "["
"]": "]"
"*": "*"
"$": "$"
"@": "@"
"~": "~"
@gengen1988
gengen1988 / install.sh
Last active June 12, 2022 02:48
configure openwrt in china
#!/bin/sh
set -e
echo === configure openwrt version 21.02.0 ===
# override shadowsocks server config
SERVER_NAME=lightsail-tokyo
METHOD=xchacha20-ietf-poly1305
HOST=
@gengen1988
gengen1988 / Turret.cs
Last active April 3, 2021 16:44
Unity Universal Turret Script
using UnityEditor;
using UnityEngine;
public class Turret : MonoBehaviour
{
[Range(0, 180f)] public float angle = 45f;
public float maxTurnSpeed = 90f;
@gengen1988
gengen1988 / install.sh
Created December 18, 2018 09:06
install kubeadm on aliyun
#!/bin/bash
apt-get update && apt-get upgrade -y && apt-get install -y socat ebtables docker.io nfs-common
# enable modules
echo ip_vs_rr >> /etc/modules-load.d/modules.conf
echo ip_vs_wrr >> /etc/modules-load.d/modules.conf
echo ip_vs_sh >> /etc/modules-load.d/modules.conf
echo ip_vs >> /etc/modules-load.d/modules.conf
@gengen1988
gengen1988 / install-shadowsocks-server.sh
Last active November 28, 2018 07:39
install shadowsocks on server
#!/bin/bash
apt-get update
apt-get install -y docker.io docker-compose
apt-get install -y linux-image-4.15.0-39-lowlatency linux-modules-4.15.0-39-lowlatency
echo "tcp_bbr" >> /etc/modules-load.d/modules.conf
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
echo "net.ipv4.tcp_fastopen=3" >> /etc/sysctl.conf
cat > docker-compose.yaml << EOF