Skip to content

Instantly share code, notes, and snippets.

View liavkoren's full-sized avatar

Liav liavkoren

View GitHub Profile
@liavkoren
liavkoren / Dockerfile
Last active May 4, 2022 19:56
Scripts that will reliably reproduce an AnyIO.EndOfStream error when using ContextMiddleware
# Note, I'm not running the docker process directly, instead I'm building the container and bashing in to start
# `$ python fast_server.py` and `python fast_client.py`.
FROM python:3.9.7
ARG REQUIREMENTS_FILE=requirements-dev.txt
WORKDIR /code
ADD requirements.txt requirements-*.txt /code/
RUN pip install -r $REQUIREMENTS_FILE
@liavkoren
liavkoren / gist:03d6676278dfba255e219a610c57c9a9
Created December 21, 2021 20:58
trying to have a convo with copilot..
Me: - Which currencies are supported? V's PR has CND and USD
Co: - Which currencies are supported? V's PR has CND and USD
Co: - Which currencies are supported? V's PR has CND and USD
Me: - What are you doing this doesn't look like your training distribution o _ o
Co: - What are you doing this doesn't look like your training distribution o _ o
Co: - What are you doing this doesn't look like your training distribution o _ o
Co: - What are you doing this doesn't look like your training distribution o _ o
@liavkoren
liavkoren / Google_Colaboratory_backup.py
Created May 9, 2018 02:23 — forked from rdinse/Google_Colaboratory_backup.py
Simple Google Drive backup script with automatic authentication for Google Colaboratory (Python 3)
# Simple Google Drive backup script with automatic authentication
# for Google Colaboratory (Python 3)
# Instructions:
# 1. Run this cell and authenticate via the link and text box.
# 2. Copy the JSON output below this cell into the `mycreds_file_contents`
# variable. Authentication will occur automatically from now on.
# 3. Create a new folder in Google Drive and copy the ID of this folder
# from the URL bar to the `folder_id` variable.
# 4. Specify the directory to be backed up in `dir_to_backup`.
$ sudo find / -name *.pth
/usr/local/lib/python2.7/site-packages/geos.pth
/usr/local/lib/python2.7/site-packages/virtualenvwrapper-4.1.1-py2.7-nspkg.pth
/usr/local/lib/python2.7/site-packages/easy-install.pth
/usr/local/lib/python2.7/site-packages/pdbmm_hijack_pdb.pth
/usr/local/lib/python2.7/site-packages/libxslt.pth
/usr/local/lib/python2.7/site-packages/configparser-3.5.0-py2.7-nspkg.pth
/usr/local/lib/python2.7/site-packages/matplotlib-1.5.0-py2.7-nspkg.pth
/usr/local/Cellar/geos/3.6.2/lib/python2.7/site-packages/geos.pth
/usr/local/Cellar/pgcli/1.9.1/libexec/vendor/lib/python2.7/site-packages/backports.csv-1.0.5-py2.7-nspkg.pth
<Successful import attempts from line 3 till line 20?>
# /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__pycache__/machinery.cpython-36.pyc matches /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/machinery.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__pycache__/machinery.cpython-36.pyc'
import 'importlib.machinery' # <_frozen_importlib_external.SourceFileLoader object at 0x1041fe518>
import 'importlib.abc' # <_frozen_importlib_external.SourceFileLoader object at 0x1041f1e10>
# trying /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.cpython-36m-darwin.so
# trying /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.abi3.so
# trying /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.so
# trying /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py
@liavkoren
liavkoren / int2word.py
Created August 14, 2017 18:50
work around paypal's self-defeating security feature
lookup = {
'1': 'one',
'2': 'two',
'3': 'three',
'4': 'four',
'5': 'five',
'6': 'six',
'7': 'seven',
'8': 'eight',
'9': 'nine',
@liavkoren
liavkoren / site.py
Created July 6, 2017 18:45
Incorrectly calculating bounce rates
from collections import defaultdict
initial_pages = defaultdict(lambda: 0)
bounce_rates = defaultdict(lambda: 0)
for line in open('site_data.csv'):
first, second = line.rstrip().split(',')
if first == '-1':
initial_pages[second] += 1
from enum import Enum
import attr
from attr.validators import instance_of
@attr.s
class EdgeNode:
"""
An Edge & a Node.
ImportError Traceback (most recent call last)
<ipython-input-1-e19bbed7988a> in <module>()
----> 1 import ipytracer
2 from IPython.core.display import display
3
4 def bubble_sort(unsorted_list):
5 x = ipytracer.ChartTracer(unsorted_list)
/Users/liavkoren/Envs/coding-university/lib/python3.6/site-packages/ipytracer/__init__.py in <module>()
14 """
Path /Users/liavkoren/.config/powerline/colorschemes/solarized.json.old is not a directory or configuration file
Path /Users/liavkoren/.config/powerline/colorschemes/vim/solarized.json.old is not a configuration file
Path /Users/liavkoren/.config/powerline/colorschemes/vim/solarizedlight.json.old is not a configuration file
One of the either variants failed. Messages from the first variant:
Error while loading groups (key /groups/email_alert)