Skip to content

Instantly share code, notes, and snippets.

View jph00's full-sized avatar
🦘

Jeremy Howard jph00

🦘
View GitHub Profile
@jph00
jph00 / understanding_fasthtml.md
Last active September 25, 2024 06:48
Understanding FastHTML Components and Architecture - a Claude Conversation

Understanding FastHTML Components and Architecture

🧑 human (Aug 26, 2024, 03:52 PM)

What are the components of FastHTML, and how do they work together? What are some key things I need to understand to write idiomatic FastHTML apps?

🤖 assistant (Aug 26, 2024, 03:52 PM)

Based on the documentation provided, here are the key components of FastHTML and how they work together to create web applications:

  1. Core Components:

Hypermedia Systems: book summary

This is a summary of "Hypermedia Systems" by Carson Gross, Adam Stepinski, Deniz Akşimşek. Summary created by Jeremy Howard with AI help.

  • Website for the book
  • The revolutionary ideas that empowered the Web
  • A simpler approach to building applications on the Web and beyond with htmx and Hyperview
  • Enhancing web applications without using SPA frameworks

1: Hypermedia: A Reintroduction

@jph00
jph00 / pathos.md
Last active September 21, 2024 08:26
Explaining Pathos in Ancient Epics and today: Claude Conversation

Explaining Pathos in Ancient Epics and today

🧑 human (Sep 21, 2024, 06:13 PM)

What is pathos, and what's it got to do with Virgil or Homer? Explain for a 12 y.o.

🤖 assistant (Sep 21, 2024, 06:13 PM)

Pathos is a way of making people feel emotions when they read or hear something. It's like when a story makes you feel sad, happy, or excited.

Virgil and Homer were famous ancient Greek and Roman poets who wrote epic stories. They used pathos a lot in their writing to make readers really care about what was happening.

For example:

@jph00
jph00 / csv-serve-main.py
Last active September 19, 2024 23:36
CSV editor sample
from fasthtml.common import *
db = database(':memory:')
tbl = None
hdrs = (Style('''
button,input { margin: 0 1rem; }
[role="group"] { border: 1px solid #ccc; }
'''), )
app, rt = fast_app(live=True, hdrs=hdrs)
@jph00
jph00 / fast_peft.py
Last active September 16, 2024 04:30
Make get_peft_model() fast
from bitsandbytes.nn.modules import Linear8bitLt, Linear4bit
from contextlib import contextmanager
def noop (x=None, *args, **kwargs):
"Do nothing"
return x
@contextmanager
def no_kaiming():
old_iku = init.kaiming_uniform_
@jph00
jph00 / qlora.py
Created November 1, 2023 01:40
Manual qlora inference example
import torch, time, os, safetensors
from torch import nn
from peft import get_peft_model, LoraConfig, TaskType
from bitsandbytes.nn import Linear4bit, Linear8bitLt
from transformers import AutoTokenizer, LlamaForCausalLM, AutoConfig, LlamaPreTrainedModel, BitsAndBytesConfig
from transformers.utils import hub, WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_INDEX_NAME
from transformers.integrations.bitsandbytes import replace_with_bnb_linear
@jph00
jph00 / sqlite.ipynb
Last active September 6, 2024 05:08
Simple overview of fastlite and sqlite-utils
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jph00
jph00 / ds_payroll.csv
Created September 5, 2024 05:25
Death Star payroll sample CSV
id name species home_planet department position midi_chlorian_count force_sensitive blaster_accuracy date_recruited salary_credits
1 Darth Vader Human Tatooine Command Supreme Commander 27700 True 95.5 19BBY 1000000
2 Grand Moff Tarkin Human Eriadu Administration Grand Moff 0 False 88.2 22BBY 500000
3 TK-421 Human Coruscant Security Stormtrooper 120 False 62.7 10BBY 50000
4 DS-61-2 Droid Geonosis Maintenance Trash Compactor Droid 0 False 0.0 14BBY 0
5 Kylo Ren Human Chandrila Command Dark Side Apprentice 20000 True 89.3 5ABY 750000
6 General Hux Human Arkanis Military General 0 False 79.1 3ABY 400000
7 Captain Phasma Human Parnassos Security Stormtrooper Captain 50 False 91.8 7ABY 200000
8 Galen Erso Human Grange Weapons Research Chief Scientist 10 False 30.5 17BBY 300000
9 Orson Krennic Human Lexrul Weapons Development Director 0 False 75.6 30BBY 450000

Building Hypermedia Apps with FastHTML

🧑 human (Sep 5, 2024, 02:05 PM)

How can FastHTML help me write Hypermedia applications?

🤖 assistant (Sep 5, 2024, 02:05 PM)

FastHTML is designed to help you write hypermedia applications efficiently by providing a framework that aligns closely with hypermedia principles. Here are some key ways FastHTML can assist:

  1. Simplified routing and handlers: FastHTML allows you to create routes using concise decorators:
@jph00
jph00 / starlette-quick.md
Last active September 1, 2024 03:35
Starlette Quick Manual for FastHTML users

🌟 Starlette Quick Manual

2020-02-09

Starlette is the ASGI web framework used as the foundation of FastHTML. Listed here are some Starlette features FastHTML developers can use directly, since the FastHTML class inherits from the Starlette class (but note that FastHTML has its own customised RouteX and RouterX classes for routing, to handle FT element trees etc).

Get uploaded file content