Skip to content

Instantly share code, notes, and snippets.

@robyoung
robyoung / main.py
Last active Sep 7, 2020
Auto-generate pydantic models
View main.py
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 Apr 12, 2020
Can I tweak score based on facet field and query?
View main.rs
//! 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 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
COMMAND=$1
shift
if [ "$COMMAND" = "logs" -o "$COMMAND" = "exec" ]; then
RESOURCE="pods"
@robyoung
robyoung / models.py
Created Oct 5, 2018
sqlalchemy multiple joins
View models.py
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(
View gist:64203a9ace9bb82e977670bf7f78bf79
### 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:
View plan.md

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
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
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
robyoung / isolation_level.py
Last active Dec 18, 2019
Flask-SQLAlchemy set per request isolation level
View isolation_level.py
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):