Skip to content

Instantly share code, notes, and snippets.

@noirbizarre
noirbizarre / no_lifespan_on_APIRouter.py
Created June 22, 2023 12:20
A minimal example showing that APIRouter does not support `lifespan`
from contextlib import asynccontextmanager
from fastapi import FastAPI, APIRouter
def fake_answer_to_everything_ml_model(x: float):
return x * 42
ml_models = {}
@noirbizarre
noirbizarre / gpg-offline-master.md
Created August 31, 2022 22:53 — forked from abeluck/gpg-offline-master.md
GPG Offline Master Key w/ smartcard
@noirbizarre
noirbizarre / Rescue-Arch-LVM-on-LUKS-with-direct-efi-boot.md
Created December 17, 2020 15:29 — forked from schlueter/Rescue-Arch-LVM-on-LUKS-with-direct-efi-boot.md
Rescue Arch LVM on LUKS with direct efi boot system
# Boot off a live usb or similar as if you're installing
# If you're more comfortable with a different keyboard layout
$ loadkeys dvorak
# populate the second argument of the cryptsetup command based on this
$ parted <<<'print'
# the third argument may be anything, it needn't be used later
$ cryptsetup open /dev/sda3 foobar
# check your volume groups to see what to mount
$ ls /dev/vg
import json
from pytezos import pytezos, crypto
CURVES = b'ed', b'sp', b'p2'
for curve in CURVES:
key = crypto.Key.generate(curve=curve)
filename = f'{key.public_key_hash()}.json'
with open(filename) as inf:
@noirbizarre
noirbizarre / .env
Created October 1, 2019 15:12
Dual stack udata demo (Python 2/Python 3)
DOMAIN=data.localhost
@noirbizarre
noirbizarre / export_as_csvs.py
Created April 17, 2019 14:27
Export LibreOffice Calc sheets to individual CSV files
'''
A LibreOffice Calc Python macro exporting each sheet to an individual CSV file.
The CSV will be named <sheet name>.csv and will be sibling the source file.
To use this macro, store this file in your LibreOffice Python Scripts dir,
ie. `~/.config/libreoffice/4/user/Scripts/python/` on Linux
'''
import os
@noirbizarre
noirbizarre / profiling.py
Created March 19, 2019 10:27
udata search index profiling
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function
import logging
import sys
from udata.app import create_app, standalone
from udata.commands import init_logging
from udata.search import es, commands as cmd
@noirbizarre
noirbizarre / deduplicate-users.js
Created November 13, 2018 12:38
Deduplicate users
db.user.aggregate([
{ $sort: { created_at: 1 } },
{
"$group": {
_id: "$email",
dups: { $addToSet: "$_id" } ,
count: { $sum : 1 }
}
},
{
@noirbizarre
noirbizarre / demo.html
Created September 27, 2018 13:16
An ODS dataset card to demonstrate that relative URLs are broken everywhere but the explore page
<!DOCTYPE html>
<html>
<head>
<title>Card</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://opendatasoft.github.io/ods-widgets/dist/ods-widgets.css">
<style>
* {
box-sizing: border-box;
@noirbizarre
noirbizarre / biggest-datasets.csv
Last active May 25, 2019 07:58
Biggest datasets and resources on data.gouv.fr (works on any udata instance)
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 5.
"id","title","url","resource.id","resource.title","resource.url","resource.size"
"583eac9ac751df6321c0bb7e","Archive en agro-écologie de BSV (Bulletins de Santé du Végétal)","https://www.data.gouv.fr/fr/datasets/583eac9ac751df6321c0bb7e/","b46eb5f2-f1a0-49e6-8981-88bd17cdc54d","Ecology Crop Disease Newsletter Corpus - PDF format","http://www.pestobserver.eu/zip/reports.zip",32000000000
"5b27873ac751df05a88224a2","Pyramide de tuiles depuis la BD Ortho®","https://www.data.gouv.fr/fr/datasets/5b27873ac751df05a88224a2/","a17a158b-0332-43b0-ac70-341df577179d","Wallis-et-Futuna - Zoom 9 à 16","https://owncloud.mapotempo.com/index.php/s/Wc2fwZykrJBHXMI/download?path=%2Ftiles-db-ortho&files=tiles-UTM01SW84.mbtiles",151375872
"5aaa829dc751df2fbd43eacb","ASCAD","https://www.data.gouv.fr/fr/datasets/5aaa829dc751df2fbd43eacb/","e7ab6f9e-79bf-431f-a5ed-faf0ebe9b08e","ASCAD_data","https://www.data.gouv.fr/s/resources/ascad/20180530-163000/ASCAD_data.zip",4435199469
"5862206588ee38254d3f4e5e","Base Sirene des entreprises et