Skip to content

Instantly share code, notes, and snippets.

View dgwyer's full-sized avatar
🏠
Working from home

David Gwyer dgwyer

🏠
Working from home
View GitHub Profile
@dgwyer
dgwyer / list.txt
Created May 31, 2025 14:11
Count of each node used in all workflows
Counter({'n8n-nodes-base.stickyNote': 7024,
'n8n-nodes-base.set': 2524,
'n8n-nodes-base.httpRequest': 2115,
'n8n-nodes-base.if': 1091,
'n8n-nodes-base.code': 1002,
'n8n-nodes-base.manualTrigger': 769,
'@n8n/n8n-nodes-langchain.lmChatOpenAi': 628,
'n8n-nodes-base.googleSheets': 597,
'n8n-nodes-base.merge': 484,
'@n8n/n8n-nodes-langchain.agent': 457,
name: Deploy Plugin
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
@dgwyer
dgwyer / wp_mcp_server.py
Last active April 16, 2025 14:45
Basic WP MCP Server
from mcp.server.fastmcp import FastMCP
import httpx
import base64
import asyncio
import os
from dotenv import load_dotenv
# Load env vars
load_dotenv()
@dgwyer
dgwyer / main.py
Created March 7, 2025 09:48
FastHTML Context Menu
from fasthtml.common import *
app,rt = fast_app(live=True)
@rt("/")
def get():
menu_css = Style("""
.context-menu {
display: none;
position: absolute;
@dgwyer
dgwyer / main.py
Created February 25, 2025 18:23
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)
@dgwyer
dgwyer / db.py
Created February 24, 2025 14:27
Audio Anki Cards
import sqlite3
# Create the SQLite database
def create_sql_questions_database():
# Connect to SQLite database (creates it if it doesn't exist)
conn = sqlite3.connect('sql_questions.db')
cursor = conn.cursor()
# Create table with auto-incrementing ID and question field
cursor.execute('''
@dgwyer
dgwyer / settings.json
Last active January 27, 2025 17:37
VS Code settings for FastHTML Pythin intellisense
{
"tailwindCSS.includeLanguages": {
"python": "html",
},
"tailwindCSS.experimental.classRegex": [
"\\b[a-zA-Z_]+\\s*=\\s*['\"]([^'\"]*)['\"]",
"\"[^\"]+\"\\s*:\\s*\"([^\"]*)\"",
"'[^']+'\\s*:\\s*'([^']*)'"
]
}
@dgwyer
dgwyer / serve.py
Created January 25, 2025 15:13
Custom FastHTML server() function for development
from fasthtml.common import *
import subprocess
def serve_dev(
app='app',
host='0.0.0.0',
port=None,
reload=True,
reload_includes=None,
reload_excludes=None,
@dgwyer
dgwyer / fasthtml-llms-ctx.txt
Last active January 23, 2025 13:05
A manually formatted version of the raw FastHTML llms-ctx.txt file to reduce file size
<project title="FastHTML" summary='FastHTML is a python library which brings together Starlette, Uvicorn, HTMX, and fastcore&#39;s `FT` "FastTags" into a library for creating server-rendered hypermedia applications. The `FastHTML` class itself inherits from `Starlette`, and adds decorator-based routing with many additions, Beforeware, automatic `FT` to HTML rendering, and much more.'>Things to remember when writing FastHTML apps:
- Although parts of its API are inspired by FastAPI, it is *not* compatible with FastAPI syntax and is not targeted at creating API services
- FastHTML includes support for Pico CSS and the fastlite sqlite library, although using both are optional; sqlalchemy can be used directly or via the fastsql library, and any CSS framework can be used. Support for the Surreal and css-scope-inline libraries are also included, but both are optional
- FastHTML is compatible with JS-native web components and any vanilla JS library, but not with React, Vue, or Svelte
- Use `serve()` for running uvi
@dgwyer
dgwyer / action-types.js
Created September 28, 2023 15:00 — forked from helgatheviking/action-types.js
Product Data Store Example
const TYPES = {
FETCH_FROM_API : "FETCH_FROM_API",
HYDRATE_PRODUCT: "HYDRATE_PRODUCT",
};
export default TYPES;