Skip to content

Instantly share code, notes, and snippets.

View jph00's full-sized avatar
🦘

Jeremy Howard jph00

🦘
View GitHub Profile
@jph00
jph00 / epi_sir_basic.ipynb
Created September 12, 2021 12:59
Basic SIR epidemic model
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jph00
jph00 / uk-young-covid.ipynb
Created August 29, 2021 23:05
Covid cases in young people (<20) in England over time
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jph00
jph00 / copilot_torch.py
Created July 18, 2021 01:18
This is the code that copilot nearly entirely auto-generates for a function called `finetune` and a 1-line docstring
# I added all the imports by hand
import torch
from torchvision.datasets import ImageFolder
from torchvision import transforms,models
from torch import nn,optim
# For all functions including this one, I wrote the name and docstring, and sometimes also the param names
def finetune(folder, model):
"""fine tune pytorch model using images from folder and report results on validation set"""
if not os.path.exists(folder): raise ValueError(f"{folder} does not exist")
@jph00
jph00 / webserver.py
Created November 17, 2020 19:18
Minimal web server demo in Python (requires fastcore: `pip install fastcore`)
from fastcore.utils import *
host = 8888,'localhost'
sock = start_server(*host)
print(f'Serving on {host}...')
while True:
conn,addr = sock.accept()
with conn:
data = conn.recv(1024)
print(data.decode())
@jph00
jph00 / type_workaround.py
Created October 21, 2020 17:56
A start on how to work around the annoying python behavior that isinstance doesn't work with generics in Python
from fastcore.all import *
from typing import _SpecialForm,_GenericAlias,Optional,Union
@patch
def __instancecheck__(self:_SpecialForm, typs): return isinstance(self, typs)
@patch(cls_method=True)
def __subclasscheck__(self:_SpecialForm, cls): return type.__subclasscheck__(self, cls)
@patch
def __subclasscheck__(self:_GenericAlias, cls):
return issubclass(cls.__origin__ if isinstance(cls, _GenericAlias) else cls, self.__origin__)
@jph00
jph00 / number_line.ipynb
Created October 18, 2020 01:10
Claire's Number Line
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<body>
<h1>Claire's Number Line</h1>
<table>
<thead>
<tr>
<th style="text-align:left"> &nbsp; &nbsp; ones<br/>tens</th>
<th style="background-color:hsla(284, 84%, 59%, 1)">0</th>
<th style="background-color:hsla(347, 87%, 78%, 1)">1</th>
<th style="background-color:hsla(46, 100%, 79%, 1)">2</th>
<th style="background-color:hsla(166, 70%, 84%, 1)">3</th>
@jph00
jph00 / py_stdlib.md
Last active September 22, 2022 18:30
Hyperlinked index to every module, function, and class in the Python standard library

All of the python 3.9 standard library

(Too big for a single gist, so see first reply for the rest)

Table of contents

@jph00
jph00 / py.md
Last active May 31, 2022 06:16
Organized and hyperlinked index to every module, function, and class in the Python standard library

All of the python 3.9 standard library

For a version without the collapsible details sections (so you can search the whole thing in your browser), click here.

@jph00
jph00 / python-stdlib.md
Created October 15, 2020 02:57
Every documented symbol in the Python standard library