Skip to content

Instantly share code, notes, and snippets.

View PiotrCzapla's full-sized avatar

Piotr Czapla PiotrCzapla

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PiotrCzapla
PiotrCzapla / 11_initializing.ipynb
Created December 27, 2022 10:08
LSUVInit + cache for m1
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PiotrCzapla
PiotrCzapla / jupyter-https.md
Created November 30, 2022 19:17
mkcert + 1pass to securely serve jupyter notebooks on .local over https

Howto

$ mkcert --install  # to generate and install your root ca
$ mkcert myserver.local # to generate certificate

Then to enable https in jupyter use this snipped (it assumes your pem and key.pem files are in ~/.jupyter)

from pathlib import Path
c.NotebookApp.keyfile, c.NotebookApp.certfile = sorted(map(str,Path.home().glob('.jupyter/*.pem')))
@PiotrCzapla
PiotrCzapla / clean_up_after_unhandled_exception.ipynb
Last active December 9, 2022 14:22
Clean up a memory leak after unhandled exception in jupyter notebooks.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PiotrCzapla
PiotrCzapla / clean_up_after_unhandled_exception.ipynb
Created December 8, 2022 17:04
Cleaning up after unhandled exception in jupyter notebooks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PiotrCzapla
PiotrCzapla / 04_minibatch_training_withoutbody.ipynb
Last active November 25, 2022 11:20
fastai 04_minibatch_training_withoutbody.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PiotrCzapla
PiotrCzapla / 03_backprop-withoutbody.ipynb
Last active November 25, 2022 11:19
fast ai 03 backprop without body
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PiotrCzapla
PiotrCzapla / nre_deployment.py
Last active June 24, 2022 17:11
Python script to log a new relic deployment information with minimal python dependency
"""
Python script to log a new relic deployment information with minimsl dependencies
# Usage:
The scripts accepts either `list` or `new` commands
$ API_KEY="..." APP_ID="..."" python nr_deployment.py new 'rev id' "my title"\
--description="some desc" --timestamp='2022-01-02' --user='test'
# Credentials configuration
@PiotrCzapla
PiotrCzapla / exchange_rate.py
Last active March 16, 2022 11:42
Get NBP currency exchange rate in python with memory cache, this can act as simple python API :)
# license: mit
import requests
from functools import lru_cache
@lru_cache(maxsize=None)
def get_nbp_exchange_rate(date:datetime, table='A'):
"""
Get the exchange rate from the NBP API, and store it in cache folder
>> get_nbp_exchange_rate(datetime(2022,3,8))['EUR']
@PiotrCzapla
PiotrCzapla / wpcli.bash_alias.sh
Created September 22, 2021 07:48
How to add a wp cli isolated ina a docker container
function wpcli(){
docker run -v $(pwd):/var/www/html --rm -it -u "$(stat -c'%u' .)" wordpress:cli "$@"
}
alias wp='wpcli wp'