Skip to content

Instantly share code, notes, and snippets.

View yajiefeng's full-sized avatar
🎯
Focusing

yajie.feng yajiefeng

🎯
Focusing
View GitHub Profile
@yajiefeng
yajiefeng / llm-wiki.md
Created April 6, 2026 13:34 — forked from karpathy/llm-wiki.md
llm-wiki

LLM Wiki

A pattern for building personal knowledge bases using LLMs.

This is an idea file, it is designed to be copy pasted to your own LLM Agent (e.g. OpenAI Codex, Claude Code, OpenCode / Pi, or etc.). Its goal is to communicate the high level idea, but your agent will build out the specifics in collaboration with you.

The core idea

Most people's experience with LLMs and documents looks like RAG: you upload a collection of files, the LLM retrieves relevant chunks at query time, and generates an answer. This works, but the LLM is rediscovering knowledge from scratch on every question. There's no accumulation. Ask a subtle question that requires synthesizing five documents, and the LLM has to find and piece together the relevant fragments every time. Nothing is built up. NotebookLM, ChatGPT file uploads, and most RAG systems work this way.

@yajiefeng
yajiefeng / curl proxy
Created June 15, 2020 14:28
curl proxy
1. You can make a alias in your ~/.bashrc file :
alias curl="curl -x <proxy_host>:<proxy_port>"
2. Another solution is to use (maybe the better solution) the ~/.curlrc file (create it if it does not exist) :
```
proxy = <proxy_host>:<proxy_port>
```
e.g.
```
@yajiefeng
yajiefeng / python_gist.py
Last active January 26, 2019 08:08
python gist
# mock side_effect
>>> iter_mock = mock.Mock(side_effect=[1, 2, 3])
>>> iter_mock()
1
>>> iter_mock()
2
>>> iter_mock()
3
# n days ago
@yajiefeng
yajiefeng / unsigned_long_string_parser.java
Created January 25, 2019 03:27
how to parse a unsigned long string
// "14714368837763236677" -> -3732375235946314939
long long_id = new BigInteger(str_id.trim()).longValue();
// -3732375235946314939 -> "cc33f07f74f48345"
String str_hex_id = Long.toHexString(long_id);
@yajiefeng
yajiefeng / gson_fromJson.java
Created January 15, 2019 11:46
gson->fromJson(List)
List<Student> retList = gson.fromJson(s2,
new TypeToken<List<Student>>() {
}.getType());
@yajiefeng
yajiefeng / inject_mock_object.java
Created January 12, 2019 04:01
inject mock object when ut
@RunWith(PowerMockRunner.class)
@PrepareForTest({DatasetInfoDao.class, DatasetResource.class})
public class DatasetResourceTest {
@Test
public void testIsDumpTimingValidTrue() throws Exception {
DatasetInfoDao dao = PowerMockito.mock(DatasetInfoDao.class);
PowerMockito.when(dao, "getCreatetimeByGroupIdAndDocName", Mockito.any(String.class), Mockito.any(String.class)).thenReturn(null);
DatasetResource resource = PowerMockito.spy(new DatasetResource());
MemberModifier.field(DatasetResource.class, "datasetInfoDao").set(resource, dao);
@yajiefeng
yajiefeng / mock_static.java
Created January 10, 2019 07:04
power mock static
@RunWith(PowerMockRunner.class)
@PrepareForTest(DriverManager.class)
public class Mocker {
@Test
public void testName() throws Exception {
//given
PowerMockito.mockStatic(DriverManager.class);
BDDMockito.given(DriverManager.getConnection(...)).willReturn(...);
@yajiefeng
yajiefeng / how-to-assert-exception.java
Last active January 10, 2019 07:49
java assert exception unitest
import static org.junit.jupiter.api.Assertions.assertThrows;
@Test
public void testUsernameIsNull() {
Exception exception = assertThrows(IllegalArgumentException.class, () -> {
User user = new User();
user.setName(null);
});
Assert.assertEquals("expected message", exception.getMessage());
}
{"sig":"87058829e86fa3d345d0f72e6a72425c2ab8e60a29fdc2b03c43dc73d414c7ab25acf466e8a14fdefcaab8a07c2e5ff760b91642b878303f0d64d149bdc0c1a30","msghash":"4b3370128fe7e0899a9d23151ab0a425f296c2bda535470e7c1b3830c32e2826"}
{"sig":"87058829e86fa3d345d0f72e6a72425c2ab8e60a29fdc2b03c43dc73d414c7ab25acf466e8a14fdefcaab8a07c2e5ff760b91642b878303f0d64d149bdc0c1a30","msghash":"4b3370128fe7e0899a9d23151ab0a425f296c2bda535470e7c1b3830c32e2826"}