Skip to content

Instantly share code, notes, and snippets.

View JacobFV's full-sized avatar
🧑‍💻
Building the thing

Jacob Valdez JacobFV

🧑‍💻
Building the thing
View GitHub Profile
@JacobFV
JacobFV / has_permissions.py
Created May 17, 2024 22:35
has_permissions
class HasPermissions(SQLBaseModel, table=False):
"""
A base class to handle permission levels for viewing and updating fields in SQLModel entities.
This class allows setting permissions at the field level and automatically applies these permissions
as SQL policies on the database.
Attributes:
__owner_field_name__ (ClassVar[Optional[str]]): The name of the field that identifies the owner of the record.
Usage:
@JacobFV
JacobFV / dont_raise_until_done.py
Created May 17, 2024 18:44
Collect all the errors in a block of code before raising
import traceback
class DontRaiseUntilDone:
def __init__(self):
self.exceptions = []
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
@JacobFV
JacobFV / sqlmodel_fastapi_crud_starter.py
Created May 1, 2024 22:19
sqlmodel_fastapi_crud_starter.py
from abc import ABC
from datetime import datetime
from enum import Enum
from typing import ClassVar, Optional, Self
from typing_extensions import Unpack
from fastapi import APIRouter, Depends
from pydantic import UUID4, BaseModel, PrivateAttr
import pydantic
from pydantic.config import ConfigDict
@JacobFV
JacobFV / README.md
Last active April 21, 2024 15:35
huggingface_to_s3

Hugging Face Repository to S3 Transfer Script

This Python script allows you to transfer files from a Hugging Face repository to an Amazon S3 bucket. It iterates over all the files in the specified repository, downloads them one at a time, and uploads them to the designated S3 bucket.

Prerequisites

Before running the script, ensure that you have the following:

  • choose the aws linux ami with 10kIOPS and IO2 storage. make sure you can https out and ssh in
First globally define the `count-lines` alias like so:
```bash
git config --global alias.count-lines "! git log --author=\"\$1\" --pretty=tformat: --numstat | awk '{ add += \$1; subs += \$2; loc += \$1 - \$2 } END { printf \"added lines: %s, removed lines: %s, total lines: %s\n\", add, subs, loc }' #"
```
Then run this for everyone:
```bash
git log --format='%aE' | sort | uniq | xargs -I {} sh -c 'echo -n "{}: "; git count-lines {}'
from celery import Celery
from enum import Enum
from sqlmodel import SQLModel, Field, create_engine, Session
from datetime import datetime, timedelta
from sqlalchemy.exc import SQLAlchemyError
from contextlib import contextmanager
import threading
import time
from loguru import logger
from sqlalchemy import Enum as SQLEnum
@JacobFV
JacobFV / inspect_mate.py
Created April 13, 2023 16:14 — forked from MacHu-GWU/inspect_mate.py
``inspect_mate`` provides more methods to get information about class attribute than the standard library ``inspect``.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
``inspect_mate`` provides more methods to get information about class attribute
than the standard library ``inspect``.
This module is Python2/3 compatible, tested under Py2.7, 3.3, 3.4, 3.5, 3.6.
Includes tester function to check:
@JacobFV
JacobFV / output.py
Created December 14, 2022 04:25
chatGPT designs an `AGI`
'''
OpenAI released their first AGI last week. In attempting to describe it's structure and function, we simply state that their AGI has many 'things' (there's too many words "cognitive architecture"/"training paradigm"/"system"/"module"/etc. to pin down any specific one). It gathers sensory information from text, video, audio, textuo-visial, textuo-audio and machine state modalities and then fuses them togethor. It tracks its internal state in a combination of sensory-specific formats (like text, which has the bonus of being directly interprettable), structured objects (for computational efficiency and compositionality), and massive tensor embeddings (for e2e differentiability). Internal information is processed recursively which allows the information in the system to reflect on its own existance and be conscious. The system is implicitly structured such that it 'feels' emotions and 'desires' objectives. Users communicate with OpenAI's AGI using one or more of its many heads: on-screen messengers, texting,
# Electromagnetism and Quantum Computing 101
This is a fast paced introductory course to the fundementals of electromagnetism and quantum computing
## Day 1 - Electrostatics
- [Khan Academy](https://www.khanacademy.org/science/ap-physics-1/ap-electric-charge-electric-force-and-voltage)
- [Experiment: electrostatics](https://phet.colorado.edu/sims/html/balloons-and-static-electricity/latest/balloons-and-static-electricity_en.html)
- [Experiment: charge distributions](https://phet.colorado.edu/sims/html/charges-and-fields/latest/charges-and-fields_en.html)