Skip to content

Instantly share code, notes, and snippets.

View crizCraig's full-sized avatar
Journeying through levels of abstraction trying to land

Craig Quiter crizCraig

Journeying through levels of abstraction trying to land
View GitHub Profile
def generic_unsync(func: Callable[..., Any]) -> Callable[..., Any]:
A function that dynamically decides whether to run asynchronously
or synchronously based on whether it's in an async context,
but always returns the result synchronously so that
you can use it from an async or sync context.
from unsync import unsync # type: ignore # pylint: disable=import-outside-toplevel
@unsync # type: ignore
import asyncio
from typing import AsyncGenerator
async_q: asyncio.Queue[str] = asyncio.Queue()
async def producer() -> None:
# Assuming `a` should be a value like 1, 2, etc.
# a = 1
await async_q.put(str(a)) # a not defined
crizCraig /
Last active September 30, 2023 19:33
  1. Love, connection, caring, compassion, tolerance, helping others, sharing, and acceptance. We value the ability to love and to be loved, to connect with others, to care for others, to be compassionate, to be tolerant, to share, to help others, and to accept others.
  2. Freedom and autonomy. We value the ability to make our own decisions and to have control over our own lives. We value the ability to believe what we want, to have our own thoughts, and to have our own feelings. We value the ability to have our own opinions and to express them freely. We value the ability to have our own goals and to pursue them. We value the ability to have our own values and to live by them. We value the ability to have our own identity and to be ourselves.
  3. Harmony and peace. We value the ability to live in harmony with others and our surroundings and to live in peace without war, violence, or conflict.
  4. The right to life and the pursuit of happiness. We value the ability to live and to pursue happiness. We value the abi
crizCraig /
Last active July 3, 2023 19:04
Python timing decorator to measure how long a function takes (handles async and sync)
import asyncio
import time
from typing import Callable, Any
def timed(fn: Callable[..., Any]) -> Callable[..., Any]:
Decorator log test start and end time of a function
:param fn: Function to decorate
:return: Decorated function
crizCraig /
Created June 18, 2021 17:30
Just a date string
from datetime import datetime
DATE_STR ='%Y_%m-%d_%H-%M.%S.%f')
crizCraig /
Last active May 6, 2024 18:58
Game of AGI

Game of AGI

Play the game in Colab

View simulator source

Game of AGI (GOA) is a socio-techno monte carlo simulation which estimates the existential risk posed by AGI. You play by setting various factors, i.e. AI spending and AGI safety spending, along with their uncertainties and GOA returns the existential risk, corruption risk, and value alignment probability associated with your guesses by sampling 1M times from guassian distributions of your guesses.

N.B. When referring to AGI's as separate entities, I am referring to autonomous groups of humans (i.e. companies, governments, groups, organizations) that are in control of some tech stack capable of AGI. There may be several autonomous AGIs within any certain stack, but we assume they have an umbrella objective defined by

# In a family with two children, what are the chances, if **one** of the children is a girl, that both children are girls?
from random import random
n = 0
c = 0
for i in range(100000):
a = random() < 0.5
b = random() < 0.5
if a or b: # **one** implies _either_ child
n += 1
if a and b:
import os
from deepdrive_zero.experiments import utils
from spinup.utils.run_utils import ExperimentGrid
from spinup import ppo_pytorch
import torch
experiment_name = os.path.basename(__file__)[:-3]
notes = """
Simplest environment. Should reach 98% average angle accuracy in about 5 minutes
crizCraig /
Last active December 8, 2019 20:25
Mastering Atari, Go, Chess and Shogi by Planning with a Learned Model - Pseudocode from supplemental materials
# Lint as: python3
"""Pseudocode description of the MuZero algorithm."""
# pylint: disable=unused-argument
# pylint: disable=missing-docstring
# pylint: disable=g-explicit-length-test
from __future__ import absolute_import
from __future__ import division
from __future__ import google_type_annotations
from __future__ import print_function