Skip to content

Instantly share code, notes, and snippets.

View jph00's full-sized avatar
🦘
roo

Jeremy Howard jph00

🦘
roo
View GitHub Profile
@jph00
jph00 / uk-young-covid.ipynb
Created August 29, 2021 23:05
Covid cases in young people (<20) in England over time
Loading
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
Last active August 28, 2025 04:52
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
Loading
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 December 9, 2024 20:43
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
@jph00
jph00 / install-wireguard-server.sh
Last active May 19, 2022 19:42
Installation of Wireguard server. Tested on Ubuntu 20.04. Should work on 18.04 as well.
#!/usr/bin/env bash
set -e
echo
if ! [[ $(id -u) = 0 ]]; then
echo "Please run 'sudo ./install-wireguard.sh'" >&2
exit 1
fi
read -e -p "Use VPN for *all* internet traffic? [y/n] " -i n ROUTE_ALL