Skip to content

Instantly share code, notes, and snippets.

View eezis's full-sized avatar

Ernest Ezis eezis

  • Boulder, CO
View GitHub Profile
@eezis
eezis / elb-usptream-sent-more-data-than-specified.md
Created November 6, 2022 17:27
Django EC2 ELB Nginx PageSpeed upstream sent more data than specified in "Content-Length" header

While upgrading EC2 servers behind an AWS Elastic Load Balancer (ELB) I noticed that the nginx error log was reporting that my health-check was getting molested. Here is the simple curl test showing the 200 result. The error message, then the solution follow.

$ curl -I localhost/ELB-health-check

HTTP/1.1 200 OK
Server: nginx
Date: Sun, 06 Nov 2022 16:59:46 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 105
@eezis
eezis / django-migrations-type-error-must-be-strings-not-bytes.md
Created October 6, 2022 19:56
Django Migrations TypeError: attribute name must be string, not 'bytes'

If you are updating and older Django project and getting an error in this form:

TypeError: attribute name must be string, not 'bytes'

It's likely that you have existing migrations in your code base that have legacy byte strings. I found them in two places. In the related_name as shown below

('article', models.ForeignKey(related_name=b'author', to='core.Article', on_delete=models.CASCADE, null=True)),
@eezis
eezis / phemex_balance_ccxt.py
Last active November 13, 2022 04:21
Get your Phemex Positions and Balance using CCXT -- in jupyter notebook
# -*- coding: utf-8 -*-
import os
import sys
from pprint import pprint
import ccxt
import pandas as pd
PHEMEX_API_KEY = os.getenv('PHEMEX_API_KEY')
@eezis
eezis / gist:1ae5050a524d7c14229db2658143ad4a
Last active January 5, 2021 13:23
Get Ethereum and ERC20 positions from an Ethereum address
"""
see my comment below the gist
"""
import re
import os
from requests_html import HTMLSession
BASE_ETHERSCAN_URL = "https://etherscan.io/address/"
@eezis
eezis / gist:3a198b9f65d1d3171c8cd20b30562d36
Created April 10, 2020 18:26
If you need to find the location of a poetry virtualenv for a project . . .
# inside an active poetry shell . . .
$ which python
/home/eezis/.cache/pypoetry/virtualenvs/airflow-_F6chCj4-py3.8/bin/python

Keybase proof

I hereby claim:

  • I am eezis on github.
  • I am ernestezis (https://keybase.io/ernestezis) on keybase.
  • I have a public key ASCKvfwAKTfOPX-0ro-E-kpjgG6zedSp2JUGk-4zSCRcuwo

To claim this, I am signing this object:

@eezis
eezis / firebaseSecurityRulesb7PUm7LmAOw.js
Created August 14, 2019 17:48
Code to accompany this video: Firestore Security Rules - How to Hack a Firebase App
// this is a helpful video, code is transcribed from it
// https://www.youtube.com/watch?v=b7PUm7LmAOw
rules_version = "2";
service cloud.firestore {
match /databases/{database}/documents {
// ** means to cascade down to all subcollections and anything nested
match /{document=**} {
// an exmaple of allowing everyone to read products collection
// but only logged in users can delete
@eezis
eezis / firebase.js
Created August 8, 2019 21:51
quasar firebase & vuefire boot file
import { firestorePlugin } from 'vuefire'
import { firebase } from '@firebase/app'
import 'firebase/firestore'
import 'firebase/auth'
import firebaseConfig from '../../firebaseConfig'
let firebaseApp = firebase.initializeApp(firebaseConfig)
let firebaseAuth = firebaseApp.auth()
const db = firebaseApp.firestore()
@eezis
eezis / cleansrt.py
Last active November 15, 2018 17:33
Udacity Nanotrading Transcript Cleaner
"""
Turn the .srt files into .txt files
1. unzip the lesson files into a directory
2. run this code in that directory.
the code will strip out the timestamps and carriage returns
and produce a text file that you can use for reference and class notes.
"""
import re
from os import listdir, getcwd
from os.path import isfile, join
@eezis
eezis / python deprecation
Created December 22, 2017 20:17
Python: deprecate a module or function
"""
"""
import warnings
from decimal import *
warnings.warn("This unit is being deprecated, ....")
def round_off(value, dec_places=9 ):
return Decimal(value).quantize(Decimal('0.00000000'))