The common FastAPI pattern of injecting a database session via Depends() creates a long-lived session that spans the entire request lifecycle. This causes subtle bugs. The pattern def get_db(): db = SessionLocal() try: yield db finally: db.close() @app.get("/users/{user_id}") def get_user(user_id: int, db: Session = Depends(get_db)): return db.query(User).filter(User.id == user_id).first() The…
import { Image } from 'astro:assets'; import readyToGo from '../images/greece/ready to go in london.jpeg'; import waitingFolkestone from '../images/greece/waiting in folkstone.jpeg'; import goodbyeLondon from '../images/greece/goodbye london.jpeg'; import antwerp1 from '../images/greece/antwerp.jpeg'; import antwerp2 from '../images/greece/antwerp2.jpeg'; import antwerp3 from…
With the explosion of agent frameworks we’re seeing different approaches to defining agent “tools” in python. The two immediately obvious approaches are using the docstring or using a pydantic model to define the tool arguments. Opinions wanted : I don’t have an agent framework to shill, nor do I really have a strong opinion about either right now. I also reserve the right to change the pros and…
Below is a set of snippets that I used frequently when using pytest in the later versions of python. asyncio tests without any plugins The following snippet adds very basic support to pytest for async tests in python 3.11 and above. Add it to your conftest.py and async tests will run in an an asyncio.Runner import asyncio import inspect import logging from contextlib import contextmanager from…
The following is my notes about flying GA to Europe from the UK. Last updated: 2022-09-23 French AIP Dutch AIP Le Touquet, France Notice: 2 hours before ETD (but seem flexible) Service Hours: ATS Summer: 0700-1130, 1300-1700. Winter: 0800-1230, 1330-1800. Handling: Not required Landing fee: 25 euro ( Schedule ) Runways: 13/31 Before you go: File a flight plan through SkyDeamon. If flying VFR you…
The best tomato sauce in the world. Add the following to a large pot: 9.0kg of tomato 1.5kg onion 100g garlic 1 tbsp ground ginger Cover with sufficient water, cook for a couple of hours - the longer the better. Put through a course sieve. Mix in and warm through: 1.5kg sugar 1/2 cup salt 1.25kg apple puree 1 cup ezy-sauce Bottle.
This is an easy mid-week loaf of bread based on Joshua Weissman's video. Ingredients 125g whole milk 175g water 440g of strong white bread flour 8g of yeast 8g of salt 21g of sugar 30g of softened butter Method Mix 125g of milk and 175g of water in a saucepan and heat to ~36C. Mix 440g of bread flour, 8g of yeast, 8g of salt and 21g of sugar in a mixer bowl. Mix the warm milk/water mixture with…
In an attempt to match a restaurant quality Neopoliatan pizza, I've been experimenting with different pizza dough recipes and toppings. Most the experiments below have been made using an Ooni Koda 12" and use Shipton Mill's 00. Jan 23 2021 For 4 pizzas... using the same ratios as last time (before I started documenting). Experimenting with timings from https://github.com/hendricius/pizza-dough .…
Inspired by Joshua Weissman's 5 Ingredient Homemade Flour Tortillas and a bunch of reddit comments about making the perfect mission style flour tortilla. You can just mix all the ingredients together, then roll out but I find letting the dough autolyse for 30mins before adding the oil and salt makes the tortilla's extra soft and tasty. Ingredients 350g plain white flour 190ml warm water 6g salt…
My go-to recipe for spag bol sauce. Ingredients 500g beef mince (not too lean - fat is tasty) 250g pancetta chopped (bacon will also do) 85g carrot finely chopped (normally ~1 carrot) 85g celery finely chopped 85g onion finely chopped (one medium onion) 50g tomato paste 210ml red or white wine 300ml milk Method Heat a bit of oil in a large saucepan and add 250g of chopped pancetta. Cook until the…
I've enrolled myself in the Duke University course Statistics with R on Coursera. This is a quick note around how I setup R and R-studio on MacOS Sierra and above. Step 1: Install Homebrew and Cask . Homebrew is a package manager for MacOS and Cask allows you to install Apps using the Homebrew CLI. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"…
Ubuntu 18.04 Bionic Beaver (the latest LTS version) was released last week. The little script below will get pip3 and pipenv up and running. # Install pip and pipenv sudo apt install python3-pip python3-dev pip3 install --user pipenv # Add pipenv (and other python scripts) to PATH echo "PATH=$HOME/.local/bin:$PATH" >> ~/.bashrc source ~/.bashrc Create a new project and install some dependencies…
I have been writing web services in Go for approaching 2 years now. The factory pattern is something I have found particularly useful, especially for writing clean, concise, maintainable and testable code. Originally I used it just for the data access layer so I could swap in and out upon MySQL, PostgreSQL, etc without changing the application layer code but it has proved useful in many other…
Day 1 & 2: Dublin - Kilkenny Landing in Dublin was eventful. The wind meant the plane was thrown around like a rag doll with wings all the way down. After surviving the descent and getting our bags, we met up with our friend Bronte, who was on exchange in Glasgow. She was taking a couple of days off before returning to Glasgow for exams. Then it was time for hire car number 2. Our steed for the…
After a relatively short bus ride in from Schiphol Amsterdam we arrived at our first AirBnB. AirBnB lets people put their spare bedroom or granny flat to good use, meet people from around the world and make some money at the same time. I love it because it means you're not in an impersonal hotel or hostel and get to meet the locals! Amsterdam is famous for its skinny houses and steep staircases as…
I love Dresden. It feels like my second home and one of the few places where I feel like a local. Known as the Florence on the Elbe it is a city with a rich and colourful history. It was firebombed at the end of World War 2 and many buildings remained destroyed until the fall of the Berlin Wall and East Germany in 1989. Since then millions of hours and euros have been spent rebuilding the city to…
Following our graduation a couple of weeks ago my better half (Genevieve) and I decided we should do something to mark the occasion. As we both share a love of travel and will only get 4 weeks of annual leave this year we decided to fill our last couple of months of freedom with one big holiday - a last hurrah! Over 52 days we will visit Dresden (via Munich), Amsterdam, Ireland, Toronto, Winnipeg,…
Steve Baxter is an entrepreneur, investor, founder of River City Labs and board member for StartupAUS. He will appear as a ‘Shark’ on Channel Ten’s Shark Tank Australia when it airs in 2015. He is also the man behind the Startup Catalyst program that has brought me and 19 other young potential entreprenuers to Silicon Valley for 12 days! He recently wrote an article for Business Spectator titled…