Skip to content

Instantly share code, notes, and snippets.

robyoung /
Last active Sep 7, 2020
Auto-generate pydantic models
from typing import Optional
import pydantic
def _create_model(name, dct, annotations):
return type(
{"__qualname__": name, "__annotations__": annotations, **dct},
robyoung /
Created Apr 12, 2020
Can I tweak score based on facet field and query?
//! This example shows searching for recipes by providing a set of ingredients available.
//! In this example I would like Fried egg to have a higher score than Egg rolls because all
//! of the ingredients required for Fried egg are satisfied.
use tantivy::collector::TopDocs;
use tantivy::query::BooleanQuery;
use tantivy::schema::*;
use tantivy::{doc, Index, DocId, SegmentReader, Score};
fn main() {
let mut schema_builder = Schema::builder();
robyoung / kg
Created Jul 9, 2019
kg run kubectl commands against a name pattern
View kg
#!/usr/bin/env bash
# Kubectl grep
# Kubectl that replaces the target with a grep search
if [ "$COMMAND" = "logs" -o "$COMMAND" = "exec" ]; then
robyoung /
Created Oct 5, 2018
sqlalchemy multiple joins
class Person(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String)
parent_id = db.Column(db.Integer, db.ForeignKey(''), nullable=True)
other_id = db.Column(db.Integer, db.ForeignKey(''), nullable=True)
house_id = db.Column(db.Integer, db.ForeignKey(''), nullable=True)
mouse_id = db.Column(db.Integer, db.ForeignKey(''), nullable=True)
parent = db.relationship(
View gist:64203a9ace9bb82e977670bf7f78bf79
### Keybase proof
I hereby claim:
* I am robyoung on github.
* I am robyoung ( on keybase.
* I have a public key ASBNoXqt0wP5ncdlj0EdqMLK6dBaOa1Y4oRljGQHbUIggAo
To claim this, I am signing this object:

Release plan for asymmetric auth

  • Create new release of auth-lib (0.0.4?)
  • Create PRs for all client services (done for agent-service)
  • Merge and deploy user-service and client services together
View custom.css
#pulls .failed {
display: none;
#pulls li:has(a[href*="artsalliancemedia/auth-service"]) {
display: none;
robyoung / repos.json
Created Mar 30, 2017
HMCTS Sustaining Fourth Wall
View repos.json
"userName": "ministryofjustice",
"repo": "courtfinder-search"
"userName": "ministryofjustice",
"repo": "manchester_traffic_offences_pleas"
robyoung / gist:e62905574366f9cad535b230f3fb2ae7
Created Mar 24, 2017
Scale Summit 2017 - Session 1 - Renew - Onboarding / Maintaining Engineers
View gist:e62905574366f9cad535b230f3fb2ae7
Adding people on day one, then ongoing maintenance of them when people move
around teams.
What do people do?
Can people deploy on day one?
Some people do deploy on day one others do not
One person, working on a very small team. We just need your github account
to deploy to live. We invested a lot in the initial setup of the dev environment.
- Very small team
robyoung /
Last active Dec 18, 2019
Flask-SQLAlchemy set per request isolation level
def isolation_level(level):
"""Return a Flask view decorator to set SQLAlchemy isolation level
@main.route("/thingy/<id>", methods=["POST"])
def update_a_thing(id):
def decorator(view):