Skip to content

Instantly share code, notes, and snippets.

@noirbizarre
noirbizarre / README.md
Last active January 2, 2024 19:06
A Python macro for LibreOffice calc exporting all the sheets from a spreadsheet to CSV files UTF-8 encoded

Manual

This macro has to be installed in your personnal user macro in:

  • ~/.config/libreoffice/4/user/Scripts/python/export_as_csvs.py on Linux
  • \AppData\Roaming\LibreOffice\4\user\Scripts\python\export_as_csvs.py on Windows
  • /Applications/LibreOffice.app/Contents/Resources/Scripts/python/export_as_csvs.py on MacOS (there may be a better alternative)

You can execute it from the menu Tools > Macros > Run macro... and then select My Macros > export_as_csv in the left column and export_sheets_to_csv in the right one and then click on Run.

@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 / emojis.json
Created February 7, 2018 16:28
Slack emojis
{
"ok": true,
"emoji": {
"bowtie": "https:\/\/emoji.slack-edge.com\/T04C2PSNY\/bowtie\/f3ec6f2bb0.png",
"squirrel": "https:\/\/emoji.slack-edge.com\/T04C2PSNY\/squirrel\/465f40c0e0.png",
"glitch_crab": "https:\/\/emoji.slack-edge.com\/T04C2PSNY\/glitch_crab\/db049f1f9c.png",
"piggy": "https:\/\/emoji.slack-edge.com\/T04C2PSNY\/piggy\/b7762ee8cd.png",
"cubimal_chick": "https:\/\/emoji.slack-edge.com\/T04C2PSNY\/cubimal_chick\/85961c43d7.png",
"dusty_stick": "https:\/\/emoji.slack-edge.com\/T04C2PSNY\/dusty_stick\/6177a62312.png",
"slack": "https:\/\/emoji.slack-edge.com\/T04C2PSNY\/slack\/5ee0c9bea3.png",
@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 / 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
@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