Skip to content

Instantly share code, notes, and snippets.

View nwthomas's full-sized avatar

Nathan Thomas nwthomas

View GitHub Profile
@nwthomas
nwthomas / in_memory_file_system.py
Last active September 4, 2025 08:19
Python in-memory file system
"""
While the origins of this are from a coding challenge I completed for fun (which I've done for years), I came up with this implementation all on my own after thinking for a while. Because of that, I'm quite proud of it.
I've also included the Python tests I wrote for it further below in this gist.
"""
### IMPLEMENTATION ###
import typing
@nwthomas
nwthomas / demo_tools_agent.py
Last active May 19, 2024 05:52
A demo LLM agent with math-related tools
from langchain.agents import AgentExecutor, create_openai_tools_agent
from langchain_openai import ChatOpenAI
from langchain.tools import tool
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from dotenv import load_dotenv
import os
load_dotenv()
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
@nwthomas
nwthomas / two_sum_dict.py
Created May 21, 2022 06:59
An initialized dictionary
tracker = {}
@nwthomas
nwthomas / PanResponder_Overview.js
Created April 3, 2021 02:28 — forked from teameh/PanResponder_Overview.js
React native PanResponder interface overview
this._panResponder = PanResponder.create({
// ----------- NEGOTIATION:
// A view can become the touch responder by implementing the correct negotiation methods.
// Should child views be prevented from becoming responder on first touch?
onStartShouldSetPanResponderCapture: (evt, gestureState) => () => {
console.info('onStartShouldSetPanResponderCapture');
return true;
},
@nwthomas
nwthomas / roam_dark_mode.css
Last active October 12, 2020 20:08
The CSS styles for Roam Research in dark mode
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: 'GT America', sans-serif;
}
div,
function outerLayer() {
const num = 10;
function innerLayer() {
return 4 * num + 5;
}
return innerLayer;
}
const closure = outerLayer();
closure();