Skip to content

Instantly share code, notes, and snippets.

View namsnath's full-sized avatar
🦕

Namit Nathwani namsnath

🦕
View GitHub Profile
def create_and_assert_credential(
register_options: Dict[str, Any],
sign_in_options: Dict[str, Any],
rp_id: str,
rp_name: str,
origin: str,
user_not_present: bool = True,
user_not_verified: bool = True,
):
from soft_webauthn import SoftWebauthnDevice
@namsnath
namsnath / pydantic_recursive_construct.py
Created May 20, 2025 11:25
Recursively construct Pydantic BaseModels without validation
from pydantic import BaseModel
class RecursiveConstruct(BaseModel):
@classmethod
def construct(cls, _fields_set: Optional[Set[str]] = None, **values: Any):
"""
Recursively construct pydantic model without validations.
Similar to `model_construct`, but recursive.
"""
@namsnath
namsnath / fixes_and_results.md
Last active November 23, 2024 06:41
Supertoken Issue#532

Potential fixes and load test results

Summary

Runner Implementation # users (locust) req/s
Python 01_normal 100 ~150
Python 02_normal_w_thread 100 ~140
Gunicorn + GThread 03_gunicorn 100 Unresponsive
Gunicorn + GThread 03_gunicorn 10 ~140
Gunicorn + GThread 04_gunicorn_w_thread 100 Failure
@namsnath
namsnath / FlutterSolarisedThemeProvider.dart
Created November 27, 2020 06:50
A ChangeNotifier that (kinda) implements the Solarised Theme for Flutter apps
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:logging/logging.dart';
class ThemeProvider extends ChangeNotifier {
final log = Logger('ThemeProvider');
bool _isDark = true;
bool get isDark => _isDark;
set isDark(bool val) {
@namsnath
namsnath / Arch.md
Last active July 19, 2024 16:47
A simple guide to installing ArchLinux and setting it up

Setting up Arch

Basic Setup

  • Check that the system is booted in UEFI mode
    • ls /sys/firmware/efi/efivars
    • If the directory is empty, might be in BIOS mode
  • Connect to the internet
    • Ethernet should work out of the box
    • iwctl for wifi
  • timedatectl set-ntp true to ensure time is correct
@namsnath
namsnath / Mailinabox.md
Last active December 25, 2019 12:49 — forked from theProgrammerDavid/Mailinabox.md
Adventures with Mailinabox

BCC-ing people:

BCC all mails sent to a given address:

  • nano /etc/postfix/main.cnf
  • add to the end: sender_bcc_maps = hash:/etc/postfix/sender_bcc_maps
  • nano /etc/postfix/sender_bcc_maps
  • Add lines in this format: <sender@email.com> <bcc@email.com>

BCC all mails recieved on a given address:

  • nano /etc/postfix/main.cnf
  • add to the end: recipient_bcc_maps = hash:/etc/postfix/recipient_bcc_maps