Skip to content

Instantly share code, notes, and snippets.

View jiacheo's full-sized avatar

jiacheo jiacheo

View GitHub Profile
@jiacheo
jiacheo / openai_api.py
Last active June 26, 2023 12:42
ChatGLM2 to openai api
from fastapi import FastAPI, Request
from transformers import AutoTokenizer, AutoModel
import uvicorn, json, datetime
import torch
import uuid
DEVICE = "cuda"
DEVICE_ID = "0"
CUDA_DEVICE = f"{DEVICE}:{DEVICE_ID}" if DEVICE_ID else DEVICE
@jiacheo
jiacheo / MerkelTreeDemo.java
Created October 27, 2022 03:57
A simple implementation of Merkel Tree with sha256
package org.jiacheo.awesome.blockchain;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.codec.digest.DigestUtils;
import org.jiacheo.awesome.p2p.cmd.codec.JsonUtil;
/**
* merkel tree simple implement.
@jiacheo
jiacheo / MultisigWallet.sol
Created August 25, 2022 10:36
a simple multisig-wallet contract implement.
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.0;
/**
* 多签名钱包简单实现。
*/
contract MultisigWallet {
///合约拥有者、发布者,还没想好怎么用。
address owner;
@jiacheo
jiacheo / SimpleDHKE.java
Last active August 23, 2022 10:33
a DHKE simple implementation demo
package org.jiacheo.awesome.blockchain.encrypt.communication;
import java.math.BigInteger;
import java.util.concurrent.ThreadLocalRandom;
/**
* a DHKE simple implementation demo.
* Created on 2022/8/23. <br/> contact: <a style="color:yellow;text-decoration:none;"
* href="mailto:jiacheo@qipeng.com" target="_blank">jiacheo[at]qipeng.com</a> <br/>
*
@jiacheo
jiacheo / SimpleRSA.java
Created August 22, 2022 08:59
simple rsa demo
package org.jiacheo.awesome.blockchain.encrypt.communication;
import java.math.BigInteger;
import java.util.Random;
/**
* Created on 2022/8/22. <br/> contact: <a style="color:yellow;text-decoration:none;"
* href="mailto:jiacheo@qipeng.com" target="_blank">jiacheo[at]qipeng.com</a> <br/>
*
* @author jiacheo
0x0578B91D92D62C3ca0dB35CaDe994A124257E3f0
@jiacheo
jiacheo / CustomCaptchaEngine.java
Created November 7, 2016 11:54
customize captcha engine with random funky color background and ignore case sencisive
import com.octo.captcha.CaptchaException;
import com.octo.captcha.CaptchaQuestionHelper;
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator;
import com.octo.captcha.component.image.backgroundgenerator.FunkyBackgroundGenerator;
import com.octo.captcha.component.image.color.ColorGenerator;
import com.octo.captcha.component.image.fontgenerator.FontGenerator;
import com.octo.captcha.component.image.fontgenerator.TwistedAndShearedRandomFontGenerator;
import com.octo.captcha.component.image.textpaster.RandomTextPaster;
import com.octo.captcha.component.image.textpaster.TextPaster;
import com.octo.captcha.component.image.wordtoimage.ComposedWordToImage;