Skip to content

Instantly share code, notes, and snippets.

@hxy9243
hxy9243 / dummy_agent.py
Created July 10, 2023 02:50
A dummy agent to illustrate the LangChain Agent interface
from typing import List, Tuple, Any
from langchain.schema import AgentAction, AgentFinish
from langchain.agents import BaseSingleActionAgent
class DummyAgent(BaseSingleActionAgent):
"""DummyAgent is an agent that simply repeats the execution of the tool
by the specified number of times.
@hxy9243
hxy9243 / api.yaml
Last active February 22, 2023 21:33
Example openAPI definition
openapi: 3.0.0
info:
title: OpenAPI Library Demo App
version: 0.0.1
servers: [
{
"url": "http://localhost:8000",
"description": "local development server",
},
]
# required libraries:
# pandas, openpyxl
import pandas as pd
def read_excel():
with open('高等学校-法宝列表.xlsx', 'rb') as f:
data = pd.read_excel(f, engine='openpyxl', header=0,
sheet_name='for dissertation')
@hxy9243
hxy9243 / docreader.py
Last active November 14, 2021 05:50
Get jieba to analyze pdf and word
# depend on third-party libraries, run the following command to install:
# sudo pip3 install jieba pdfplumber docx2txt
#
# run the script with:
# python3 reader.py <yourfile.pdf> <yourfile.doc>
#
# see more at: https://github.com/fxsjy/jieba
import sys
@hxy9243
hxy9243 / ocr.ipynb
Last active May 26, 2022 04:57
Excel OCR example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hxy9243
hxy9243 / unique_products.py
Last active February 13, 2021 04:58
Some CS competition problem
import os
inputstr = input('input: ')
splitted = inputstr.split()
assert len(splitted) == 2, 'Error: invalid input'
N = int(splitted[0])
M = int(splitted[1])
print('input: M = %d, N = %d' % (M, N))
@hxy9243
hxy9243 / parse.py
Last active August 11, 2019 21:27
A snippet to generate Anki-compatible csv for flashcards
# gre.txt from plaintext in
# https://gre.economist.com/gre-advice/gre-vocabulary/which-words-study/most-common-gre-vocabulary-list-organized-difficulty
with open('gre.txt') as inf, \
open('out.csv', 'w') as outf:
count = 0
while True:
line = inf.readline()
if line == '':
@hxy9243
hxy9243 / DistributedSystem.md
Created May 19, 2019 23:12
Distributed System Topics Mindmap
@hxy9243
hxy9243 / daemon.go
Last active May 18, 2018 05:38
Useful go snippets
package main
import (
"os"
"syscall"
"os/exec"
"fmt"
)
// Start daemon function
@hxy9243
hxy9243 / Dockerfile
Last active December 4, 2018 03:17
Dockerfile and scripts to make an LLVM docker image
FROM ubuntu
MAINTAINER Kevin Hu <hxy9243@gmail.com>
ARG LLVM_SRC=llvm-project
RUN apt-get update
RUN apt-get install -y cmake ninja-build $COMPILER
RUN apt-get build-dep -y llvm clang
RUN apt-get clean