Skip to content

Instantly share code, notes, and snippets.

View naifen's full-sized avatar

Jerry G naifen

View GitHub Profile
@naifen
naifen / docker-cheatsheet.md
Last active August 24, 2016 03:08
docker and docker-compose command cheatsheet
# list docker volumes
docker volume ls -f dangling=true

# rm all docker volumes
docker volume rm $(docker volume ls -qf dangling=true)

# stop all docker containers
docker stop $(docker ps -a -q)
@naifen
naifen / flatten_array.rb
Created June 17, 2019 23:17
a ruby method that flatten an array with associated test
def flatten_array(ary, result = [])
raise 'Please pass an array as argument' unless ary.kind_of? Array
# if an element in the given array is an array, recursively call flatten_array
# on the element, otherwise push it into the result array
ary.each do |ele|
if ele.class == Array
flatten_array(ele, result)
else
result << ele

React.js learning notes

React functional componenets and hooks

Use React memo API to prevent re-renders

In this example, every time you type something in the input field, the App component updates its state and triggers re-renders of the Count component. Use React memo in React Function Components to prevent a rerender when the incoming props of this component haven't changed:

import React, { useState, memo } from 'react';
@naifen
naifen / llm-wiki.md
Created April 30, 2026 07:23 — 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.