Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am robyoung on github.
  • I am robyoung (https://keybase.io/robyoung) on keybase.
  • I have a public key ASBYweXvVY0udKQyNoa22crNazq_3Rw-onOncp4SeAxdIAo

To claim this, I am signing this object:

@robyoung
robyoung / isolation_level.py
Last active January 31, 2022 06:35
Flask-SQLAlchemy set per request isolation level
def isolation_level(level):
"""Return a Flask view decorator to set SQLAlchemy isolation level
Usage::
@main.route("/thingy/<id>", methods=["POST"])
@isolation_level("SERIALIZABLE")
def update_a_thing(id):
...
"""
def decorator(view):
@robyoung
robyoung / main.py
Last active September 7, 2020 08:23
Auto-generate pydantic models
from typing import Optional
import pydantic
def _create_model(name, dct, annotations):
return type(
name,
(pydantic.BaseModel,),
{"__qualname__": name, "__annotations__": annotations, **dct},
@robyoung
robyoung / main.rs
Created April 12, 2020 14:20
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
robyoung / kg
Created July 9, 2019 09:10
kg run kubectl commands against a name pattern
#!/usr/bin/env bash
#
# Kubectl grep
#
# Kubectl that replaces the target with a grep search
COMMAND=$1
shift
if [ "$COMMAND" = "logs" -o "$COMMAND" = "exec" ]; then
RESOURCE="pods"
@robyoung
robyoung / models.py
Created October 5, 2018 15:26
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('person.id'), nullable=True)
other_id = db.Column(db.Integer, db.ForeignKey('person.id'), nullable=True)
house_id = db.Column(db.Integer, db.ForeignKey('house.id'), nullable=True)
mouse_id = db.Column(db.Integer, db.ForeignKey('house.id'), nullable=True)
parent = db.relationship(
### Keybase proof
I hereby claim:
* I am robyoung on github.
* I am robyoung (https://keybase.io/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
@robyoung
robyoung / custom.css
Last active September 20, 2017 08:38
custom css
#pulls .failed {
display: none;
}
#pulls li:has(a[href*="artsalliancemedia/auth-service"]) {
display: none;
}
@robyoung
robyoung / repos.json
Created March 30, 2017 08:48
HMCTS Sustaining Fourth Wall
[
{
"userName": "ministryofjustice",
"repo": "courtfinder-search"
},
{
"userName": "ministryofjustice",
"repo": "manchester_traffic_offences_pleas"
}
]