Skip to content

Instantly share code, notes, and snippets.

View lgs's full-sized avatar

Luca G. Soave lgs

View GitHub Profile
@lgs
lgs / main.py
Created February 26, 2025 08:45 — forked from dgwyer/main.py
Todo Pagination
from fasthtml.common import *
from datetime import datetime
def render(todo):
show = AX(todo.title, f'/todos/{todo.id}', 'current-todo')
edit = AX('edit', f'/edit/{todo.id}' , 'current-todo')
dt = ' (done)' if todo.done else ''
return Li(show, dt, ' | ', edit, id=f'todo-{todo.id}')
app,rt,todos,Todo = fast_app('data/todos.db', render, id=int, title=str, done=bool, pk='id', live=True)

Organizing FastHTML Applications Across Multiple Files

Let's explore two main approaches to splitting FastHTML applications into multiple files: using Mount and using APIRouter. I'll explain the pros and cons of each and provide practical examples.

1. Using Mount - The "Mini-Apps" Approach

Mount is ideal when you want to create semi-independent sub-applications that could potentially be reused across different projects. Think of these as "mini-apps" that handle specific features.

# blog/routes.py
@lgs
lgs / hbr-questions.md
Created February 9, 2025 16:57 — forked from jph00/hbr-questions.md
The Surprising Power of Questions - HBR

The Surprising Power of Questions

It goes far beyond exchanging information.

by

  • Alison Wood Brooks
  • Leslie K. John

From Harvard Business Review Magazine (May–June 2018)

@lgs
lgs / pathos.md
Created February 9, 2025 16:56 — forked from jph00/pathos.md
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:

@lgs
lgs / solveit.md
Created February 9, 2025 16:52 — forked from jph00/solveit.md
deepseek-solveit

The Future of AI Education: fast.ai Joins Forces with Answer.AI

Date: November 20, 2024
Author: Jeremy Howard
Categories: AI Education, fast.ai, Answer.AI


In the rapidly evolving world of artificial intelligence, the need for accessible, practical education has never been more crucial. Today, I am excited to announce that fast.ai is joining forces with Answer.AI to bring you a new era of AI education. This partnership is not just about combining resources; it's about creating a new kind of learning experience that leverages the power of AI to solve real-world problems.

@lgs
lgs / polya.md
Created February 9, 2025 16:46 — forked from jph00/polya.md
Summary of Polya's "How To Solve It With Code"

A guide to George Polya's "How to Solve It"

Introduction

George Polya (1887-1985) was a Hungarian mathematician and educator who revolutionized our understanding of problem-solving and teaching. While he made significant contributions to mathematics, his most enduring legacy is his insights into how people learn and solve problems. His 1945 book "How to Solve It" has influenced educators across numerous fields, extending far beyond mathematics.

Polya's Teaching Philosophy

Polya's approach centered on three key principles. First, he championed active learning, believing students learn best by discovering solutions themselves rather than being told answers. Second, he emphasized heuristic thinking - the art of guided discovery and learning from experience, viewing problem-solving as a skill that can be developed through practice. Third, he developed sophisticated questionin

@lgs
lgs / README.md
Created April 1, 2024 17:37 — forked from disler/README.md
Use these Prompt Chains to build HIGH QUALITY AI Agents (Agentic Building Blocks)

Setup

  1. Create a new directory with these three files (requirements.txt, main.py, README.md)
  2. python -m venv venv
  3. source venv/bin/activate
  4. pip install -r requirements.txt
  5. python main.py
  6. Update main() to run the example prompt chains
@lgs
lgs / README.md
Created March 19, 2024 18:37 — forked from lmammino/README.md
Setup SSM to connect your VSCode to a remote Cloud9 Instance (awsbites.com)

Initial steps

  1. Launch Cloud9 IDE with SSM option
  2. When it launchers, open the Cloud9 IDE in the AWS Console

With SSM

Install:

  • AWS CLI
from langchain.chat_models import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
from langchain.schema.output_parser import StrOutputParser
import requests
from bs4 import BeautifulSoup
from langchain.schema.runnable import RunnablePassthrough, RunnableLambda
from langchain.utilities import DuckDuckGoSearchAPIWrapper
import json
RESULTS_PER_QUESTION = 3
@lgs
lgs / self_execute_function_agent.py
Created November 5, 2023 10:08 — forked from bonadio/self_execute_function_agent.py
Autogen Agent that can auto execute a function_call
# %%
import os
import openai
# import autogen
from autogen import Agent, ConversableAgent, oai, UserProxyAgent, AssistantAgent
import types
from dotenv import load_dotenv, find_dotenv
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
_ = load_dotenv(find_dotenv()) # read local .env file