Skip to content

Instantly share code, notes, and snippets.

@mybigman
mybigman / renderers.py
Created June 2, 2022 10:51 — forked from erny/renderers.py
FastAPI Simple content negotiation
"""Simple content negotiation
Usage:
Example 1:
from renderers import render
@router.post("/myapp/items/")
async def api_login(item: Item, accept: Optional[str] = Header(default='application/jwt')):
@mybigman
mybigman / app.py
Created June 2, 2022 03:19 — forked from PhilippHomann/app.py
FastAPI file upload with streaming_form_data to parse multipart/form-data
from fastapi import FastAPI, UploadFile, HTTPException
from starlette.requests import Request
from streaming_form_data import StreamingFormDataParser
from streaming_form_data.targets import FileTarget
from tempfile import NamedTemporaryFile
import os
import shutil
from typing import Optional
import base64
from passlib.context import CryptContext
from datetime import datetime, timedelta
import jwt
from jwt import PyJWTError
from pydantic import BaseModel
@mybigman
mybigman / freebsd.md
Created January 30, 2022 22:46 — forked from qis/freebsd.md
Installation and setup instructions for FreeBSD

FreeBSD

Installation template for FreeBSD RELEASE, STABLE and CURRENT.

Distribution Select

[ ] doc
[*] src (for building ports)
### FDE
man mkinitfs-bootparam
# filename and path is important
dd bs=512 count=4 if=/dev/urandom of=/crypto_keyfile.bin
cryptsetup luksAddKey /dev/sda1 /crypto_keyfile.bin
chmod 0 /crypto_keyfile.bin
cat /etc/mkinitfs/mkinitfs.conf
features="... cryptsetup cryptkey"
@mybigman
mybigman / install_notes.md
Created December 31, 2021 05:42
Arch Linux install notes (LUKS, btrfs,...)

Arch Linux, with LUKS, btrfs, systemd-homed, systemd-oomd, zram swap, encrypted DNS

Work in Progress ! Be very careful. This has had major modifications without having been thouroughly tested afterwards

Follow all steps in Arch Installation Guide and General recommandations, with following specificities. The steps are numbered as in the Arch wiki.

  • This is NOT a full setup guide, it does NOT contain all the steps required for a functioning Arch setup. Follow the official Installation Guide, and refer to this one when at the corresponding steps (check the numbers). This is intended to help in keeping this guide current, and because one should always refer to the original documentation.
  • Read through everything first
  • This is first and foremost an attempt at a modern Arch Linux setup, and a way to store my own pers
@mybigman
mybigman / 01_alpinelvmsetup.sh
Created December 20, 2021 05:29 — forked from cameroncking/01_alpinelvmsetup.sh
alpine 3.11 lvm setup
setup-keymap
setup-hostname
setup-interfaces
setup-dns
hostname=$(cat /etc/hostname)
hostname $hostname
domainname=$(grep search /etc/resolv.conf|cut -f2)
rc-service networking start
passwd
setup-timezone
@mybigman
mybigman / mysql
Created November 29, 2021 21:53 — forked from eksiscloud/mysql
Monit: MariaDB and MySQL
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
group database
group mysql
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"
if failed host localhost port 3306 protocol mysql with timeout 15 seconds for 3 times within 4 cycles then restart
if failed unixsocket /var/run/mysqld/mysqld.sock protocol mysql for 3 times within 4 cycles then restart
if 5 restarts with 5 cycles then timeout
depend mysql_bin
depend mysql_rc
@mybigman
mybigman / Installation.md
Created October 27, 2021 08:49 — forked from angerman/Installation.md
Installing nix on macOS BigSur

The nixos.org website suggests to use:

sh <(curl -L https://nixos.org/nix/install)

For macOS on Intel (x86_64) or Apple Silicon (arm64) based macs, we need to use

sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume
sudo chroot /mnt/sysroot /bin/bash --login
# set partition codes
sgdisk -t 1:ef00 /dev/vda
sgdisk -t 2:8304 /dev/vda
partprobe
# remove GRUB and exclude it from being reinstalled
rpm -v --nodeps --erase $(rpm -qa | grep "^grub2-\|^os-prober-\|^grubby-")
echo "exclude=grub2-*,os-prober,grubby" >> /etc/dnf/dnf.conf